Samsuik / Sakura

11 stars 7 forks source link

Null SpawnReason? #10

Closed IAISI closed 7 months ago

IAISI commented 7 months ago

I was playing around with this a bit on testing server with PlotSquared installed and P2 started spitting exceptions:

[16:19:13] [Server thread/WARN]: java.lang.NullPointerException: Cannot invoke "org.bukkit.event.entity.CreatureSpawnEvent$SpawnReason.name()" because the return value of "org.bukkit.entity.Entity.getEntitySpawnReason()" is null
[16:19:13] [Server thread/WARN]:     at PlotSquared-Bukkit.jar//com.plotsquared.bukkit.BukkitPlatform.lambda$runEntityTask$5(BukkitPlatform.java:782)
[16:19:13] [Server thread/WARN]:     at PlotSquared-Bukkit.jar//com.plotsquared.core.plot.world.PlotAreaManager.forEachPlotArea(PlotAreaManager.java:223)
[16:19:13] [Server thread/WARN]:     at PlotSquared-Bukkit.jar//com.plotsquared.bukkit.BukkitPlatform.lambda$runEntityTask$6(BukkitPlatform.java:772)
[16:19:13] [Server thread/WARN]:     at PlotSquared-Bukkit.jar//com.plotsquared.bukkit.util.task.BukkitPlotSquaredTask.runTask(BukkitPlotSquaredTask.java:39)
[16:19:13] [Server thread/WARN]:     at PlotSquared-Bukkit.jar//com.plotsquared.core.util.task.PlotSquaredTask.run(PlotSquaredTask.java:44)
[16:19:13] [Server thread/WARN]:     at org.bukkit.craftbukkit.v1_20_R3.scheduler.CraftTask.run(CraftTask.java:101)
[16:19:13] [Server thread/WARN]:     at org.bukkit.craftbukkit.v1_20_R3.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:480)
[16:19:13] [Server thread/WARN]:     at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:1647)
[16:19:13] [Server thread/WARN]:     at net.minecraft.server.dedicated.DedicatedServer.b(DedicatedServer.java:451)
[16:19:13] [Server thread/WARN]:     at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:1526)
[16:19:13] [Server thread/WARN]:     at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:1221)
[16:19:13] [Server thread/WARN]:     at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:322)
[16:19:13] [Server thread/WARN]:     at java.base/java.lang.Thread.run(Thread.java:840)

But according to https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/entity/CreatureSpawnEvent.html#getSpawnReason() spawnReason shouldn't ever be null?

Samsuik commented 7 months ago

PlotSquared is calling the Entity#getEntitySpawnReason method which returned null. To me this looks like an entity was added to the world with a null spawn reason.

IAISI commented 7 months ago

I've retested with paper spigot, and the issue still occurs, not Sakura issue, my bad.