1.14.4 Error: Asynchronous player tracker clear!

Discussion in 'Spigot Plugin Development' started by Elias177Dev, Jan 24, 2020.

  1. Hey,
    I'm doing a plugin where only the people who are in a Discord channel see each other, but when I do a channel joine the error occurs

    Error:
    Code (Text):
    [16:23:01] [JDA MainWS-ReadThread/WARN]: [JDA MainWS-ReadThread] ERROR JDA - One of the EventListeners had an uncaught exception
    [16:23:01] [JDA MainWS-ReadThread/WARN]: java.lang.IllegalStateException: Asynchronous player tracker clear!
    [16:23:01] [JDA MainWS-ReadThread/WARN]:        at org.spigotmc.AsyncCatcher.catchOp(AsyncCatcher.java:14)
    [16:23:01] [JDA MainWS-ReadThread/WARN]:        at net.minecraft.server.v1_14_R1.PlayerChunkMap$EntityTracker.clear(PlayerChunkMap.java:1205)
    [16:23:01] [JDA MainWS-ReadThread/WARN]:        at org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer.hidePlayer0(CraftPlayer.java:1047)
    [16:23:01] [JDA MainWS-ReadThread/WARN]:        at org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer.hidePlayer(CraftPlayer.java:1015)
    [16:23:01] [JDA MainWS-ReadThread/WARN]:        at de.elias177.discordvanish.listener.discord.ChannelJoin.onGuildVoiceJoin(ChannelJoin.java:44)
    [16:23:01] [JDA MainWS-ReadThread/WARN]:        at net.dv8tion.jda.api.hooks.ListenerAdapter.onEvent(ListenerAdapter.java:567)
    [16:23:01] [JDA MainWS-ReadThread/WARN]:        at net.dv8tion.jda.api.hooks.InterfacedEventManager.handle(InterfacedEventManager.java:96)
    [16:23:01] [JDA MainWS-ReadThread/WARN]:        at net.dv8tion.jda.internal.hooks.EventManagerProxy.handle(EventManagerProxy.java:64)
    [16:23:01] [JDA MainWS-ReadThread/WARN]:        at net.dv8tion.jda.internal.JDAImpl.handleEvent(JDAImpl.java:152)
    [16:23:01] [JDA MainWS-ReadThread/WARN]:        at net.dv8tion.jda.internal.handle.VoiceStateUpdateHandler.handleGuildVoiceState(VoiceStateUpdateHandler.java:133)
    [16:23:01] [JDA MainWS-ReadThread/WARN]:        at net.dv8tion.jda.internal.handle.VoiceStateUpdateHandler.handleInternally(VoiceStateUpdateHandler.java:50)
    [16:23:01] [JDA MainWS-ReadThread/WARN]:        at net.dv8tion.jda.internal.handle.SocketHandler.handle(SocketHandler.java:37)
    [16:23:01] [JDA MainWS-ReadThread/WARN]:        at net.dv8tion.jda.internal.requests.WebSocketClient.onDispatch(WebSocketClient.java:843)
    [16:23:01] [JDA MainWS-ReadThread/WARN]:        at net.dv8tion.jda.internal.requests.WebSocketClient.onEvent(WebSocketClient.java:739)
    [16:23:01] [JDA MainWS-ReadThread/WARN]:        at net.dv8tion.jda.internal.requests.WebSocketClient.handleEvent(WebSocketClient.java:718)
    [16:23:01] [JDA MainWS-ReadThread/WARN]:        at net.dv8tion.jda.internal.requests.WebSocketClient.onBinaryMessage(WebSocketClient.java:881)
    [16:23:01] [JDA MainWS-ReadThread/WARN]:        at com.neovisionaries.ws.client.ListenerManager.callOnBinaryMessage(ListenerManager.java:385)
    [16:23:01] [JDA MainWS-ReadThread/WARN]:        at com.neovisionaries.ws.client.ReadingThread.callOnBinaryMessage(ReadingThread.java:276)
    [16:23:01] [JDA MainWS-ReadThread/WARN]:        at com.neovisionaries.ws.client.ReadingThread.handleBinaryFrame(ReadingThread.java:996)
    [16:23:01] [JDA MainWS-ReadThread/WARN]:        at com.neovisionaries.ws.client.ReadingThread.handleFrame(ReadingThread.java:755)
    [16:23:01] [JDA MainWS-ReadThread/WARN]:        at com.neovisionaries.ws.client.ReadingThread.main(ReadingThread.java:108)
    [16:23:01] [JDA MainWS-ReadThread/WARN]:        at com.neovisionaries.ws.client.ReadingThread.runMain(ReadingThread.java:64)
    [16:23:01] [JDA MainWS-ReadThread/WARN]:        at com.neovisionaries.ws.client.WebSocketThread.run(WebSocketThread.java:45)
    Code:
    Code (Java):
        @Override
        public void onGuildVoiceJoin(GuildVoiceJoinEvent e) {
           
            Member user = e.getMember();
            if(ConnectDatabase.playerExistsDiscordID(user.getId())) {
                String uuid = ConnectDatabase.getUUID(user.getId());
                String name = ConnectDatabase.getName(uuid);
                if(ConnectDatabase.getStatus(uuid).equals("CONNECTED")) {

                    List<Member> member = e.getVoiceState().getChannel().getMembers();

                    if(!Var.inChannel.contains(name)) {
                        Var.inChannel.add(name);
                    }

                    Player p = Bukkit.getPlayer(name);

                    if(p == null) {
                        return;
                    }
                   
                    p.sendMessage("Right");
                   
                    for(Player all : Bukkit.getOnlinePlayers()) {
                        if(all != p) {
                            p.hidePlayer(all);
                            all.hidePlayer(p);
                           
                            if(ConnectDatabase.playerExists(all.getUniqueId().toString())) {
       
                                Member tar = Main.getInstance().getJDA().getGuildById(Var.serverID).getMemberById(ConnectDatabase.getDiscordID(all.getUniqueId().toString()));
       
                                if(member.contains(tar)) {
                                    p.showPlayer(all);
                                    all.showPlayer(p);
                                }
                               
                            }else {
                                Bukkit.getOnlinePlayers().forEach(all2 -> {
                                    all2.hidePlayer(p);
                                });
                            }
                            System.err.println(all.getName());
                        }
                    }
                   
                }
               
            }
           
           
        }
     
  2. FrostedSnowman

    Resource Staff

    Don’t access the bukkit methods async
     
    • Agree Agree x 1
  3. SteelPhoenix

    Moderator

    JDA works asynchronous, as it should
     
  4. okay how can i make it in sync?
     
  5. Use the Bukkit scheduler or a BukkitRunnable and run a synchronized task. Remember that collections are also likely to give concurrency issues if handled improperly.
     
  6. Thank you very much, it is now possible with a BukkitRunnable
     
    #6 Elias177Dev, Jan 24, 2020
    Last edited: Jan 24, 2020