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
-
Constructor Summary
ConstructorDescriptionPlotPlayer
(@NonNull PlotAreaManager plotAreaManager, @NonNull EventDispatcher eventDispatcher, @NonNull PermissionHandler permissionHandler) -
Method Summary
Modifier and TypeMethodDescription<T> @NonNull MetaDataAccess<T>
Access keyed persistent meta data for this player.<T> @NonNull MetaDataAccess<T>
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>
int
Get the total number of allowed plotsboolean
getAttribute
(String key) Retrieves the attribute of this player.Get theAudience
that represents this plot playerint
int
getClusterCount
(String world) Get this player's current plot.static Collection<PlotPlayer<?>>
static Collection<PlotPlayer<?>>
abstract boolean
Determines whether or not the player can fly.Get this player's gamemode.Get the locale used by the holderGet 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)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.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.Get the type of the callergetUUID()
Get this player's UUID.boolean
int
hashCode()
final boolean
Check if the owner of the profile has a given keyed permission.boolean
hasPermission
(@NonNull String permission) Check the player's permissions.final boolean
hasPermission
(@NonNull String permission, boolean notify) Checks if the owner of the profile has a permission, and optionally send the no permission message if applicable.final 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.abstract void
removeEffect
(@NonNull String name) Removes any effects present of the given type.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 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 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, hasPermission, hasPermission, hasPermissionRange, 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
-
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
-
hasPermission
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 interfacePermissionHolder
- Parameters:
permission
- Permissionnotify
- If to notify the permission holder- Returns:
true
if the owner has the given permission, elsefalse
-
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
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
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
-
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.Take a look at
PlotSquared
for more searching functions. SeegetPlotCount()
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 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
orfalse
-
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
Get this player's gamemode.- Returns:
- the gamemode of the player.
-
setGameMode
Set this player's gameMode.- Parameters:
gameMode
- the gamemode to set
-
setTime
Set this player's local time (ticks).- Parameters:
time
- the time visible to the player
-
getFlight
Determines whether or not the player can fly.- Returns:
true
if the player is allowed to fly
-
setFlight
Sets whether or not this player can fly.- Parameters:
fly
-true
if the player can fly, otherwisefalse
-
playMusic
Play music at a location for this player.- Parameters:
location
- where to play the musicid
- the record item id
-
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
-
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
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
-
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
-
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
-
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
-
equals
-
getAudience
Get theAudience
that represents this plot player- Returns:
- Player audience
-
getLockRepository
Get this player'sLockRepository
- Returns:
- Lock repository instance
-
removeEffect
Removes any effects present of the given type.- Parameters:
name
- the name of the type to remove- Since:
- 6.10.0
-