Jump to content

Recommended Posts

Posted

Hey,

 

Can anyone tell me how I can get all players on a Server ?

I try to make something like this:

When I push 'F' I should get a list with all players currently on the server and their current position.

The problem is that the server is null because the KeyHandler is called client side but how can I fix this ?

I don't want to send packets and stuff like this. I just need all players... Can I somehow run this server side ?

public class KeyHandler{

private KeyBinding key = new KeyBinding("Key", Keyboard.KEY_F, "KEY");

        @SubscribeEvent
public void KeyInputEvent(KeyInputEvent event) {
	MinecraftServer server = MinecraftServer.getServer(); //Server return null? 
                List<EntityPlayerMP> list = server.getConfigurationManager().playerEntityList;
                for (int i = 0; i < list.size(); i++) {
			EntityPlayerMP player = list.get(i);
			System.out.println(player.getDisplayName() + ": x:" + player.posX + " y:" + player.posY + " z:" + player.posZ);
		}
}
}

 

I would really appreciate any help. Thank you.

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.