#Code runs as expected on one account, but not another when hosting 2 instances at one time
1 messages · Page 1 of 1 (latest)
and if i add a message to the nullpointerexception it runs it 100% of the time once the TextComponent is used
Never, ever, catch NullpointerExceptions. Fix the exception.
i dont know how to
Send it, then we can help
Nullpointer almost always occur for fundamental design flaws. They are one of the best indicators that something is wrong with your design/code.
give me one second. im gonna test a theory and if it doesnt work ill let you know
it always sends java if (!plugin.getPlayerToPunish().containsKey(player.getUniqueId().toString())) { MessageManager.playerBad(player, "You do not have anyone selected to punish"); return true; } to one account but to the other it displays as expected
Would you mind doing a bit of refactoring with early escapes?
This code is quite unpleasant to read.
An early escape for example is:
if (!(sender instanceof Player player)) {
return;
}
i know what they are, i just dont know where to use them for this code
For example in that code you just sent, the check here should be inverse with an early return
okay @shy plank first thing. Print the stacktrace instead of sending the player a message. and send us the stacktrace
[19:29:45] [Server thread/WARN]: at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45)
[19:29:45] [Server thread/WARN]: at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:149)
[19:29:45] [Server thread/WARN]: at org.bukkit.craftbukkit.v1_18_R2.CraftServer.dispatchCommand(CraftServer.java:826)
[19:29:45] [Server thread/WARN]: at net.minecraft.server.network.PlayerConnection.a(PlayerConnection.java:1957)
[19:29:45] [Server thread/WARN]: at net.minecraft.server.network.PlayerConnection.a(PlayerConnection.java:1796)
[19:29:45] [Server thread/WARN]: at net.minecraft.server.network.PlayerConnection.a(PlayerConnection.java:1777)
[19:29:45] [Server thread/WARN]: at net.minecraft.network.protocol.game.PacketPlayInChat.a(PacketPlayInChat.java:46)
[19:29:45] [Server thread/WARN]: at net.minecraft.network.protocol.game.PacketPlayInChat.a(PacketPlayInChat.java:1)
[19:29:45] [Server thread/WARN]: at net.minecraft.network.protocol.PlayerConnectionUtils.lambda$0(PlayerConnectionUtils.java:31)
[19:29:45] [Server thread/WARN]: at net.minecraft.server.TickTask.run(SourceFile:18)
[19:29:45] [Server thread/WARN]: at net.minecraft.util.thread.IAsyncTaskHandler.d(SourceFile:157)
[19:29:45] [Server thread/WARN]: at net.minecraft.util.thread.IAsyncTaskHandlerReentrant.d(SourceFile:23)
[19:29:45] [Server thread/WARN]: at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:1190)
[19:29:45] [Server thread/WARN]: at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:1)
[19:29:45] [Server thread/WARN]: at net.minecraft.util.thread.IAsyncTaskHandler.y(SourceFile:131)
[19:29:45] [Server thread/WARN]: at net.minecraft.server.MinecraftServer.be(MinecraftServer.java:1169)
[19:29:45] [Server thread/WARN]: at net.minecraft.server.MinecraftServer.y(MinecraftServer.java:1162)
[19:29:45] [Server thread/WARN]: at net.minecraft.util.thread.IAsyncTaskHandler.c(SourceFile:140)
[19:29:45] [Server thread/WARN]: at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1146)
[19:29:45] [Server thread/WARN]: at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:1051)
[19:29:45] [Server thread/WARN]: at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:304)
[19:29:45] [Server thread/WARN]: at java.base/java.lang.Thread.run(Thread.java:842)```
what;s line 83?
SomeMethod(){
if(xyz){
return;
}
if(!xyz){
return;
}
if(!(xyz)){
return;
}
// Then follow with whatever operations
}```
instead of
if (sender instanceof Player) {
dosomething();
}
if (!(sender instanceof Player))
return;
dosomething();
if (plugin.getPlayerToPunish().get(player.getUniqueId().toString()).equalsIgnoreCase(target.getUniqueId().toString()))
yeah so target is null
most likely
i kinda fixed ur code
it removes the player/target from the playerToPunish hashmap after the confirm command is executed
PlayerToPunish may also be null
you didnt even send this
the entire thing that is
idk. but that is line 83
[19:29:45] [Server thread/WARN]: at games.kingdoms.kingdoms.admin.punishCMD.ConfirmPunishment.onCommand(ConfirmPunishment.java:83)
[19:29:45] [Server thread/WARN]: at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45)
[19:29:45] [Server thread/WARN]: at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:149)
[19:29:45] [Server thread/WARN]: at org.bukkit.craftbukkit.v1_18_R2.CraftServer.dispatchCommand(CraftServer.java:826)
[19:29:45] [Server thread/WARN]: at net.minecraft.server.network.PlayerConnection.a(PlayerConnection.java:1957)
[19:29:45] [Server thread/WARN]: at net.minecraft.server.network.PlayerConnection.a(PlayerConnection.java:1796)
[19:29:45] [Server thread/WARN]: at net.minecraft.server.network.PlayerConnection.a(PlayerConnection.java:1777)
[19:29:45] [Server thread/WARN]: at net.minecraft.network.protocol.game.PacketPlayInChat.a(PacketPlayInChat.java:46)
[19:29:45] [Server thread/WARN]: at net.minecraft.network.protocol.game.PacketPlayInChat.a(PacketPlayInChat.java:1)
[19:29:45] [Server thread/WARN]: at net.minecraft.network.protocol.PlayerConnectionUtils.lambda$0(PlayerConnectionUtils.java:31)
[19:29:45] [Server thread/WARN]: at net.minecraft.server.TickTask.run(SourceFile:18)
[19:29:45] [Server thread/WARN]: at net.minecraft.util.thread.IAsyncTaskHandler.d(SourceFile:157)
[19:29:45] [Server thread/WARN]: at net.minecraft.util.thread.IAsyncTaskHandlerReentrant.d(SourceFile:23)
[19:29:45] [Server thread/WARN]: at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:1190)
[19:29:45] [Server thread/WARN]: at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:1)
[19:29:45] [Server thread/WARN]: at net.minecraft.util.thread.IAsyncTaskHandler.y(SourceFile:131)
[19:29:45] [Server thread/WARN]: at net.minecraft.server.MinecraftServer.be(MinecraftServer.java:1169)
[19:29:45] [Server thread/WARN]: at net.minecraft.server.MinecraftServer.y(MinecraftServer.java:1162)
[19:29:45] [Server thread/WARN]: at net.minecraft.util.thread.IAsyncTaskHandler.c(SourceFile:140)
[19:29:45] [Server thread/WARN]: at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1146)
[19:29:45] [Server thread/WARN]: at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:1051)
[19:29:45] [Server thread/WARN]: at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:304)
[19:29:45] [Server thread/WARN]: at java.base/java.lang.Thread.run(Thread.java:842)
[19:38:19] [Server thread/WARN]: Can't keep up! Is the server overloaded? Running 5559ms or 111 ticks behind```
plugin.getPlayerToPunish().get(player.getUniqueId().toString())
the map does not have a mapping for the player uuid
don't use strings, just use uuids
Map<String,String> can be
Map<UUID,UUID>
The problem is i dont know if the custom config class i use can restore uuids from the config
UUID.fromString(uuidstring)
ah