Pyrbu / ZNPCsPlus

A Spigot plugin for creating interactable fake entities
https://www.spigotmc.org/resources/znpcsplus.109380/
GNU General Public License v3.0
118 stars 29 forks source link

fix null check for shutdownTasks before iterating and executing tasks #126

Closed inkerxoe closed 9 months ago

Pyrbu commented 9 months ago

Did you even try to test this? This literally makes it so none of the shutdown tasks run.

Pyrbu commented 9 months ago

Also even if you were actually checking if the list is empty that wouldnt change a thing since if its empty the loop just wont run. What are you even trying to fix here?

inkerxoe commented 9 months ago

[11:57:40 ERROR]: [ZNPCsPlus] One of the registered shutdown tasks threw an exception: [11:57:40 WARN]: java.lang.IllegalStateException: Not scheduled yet [11:57:40 WARN]: at org.bukkit.scheduler.BukkitRunnable.checkScheduled(BukkitRunnable.java:156) [11:57:40 WARN]: at org.bukkit.scheduler.BukkitRunnable.getTaskId(BukkitRunnable.java:150) [11:57:40 WARN]: at org.bukkit.scheduler.BukkitRunnable.cancel(BukkitRunnable.java:30) [11:57:40 WARN]: at Z[NPC]ZNPCsPlus-2.0.0-SNAPSHOT.jar//lol.pyr.znpcsplus.updater.UpdateChecker.shutdown(UpdateChecker.java:44) [11:57:40 WARN]: at Z[NPC]ZNPCsPlus-2.0.0-SNAPSHOT.jar//lol.pyr.znpcsplus.ZNpcsPlus.onDisable(ZNpcsPlus.java:206) [11:57:40 WARN]: at Z[NPC]ZNPCsPlus-2.0.0-SNAPSHOT.jar//lol.pyr.znpcsplus.ZNpcsPlusBootstrap.onDisable(ZNpcsPlusBootstrap.java:94) [11:57:40 WARN]: at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:283) [11:57:40 WARN]: at io.papermc.paper.plugin.manager.PaperPluginInstanceManager.disablePlugin(PaperPluginInstanceManager.java:223) [11:57:40 WARN]: at io.papermc.paper.plugin.manager.PaperPluginInstanceManager.disablePlugins(PaperPluginInstanceManager.java:147) [11:57:40 WARN]: at io.papermc.paper.plugin.manager.PaperPluginManagerImpl.disablePlugins(PaperPluginManagerImpl.java:92) [11:57:40 WARN]: at org.bukkit.plugin.SimplePluginManager.disablePlugins(SimplePluginManager.java:528) [11:57:40 WARN]: at org.bukkit.craftbukkit.v1_20_R3.CraftServer.disablePlugins(CraftServer.java:582) [11:57:40 WARN]: at net.minecraft.server.MinecraftServer.t(MinecraftServer.java:986) [11:57:40 WARN]: at net.minecraft.server.dedicated.DedicatedServer.t(DedicatedServer.java:861) [11:57:40 WARN]: at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:1288) [11:57:40 WARN]: at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:323) [11:57:40 WARN]: at java.base/java.lang.Thread.run(Thread.java:833)

inkerxoe commented 9 months ago

Sorry that there was no error attached

Pyrbu commented 9 months ago

This exception happens because the update checker task has a delay on it but the shutdown task for it gets registerred straight away so if you shut the server down quick enough it throws that since its trying to cancel the task before its even ran. Ive actually already tried to fix this (the getTaskId call) but that also just throws the same exception. If you want to go look for a way to fix this then go ahead but I looked for quite a while and didn't find anything and the error doesnt even matter that much because its just the update checker.

inkerxoe commented 9 months ago

There's no way around that, but it's okay if it doesn't affect the use