Posted June 17, 20196 yr 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
June 17, 20196 yr Is player.getServer() returning null, or is the player you want from the event returning null?
June 17, 20196 yr Author 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
June 18, 20196 yr Author 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 June 18, 20196 yr by Osito1325
June 19, 20196 yr Author 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
June 19, 20196 yr Author 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.