Solved Bukkit.dispatchCommand causing spigot asynchronous check to murder me.

Discussion in 'Spigot Plugin Development' started by creepercannyon, Feb 8, 2020.

  1. My code is pretty simple and unnecessary, but I'll provide it anyways. Please excuse my trash code.


    public void flag(OfflinePlayer p, int vl) {
    for (int i = prevVl + 1; i <= vl; i++) {
    List<String> toExecute = ConfigManager.config.getStringList("Checks." + name + ".Actions." + vl);
    if (toExecute == null)
    continue;
    if (toExecute.size() == 0)
    continue;
    for (String string : toExecute) {
    Bukkit.dispatchCommand(Bukkit.getConsoleSender(), ChatUtils.actionReplace(string, p, String.valueOf(vl)));
    }
    }
    prevVl = vl;
    }


    Here's stacktrace

    [22:35:41] [Netty Epoll Server IO #2/INFO]: An unknown error occurred while attempting to perform this command
    [22:35:41] [Netty Epoll Server IO #2/WARN]: Unknown CommandBlock failed to handle command
    java.lang.IllegalStateException: Asynchronous entity untrack!
    at org.spigotmc.AsyncCatcher.catchOp(AsyncCatcher.java:14) ~[spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
    at net.minecraft.server.v1_8_R3.EntityTracker.untrackEntity(EntityTracker.java:149) ~[spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
    at net.minecraft.server.v1_8_R3.WorldManager.b(WorldManager.java:22) ~[spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
    at net.minecraft.server.v1_8_R3.World.b(World.java:1074) ~[spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
    at net.minecraft.server.v1_8_R3.WorldServer.b(WorldServer.java:984) ~[spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
    at net.minecraft.server.v1_8_R3.World.kill(World.java:1110) ~[spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
    at net.minecraft.server.v1_8_R3.PlayerList.disconnect(PlayerList.java:360) ~[spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
    at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:871) ~[spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
    at net.minecraft.server.v1_8_R3.PlayerConnection.disconnect(PlayerConnection.java:183) ~[spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
    at net.minecraft.server.v1_8_R3.CommandKick.execute(SourceFile:50) ~[spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
    at org.bukkit.craftbukkit.v1_8_R3.command.VanillaCommandWrapper.dispatchVanillaCommand(VanillaCommandWrapper.java:108) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
    at org.bukkit.craftbukkit.v1_8_R3.command.VanillaCommandWrapper.execute(VanillaCommandWrapper.java:43) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
    at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
    at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:641) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
    at org.bukkit.Bukkit.dispatchCommand(Bukkit.java:576) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
    at uwu.smsgamer.uwuanticheat.checks.Check.flag(Check.java:48) [UwUAntiCheat-1.0.jar:?]
    at uwu.smsgamer.uwuanticheat.checks.Combat.AimBot.AimBotA.onPacket(AimBotA.java:60) [UwUAntiCheat-1.0.jar:?]
    at uwu.smsgamer.uwuanticheat.events.EventManager.onEvent(EventManager.java:75) [UwUAntiCheat-1.0.jar:?]
    at sun.reflect.GeneratedMethodAccessor19.invoke(Unknown Source) ~[?:?]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_242]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_242]
    at cc.funkemunky.api.reflections.types.WrappedMethod.invoke(WrappedMethod.java:34) [Atlas.jar:?]
    at cc.funkemunky.api.events.EventManager.callEvent(EventManager.java:79) [Atlas.jar:?]
    at cc.funkemunky.api.tinyprotocol.api.TinyProtocolHandler.onPacketInAsync(TinyProtocolHandler.java:87) [Atlas.jar:?]
    at cc.funkemunky.api.tinyprotocol.api.TinyProtocolHandler$2.onPacketInAsync(TinyProtocolHandler.java:43) [Atlas.jar:?]
    at cc.funkemunky.api.tinyprotocol.api.packets.channelhandler.TinyProtocol1_8$PacketInterceptor.channelRead(TinyProtocol1_8.java:539) [Atlas.jar:?]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:163) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:163) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:163) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
    at io.netty.handler.timeout.ReadTimeoutHandler.channelRead(ReadTimeoutHandler.java:150) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:787) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
    at io.netty.channel.epoll.EpollSocketChannel$EpollSocketUnsafe.epollInReady(EpollSocketChannel.java:722) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
    at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:326) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
    at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:264) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
    at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116) [spigot-1.8.8.jar:git-Spigot-21fe707-e1ebe52]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_242]

    Also when I did
    Bukkit.broadcastMessage(Thread.currentThread() + " " + MinecraftServer.getServer().primaryThread + " " + (Thread.currentThread() != MinecraftServer.getServer().primaryThread));
    It prints
    Thread[Netty Epoll Server IO #2,5,main] Thread[Server thread,5,main] true
    So obviously the current thread and "primary thread" are different, thus causing spigot to die. I really need a fix. Please. I've spent way too much time on this and it's rare I ask for help on spigot forums, but everything I ask responds ¯\_(ツ)_/¯

    Thanks in advance. :)
     
  2. wrap your command in scheduler
     
  3. omfg thanks so much you fixed it I can't believe I didn't think of that it makes soooooo much sense lol
     
  4. Mark as solved
     
  5. that would be smart
     
  6. Strahan

    Benefactor

    Also just so you know, getStringList cannot return null so the null check for that is irrelevant.
     
  7. lol ok thanks