Package com.plotsquared.core.player
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
.-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionPlotPlayer(@NonNull PlotAreaManager plotAreaManager, @NonNull EventDispatcher eventDispatcher, @NonNull PermissionHandler permissionHandler)
-
Method Summary
Modifier and TypeMethodDescription<T> @NonNull MetaDataAccess<T>
accessPersistentMetaData(@NonNull MetaDataKey<T> key)
Access keyed persistent meta data for this player.<T> @NonNull MetaDataAccess<T>
accessTemporaryMetaData(@NonNull MetaDataKey<T> key)
Access keyed temporary meta data for this player.abstract boolean
canSee(PlotPlayer<?> other)
Check if the player is able to see the other player.boolean
canTeleport(@NonNull Location location)
boolean
static <T> PlotPlayer<T>
from(@NonNull T object)
int
Get the total number of allowed plotsboolean
getAttribute(String key)
Retrieves the attribute of this player.abstract @NonNull net.kyori.adventure.audience.Audience
Get theAudience
that represents this plot playerint
int
getClusterCount(String world)
Get this player's current plot.static Collection<PlotPlayer<?>>
static Collection<PlotPlayer<?>>
getDebugModePlayersInPlot(@NonNull Plot plot)
abstract boolean
Determines whether or not the player can fly.abstract @NonNull com.sk89q.worldedit.world.gamemode.GameMode
Get this player's gamemode.@NonNull Locale
Get the locale used by the holder@NonNull Location
Get this player's last recorded location or null if they don't any plot relevant location.abstract Location
Get this player's full location (including yaw/pitch)@NonNull LockRepository
Get this player'sLockRepository
getMeta()
abstract P
int
Get the amount of clusters this player owns.int
getPlayerClusterCount(String world)
Get the amount of clusters this player owns in the specific world.@Nullable PlotArea
Return the PlotArea this player is currently in, or null.int
Get the number of plots this player owns.int
getPlotCount(String world)
Get the number of plots this player owns in the world.getPlots()
Get aSet
of plots owned by this player.Return aSet
of all plots this player owns in a certain world.@NonNull RequiredType
Get the type of the callerabstract @NonNull UUID
getUUID()
Get this player's UUID.boolean
int
hashCode()
boolean
hasKeyedPermission(@Nullable String world, @NonNull String permission, @NonNull String key)
Check if the owner of the profile has a given keyed permission.boolean
hasPermission(@NonNull String permission)
Check the player's permissions.boolean
hasPermission(@Nullable String world, @NonNull String permission)
Check if the owner of the profile has a given permissionabstract boolean
isBanned()
Check if this player is banned.abstract void
Kick this player from the game.abstract void
Play music at a location for this player.void
Kick this player to a locationvoid
void
static <T> void
registerConverter(@NonNull Class<T> clazz, PlotPlayer.PlotPlayerConverter<T> converter)
void
removeAttribute(String key)
Remove an attribute from a player.void
sendActionBar(@NonNull Caption caption, @NonNull net.kyori.adventure.text.minimessage.Template... replacements)
Method designed to send an ActionBar to a player.void
sendMessage(@NonNull Caption caption, @NonNull net.kyori.adventure.text.minimessage.Template... replacements)
Send a message to the command callervoid
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 playervoid
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 ticksvoid
setAttribute(String key)
Set player data that will persist restarts.abstract void
setCompassTarget(Location location)
Set this compass target.abstract void
setFlight(boolean fly)
Sets whether or not this player can fly.abstract void
setGameMode(@NonNull com.sk89q.worldedit.world.gamemode.GameMode gameMode)
Set this player's gameMode.void
Set the locale for the holderabstract void
setTime(long time)
Set this player's local time (ticks).protected void
abstract void
setWeather(@NonNull PlotWeather weather)
Sets the local weather for this Player.abstract void
void
Teleport this player to a location.abstract void
teleport(Location location, TeleportCause cause)
Teleport this player to a location.abstract com.sk89q.worldedit.extension.platform.Actor
toActor()
toString()
This player's name.void
Called when this player quits.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.plotsquared.core.player.OfflinePlotPlayer
getLastPlayed, getName
Methods inherited from interface com.plotsquared.core.permissions.PermissionHolder
hasKeyedPermission, hasPermissionRange
-
Constructor Details
-
PlotPlayer
public PlotPlayer(@NonNull PlotAreaManager plotAreaManager, @NonNull EventDispatcher eventDispatcher, @NonNull PermissionHandler permissionHandler)
-
-
Method Details
-
from
-
registerConverter
public static <T> void registerConverter(@NonNull Class<T> clazz, PlotPlayer.PlotPlayerConverter<T> converter) -
getDebugModePlayers
-
getDebugModePlayersInPlot
-
setupPermissionProfile
protected void setupPermissionProfile() -
hasPermission
Description copied from interface:PermissionHolder
Check if the owner of the profile has a given permission- Specified by:
hasPermission
in interfacePermissionHolder
- Parameters:
world
- World namepermission
- Permission- Returns:
true
if the owner has the given permission, elsefalse
-
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 bothpermission.key
andpermission.*
- Specified by:
hasKeyedPermission
in interfacePermissionHolder
- Parameters:
world
- World namepermission
- Permissionkey
- Permission "key"- Returns:
true
if the owner has the given permission, elsefalse
-
toActor
public abstract com.sk89q.worldedit.extension.platform.Actor toActor() -
getPlatformPlayer
-
getMeta
-
toString
This player's name. -
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:
getPlotCount(String)
,getPlots()
-
getClusterCount
public int getClusterCount() -
getPlotCount
Get the number of plots this player owns in the world.- Parameters:
world
- the name of the plotworld to check.- Returns:
- plot count
-
getClusterCount
-
getPlots
Get aSet
of plots owned by this player.- Returns:
- a
Set
of plots owned by the player - See Also:
for more searching functions
,for the number of plots
-
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 interfaceCommandCaller
- 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
Get this player's full location (including yaw/pitch)- Returns:
- location
-
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 interfaceOfflinePlotPlayer
- Returns:
- UUID
-
canTeleport
-
teleport
Teleport this player to a location.- Parameters:
location
- the target location
-
teleport
Teleport this player to a location.- Parameters:
location
- the target locationcause
- the cause of the teleport
-
plotkick
Kick this player to a location- Parameters:
location
- the target location
-
setCompassTarget
Set this compass target.- Parameters:
location
- the target location
-
setAttribute
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
Retrieves the attribute of this player.- Parameters:
key
- metadata key- Returns:
- the attribute will be either true or false
-
removeAttribute
Remove an attribute from a player.- Parameters:
key
- metadata key
-
setWeather
Sets the local weather for this Player.- Parameters:
weather
- the weather visible to the player
-
getGameMode
public abstract @NonNull com.sk89q.worldedit.world.gamemode.GameMode getGameMode()Get this player's gamemode.- Returns:
- the gamemode of the player.
-
setGameMode
public abstract void setGameMode(@NonNull com.sk89q.worldedit.world.gamemode.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, otherwisefalse
-
playMusic
public abstract void playMusic(@NonNull Location location, @NonNull com.sk89q.worldedit.world.item.ItemType id)Play music at a location for this player.- Parameters:
location
- where to play the musicid
- 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
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
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
Return aSet
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
public void 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 textsubtitle
- Subtitle textreplacements
- 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
- Titlesubtitle
- SubtitlefadeIn
- 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
- Captionreplacements
- 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 interfaceCommandCaller
- Parameters:
caption
- Caption to sendreplacements
- Variable replacements
-
hasPermission
Description copied from interface:CommandCaller
Check the player's permissions. Will be cached if permission caching is enabled.- Specified by:
hasPermission
in interfaceCommandCaller
- Specified by:
hasPermission
in interfacePermissionHolder
- Parameters:
permission
- the name of the permission- Returns:
- if permission is had
-
canSee
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 interfaceLocaleHolder
- Returns:
- Locale
-
setLocale
Description copied from interface:LocaleHolder
Set the locale for the holder- Specified by:
setLocale
in interfaceLocaleHolder
- Parameters:
locale
- New locale
-
hashCode
public int hashCode() -
equals
-
getAudience
public abstract @NonNull net.kyori.adventure.audience.Audience getAudience()Get theAudience
that represents this plot player- Returns:
- Player audience
-
getLockRepository
Get this player'sLockRepository
- Returns:
- Lock repository instance
-