Jump to content

[1.13.2] Get server data


Osito1325

Recommended Posts

18 hours ago, diesieben07 said:

PlayerLoggedInEvent fires on the server. So the server they are connected to would be the current server (ServerLifecycleHooks.getCurrentServer).

It works, thanks, but the event "PlayerLoggedInEvent" is not launched, I probe it using the chat event to check and that way it works, but I want to detect when it enters a server or even a world (single player)

 

ServerLifecycleHooks.getCurrentServer();

 

Returns null values if the player is on a multiplayer server

 

Edited by Osito1325
Link to comment
Share on other sites

10 hours ago, diesieben07 said:

You can use Minecraft#getCurrentServerData to get the server currently connected to, if any (will be null for single player).

The maximum number of players is not reliably available while in the game, it's only obtained when the server is pinged in the server list, and that might not happen if you use a direct connection (or if the player connects before the ping has finished).

To get the currently connected users use NetHandlerPlayerClient#getPlayerInfoMap.

I will do it and thank you, what he told me really worked

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.

×
×
  • Create New...

Important Information

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