Package org.bukkit

Interface OfflinePlayer

All Superinterfaces:
AnimalTamer, ConfigurationSerializable, ServerOperator
All Known Subinterfaces:
Player

public interface OfflinePlayer extends ServerOperator, AnimalTamer, ConfigurationSerializable
Represents a reference to a player identity and the data belonging to a player that is stored on the disk and can, thus, be retrieved without the player needing to be online.
  • Method Details

    • isOnline

      boolean isOnline()
      Checks if this player is currently online
      Returns:
      true if they are online
    • getName

      @Nullable String getName()
      Returns the name of this player

      Names are no longer unique past a single game session. For persistent storage it is recommended that you use getUniqueId() instead.

      Specified by:
      getName in interface AnimalTamer
      Returns:
      Player name or null if we have not seen a name for this player yet
    • getUniqueId

      @NotNull UUID getUniqueId()
      Returns the UUID of this player
      Specified by:
      getUniqueId in interface AnimalTamer
      Returns:
      Player UUID
    • getPlayerProfile

      @NotNull PlayerProfile 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
    • ban

      @Nullable BanEntry<PlayerProfile> ban(@Nullable String reason, @Nullable Date expires, @Nullable String source)
      Adds this user to the ProfileBanList. If a previous ban exists, this will update the entry.
      Parameters:
      reason - reason for the ban, null indicates implementation default
      expires - date for the ban's expiration (unban), or null to imply forever
      source - 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 BanEntry<PlayerProfile> ban(@Nullable String reason, @Nullable Instant expires, @Nullable String source)
      Adds this user to the ProfileBanList. If a previous ban exists, this will update the entry.
      Parameters:
      reason - reason for the ban, null indicates implementation default
      expires - instant for the ban's expiration (unban), or null to imply forever
      source - 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 BanEntry<PlayerProfile> ban(@Nullable String reason, @Nullable Duration duration, @Nullable String source)
      Adds this user to the ProfileBanList. If a previous ban exists, this will update the entry.
      Parameters:
      reason - reason for the ban, null indicates implementation default
      duration - how long the ban last, or null to imply forever
      source - 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

      @Nullable Player getPlayer()
      Gets a Player object that this represents, if there is one

      If 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

      long getLastPlayed()
      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

      @Nullable @Deprecated(since="1.20.4") Location 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:
    • getRespawnLocation

      @Nullable Location 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

      void incrementStatistic(@NotNull Statistic statistic) throws IllegalArgumentException
      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 null
      IllegalArgumentException - if the statistic requires an additional parameter
    • decrementStatistic

      void decrementStatistic(@NotNull Statistic statistic) throws IllegalArgumentException
      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 null
      IllegalArgumentException - if the statistic requires an additional parameter
    • incrementStatistic

      void incrementStatistic(@NotNull Statistic statistic, int amount) throws IllegalArgumentException
      Increments the given statistic for this player.
      Parameters:
      statistic - Statistic to increment
      amount - Amount to increment this statistic by
      Throws:
      IllegalArgumentException - if statistic is null
      IllegalArgumentException - if amount is negative
      IllegalArgumentException - if the statistic requires an additional parameter
    • decrementStatistic

      void decrementStatistic(@NotNull Statistic statistic, int amount) throws IllegalArgumentException
      Decrements the given statistic for this player.
      Parameters:
      statistic - Statistic to decrement
      amount - Amount to decrement this statistic by
      Throws:
      IllegalArgumentException - if statistic is null
      IllegalArgumentException - if amount is negative
      IllegalArgumentException - if the statistic requires an additional parameter
    • setStatistic

      void setStatistic(@NotNull Statistic statistic, int newValue) throws IllegalArgumentException
      Sets the given statistic for this player.
      Parameters:
      statistic - Statistic to set
      newValue - The value to set this statistic to
      Throws:
      IllegalArgumentException - if statistic is null
      IllegalArgumentException - if newValue is negative
      IllegalArgumentException - if the statistic requires an additional parameter
    • getStatistic

      int getStatistic(@NotNull Statistic statistic) throws IllegalArgumentException
      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 null
      IllegalArgumentException - if the statistic requires an additional parameter
    • incrementStatistic

      void incrementStatistic(@NotNull Statistic statistic, @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 increment
      material - Material to offset the statistic with
      Throws:
      IllegalArgumentException - if statistic is null
      IllegalArgumentException - if material is null
      IllegalArgumentException - if the given parameter is not valid for the statistic
    • decrementStatistic

      void decrementStatistic(@NotNull Statistic statistic, @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 decrement
      material - Material to offset the statistic with
      Throws:
      IllegalArgumentException - if statistic is null
      IllegalArgumentException - if material is null
      IllegalArgumentException - if the given parameter is not valid for the statistic
    • getStatistic

      int getStatistic(@NotNull Statistic statistic, @NotNull Material material) throws IllegalArgumentException
      Gets the value of the given statistic for this player.
      Parameters:
      statistic - Statistic to check
      material - Material offset of the statistic
      Returns:
      the value of the given statistic
      Throws:
      IllegalArgumentException - if statistic is null
      IllegalArgumentException - if material is null
      IllegalArgumentException - if the given parameter is not valid for the statistic
    • incrementStatistic

      void incrementStatistic(@NotNull Statistic statistic, @NotNull Material material, int amount) throws IllegalArgumentException
      Increments the given statistic for this player for the given material.
      Parameters:
      statistic - Statistic to increment
      material - Material to offset the statistic with
      amount - Amount to increment this statistic by
      Throws:
      IllegalArgumentException - if statistic is null
      IllegalArgumentException - if material is null
      IllegalArgumentException - if amount is negative
      IllegalArgumentException - if the given parameter is not valid for the statistic
    • decrementStatistic

      void decrementStatistic(@NotNull Statistic statistic, @NotNull Material material, int amount) throws IllegalArgumentException
      Decrements the given statistic for this player for the given material.
      Parameters:
      statistic - Statistic to decrement
      material - Material to offset the statistic with
      amount - Amount to decrement this statistic by
      Throws:
      IllegalArgumentException - if statistic is null
      IllegalArgumentException - if material is null
      IllegalArgumentException - if amount is negative
      IllegalArgumentException - if the given parameter is not valid for the statistic
    • setStatistic

      void setStatistic(@NotNull Statistic statistic, @NotNull Material material, int newValue) throws IllegalArgumentException
      Sets the given statistic for this player for the given material.
      Parameters:
      statistic - Statistic to set
      material - Material to offset the statistic with
      newValue - The value to set this statistic to
      Throws:
      IllegalArgumentException - if statistic is null
      IllegalArgumentException - if material is null
      IllegalArgumentException - if newValue is negative
      IllegalArgumentException - if the given parameter is not valid for the statistic
    • incrementStatistic

      void incrementStatistic(@NotNull Statistic statistic, @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 increment
      entityType - EntityType to offset the statistic with
      Throws:
      IllegalArgumentException - if statistic is null
      IllegalArgumentException - if entityType is null
      IllegalArgumentException - if the given parameter is not valid for the statistic
    • decrementStatistic

      void decrementStatistic(@NotNull Statistic statistic, @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 decrement
      entityType - EntityType to offset the statistic with
      Throws:
      IllegalArgumentException - if statistic is null
      IllegalArgumentException - if entityType is null
      IllegalArgumentException - if the given parameter is not valid for the statistic
    • getStatistic

      int getStatistic(@NotNull Statistic statistic, @NotNull EntityType entityType) throws IllegalArgumentException
      Gets the value of the given statistic for this player.
      Parameters:
      statistic - Statistic to check
      entityType - EntityType offset of the statistic
      Returns:
      the value of the given statistic
      Throws:
      IllegalArgumentException - if statistic is null
      IllegalArgumentException - if entityType is null
      IllegalArgumentException - if the given parameter is not valid for the statistic
    • incrementStatistic

      void incrementStatistic(@NotNull Statistic statistic, @NotNull EntityType entityType, int amount) throws IllegalArgumentException
      Increments the given statistic for this player for the given entity.
      Parameters:
      statistic - Statistic to increment
      entityType - EntityType to offset the statistic with
      amount - Amount to increment this statistic by
      Throws:
      IllegalArgumentException - if statistic is null
      IllegalArgumentException - if entityType is null
      IllegalArgumentException - if amount is negative
      IllegalArgumentException - if the given parameter is not valid for the statistic
    • decrementStatistic

      void decrementStatistic(@NotNull Statistic statistic, @NotNull EntityType entityType, int amount)
      Decrements the given statistic for this player for the given entity.
      Parameters:
      statistic - Statistic to decrement
      entityType - EntityType to offset the statistic with
      amount - Amount to decrement this statistic by
      Throws:
      IllegalArgumentException - if statistic is null
      IllegalArgumentException - if entityType is null
      IllegalArgumentException - if amount is negative
      IllegalArgumentException - if the given parameter is not valid for the statistic
    • setStatistic

      void setStatistic(@NotNull Statistic statistic, @NotNull EntityType entityType, int newValue)
      Sets the given statistic for this player for the given entity.
      Parameters:
      statistic - Statistic to set
      entityType - EntityType to offset the statistic with
      newValue - The value to set this statistic to
      Throws:
      IllegalArgumentException - if statistic is null
      IllegalArgumentException - if entityType is null
      IllegalArgumentException - if newValue is negative
      IllegalArgumentException - if the given parameter is not valid for the statistic
    • getLastDeathLocation

      @Nullable Location getLastDeathLocation()
      Gets the player's last death location.
      Returns:
      the last death location if it exists, otherwise null.
    • getLocation

      @Nullable Location getLocation()
      Gets the player's current location.
      Returns:
      the player's location, null if player hasn't ever played before.