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 TypeMethodDescriptionabstract @NonNull PcreatePlayer(@NonNull UUID uuid)static @NonNull StringGet the name from a UUID.static @NonNull StringGet the name from a 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 UUID@NonNull PGet a plot player from a UUID.abstract @NonNull PGet a plot player from a platform player object.@Nullable PgetPlayerIfExists(@Nullable String name)@Nullable PgetPlayerIfExists(@Nullable UUID uuid)Get the player from its UUID if it is stored in the player map.static @NonNull net.kyori.adventure.text.ComponentgetPlayerList(@NonNull Collection<UUID> uuids, LocaleHolder localeHolder)Get a list of names given a list of UUIDsGet all online playersstatic 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 map
-
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 net.kyori.adventure.text.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
-
getName
Get the name from a UUID.- Parameters:
owner- Owner UUID- Returns:
- The player's name, None, Everyone or Unknown
-
getName
Get the name from a UUID.- Parameters:
owner- Owner UUIDblocking- Whether or not the operation can be blocking- Returns:
- The player's name, None, Everyone or Unknown
-
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
-