Showing player when they chat

Discussion in 'Spigot Plugin Development' started by Accessory, Jun 22, 2016.

  1. I'm trying to reveal a player after they first type in chat:
    Code (Text):
                    if(profile.isHidden()) {
                        profile.setHidden(false);
                        cxPlayer.setDisplayParticles(true);
                        all.showPlayer(player);
                    }
    But I get this error:
    Code (Text):
    [03:49:55] [Async Chat Thread - #0/ERROR]: Could not pass event AsyncPlayerChatEvent to cxHub vAlpha 1.0
    org.bukkit.event.EventException
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:310) ~[server.jar:git-PaperSpigot-7aa4900-62a2169]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[server.jar:git-PaperSpigot-7aa4900-62a2169]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [server.jar:git-PaperSpigot-7aa4900-62a2169]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:484) [server.jar:git-PaperSpigot-7aa4900-62a2169]
        at net.minecraft.server.v1_8_R3.PlayerConnection.chat(PlayerConnection.java:1087) [server.jar:git-PaperSpigot-7aa4900-62a2169]
        at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:1025) [server.jar:git-PaperSpigot-7aa4900-62a2169]
        at net.minecraft.server.v1_8_R3.PacketPlayInChat$1.run(PacketPlayInChat.java:39) [server.jar:git-PaperSpigot-7aa4900-62a2169]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [?:1.7.0_79]
        at java.util.concurrent.FutureTask.run(FutureTask.java:262) [?:1.7.0_79]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [?:1.7.0_79]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [?:1.7.0_79]
        at java.lang.Thread.run(Thread.java:745) [?:1.7.0_79]
    Caused by: java.lang.IllegalStateException: Asynchronous player tracker update!
        at org.spigotmc.AsyncCatcher.catchOp(AsyncCatcher.java:14) ~[server.jar:git-PaperSpigot-7aa4900-62a2169]
        at net.minecraft.server.v1_8_R3.EntityTrackerEntry.updatePlayer(EntityTrackerEntry.java:331) ~[server.jar:git-PaperSpigot-7aa4900-62a2169]
        at org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer.showPlayer(CraftPlayer.java:907) ~[server.jar:git-PaperSpigot-7aa4900-62a2169]
        at com.Accessory.cxHub.listeners.ChatListener.onChat(ChatListener.java:39) ~[?:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_79]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_79]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_79]
        at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_79]
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[server.jar:git-PaperSpigot-7aa4900-62a2169]
        ... 11 more
    This is line 39: all.showPlayer(player);
    Is there a way I can show players without calling the bukkit api asynchronously?
     
  2. Create a bukkit Runnable that has a delayed task of just 1 tick. This should make it not asynchronous anymore
     
  3. MiniDigger

    Supporter

    the chat event is async (as the name suggests). you need to sync back to the main thread to access the bukkit api. there is no need to delay the action (as bram0101 suggests). using https://hub.spigotmc.org/javadocs/s...org.bukkit.plugin.Plugin, java.lang.Runnable) will make the code in the runnable run synced to the main thread.
     
    • Agree Agree x 2