Class PlayerManager<P extends PlotPlayer<? extends T>,T>

java.lang.Object
com.plotsquared.core.util.PlayerManager<P,T>

public abstract class PlayerManager<P extends PlotPlayer<? extends T>,T> extends Object
Manages player instances
  • 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 format TranslatableCaption.of(String) of "info.plot_user_list" for the returned string
      Parameters:
      uuids - UUIDs
      localeHolder - the localeHolder to localize the component for
      Returns:
      Component of name list
    • getName

      @Deprecated(forRemoval=true, since="6.4.0") public static @NonNull String getName(@Nullable UUID owner)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Get the name from a UUID.
      Parameters:
      owner - Owner UUID
      Returns:
      The player's name, None, Everyone or Unknown
    • getName

      @Deprecated(forRemoval=true, since="6.4.0") public static @NonNull String getName(@Nullable UUID owner, boolean blocking)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Get the name from a UUID.
      Parameters:
      owner - Owner UUID
      blocking - Whether or not the operation can be blocking
      Returns:
      The player's name, None, Everyone or Unknown
    • resolveName

      public static @NonNull Caption resolveName(@Nullable UUID owner)
      Attempts to resolve the username by an uuid

      Note: 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, Everyone or Unknown
      Since:
      6.4.0
      See Also:
    • resolveName

      public static @NonNull Caption resolveName(@Nullable UUID owner, boolean blocking)
      Attempts to resolve the username by an uuid
      Parameters:
      owner - The UUID of the owner
      blocking - If the operation should block the current thread for Settings.UUID.BLOCKING_TIMEOUT milliseconds
      Returns:
      A caption containing either the name, None, Everyone or Unknown
      Since:
      6.4.0
    • removePlayer

      public void removePlayer(@NonNull PlotPlayer<?> plotPlayer)
      Remove a player from the player map
      Parameters:
      plotPlayer - Player to remove
    • removePlayer

      public void removePlayer(@NonNull UUID uuid)
      Remove a player from the player map
      Parameters:
      uuid - Player to remove
    • getPlayerIfExists

      public @Nullable P getPlayerIfExists(@Nullable UUID uuid)
      Get the player from its UUID if it is stored in the player map.
      Parameters:
      uuid - Player UUID
      Returns:
      Player, or null
    • getPlayerIfExists

      public @Nullable P getPlayerIfExists(@Nullable String name)
    • getPlayer

      public abstract @NonNull P getPlayer(@NonNull T object)
      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

      public @NonNull P getPlayer(@NonNull UUID uuid)
      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

      public abstract @NonNull P createPlayer(@NonNull UUID uuid)
    • getOfflinePlayer

      public abstract @Nullable OfflinePlotPlayer getOfflinePlayer(@Nullable UUID uuid)
      Get an an offline player object from the player's UUID
      Parameters:
      uuid - Player UUID
      Returns:
      Offline player object
    • getOfflinePlayer

      public abstract @Nullable OfflinePlotPlayer getOfflinePlayer(@NonNull String username)
      Get an offline player object from the player's username
      Parameters:
      username - Player name
      Returns:
      Offline player object
    • getPlayers

      public Collection<P> getPlayers()
      Get all online players
      Returns:
      Unmodifiable collection of players