Class PlotPlayer<P>

java.lang.Object
com.plotsquared.core.player.PlotPlayer<P>
All Implemented Interfaces:
CommandCaller, LocaleHolder, PermissionHolder, OfflinePlotPlayer
Direct Known Subclasses:
ConsolePlayer

public abstract class PlotPlayer<P> extends Object implements CommandCaller, OfflinePlotPlayer, LocaleHolder
The abstract class supporting BukkitPlayer and SpongePlayer.
  • Constructor Details

  • Method Details

    • from

      public static <T> PlotPlayer<T> from(@NonNull T object)
    • registerConverter

      public static <T> void registerConverter(@NonNull Class<T> clazz, PlotPlayer.PlotPlayerConverter<T> converter)
    • getDebugModePlayers

    • getDebugModePlayersInPlot

    • setupPermissionProfile

      protected void setupPermissionProfile()
    • hasPermission

      public final boolean hasPermission(@Nullable String world, @NonNull String permission)
      Description copied from interface: PermissionHolder
      Check if the owner of the profile has a given permission
      Specified by:
      hasPermission in interface PermissionHolder
      Parameters:
      world - World name
      permission - Permission
      Returns:
      true if the owner has the given permission, else false
    • hasKeyedPermission

      public final boolean hasKeyedPermission(@Nullable String world, @NonNull String permission, @NonNull String key)
      Description copied from interface: PermissionHolder
      Check if the owner of the profile has a given keyed permission. Checks both permission.key and permission.*
      Specified by:
      hasKeyedPermission in interface PermissionHolder
      Parameters:
      world - World name
      permission - Permission
      key - Permission "key"
      Returns:
      true if the owner has the given permission, else false
    • hasPermission

      public final boolean hasPermission(@NonNull String permission, boolean notify)
      Description copied from interface: PermissionHolder
      Checks if the owner of the profile has a permission, and optionally send the no permission message if applicable.
      Specified by:
      hasPermission in interface PermissionHolder
      Parameters:
      permission - Permission
      notify - If to notify the permission holder
      Returns:
      true if the owner has the given permission, else false
    • toActor

      public abstract Actor toActor()
    • getPlatformPlayer

      public abstract P getPlatformPlayer()
    • getMeta

    • toString

      public String toString()
      This player's name.
      Overrides:
      toString in class Object
      Returns:
      the name of the player
    • getCurrentPlot

      public Plot getCurrentPlot()
      Get this player's current plot.
      Returns:
      the plot the player is standing on or null if standing on a road or not in a PlotArea
    • getAllowedPlots

      public int getAllowedPlots()
      Get the total number of allowed plots
      Returns:
      number of allowed plots within the scope (globally, or in the player's current world as defined in the settings.yml)
    • getPlotCount

      public int getPlotCount()
      Get the number of plots this player owns.
      Returns:
      number of plots within the scope (globally, or in the player's current world as defined in the settings.yml)
      See Also:
    • getClusterCount

      public int getClusterCount()
    • getPlotCount

      public int getPlotCount(String world)
      Get the number of plots this player owns in the world.
      Parameters:
      world - the name of the plotworld to check.
      Returns:
      plot count
    • getClusterCount

      public int getClusterCount(String world)
    • getPlots

      public Set<Plot> getPlots()
      Get a Set of plots owned by this player.

      Take a look at PlotSquared for more searching functions. See getPlotCount() for the number of plots.

      Returns:
      a Set of plots owned by the player
    • getPlotAreaAbs

      Return the PlotArea this player is currently in, or null.
      Returns:
      Plot area the player is currently in, or null
    • getApplicablePlotArea

    • getSuperCaller

      Description copied from interface: CommandCaller
      Get the type of the caller
      Specified by:
      getSuperCaller in interface CommandCaller
      Returns:
      Caller type
    • getLocation

      Get this player's last recorded location or null if they don't any plot relevant location.
      Returns:
      The location
    • getLocationFull

      public abstract Location getLocationFull()
      Get this player's full location (including yaw/pitch)
      Returns:
      location
    • getUUID

      public abstract @NonNull UUID getUUID()
      Get this player's UUID. === !IMPORTANT ===
      The UUID is dependent on the mode chosen in the settings.yml and may not be the same as Bukkit has (especially if using an old version of Bukkit that does not support UUIDs)
      Specified by:
      getUUID in interface OfflinePlotPlayer
      Returns:
      UUID
    • canTeleport

      public boolean canTeleport(@NonNull Location location)
    • teleport

      public void teleport(Location location)
      Teleport this player to a location.
      Parameters:
      location - the target location
    • teleport

      public abstract void teleport(Location location, TeleportCause cause)
      Teleport this player to a location.
      Parameters:
      location - the target location
      cause - the cause of the teleport
    • plotkick

      public void plotkick(Location location)
      Kick this player to a location
      Parameters:
      location - the target location
    • setCompassTarget

      public abstract void setCompassTarget(Location location)
      Set this compass target.
      Parameters:
      location - the target location
    • setAttribute

      public void setAttribute(String key)
      Set player data that will persist restarts. - Please note that this is not intended to store large values - For session only data use meta
      Parameters:
      key - metadata key
    • getAttribute

      public boolean getAttribute(String key)
      Retrieves the attribute of this player.
      Parameters:
      key - metadata key
      Returns:
      the attribute will be either true or false
    • removeAttribute

      public void removeAttribute(String key)
      Remove an attribute from a player.
      Parameters:
      key - metadata key
    • setWeather

      public abstract void setWeather(@NonNull PlotWeather weather)
      Sets the local weather for this Player.
      Parameters:
      weather - the weather visible to the player
    • getGameMode

      public abstract @NonNull GameMode getGameMode()
      Get this player's gamemode.
      Returns:
      the gamemode of the player.
    • setGameMode

      public abstract void setGameMode(@NonNull GameMode gameMode)
      Set this player's gameMode.
      Parameters:
      gameMode - the gamemode to set
    • setTime

      public abstract void setTime(long time)
      Set this player's local time (ticks).
      Parameters:
      time - the time visible to the player
    • getFlight

      public abstract boolean getFlight()
      Determines whether or not the player can fly.
      Returns:
      true if the player is allowed to fly
    • setFlight

      public abstract void setFlight(boolean fly)
      Sets whether or not this player can fly.
      Parameters:
      fly - true if the player can fly, otherwise false
    • playMusic

      public abstract void playMusic(@NonNull Location location, @NonNull ItemType id)
      Play music at a location for this player.
      Parameters:
      location - where to play the music
      id - the record item id
    • isBanned

      public abstract boolean isBanned()
      Check if this player is banned.
      Returns:
      true if the player is banned, false otherwise.
    • kick

      public abstract void kick(String message)
      Kick this player from the game.
      Parameters:
      message - the reason for the kick
    • refreshDebug

      public void refreshDebug()
    • unregister

      public void unregister()
      Called when this player quits.
    • getPlayerClusterCount

      public int getPlayerClusterCount(String world)
      Get the amount of clusters this player owns in the specific world.
      Parameters:
      world - world
      Returns:
      number of clusters owned
    • getPlayerClusterCount

      public int getPlayerClusterCount()
      Get the amount of clusters this player owns.
      Returns:
      the number of clusters this player owns
    • getPlots

      public Set<Plot> getPlots(String world)
      Return a Set of all plots this player owns in a certain world.
      Parameters:
      world - the world to retrieve plots from
      Returns:
      a Set of plots this player owns in the provided world
    • populatePersistentMetaMap

    • accessPersistentMetaData

      Access keyed persistent meta data for this player. This returns a meta data access instance, that MUST be closed. It is meant to be used with try-with-resources, like such:
      
       try (final MetaDataAccess<Integer> access = player.accessPersistentMetaData(PlayerMetaKeys.GRANTS)) {
           int grants = access.get();
           access.set(grants + 1);
       }
       
      Type Parameters:
      T - Meta data type
      Parameters:
      key - Meta data key
      Returns:
      Meta data access. MUST be closed after being used
    • accessTemporaryMetaData

      Access keyed temporary meta data for this player. This returns a meta data access instance, that MUST be closed. It is meant to be used with try-with-resources, like such:
      
       try (final MetaDataAccess<Integer> access = player.accessTemporaryMetaData(PlayerMetaKeys.GRANTS)) {
           int grants = access.get();
           access.set(grants + 1);
       }
       
      Type Parameters:
      T - Meta data type
      Parameters:
      key - Meta data key
      Returns:
      Meta data access. MUST be closed after being used
    • sendTitle

      public void sendTitle(@NonNull Caption title, @NonNull Caption subtitle, @NonNull net.kyori.adventure.text.minimessage.Template... replacements)
      Send a title to the player that fades in, in 10 ticks, stays for 50 ticks and fades out in 20 ticks
      Parameters:
      title - Title text
      subtitle - Subtitle text
      replacements - Variable replacements
    • sendTitle

      public void sendTitle(@NonNull Caption title, @NonNull Caption subtitle, int fadeIn, int stay, int fadeOut, @NonNull net.kyori.adventure.text.minimessage.Template... replacements)
      Send a title to the player
      Parameters:
      title - Title
      subtitle - Subtitle
      fadeIn - Fade in time (in ticks)
      stay - The title stays for (in ticks)
      fadeOut - Fade out time (in ticks)
      replacements - Variable replacements
    • sendActionBar

      public void sendActionBar(@NonNull Caption caption, @NonNull net.kyori.adventure.text.minimessage.Template... replacements)
      Method designed to send an ActionBar to a player.
      Parameters:
      caption - Caption
      replacements - Variable replacements
    • sendMessage

      public void sendMessage(@NonNull Caption caption, @NonNull net.kyori.adventure.text.minimessage.Template... replacements)
      Description copied from interface: CommandCaller
      Send a message to the command caller
      Specified by:
      sendMessage in interface CommandCaller
      Parameters:
      caption - Caption to send
      replacements - Variable replacements
    • hasPermission

      public boolean hasPermission(@NonNull String permission)
      Description copied from interface: CommandCaller
      Check the player's permissions. Will be cached if permission caching is enabled.
      Specified by:
      hasPermission in interface CommandCaller
      Specified by:
      hasPermission in interface PermissionHolder
      Parameters:
      permission - the name of the permission
      Returns:
      if permission is had
    • canSee

      public abstract boolean canSee(PlotPlayer<?> other)
      Check if the player is able to see the other player. This does not mean that the other player is in line of sight of the player, but rather that the player is permitted to see the other player.
      Parameters:
      other - Other player
      Returns:
      true if the player is able to see the other player, false if not
    • stopSpectating

      public abstract void stopSpectating()
    • hasDebugMode

      public boolean hasDebugMode()
    • getLocale

      Description copied from interface: LocaleHolder
      Get the locale used by the holder
      Specified by:
      getLocale in interface LocaleHolder
      Returns:
      Locale
    • setLocale

      public void setLocale(@NonNull Locale locale)
      Description copied from interface: LocaleHolder
      Set the locale for the holder
      Specified by:
      setLocale in interface LocaleHolder
      Parameters:
      locale - New locale
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • getAudience

      public abstract @NonNull Audience getAudience()
      Get the Audience that represents this plot player
      Returns:
      Player audience
    • getLockRepository

      Get this player's LockRepository
      Returns:
      Lock repository instance
    • removeEffect

      public abstract void removeEffect(@NonNull String name)
      Removes any effects present of the given type.
      Parameters:
      name - the name of the type to remove
      Since:
      6.10.0