Package com.plotsquared.core.util
Class PlayerManager<P extends PlotPlayer<? extends T>,T>
java.lang.Object
com.plotsquared.core.util.PlayerManager<P,T>
Manages player instances
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreatePlayer(@NonNull UUID uuid) abstract @Nullable OfflinePlotPlayergetOfflinePlayer(@NonNull String username) Get an offline player object from the player's usernameabstract @Nullable OfflinePlotPlayergetOfflinePlayer(@Nullable UUID uuid) Get an an offline player object from the player's UUIDGet a plot player from a platform player object.Get a plot player from a UUID.getPlayerIfExists(@Nullable String name) getPlayerIfExists(@Nullable UUID uuid) Get the player from its UUID if it is stored in the player map.getPlayerList(@NonNull Collection<UUID> uuids, LocaleHolder localeHolder) Get a list of names given a list of UUIDs.Get all online playersgetUsernameCaption(@Nullable UUID uuid) Resolves a UUID to a formattedCaptionrepresenting the player behind the UUID.static voidgetUUIDsFromString(@NonNull String list, @NonNull BiConsumer<Collection<UUID>, Throwable> consumer) voidremovePlayer(@NonNull PlotPlayer<?> plotPlayer) Remove a player from the player mapvoidremovePlayer(@NonNull UUID uuid) Remove a player from the player mapresolveName(@Nullable UUID owner) Deprecated.resolveName(@Nullable UUID owner, boolean blocking) Deprecated.Don't unnecessarily block threads and utilize playerMap - seegetUsernameCaption(UUID)
-
Constructor Details
-
PlayerManager
public PlayerManager()
-
-
Method Details
-
getUUIDsFromString
public static void getUUIDsFromString(@NonNull String list, @NonNull BiConsumer<Collection<UUID>, Throwable> consumer) -
getPlayerList
public static @NonNull Component getPlayerList(@NonNull Collection<UUID> uuids, LocaleHolder localeHolder) Get a list of names given a list of UUIDs. - Uses the formatTranslatableCaption.of(String)of "info.plot_user_list" for the returned string- Parameters:
uuids- UUIDslocaleHolder- the localeHolder to localize the component for- Returns:
- Component of name list
-
resolveName
Deprecated.Don't unnecessarily block threads and utilize playerMap - seegetUsernameCaption(UUID)Attempts to resolve the username by an uuidNote: blocks the thread until the name was resolved or failed
- Parameters:
owner- The UUID of the owner- Returns:
- A caption containing either the name,
None,EveryoneorUnknown - Since:
- 6.4.0
- See Also:
-
resolveName
@Deprecated(since="7.1.0") public static @NonNull Caption resolveName(@Nullable UUID owner, boolean blocking) Deprecated.Don't unnecessarily block threads and utilize playerMap - seegetUsernameCaption(UUID)Attempts to resolve the username by an uuid- Parameters:
owner- The UUID of the ownerblocking- If the operation should block the current thread forSettings.UUID.BLOCKING_TIMEOUTmilliseconds- Returns:
- A caption containing either the name,
None,EveryoneorUnknown - Since:
- 6.4.0
-
getUsernameCaption
@Contract("_->!null") public @NonNull CompletableFuture<Caption> getUsernameCaption(@Nullable UUID uuid) Resolves a UUID to a formattedCaptionrepresenting the player behind the UUID. Returns aCompletableFutureinstead of a plainUUIDas this method may query theImpromptuUUIDPipeline.
Special Cases:null: Resolves to aTranslatableCaptionwith the keyinfo.noneDBFunc.EVERYONE: Resolves to aTranslatableCaptionwith the keyinfo.everyoneDBFunc.SERVER: Resolves to aTranslatableCaptionwith the keyinfo.server
Otherwise, if the UUID is a valid UUID and not reserved by PlotSquared itself, this method first attempts to query the online players (getPlayerIfExists(UUID)) for the specific UUID. If no online player was found for that UUID, theImpromptuUUIDPipelineis queried to retrieve the known username- Parameters:
uuid- The UUID of the player (for example provided byPlot.getOwner()- Returns:
- A CompletableFuture resolving to a Caption representing the players name of the uuid
- Since:
- 7.1.0
-
removePlayer
Remove a player from the player map- Parameters:
plotPlayer- Player to remove
-
removePlayer
Remove a player from the player map- Parameters:
uuid- Player to remove
-
getPlayerIfExists
Get the player from its UUID if it is stored in the player map.- Parameters:
uuid- Player UUID- Returns:
- Player, or null
-
getPlayerIfExists
-
getPlayer
Get a plot player from a platform player object. This method requires that the caller actually knows that the player exists and is online.The method will throw an exception if there is no such player online.
- Parameters:
object- Platform player object- Returns:
- Player object
-
getPlayer
Get a plot player from a UUID. This method requires that the caller actually knows that the player exists.The method will throw an exception if there is no such player online.
- Parameters:
uuid- Player UUID- Returns:
- Player object
-
createPlayer
-
getOfflinePlayer
Get an an offline player object from the player's UUID- Parameters:
uuid- Player UUID- Returns:
- Offline player object
-
getOfflinePlayer
Get an offline player object from the player's username- Parameters:
username- Player name- Returns:
- Offline player object
-
getPlayers
Get all online players- Returns:
- Unmodifiable collection of players
-
getUsernameCaption(UUID)