Error With Hitdelay

Discussion in 'Spigot Plugin Development' started by eMuffin, Jul 13, 2018.

  1. Code (Text):

    13.07 01:54:02 [Server] INFO at java.lang.Thread.run(Thread.java:748) [?:1.8.0_151]
    13.07 01:54:02 [Server] INFO at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:665) [paperspigot.jar:git-Paper-1488]
    13.07 01:54:02 [Server] INFO at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:773) [paperspigot.jar:git-Paper-1488]
    13.07 01:54:02 [Server] INFO at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:427) [paperspigot.jar:git-Paper-1488]
    13.07 01:54:02 [Server] INFO at net.minecraft.server.v1_12_R1.MinecraftServer.D(MinecraftServer.java:849) [paperspigot.jar:git-Paper-1488]
    13.07 01:54:02 [Server] INFO at net.minecraft.server.v1_12_R1.SystemUtils.a(SourceFile:46) [paperspigot.jar:git-Paper-1488]
    13.07 01:54:02 [Server] INFO at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_151] 1
    3.07 01:54:02 [Server] INFO at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_151]
    13.07 01:54:02 [Server] INFO at net.minecraft.server.v1_12_R1.PlayerConnectionUtils.lambda$ensureMainThread$0(PlayerConnectionUtils.java:14) ~[paperspigot.jar:git-Paper-1488]
    13.07 01:54:02 [Server] INFO at net.minecraft.server.v1_12_R1.PacketPlayInUseEntity.a(PacketPlayInUseEntity.java:6) ~[paperspigot.jar:git-Paper-1488]
    13.07 01:54:02 [Server] INFO at net.minecraft.server.v1_12_R1.PacketPlayInUseEntity.a(PacketPlayInUseEntity.java:49) ~[paperspigot.jar:git-Paper-1488]
    13.07 01:54:02 [Server] INFO at net.minecraft.server.v1_12_R1.PlayerConnection.a(PlayerConnection.java:1703) ~[paperspigot.jar:git-Paper-1488]
    13.07 01:54:02 [Server] INFO at net.minecraft.server.v1_12_R1.EntityPlayer.attack(EntityPlayer.java:1366) ~[paperspigot.jar:git-Paper-1488]
    13.07 01:54:02 [Server] INFO at net.minecraft.server.v1_12_R1.EntityHuman.attack(EntityHuman.java:1028) ~[paperspigot.jar:git-Paper-1488]
    13.07 01:54:02 [Server] INFO at net.minecraft.server.v1_12_R1.EntityZombie.damageEntity(EntityZombie.java:163) ~[paperspigot.jar:git-Paper-1488]
    13.07 01:54:02 [Server] INFO at net.minecraft.server.v1_12_R1.EntityMonster.damageEntity(EntityMonster.java:44) ~[paperspigot.jar:git-Paper-1488]
    13.07 01:54:02 [Server] INFO at net.minecraft.server.v1_12_R1.EntityLiving.damageEntity(EntityLiving.java:879) ~[paperspigot.jar:git-Paper-1488]
    13.07 01:54:02 [Server] INFO at net.minecraft.server.v1_12_R1.EntityLiving.damageEntity0(EntityLiving.java:1387) ~[paperspigot.jar:git-Paper-1488] 13.07 01:54:02 [Server] INFO at org.bukkit.craftbukkit.v1_12_R1.event.CraftEventFactory.handleLivingEntityDamageEvent(CraftEventFactory.java:613) ~[paperspigot.jar:git-Paper-1488]
    13.07 01:54:02 [Server] INFO at org.bukkit.craftbukkit.v1_12_R1.event.CraftEventFactory.handleEntityDamageEvent(CraftEventFactory.java:484) ~[paperspigot.jar:git-Paper-1488]
    13.07 01:54:02 [Server] INFO at org.bukkit.craftbukkit.v1_12_R1.event.CraftEventFactory.callEntityDamageEvent(CraftEventFactory.java:581) ~[paperspigot.jar:git-Paper-1488]
    13.07 01:54:02 [Server] INFO at org.bukkit.craftbukkit.v1_12_R1.event.CraftEventFactory.callEvent(CraftEventFactory.java:94) ~[paperspigot.jar:git-Paper-1488]
    13.07 01:54:02 [Server] INFO at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:512) ~[paperspigot.jar:git-Paper-1488]
    13.07 01:54:02 [Server] INFO at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:527) ~[paperspigot.jar:git-Paper-1488]
    13.07 01:54:02 [Server] INFO at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[paperspigot.jar:git-Paper-1488]
    13.07 01:54:02 [Server] INFO at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:78) ~[paperspigot.jar:git-Paper-1488]
    13.07 01:54:02 [Server] INFO at org.bukkit.plugin.EventExecutor$2.execute(EventExecutor.java:70) ~[paperspigot.jar:git-Paper-1488]
    13.07 01:54:02 [Server] INFO at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor44.execute(Unknown Source) ~[?:?]
    13.07 01:54:02 [Server] INFO at com.seven.core.damage.hitDetection(damage.java:158) ~[?:?]
    13.07 01:54:02 [Server] INFO java.lang.NoClassDefFoundError: com/seven/core/damage$1 13.07 01:54:02 [Server] ERROR Could not pass event EntityDamageByEntityEvent to Seven v1.0
     
    So I'm getting that stacktrace. Before you say it's paper, this was happening on my Spigot.jar as well.
    Here's the code:
    Code (Text):

    @EventHandler (priority = EventPriority.LOWEST)
        public void hitDetection(EntityDamageByEntityEvent event) {
           
            if (!(event.getEntity().isDead())) {
                if (event.getEntity() instanceof LivingEntity) {
                    LivingEntity victim = (LivingEntity) event.getEntity();
                        new BukkitRunnable() {
                            @Override
                            public void run() {
                                victim.setNoDamageTicks(0);
                            }
                               
                        }.runTaskLaterAsynchronously(Main, 1L);
                }
            }
           
        }
     
    It's been happening only certain times though. I may restart the server and it will happen, other times it's fine, its rather peculiar and I don't see how its causing an error. I've also tried swapping between Async and Sync, no luck. Async performs better so I'm sticking to that.
     
  2. Your NoClassDefFoundError is similar to my errors relating to Bukkit schedulers still running on plugin disable. And what do you know, you're scheduling an async task. In your onDisable method in your main class, perhaps adding this line will help:
    Code (Text):
    Bukkit.getScheduler().cancelTasks(this);
     
  3. Okay, but the plugin isn't disabling till the server ends, is the task persisting past restarts?

    I do use schedulers quite a bit, but it's always referencing a Main scheduler.
     
  4. Oh, a restart? That's weird. Usually I get that error if something is calling a class that doesn't exist, such as if I'm screwing around with incompatible NMS versions, rebuilding the jar while it's in use, and reloading without killing repeating Bukkit tasks or other threads.

    What's even more strange is that you're making a new non-repeatable task, so I guess my suggestion won't help either.

    I just realized that your stacktrace is probably upside down. (I hate consoles that spit things out the wrong way.) Whats in line 158 in your damage class?
     
    #4 Islandscout, Jul 13, 2018
    Last edited: Jul 13, 2018
  5. Line 158 should be the bukkitRunnable. I think it has to do with the plugin reference @ Main, which is just a Main getter / constructor.
     
  6. Bump, this is also happening with like two other runnables, same error, same idea.