Jump to content

Recommended Posts

Posted (edited)
    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 by logan121
Posted

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.