Development Assistance Why work this kick not?

Discussion in 'Plugin Help/Development/Requests' started by ImAFlo, Apr 12, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    ImAFlo

    Why does the "kick" not work?

    Code:
    Code:
    if (this.getConfig().getBoolean("sChat.General.BlockedSpecificChars")) {
    if (!p.hasPermission("sChat.BlockedChars.ignore")) {
    if (msg.startsWith("*") || msg.startsWith("+") || msg.startsWith(".") || msg.startsWith(",") || msg.startsWith("^")) {
    e.setCancelled(true);
    p.sendMessage(prefix + " §cA message can't start with (*+,.)");
    p.sendMessage(prefix + " §cThe next time you're going to get kicked.");
    if (blocked.contains(p)) {
    /*line 218*/ Bukkit.getPlayerExact(p.getName()).kickPlayer("+++ You get kicked +++");
    } else {
    blocked.add(p);
    }
    }
    }
    }
    
    Error:
    Code:
    [21:34:53 ERROR]: Could not pass event AsyncPlayerChatEvent to sChat v1.3
    org.bukkit.event.EventException
    at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:305) ~[spigot.jar:git-Spigot-5ffe41c-bd703b8]
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot.jar:git-Spigot-5ffe41c-bd703b8]
    at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [spigot.jar:git-Spigot-5ffe41c-bd703b8]
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:484) [spigot.jar:git-Spigot-5ffe41c-bd703b8]
    at net.minecraft.server.v1_8_R1.PlayerConnection.chat(PlayerConnection.java:1036) [spigot.jar:git-Spigot-5ffe41c-bd703b8]
    at net.minecraft.server.v1_8_R1.PlayerConnection.a(PlayerConnection.java:975) [spigot.jar:git-Spigot-5ffe41c-bd703b8]
    at net.minecraft.server.v1_8_R1.PacketPlayInChat.a(PacketPlayInChat.java:26) [spigot.jar:git-Spigot-5ffe41c-bd703b8]
    at net.minecraft.server.v1_8_R1.PacketPlayInChat$1.run(PacketPlayInChat.java:47) [spigot.jar:git-Spigot-5ffe41c-bd703b8]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_25]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_25]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_25]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_25]
    at java.lang.Thread.run(Thread.java:745) [?:1.8.0_25]
    Caused by: java.lang.IllegalStateException: Asynchronous player kick!
    at org.spigotmc.AsyncCatcher.catchOp(AsyncCatcher.java:14) ~[spigot.jar:git-Spigot-5ffe41c-bd703b8]
    at org.bukkit.craftbukkit.v1_8_R1.entity.CraftPlayer.kickPlayer(CraftPlayer.java:218) ~[spigot.jar:git-Spigot-5ffe41c-bd703b8]
    at me.flo.sChat.sChat.onPlayerChat(sChat.java:218) ~[?:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_25]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_25]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_25]
    at java.lang.reflect.Method.invoke(Method.java:483) ~[?:1.8.0_25]
    at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:301) ~[spigot.jar:git-Spigot-5ffe41c-bd703b8]
    ... 12 more
    

    Thanks in Advance!
     
  2. @ImAFlo You don't need to use Bukkit.getPlayerExact() since you already have the player (p)
     
  3. Online

    timtower Administrator Administrator Moderator

    Moved to Bukkit alternatives.
    @ImAFlo You can only use kick on the main thread, you are in an async thread, the async player chat event, make a runnable and let it run on the main thread, that will fix it.
    Code:
    Caused by: java.lang.IllegalStateException: Asynchronous player kick!
     
Thread Status:
Not open for further replies.

Share This Page