Skip to content

Modules

Users and network API

Read profiles and preferences, track sessions safely and locate players and servers across the network.

Loading module data per session

  1. Subscribe to UserSessionReadyEvent (UUID, session and base profile ready).
  2. Start your own asynchronous load.
  3. When it completes, schedule Bukkit work on the server thread and check that OnlineUsers.sessionId(uuid) still matches the event's session.
  4. Subscribe to UserSessionClosedEvent and drop that session's data.
  5. If your plugin enables while players are online, iterate OnlineUsers.readySessions() after subscribing.

Never store the Player object in your load tasks, and discard responses from an older session even if the UUID matches.

Preferences

UserService changes preferences with compare-and-set: setAnnouncementsAsync, setBossBarAsync, setPrivateMessagesAsync, setTagAsync, setMentionSoundAsync, setLocalRankAsync. Writes also refresh the player on this server.

Player directory

PlayerDirectory knows where each player is connected in the network: findAsync(name), findAsync(uuid), serverAsync(serverId) and rosterAsync(). serverId() returns this server's server.id.