Interface OfflinePlayer
- All Superinterfaces:
AnimalTamer
,ConfigurationSerializable
,PersistentDataViewHolder
,ServerOperator
- All Known Subinterfaces:
Player
-
Method Summary
Modifier and TypeMethodDescription<E extends BanEntry<? super PlayerProfile>>
EAdds this user to theProfileBanList
.<E extends BanEntry<? super PlayerProfile>>
EAdds this user to theProfileBanList
.<E extends BanEntry<? super PlayerProfile>>
EAdds this user to theProfileBanList
.Deprecated.Deprecated.Deprecated.Deprecated.Deprecated.void
decrementStatistic
(@NotNull Statistic statistic) Decrements the given statistic for this player.void
decrementStatistic
(@NotNull Statistic statistic, int amount) Decrements the given statistic for this player.void
decrementStatistic
(@NotNull Statistic statistic, @NotNull Material material) Decrements the given statistic for this player for the given material.void
decrementStatistic
(@NotNull Statistic statistic, @NotNull Material material, int amount) Decrements the given statistic for this player for the given material.void
decrementStatistic
(@NotNull Statistic statistic, @NotNull EntityType entityType) Decrements the given statistic for this player for the given entity.void
decrementStatistic
(@NotNull Statistic statistic, @NotNull EntityType entityType, int amount) Decrements the given statistic for this player for the given entity.boolean
Determines if the OfflinePlayer is allowed to fly via jump key double-tap like in creative mode.Deprecated.Misleading name.long
Gets the first date and time that this player was witnessed on this server.float
Gets the current allowed speed that a client can fly.Gets the player's last death location.long
Gets the last date and time that this player logged into the server.long
Deprecated.The API contract is ambiguous and the implementation may or may not return the correct value given this API ambiguity.long
Gets the last date and time that this player was seen on the server.Gets the player's current location.getName()
Returns the name of this playerYields a view of the persistent data container for this offline player.Gets aPlayer
object that this represents, if there is oneGets a copy of the player's profile.Gets the Location where the player will spawn at, null if they don't have a valid respawn point.int
getStatistic
(@NotNull Statistic statistic) Gets the value of the given statistic for this player.int
getStatistic
(@NotNull Statistic statistic, @NotNull Material material) Gets the value of the given statistic for this player.int
getStatistic
(@NotNull Statistic statistic, @NotNull EntityType entityType) Gets the value of the given statistic for this player.Returns the UUID of this playerfloat
Gets the current allowed speed that a client can walk.boolean
Checks if this player has played on this server before.void
incrementStatistic
(@NotNull Statistic statistic) Increments the given statistic for this player.void
incrementStatistic
(@NotNull Statistic statistic, int amount) Increments the given statistic for this player.void
incrementStatistic
(@NotNull Statistic statistic, @NotNull Material material) Increments the given statistic for this player for the given material.void
incrementStatistic
(@NotNull Statistic statistic, @NotNull Material material, int amount) Increments the given statistic for this player for the given material.void
incrementStatistic
(@NotNull Statistic statistic, @NotNull EntityType entityType) Increments the given statistic for this player for the given entity.void
incrementStatistic
(@NotNull Statistic statistic, @NotNull EntityType entityType, int amount) Increments the given statistic for this player for the given entity.boolean
isBanned()
Checks if this player has had their profile banned.boolean
Checks whether the connection to this player is still valid.boolean
isFlying()
Checks to see if this player is currently flying or not.boolean
isOnline()
Checks if this player is currently online It should be noted that this will return true if any instance of this player is online! This instance may have disconnected.boolean
Checks if this player is whitelisted or notvoid
setAllowFlight
(boolean flight) Sets if the OfflinePlayer is allowed to fly via jump key double-tap like in creative mode.void
setFlying
(boolean value) Makes this player start or stop flying.void
setFlySpeed
(float value) Sets the speed at which a client will fly.void
setStatistic
(@NotNull Statistic statistic, int newValue) Sets the given statistic for this player.void
setStatistic
(@NotNull Statistic statistic, @NotNull Material material, int newValue) Sets the given statistic for this player for the given material.void
setStatistic
(@NotNull Statistic statistic, @NotNull EntityType entityType, int newValue) Sets the given statistic for this player for the given entity.void
setWalkSpeed
(float value) Sets the speed at which a client will walk.void
setWhitelisted
(boolean value) Sets if this player is whitelisted or notboolean
teleportOffline
(Location destination) Sets OfflinePlayer's location.boolean
teleportOffline
(Location destination, PlayerTeleportEvent.TeleportCause cause) Sets OfflinePlayer's location.teleportOfflineAsync
(@NotNull Location destination) Sets OfflinePlayer's location.teleportOfflineAsync
(@NotNull Location destination, PlayerTeleportEvent.TeleportCause cause) Sets OfflinePlayer's location.Methods inherited from interface org.bukkit.configuration.serialization.ConfigurationSerializable
serialize
Methods inherited from interface org.bukkit.permissions.ServerOperator
isOp, setOp
-
Method Details
-
isOnline
boolean isOnline()Checks if this player is currently online It should be noted that this will return true if any instance of this player is online! This instance may have disconnected. If you wish to check if this specific instance of the player is still online, seeisConnected()
.- Returns:
- true if they are online
-
isConnected
boolean isConnected()Checks whether the connection to this player is still valid. This will return true as long as this specific instance of the player is still connected. This will return false after this instance has disconnected, even if the same player has reconnected since.- Returns:
- true if this player instance is connected
-
getName
Returns the name of this playerNames are no longer unique past a single game session. For persistent storage it is recommended that you use
getUniqueId()
instead.- Specified by:
getName
in interfaceAnimalTamer
- Returns:
- Player name or null if we have not seen a name for this player yet
-
getUniqueId
Returns the UUID of this player- Specified by:
getUniqueId
in interfaceAnimalTamer
- Returns:
- Player UUID
-
getPlayerProfile
Gets a copy of the player's profile.If the player is online, the returned profile will be complete. Otherwise, only the unique id is guaranteed to be present. You can use
PlayerProfile.update()
to complete the returned profile.- Returns:
- the player's profile
-
isBanned
boolean isBanned()Checks if this player has had their profile banned.- Returns:
- true if banned, otherwise false
-
banPlayer
@NotNull @Deprecated(since="1.20.4") default @NotNull BanEntry banPlayer(@Nullable @Nullable String reason) Deprecated.Permanently Bans this player from the server- Parameters:
reason
- Reason for Ban- Returns:
- Ban Entry
-
banPlayer
@NotNull @Deprecated(since="1.20.4") default @NotNull BanEntry banPlayer(@Nullable @Nullable String reason, @Nullable @Nullable String source) Deprecated.Permanently Bans this player from the server- Parameters:
reason
- Reason for Bansource
- Source of the ban, or null for default- Returns:
- Ban Entry
-
banPlayer
@NotNull @Deprecated(since="1.20.4") default @NotNull BanEntry banPlayer(@Nullable @Nullable String reason, @Nullable Date expires) Deprecated.Bans this player from the server- Parameters:
reason
- Reason for Banexpires
- When to expire the ban- Returns:
- Ban Entry
-
banPlayer
@NotNull @Deprecated(since="1.20.4") default @NotNull BanEntry banPlayer(@Nullable @Nullable String reason, @Nullable Date expires, @Nullable @Nullable String source) Deprecated.Bans this player from the server- Parameters:
reason
- Reason for Banexpires
- When to expire the bansource
- Source of the ban or null for default- Returns:
- Ban Entry
-
banPlayer
@NotNull @Deprecated(since="1.20.4") default @NotNull BanEntry banPlayer(@Nullable @Nullable String reason, @Nullable Date expires, @Nullable @Nullable String source, boolean kickIfOnline) Deprecated. -
ban
@Nullable <E extends BanEntry<? super PlayerProfile>> E ban(@Nullable @Nullable String reason, @Nullable @Nullable Date expires, @Nullable @Nullable String source) Adds this user to theProfileBanList
. If a previous ban exists, this will update the entry.- Parameters:
reason
- reason for the ban, null indicates implementation defaultexpires
- date for the ban's expiration (unban), or null to imply foreversource
- source of the ban, null indicates implementation default- Returns:
- the entry for the newly created ban, or the entry for the (updated) previous ban
-
ban
@Nullable <E extends BanEntry<? super PlayerProfile>> E ban(@Nullable @Nullable String reason, @Nullable @Nullable Instant expires, @Nullable @Nullable String source) Adds this user to theProfileBanList
. If a previous ban exists, this will update the entry.- Parameters:
reason
- reason for the ban, null indicates implementation defaultexpires
- instant for the ban's expiration (unban), or null to imply foreversource
- source of the ban, null indicates implementation default- Returns:
- the entry for the newly created ban, or the entry for the (updated) previous ban
-
ban
@Nullable <E extends BanEntry<? super PlayerProfile>> E ban(@Nullable @Nullable String reason, @Nullable @Nullable Duration duration, @Nullable @Nullable String source) Adds this user to theProfileBanList
. If a previous ban exists, this will update the entry.- Parameters:
reason
- reason for the ban, null indicates implementation defaultduration
- how long the ban last, or null to imply foreversource
- source of the ban, null indicates implementation default- Returns:
- the entry for the newly created ban, or the entry for the (updated) previous ban
-
isWhitelisted
boolean isWhitelisted()Checks if this player is whitelisted or not- Returns:
- true if whitelisted
-
setWhitelisted
void setWhitelisted(boolean value) Sets if this player is whitelisted or not- Parameters:
value
- true if whitelisted
-
getPlayer
Gets aPlayer
object that this represents, if there is oneIf the player is online, this will return that player. Otherwise, it will return null.
- Returns:
- Online player
-
getFirstPlayed
long getFirstPlayed()Gets the first date and time that this player was witnessed on this server.If the player has never played before, this will return 0. Otherwise, it will be the amount of milliseconds since midnight, January 1, 1970 UTC.
- Returns:
- Date of first log-in for this player, or 0
-
getLastPlayed
Deprecated.The API contract is ambiguous and the implementation may or may not return the correct value given this API ambiguity. It is instead recommended usegetLastLogin()
orgetLastSeen()
depending on your needs.Gets the last date and time that this player was witnessed on this server.If the player has never played before, this will return 0. Otherwise, it will be the amount of milliseconds since midnight, January 1, 1970 UTC.
- Returns:
- Date of last log-in for this player, or 0
-
hasPlayedBefore
boolean hasPlayedBefore()Checks if this player has played on this server before.- Returns:
- True if the player has played before, otherwise false
-
getBedSpawnLocation
Deprecated.Misleading name. This method also returns the location of respawn anchors.Gets the Location where the player will spawn at their bed, null if they have not slept in one or their current bed spawn is invalid.- Returns:
- Bed Spawn Location if bed exists, otherwise null.
- See Also:
-
getLastLogin
long getLastLogin()Gets the last date and time that this player logged into the server.If the player has never played before, this will return 0. Otherwise, it will be the amount of milliseconds since midnight, January 1, 1970 UTC.
- Returns:
- last login time
-
getLastSeen
long getLastSeen()Gets the last date and time that this player was seen on the server.If the player has never played before, this will return 0. If the player is currently online, this will return the current time. Otherwise it will be the amount of milliseconds since midnight, January 1, 1970 UTC.
- Returns:
- last seen time
-
getRespawnLocation
Gets the Location where the player will spawn at, null if they don't have a valid respawn point.- Returns:
- respawn location if exists, otherwise null.
-
incrementStatistic
Increments the given statistic for this player.This is equivalent to the following code:
incrementStatistic(Statistic, 1)
- Parameters:
statistic
- Statistic to increment- Throws:
IllegalArgumentException
- if statistic is nullIllegalArgumentException
- if the statistic requires an additional parameter
-
decrementStatistic
Decrements the given statistic for this player.This is equivalent to the following code:
decrementStatistic(Statistic, 1)
- Parameters:
statistic
- Statistic to decrement- Throws:
IllegalArgumentException
- if statistic is nullIllegalArgumentException
- if the statistic requires an additional parameter
-
incrementStatistic
void incrementStatistic(@NotNull @NotNull Statistic statistic, int amount) throws IllegalArgumentException Increments the given statistic for this player.- Parameters:
statistic
- Statistic to incrementamount
- Amount to increment this statistic by- Throws:
IllegalArgumentException
- if statistic is nullIllegalArgumentException
- if amount is negativeIllegalArgumentException
- if the statistic requires an additional parameter
-
decrementStatistic
void decrementStatistic(@NotNull @NotNull Statistic statistic, int amount) throws IllegalArgumentException Decrements the given statistic for this player.- Parameters:
statistic
- Statistic to decrementamount
- Amount to decrement this statistic by- Throws:
IllegalArgumentException
- if statistic is nullIllegalArgumentException
- if amount is negativeIllegalArgumentException
- if the statistic requires an additional parameter
-
setStatistic
void setStatistic(@NotNull @NotNull Statistic statistic, int newValue) throws IllegalArgumentException Sets the given statistic for this player.- Parameters:
statistic
- Statistic to setnewValue
- The value to set this statistic to- Throws:
IllegalArgumentException
- if statistic is nullIllegalArgumentException
- if newValue is negativeIllegalArgumentException
- if the statistic requires an additional parameter
-
getStatistic
Gets the value of the given statistic for this player.- Parameters:
statistic
- Statistic to check- Returns:
- the value of the given statistic
- Throws:
IllegalArgumentException
- if statistic is nullIllegalArgumentException
- if the statistic requires an additional parameter
-
incrementStatistic
void incrementStatistic(@NotNull @NotNull Statistic statistic, @NotNull @NotNull Material material) throws IllegalArgumentException Increments the given statistic for this player for the given material.This is equivalent to the following code:
incrementStatistic(Statistic, Material, 1)
- Parameters:
statistic
- Statistic to incrementmaterial
- Material to offset the statistic with- Throws:
IllegalArgumentException
- if statistic is nullIllegalArgumentException
- if material is nullIllegalArgumentException
- if the given parameter is not valid for the statistic
-
decrementStatistic
void decrementStatistic(@NotNull @NotNull Statistic statistic, @NotNull @NotNull Material material) throws IllegalArgumentException Decrements the given statistic for this player for the given material.This is equivalent to the following code:
decrementStatistic(Statistic, Material, 1)
- Parameters:
statistic
- Statistic to decrementmaterial
- Material to offset the statistic with- Throws:
IllegalArgumentException
- if statistic is nullIllegalArgumentException
- if material is nullIllegalArgumentException
- if the given parameter is not valid for the statistic
-
getStatistic
int getStatistic(@NotNull @NotNull Statistic statistic, @NotNull @NotNull Material material) throws IllegalArgumentException Gets the value of the given statistic for this player.- Parameters:
statistic
- Statistic to checkmaterial
- Material offset of the statistic- Returns:
- the value of the given statistic
- Throws:
IllegalArgumentException
- if statistic is nullIllegalArgumentException
- if material is nullIllegalArgumentException
- if the given parameter is not valid for the statistic
-
incrementStatistic
void incrementStatistic(@NotNull @NotNull Statistic statistic, @NotNull @NotNull Material material, int amount) throws IllegalArgumentException Increments the given statistic for this player for the given material.- Parameters:
statistic
- Statistic to incrementmaterial
- Material to offset the statistic withamount
- Amount to increment this statistic by- Throws:
IllegalArgumentException
- if statistic is nullIllegalArgumentException
- if material is nullIllegalArgumentException
- if amount is negativeIllegalArgumentException
- if the given parameter is not valid for the statistic
-
decrementStatistic
void decrementStatistic(@NotNull @NotNull Statistic statistic, @NotNull @NotNull Material material, int amount) throws IllegalArgumentException Decrements the given statistic for this player for the given material.- Parameters:
statistic
- Statistic to decrementmaterial
- Material to offset the statistic withamount
- Amount to decrement this statistic by- Throws:
IllegalArgumentException
- if statistic is nullIllegalArgumentException
- if material is nullIllegalArgumentException
- if amount is negativeIllegalArgumentException
- if the given parameter is not valid for the statistic
-
setStatistic
void setStatistic(@NotNull @NotNull Statistic statistic, @NotNull @NotNull Material material, int newValue) throws IllegalArgumentException Sets the given statistic for this player for the given material.- Parameters:
statistic
- Statistic to setmaterial
- Material to offset the statistic withnewValue
- The value to set this statistic to- Throws:
IllegalArgumentException
- if statistic is nullIllegalArgumentException
- if material is nullIllegalArgumentException
- if newValue is negativeIllegalArgumentException
- if the given parameter is not valid for the statistic
-
incrementStatistic
void incrementStatistic(@NotNull @NotNull Statistic statistic, @NotNull @NotNull EntityType entityType) throws IllegalArgumentException Increments the given statistic for this player for the given entity.This is equivalent to the following code:
incrementStatistic(Statistic, EntityType, 1)
- Parameters:
statistic
- Statistic to incremententityType
- EntityType to offset the statistic with- Throws:
IllegalArgumentException
- if statistic is nullIllegalArgumentException
- if entityType is nullIllegalArgumentException
- if the given parameter is not valid for the statistic
-
decrementStatistic
void decrementStatistic(@NotNull @NotNull Statistic statistic, @NotNull @NotNull EntityType entityType) throws IllegalArgumentException Decrements the given statistic for this player for the given entity.This is equivalent to the following code:
decrementStatistic(Statistic, EntityType, 1)
- Parameters:
statistic
- Statistic to decremententityType
- EntityType to offset the statistic with- Throws:
IllegalArgumentException
- if statistic is nullIllegalArgumentException
- if entityType is nullIllegalArgumentException
- if the given parameter is not valid for the statistic
-
getStatistic
int getStatistic(@NotNull @NotNull Statistic statistic, @NotNull @NotNull EntityType entityType) throws IllegalArgumentException Gets the value of the given statistic for this player.- Parameters:
statistic
- Statistic to checkentityType
- EntityType offset of the statistic- Returns:
- the value of the given statistic
- Throws:
IllegalArgumentException
- if statistic is nullIllegalArgumentException
- if entityType is nullIllegalArgumentException
- if the given parameter is not valid for the statistic
-
incrementStatistic
void incrementStatistic(@NotNull @NotNull Statistic statistic, @NotNull @NotNull EntityType entityType, int amount) throws IllegalArgumentException Increments the given statistic for this player for the given entity.- Parameters:
statistic
- Statistic to incremententityType
- EntityType to offset the statistic withamount
- Amount to increment this statistic by- Throws:
IllegalArgumentException
- if statistic is nullIllegalArgumentException
- if entityType is nullIllegalArgumentException
- if amount is negativeIllegalArgumentException
- if the given parameter is not valid for the statistic
-
decrementStatistic
void decrementStatistic(@NotNull @NotNull Statistic statistic, @NotNull @NotNull EntityType entityType, int amount) Decrements the given statistic for this player for the given entity.- Parameters:
statistic
- Statistic to decremententityType
- EntityType to offset the statistic withamount
- Amount to decrement this statistic by- Throws:
IllegalArgumentException
- if statistic is nullIllegalArgumentException
- if entityType is nullIllegalArgumentException
- if amount is negativeIllegalArgumentException
- if the given parameter is not valid for the statistic
-
setStatistic
void setStatistic(@NotNull @NotNull Statistic statistic, @NotNull @NotNull EntityType entityType, int newValue) Sets the given statistic for this player for the given entity.- Parameters:
statistic
- Statistic to setentityType
- EntityType to offset the statistic withnewValue
- The value to set this statistic to- Throws:
IllegalArgumentException
- if statistic is nullIllegalArgumentException
- if entityType is nullIllegalArgumentException
- if newValue is negativeIllegalArgumentException
- if the given parameter is not valid for the statistic
-
getLastDeathLocation
Gets the player's last death location.- Returns:
- the last death location if it exists, otherwise null.
-
getLocation
Gets the player's current location.- Returns:
- the player's location,
null
if player hasn't ever played before.
-
getPersistentDataContainer
@NotNull PersistentDataContainerView getPersistentDataContainer()Yields a view of the persistent data container for this offline player. In case thisOfflinePlayer
instance was created for an offline player, the returned view will wrap the persistent data on disk.As such, this method as well as queries to the
PersistentDataContainerView
may produce blocking IO requests to read the requested data from disk. Caution in its usage is hence advised.- Specified by:
getPersistentDataContainer
in interfacePersistentDataViewHolder
- Returns:
- the persistent data container view
- See Also:
-
getAllowFlight
boolean getAllowFlight()Determines if the OfflinePlayer is allowed to fly via jump key double-tap like in creative mode.- Returns:
- True if the player is allowed to fly.
-
setAllowFlight
void setAllowFlight(boolean flight) Sets if the OfflinePlayer is allowed to fly via jump key double-tap like in creative mode.- Parameters:
flight
- If flight should be allowed.
-
isFlying
boolean isFlying()Checks to see if this player is currently flying or not.- Returns:
- True if the player is flying, else false.
-
setFlying
void setFlying(boolean value) Makes this player start or stop flying.- Parameters:
value
- True to fly.
-
setFlySpeed
Sets the speed at which a client will fly. Negative values indicate reverse directions.- Parameters:
value
- The new speed, from -1 to 1.- Throws:
IllegalArgumentException
- If new speed is less than -1 or greater than 1
-
setWalkSpeed
Sets the speed at which a client will walk. Negative values indicate reverse directions.- Parameters:
value
- The new speed, from -1 to 1.- Throws:
IllegalArgumentException
- If new speed is less than -1 or greater than 1
-
getFlySpeed
float getFlySpeed()Gets the current allowed speed that a client can fly.- Returns:
- The current allowed speed, from -1 to 1
-
getWalkSpeed
float getWalkSpeed()Gets the current allowed speed that a client can walk.- Returns:
- The current allowed speed, from -1 to 1
-
teleportOffline
Sets OfflinePlayer's location. If player is online, it falls back to the Player#teleport implementation.- Parameters:
destination
-- Returns:
- true if teleportation was successful
-
teleportOffline
boolean teleportOffline(@NotNull Location destination, @NotNull PlayerTeleportEvent.TeleportCause cause) Sets OfflinePlayer's location. If player is online, it falls back to the Player#teleport implementation.- Parameters:
destination
-cause
- Teleport cause used if player is online- Returns:
- true if teleportation was successful
-
teleportOfflineAsync
Sets OfflinePlayer's location. If player is online, it falls back to the Player#teleportAsync implementation.- Parameters:
destination
-- Returns:
true
if teleportation successful
-
teleportOfflineAsync
@NotNull CompletableFuture<Boolean> teleportOfflineAsync(@NotNull @NotNull Location destination, @NotNull PlayerTeleportEvent.TeleportCause cause) Sets OfflinePlayer's location. If player is online, it falls back to the Player#teleportAsync implementation.- Parameters:
destination
-cause
- Teleport cause used if player is online- Returns:
true
if teleportation successful
-
ban(String, Date, String)