Posted September 16, 20205 yr if(!webhook) { if(mc.getCurrentServerData() != null || mc.getCurrentServerData().serverIP != null) { w.send("`" + "They are currently on server: " + mc.getCurrentServerData().serverIP + "\n`"); webhook = true;} }else if (mc.getCurrentServerData() == null || mc.getCurrentServerData().serverIP == null) { w.send("`" + "They are currently on Single player world" + "\n`"); webhook = true; }else { webhook = true; } } Hello, im currently struggling with this null pointer. I thought my If checks would stop this, not sure what i am doing wrong? java.lang.NullPointerException: Unexpected error ``` if(mc.getCurrentServerData() != null || mc.getCurrentServerData().serverIP != null) {``` this is returning null. Edited September 16, 20205 yr by logan121
September 16, 20205 yr It sounds like mc itself is null. This happens when you refer to the Minecraft.java class from within server-only code, as it does not exist on the server. Do you have a World reference with which to check world.isRemote, to ensure that you are on a client and mc is a valid class?
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.