Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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

  • 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

  • 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 by Osito1325

  • 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

  • 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.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.