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>Access keyed persistent meta data for this player.<T> @NonNull MetaDataAccess<T>Access keyed temporary meta data for this player.abstract booleancanSee(PlotPlayer<?> other) Check if the player is able to see the other player.booleancanTeleport(@NonNull Location location) booleanstatic <T> PlotPlayer<T>intGet the total number of allowed plotsbooleangetAttribute(String key) Retrieves the attribute of this player.Get theAudiencethat represents this plot playerintintgetClusterCount(String world) Get this player's current plot.static Collection<PlotPlayer<?>>static Collection<PlotPlayer<?>>abstract booleanDetermines 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 LocationGet this player's full location (including yaw/pitch)Get this player'sLockRepositorygetMeta()abstract PintGet the amount of clusters this player owns.intgetPlayerClusterCount(String world) Get the amount of clusters this player owns in the specific world.Return the PlotArea this player is currently in, or null.intGet the number of plots this player owns.intgetPlotCount(String world) Get the number of plots this player owns in the world.getPlots()Get aSetof plots owned by this player.Return aSetof all plots this player owns in a certain world.Get the type of the callergetUUID()Get this player's UUID.booleaninthashCode()final booleanCheck if the owner of the profile has a given keyed permission.booleanhasPermission(@NonNull String permission) Check the player's permissions.final booleanhasPermission(@Nullable String world, @NonNull String permission) Check if the owner of the profile has a given permissionabstract booleanisBanned()Check if this player is banned.abstract voidKick this player from the game.abstract voidPlay music at a location for this player.voidKick this player to a locationvoidvoidstatic <T> voidregisterConverter(@NonNull Class<T> clazz, PlotPlayer.PlotPlayerConverter<T> converter) voidremoveAttribute(String key) Remove an attribute from a player.voidsendActionBar(@NonNull Caption caption, @NonNull net.kyori.adventure.text.minimessage.Template... replacements) Method designed to send an ActionBar to a player.voidsendMessage(@NonNull Caption caption, @NonNull net.kyori.adventure.text.minimessage.Template... replacements) Send a message to the command callervoidsendTitle(@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 playervoidsendTitle(@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 ticksvoidsetAttribute(String key) Set player data that will persist restarts.abstract voidsetCompassTarget(Location location) Set this compass target.abstract voidsetFlight(boolean fly) Sets whether or not this player can fly.abstract voidsetGameMode(@NonNull GameMode gameMode) Set this player's gameMode.voidSet the locale for the holderabstract voidsetTime(long time) Set this player's local time (ticks).protected voidabstract voidsetWeather(@NonNull PlotWeather weather) Sets the local weather for this Player.abstract voidvoidTeleport this player to a location.abstract voidteleport(Location location, TeleportCause cause) Teleport this player to a location.abstract ActortoActor()toString()This player's name.voidCalled when this player quits.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.plotsquared.core.player.OfflinePlotPlayer
getLastPlayed, getNameMethods 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:PermissionHolderCheck if the owner of the profile has a given permission- Specified by:
hasPermissionin interfacePermissionHolder- Parameters:
world- World namepermission- Permission- Returns:
trueif 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:PermissionHolderCheck if the owner of the profile has a given keyed permission. Checks bothpermission.keyandpermission.*- Specified by:
hasKeyedPermissionin interfacePermissionHolder- Parameters:
world- World namepermission- Permissionkey- Permission "key"- Returns:
trueif 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
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
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 aSetof plots owned by this player.Take a look at
PlotSquaredfor more searching functions. SeegetPlotCount()for the number of plots.- Returns:
- a
Setof 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:CommandCallerGet the type of the caller- Specified by:
getSuperCallerin 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:
getUUIDin 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
trueorfalse
-
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
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:
trueif the player is allowed to fly
-
setFlight
public abstract void setFlight(boolean fly) Sets whether or not this player can fly.- Parameters:
fly-trueif 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
public abstract boolean isBanned()Check if this player is banned.- Returns:
trueif the player is banned,falseotherwise.
-
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 aSetof all plots this player owns in a certain world.- Parameters:
world- the world to retrieve plots from- Returns:
- a
Setof 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:CommandCallerSend a message to the command caller- Specified by:
sendMessagein interfaceCommandCaller- Parameters:
caption- Caption to sendreplacements- Variable replacements
-
hasPermission
Description copied from interface:CommandCallerCheck the player's permissions. Will be cached if permission caching is enabled.- Specified by:
hasPermissionin interfaceCommandCaller- Specified by:
hasPermissionin 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:
trueif the player is able to see the other player,falseif not
-
stopSpectating
public abstract void stopSpectating() -
hasDebugMode
public boolean hasDebugMode() -
getLocale
Description copied from interface:LocaleHolderGet the locale used by the holder- Specified by:
getLocalein interfaceLocaleHolder- Returns:
- Locale
-
setLocale
Description copied from interface:LocaleHolderSet the locale for the holder- Specified by:
setLocalein interfaceLocaleHolder- Parameters:
locale- New locale
-
hashCode
public int hashCode() -
equals
-
getAudience
Get theAudiencethat represents this plot player- Returns:
- Player audience
-
getLockRepository
Get this player'sLockRepository- Returns:
- Lock repository instance
-