Jump to content

Weird bug on server


Thor597

Recommended Posts

I have a block which changes the time, but when I choose one of the options and on client it changes the time, on server. Either it doesnt do anything, or it gives me an NPE on the if() lines, code:

 


public void actionPerformed(GuiButton guibutton)
{
	if(guibutton.id == 1)
	{
		for (int var3 = 0; var3 < MinecraftServer.getServer().theWorldServer.length; ++var3)
		{
			MinecraftServer.getServer().theWorldServer[var3].setTime(7000);
		}

	}

	if(guibutton.id == 2)
	{
		for (int var3 = 0; var3 < MinecraftServer.getServer().theWorldServer.length; ++var3)
		{
			MinecraftServer.getServer().theWorldServer[var3].setTime(17000);
		}

	}

	if(guibutton.id == 3)
	{
		for (int var3 = 0; var3 < MinecraftServer.getServer().theWorldServer.length; ++var3)
		{
			MinecraftServer.getServer().theWorldServer[var3].setTime(0);
		}

	}

	if(guibutton.id == 4)
	{
		for (int var3 = 0; var3 < MinecraftServer.getServer().theWorldServer.length; ++var3)
		{
			MinecraftServer.getServer().theWorldServer[var3].setTime(13000);
		}

	}

}    

Link to comment
Share on other sites

I have a block which changes the time, but when I choose one of the options and on client it changes the time, on server. Either it doesnt do anything, or it gives me an NPE on the if() lines, code:

 


public void actionPerformed(GuiButton guibutton)
{
	if(guibutton.id == 1)
	{
		for (int var3 = 0; var3 < MinecraftServer.getServer().theWorldServer.length; ++var3)
		{
			MinecraftServer.getServer().theWorldServer[var3].setTime(7000);
		}

	}

	if(guibutton.id == 2)
	{
		for (int var3 = 0; var3 < MinecraftServer.getServer().theWorldServer.length; ++var3)
		{
			MinecraftServer.getServer().theWorldServer[var3].setTime(17000);
		}

	}

	if(guibutton.id == 3)
	{
		for (int var3 = 0; var3 < MinecraftServer.getServer().theWorldServer.length; ++var3)
		{
			MinecraftServer.getServer().theWorldServer[var3].setTime(0);
		}

	}

	if(guibutton.id == 4)
	{
		for (int var3 = 0; var3 < MinecraftServer.getServer().theWorldServer.length; ++var3)
		{
			MinecraftServer.getServer().theWorldServer[var3].setTime(13000);
		}

	}

}    

 

Because the GUI classes are only called client-side. If you call MinecraftServer.getServer() in a client, it gives you only the InternalServer. If you are connected to a dedi server, it gives you a null object (unless you call this method on the dedi server).

I would recommend to send packets for this one.

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Link to comment
Share on other sites

I have a block which changes the time, but when I choose one of the options and on client it changes the time, on server. Either it doesnt do anything, or it gives me an NPE on the if() lines, code:

 


public void actionPerformed(GuiButton guibutton)
{
	if(guibutton.id == 1)
	{
		for (int var3 = 0; var3 < MinecraftServer.getServer().theWorldServer.length; ++var3)
		{
			MinecraftServer.getServer().theWorldServer[var3].setTime(7000);
		}

	}

	if(guibutton.id == 2)
	{
		for (int var3 = 0; var3 < MinecraftServer.getServer().theWorldServer.length; ++var3)
		{
			MinecraftServer.getServer().theWorldServer[var3].setTime(17000);
		}

	}

	if(guibutton.id == 3)
	{
		for (int var3 = 0; var3 < MinecraftServer.getServer().theWorldServer.length; ++var3)
		{
			MinecraftServer.getServer().theWorldServer[var3].setTime(0);
		}

	}

	if(guibutton.id == 4)
	{
		for (int var3 = 0; var3 < MinecraftServer.getServer().theWorldServer.length; ++var3)
		{
			MinecraftServer.getServer().theWorldServer[var3].setTime(13000);
		}

	}

}    

 

Because the GUI classes are only called client-side. If you call MinecraftServer.getServer() in a client, it gives you only the InternalServer. If you are connected to a dedi server, it gives you a null object (unless you call this method on the dedi server).

I would recommend to send packets for this one.

 

oh gawd packets

Link to comment
Share on other sites

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.