-
Bug
-
Resolution: Fixed
-
Minor
-
None
-
None
-
None
-
git-Spigot-758abbe-2b00831 (MC: 1.16.1) (Implementing API version 1.16.1-R0.1-SNAPSHOT)
-
SpigotTest
-
Yes
Basicly this code returns null but in spigot 1.15.2 it used to work fine.
player.getAttribute(Attribute.GENERIC_MAX_HEALTH)
Here you have the command code:
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { if (cmd.getName().equalsIgnoreCase("heal")) { if (sender instanceof Player) { Player p = (Player) sender; p.sendMessage("Attribute Movement: " + p.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED)); p.sendMessage("Attribute Max Health: " + p.getAttribute(Attribute.GENERIC_MAX_HEALTH)); p.setHealth(p.getAttribute(Attribute.GENERIC_MAX_HEALTH).getDefaultValue()); } } return true; }
Here you have the NPE:
[23:37:49] [Server thread/INFO]: xtomyserrax issued server command: /heal [23:37:49] [Server thread/ERROR]: null org.bukkit.command.CommandException: Unhandled exception executing command 'heal' in plugin SpigotTest v1.0 at org.bukkit.command.PluginCommand.execute(PluginCommand.java:47) ~[spigot.jar:git-Spigot-758abbe-2b00831] at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:149) ~[spigot.jar:git-Spigot-758abbe-2b00831] at org.bukkit.craftbukkit.v1_16_R1.CraftServer.dispatchCommand(CraftServer.java:747) ~[spigot.jar:git-Spigot-758abbe-2b00831] at net.minecraft.server.v1_16_R1.PlayerConnection.handleCommand(PlayerConnection.java:1702) ~[spigot.jar:git-Spigot-758abbe-2b00831] at net.minecraft.server.v1_16_R1.PlayerConnection.a(PlayerConnection.java:1545) ~[spigot.jar:git-Spigot-758abbe-2b00831] at net.minecraft.server.v1_16_R1.PacketPlayInChat.a(PacketPlayInChat.java:47) ~[spigot.jar:git-Spigot-758abbe-2b00831] at net.minecraft.server.v1_16_R1.PacketPlayInChat.a(PacketPlayInChat.java:1) ~[spigot.jar:git-Spigot-758abbe-2b00831] at net.minecraft.server.v1_16_R1.PlayerConnectionUtils.lambda$0(PlayerConnectionUtils.java:19) ~[spigot.jar:git-Spigot-758abbe-2b00831] at net.minecraft.server.v1_16_R1.TickTask.run(SourceFile:18) ~[spigot.jar:git-Spigot-758abbe-2b00831] at net.minecraft.server.v1_16_R1.IAsyncTaskHandler.executeTask(SourceFile:144) ~[spigot.jar:git-Spigot-758abbe-2b00831] at net.minecraft.server.v1_16_R1.IAsyncTaskHandlerReentrant.executeTask(SourceFile:23) ~[spigot.jar:git-Spigot-758abbe-2b00831] at net.minecraft.server.v1_16_R1.IAsyncTaskHandler.executeNext(SourceFile:118) ~[spigot.jar:git-Spigot-758abbe-2b00831] at net.minecraft.server.v1_16_R1.MinecraftServer.aZ(MinecraftServer.java:941) ~[spigot.jar:git-Spigot-758abbe-2b00831] at net.minecraft.server.v1_16_R1.MinecraftServer.executeNext(MinecraftServer.java:934) ~[spigot.jar:git-Spigot-758abbe-2b00831] at net.minecraft.server.v1_16_R1.IAsyncTaskHandler.awaitTasks(SourceFile:127) ~[spigot.jar:git-Spigot-758abbe-2b00831] at net.minecraft.server.v1_16_R1.MinecraftServer.sleepForTick(MinecraftServer.java:918) ~[spigot.jar:git-Spigot-758abbe-2b00831] at net.minecraft.server.v1_16_R1.MinecraftServer.v(MinecraftServer.java:850) ~[spigot.jar:git-Spigot-758abbe-2b00831] at net.minecraft.server.v1_16_R1.MinecraftServer.lambda$0(MinecraftServer.java:164) ~[spigot.jar:git-Spigot-758abbe-2b00831] at java.lang.Thread.run(Unknown Source) [?:1.8.0_251] Caused by: java.lang.NullPointerException at me.xtomyserrax.SpigotTest.Main.onCommand(Main.java:34) ~[?:?] at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[spigot.jar:git-Spigot-758abbe-2b00831] ... 18 more
As you may see the screenshot, bost showed attributes return null. Line 34 is the one trying to heal, because Im basicly trying to heal with a null double. This code used to work in spigot 1.15.2.
Thank you for the amazing work and for your patience! Hope this helps