Jump to content

Recommended Posts

Posted

Hi, I want to get the information of the server the player is on, try "PlayerEvent.PlayerLoggedInEvent" to get the server with "player.getServer();" but returns null

Posted

Well, I want to obtain the data of the server in which the user is connected, I found some help post but they do not work for me, I think it is different in 1.13.2

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

Yes, I just want to know if a player enters a server (multiplayer) and get data from the server, such as the host, connected users, maximum number of players and those things

Posted
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

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.