DevotedMC / JukeAlert

A plugin that creates a new block in Minecraft that records player entries and actions. Anti-grief tool. Built for Spigot 1.12
https://www.devotedmc.com/jukealert.html
BSD 3-Clause "New" or "Revised" License
2 stars 10 forks source link

member_iter_ while command called on potential null object #32

Closed rbp15 closed 7 years ago

rbp15 commented 7 years ago

This error pops up(below) - seems related to an issue with how memberiter is being handled as null here: https://github.com/DevotedMC/JukeAlert/blob/master/src/main/java/com/untamedears/JukeAlert/util/OnlineGroupMembers.java#L188

If memberiter is null then the while statement will fail as you are accessing a method on a null object. The check for null either needs to return the function within it's block scope or a result var needs to be created and populated, a following if !null conditional created with result var - then at the end of the function do a 'return result;'

This will safely handle whether or not memberiter is null and of course you can add messaging to tell the consumer what is going on and why it being null may or may not be a good thing.

ERROR: 19:13:44 ERROR]: [JukeAlert] handleSnitchEntry generated an exception java.lang.NullPointerException at com.untamedears.JukeAlert.util.OnlineGroupMembers.getNextMember(OnlineGroupMembers.java:173) ~[JukeAlert-1.4.3.jar:?] at com.untamedears.JukeAlert.util.OnlineGroupMembers.getPlayerByState(OnlineGroupMembers.java:195) ~[JukeAlert-1.4.3.jar:?] at com.untamedears.JukeAlert.util.OnlineGroupMembers.getNextPlayer(OnlineGroupMembers.java:241) ~[JukeAlert-1.4.3.jar:?] at com.untamedears.JukeAlert.util.OnlineGroupMembers.next(OnlineGroupMembers.java:99) ~[JukeAlert-1.4.3.jar:?] at com.untamedears.JukeAlert.util.OnlineGroupMembers.next(OnlineGroupMembers.java:28) ~[JukeAlert-1.4.3.jar:?] at com.untamedears.JukeAlert.util.Utility.notifyGroup(Utility.java:69) ~[JukeAlert-1.4.3.jar:?] at com.untamedears.JukeAlert.listener.JukeAlertListener.handleSnitchEntry(JukeAlertListener.java:463) [JukeAlert-1.4.3.jar:?] at com.untamedears.JukeAlert.listener.JukeAlertListener.enterSnitchProximity(JukeAlertListener.java:402) [JukeAlert-1.4.3.jar:?] at sun.reflect.GeneratedMethodAccessor59.invoke(Unknown Source) ~[?:?] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_121] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_121] at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:302) [spigot-1.10.2-R0.1-SNAPSHOT-latest.jar:git-Spigot-72c2605-251a5b6] at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) [spigot-1.10.2-R0.1-SNAPSHOT-latest.jar:git-Spigot-72c2605-251a5b6] at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [spigot-1.10.2-R0.1-SNAPSHOT-latest.jar:git-Spigot-72c2605-251a5b6] at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) [spigot-1.10.2-R0.1-SNAPSHOT-latest.jar:git-Spigot-72c2605-251a5b6] at net.minecraft.server.v1_10_R1.PlayerConnection.a(PlayerConnection.java:610) [spigot-1.10.2-R0.1-SNAPSHOT-latest.jar:git-Spigot-72c2605-251a5b6] at net.minecraft.server.v1_10_R1.PacketPlayInFlying.a(SourceFile:126) [spigot-1.10.2-R0.1-SNAPSHOT-latest.jar:git-Spigot-72c2605-251a5b6] at net.minecraft.server.v1_10_R1.PacketPlayInFlying$PacketPlayInPosition.a(SourceFile:57) [spigot-1.10.2-R0.1-SNAPSHOT-latest.jar:git-Spigot-72c2605-251a5b6] at net.minecraft.server.v1_10_R1.PlayerConnectionUtils$1.run(SourceFile:13) [spigot-1.10.2-R0.1-SNAPSHOT-latest.jar:git-Spigot-72c2605-251a5b6] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_121] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_121] at net.minecraft.server.v1_10_R1.SystemUtils.a(SourceFile:45) [spigot-1.10.2-R0.1-SNAPSHOT-latest.jar:git-Spigot-72c2605-251a5b6] at net.minecraft.server.v1_10_R1.MinecraftServer.D(MinecraftServer.java:732) [spigot-1.10.2-R0.1-SNAPSHOT-latest.jar:git-Spigot-72c2605-251a5b6] at net.minecraft.server.v1_10_R1.DedicatedServer.D(DedicatedServer.java:400) [spigot-1.10.2-R0.1-SNAPSHOT-latest.jar:git-Spigot-72c2605-251a5b6] at net.minecraft.server.v1_10_R1.MinecraftServer.C(MinecraftServer.java:668) [spigot-1.10.2-R0.1-SNAPSHOT-latest.jar:git-Spigot-72c2605-251a5b6] at net.minecraft.server.v1_10_R1.MinecraftServer.run(MinecraftServer.java:567) [spigot-1.10.2-R0.1-SNAPSHOT-latest.jar:git-Spigot-72c2605-251a5b6] at java.lang.Thread.run(Thread.java:745) [?:1.8.0_121] [19:13:45 INFO]: Entity data updated to: {AgeLocked:0b,HurtByTimestamp:0,Attributes:[0:{Base:100.0d,Name:"generic.maxHealth"},1:{Base:0.0d,Name:"generic.knockbackResistance"},2:{Base:0 .3d,Name:"generic.movementSpeed"},3:{Base:0.0d,Name:"generic.armor"},4:{Base:0.0d,Name:"generic.armorToughness"},5:{Base:16.0d,Modifiers:[0:{UUIDMost:-8152399133375247989L,UUIDLeast:-9 138049747182086789L,Amount:0.035636529259992236d,Operation:1,Name:"Random spawn bonus"}],Name:"generic.followRange"}],Riches:0,Invulnerable:0b,FallFlying:0b,

awoo-civ commented 7 years ago

Duplicate of https://github.com/DevotedMC/JukeAlert/issues/4