Interface Player

All Superinterfaces:
AnimalTamer, CommandSender, ConfigurationSerializable, Conversable, Damageable, Entity, HumanEntity, InventoryHolder, LivingEntity, Metadatable, OfflinePlayer, Permissible, PluginMessageRecipient, ProjectileSource, ServerOperator

public interface Player
extends HumanEntity, Conversable, CommandSender, OfflinePlayer, PluginMessageRecipient
Represents a player, connected or not
  • Method Details

    • getDisplayName

      java.lang.String getDisplayName()
      Gets the "friendly" name to display of this player. This may include color.

      Note that this name will not be displayed in game, only in chat and places defined by plugins.

      Returns:
      the friendly name
    • setDisplayName

      void setDisplayName​(java.lang.String name)
      Sets the "friendly" name to display of this player. This may include color.

      Note that this name will not be displayed in game, only in chat and places defined by plugins.

      Parameters:
      name - The new display name.
    • getPlayerListName

      java.lang.String getPlayerListName()
      Gets the name that is shown on the player list.
      Returns:
      the player list name
    • setPlayerListName

      void setPlayerListName​(java.lang.String name)
      Sets the name that is shown on the in-game player list.

      The name cannot be longer than 16 characters, but ChatColor is supported.

      If the value is null, the name will be identical to HumanEntity.getName().

      This name is case sensitive and unique, two names with different casing will appear as two different people. If a player joins afterwards with a name that conflicts with a player's custom list name, the joining player's player list name will have a random number appended to it (1-2 characters long in the default implementation). If the joining player's name is 15 or 16 characters long, part of the name will be truncated at the end to allow the addition of the two digits.

      Parameters:
      name - new player list name
      Throws:
      java.lang.IllegalArgumentException - if the name is already used by someone else
      java.lang.IllegalArgumentException - if the length of the name is too long
    • setCompassTarget

      void setCompassTarget​(Location loc)
      Set the target of the player's compass.
      Parameters:
      loc - Location to point to
    • getCompassTarget

      Location getCompassTarget()
      Get the previously set compass target.
      Returns:
      location of the target
    • getAddress

      java.net.InetSocketAddress getAddress()
      Gets the socket address of this player
      Returns:
      the player's address
    • sendRawMessage

      void sendRawMessage​(java.lang.String message)
      Sends this sender a message raw
      Specified by:
      sendRawMessage in interface Conversable
      Parameters:
      message - Message to be displayed
    • kickPlayer

      void kickPlayer​(java.lang.String message)
      Kicks player with custom kick message.
      Parameters:
      message - kick message
    • chat

      void chat​(java.lang.String msg)
      Says a message (or runs a command).
      Parameters:
      msg - message to print
    • performCommand

      boolean performCommand​(java.lang.String command)
      Makes the player perform the given command
      Parameters:
      command - Command to perform
      Returns:
      true if the command was successful, otherwise false
    • isSneaking

      boolean isSneaking()
      Returns if the player is in sneak mode
      Returns:
      true if player is in sneak mode
    • setSneaking

      void setSneaking​(boolean sneak)
      Sets the sneak mode the player
      Parameters:
      sneak - true if player should appear sneaking
    • isSprinting

      boolean isSprinting()
      Gets whether the player is sprinting or not.
      Returns:
      true if player is sprinting.
    • setSprinting

      void setSprinting​(boolean sprinting)
      Sets whether the player is sprinting or not.
      Parameters:
      sprinting - true if the player should be sprinting
    • saveData

      void saveData()
      Saves the players current location, health, inventory, motion, and other information into the username.dat file, in the world/player folder
    • loadData

      void loadData()
      Loads the players current location, health, inventory, motion, and other information from the username.dat file, in the world/player folder.

      Note: This will overwrite the players current inventory, health, motion, etc, with the state from the saved dat file.

    • setSleepingIgnored

      void setSleepingIgnored​(boolean isSleeping)
      Sets whether the player is ignored as not sleeping. If everyone is either sleeping or has this flag set, then time will advance to the next day. If everyone has this flag set but no one is actually in bed, then nothing will happen.
      Parameters:
      isSleeping - Whether to ignore.
    • isSleepingIgnored

      boolean isSleepingIgnored()
      Returns whether the player is sleeping ignored.
      Returns:
      Whether player is ignoring sleep.
    • playNote

      @Deprecated void playNote​(Location loc, byte instrument, byte note)
      Deprecated.
      Magic value
      Play a note for a player at a location. This requires a note block at the particular location (as far as the client is concerned). This will not work without a note block. This will not work with cake.
      Parameters:
      loc - The location of a note block.
      instrument - The instrument ID.
      note - The note ID.
    • playNote

      void playNote​(Location loc, Instrument instrument, Note note)
      Play a note for a player at a location. This requires a note block at the particular location (as far as the client is concerned). This will not work without a note block. This will not work with cake.
      Parameters:
      loc - The location of a note block
      instrument - The instrument
      note - The note
    • playSound

      void playSound​(Location location, Sound sound, float volume, float pitch)
      Play a sound for a player at the location.

      This function will fail silently if Location or Sound are null.

      Parameters:
      location - The location to play the sound
      sound - The sound to play
      volume - The volume of the sound
      pitch - The pitch of the sound
    • playSound

      void playSound​(Location location, java.lang.String sound, float volume, float pitch)
      Play a sound for a player at the location.

      This function will fail silently if Location or Sound are null. No sound will be heard by the player if their client does not have the respective sound for the value passed.

      Parameters:
      location - the location to play the sound
      sound - the internal sound name to play
      volume - the volume of the sound
      pitch - the pitch of the sound
    • playEffect

      @Deprecated void playEffect​(Location loc, Effect effect, int data)
      Deprecated.
      Magic value
      Plays an effect to just this player.
      Parameters:
      loc - the location to play the effect at
      effect - the Effect
      data - a data bit needed for some effects
    • playEffect

      <T> void playEffect​(Location loc, Effect effect, T data)
      Plays an effect to just this player.
      Type Parameters:
      T - the data based based on the type of the effect
      Parameters:
      loc - the location to play the effect at
      effect - the Effect
      data - a data bit needed for some effects
    • sendBlockChange

      @Deprecated void sendBlockChange​(Location loc, Material material, byte data)
      Deprecated.
      Magic value
      Send a block change. This fakes a block change packet for a user at a certain location. This will not actually change the world in any way.
      Parameters:
      loc - The location of the changed block
      material - The new block
      data - The block data
    • sendChunkChange

      @Deprecated boolean sendChunkChange​(Location loc, int sx, int sy, int sz, byte[] data)
      Deprecated.
      Magic value
      Send a chunk change. This fakes a chunk change packet for a user at a certain location. The updated cuboid must be entirely within a single chunk. This will not actually change the world in any way.

      At least one of the dimensions of the cuboid must be even. The size of the data buffer must be 2.5*sx*sy*sz and formatted in accordance with the Packet51 format.

      Parameters:
      loc - The location of the cuboid
      sx - The x size of the cuboid
      sy - The y size of the cuboid
      sz - The z size of the cuboid
      data - The data to be sent
      Returns:
      true if the chunk change packet was sent
    • sendBlockChange

      @Deprecated void sendBlockChange​(Location loc, int material, byte data)
      Deprecated.
      Magic value
      Send a block change. This fakes a block change packet for a user at a certain location. This will not actually change the world in any way.
      Parameters:
      loc - The location of the changed block
      material - The new block ID
      data - The block data
    • sendSignChange

      void sendSignChange​(Location loc, java.lang.String[] lines) throws java.lang.IllegalArgumentException
      Send a sign change. This fakes a sign change packet for a user at a certain location. This will not actually change the world in any way. This method will use a sign at the location's block or a faked sign sent via sendBlockChange(org.bukkit.Location, int, byte) or sendBlockChange(org.bukkit.Location, org.bukkit.Material, byte).

      If the client does not have a sign at the given location it will display an error message to the user.

      Parameters:
      loc - the location of the sign
      lines - the new text on the sign or null to clear it
      Throws:
      java.lang.IllegalArgumentException - if location is null
      java.lang.IllegalArgumentException - if lines is non-null and has a length less than 4
    • sendMap

      void sendMap​(MapView map)
      Render a map and send it to the player in its entirety. This may be used when streaming the map in the normal manner is not desirable.
      Parameters:
      map - The map to be sent
    • updateInventory

      void updateInventory()
      Forces an update of the player's entire inventory.
    • awardAchievement

      void awardAchievement​(Achievement achievement)
      Awards the given achievement and any parent achievements that the player does not have.
      Parameters:
      achievement - Achievement to award
      Throws:
      java.lang.IllegalArgumentException - if achievement is null
    • removeAchievement

      void removeAchievement​(Achievement achievement)
      Removes the given achievement and any children achievements that the player has.
      Parameters:
      achievement - Achievement to remove
      Throws:
      java.lang.IllegalArgumentException - if achievement is null
    • hasAchievement

      boolean hasAchievement​(Achievement achievement)
      Gets whether this player has the given achievement.
      Parameters:
      achievement - the achievement to check
      Returns:
      whether the player has the achievement
      Throws:
      java.lang.IllegalArgumentException - if achievement is null
    • incrementStatistic

      void incrementStatistic​(Statistic statistic) throws java.lang.IllegalArgumentException
      Increments the given statistic for this player.

      This is equivalent to the following code: incrementStatistic(Statistic, 1)

      Parameters:
      statistic - Statistic to increment
      Throws:
      java.lang.IllegalArgumentException - if statistic is null
      java.lang.IllegalArgumentException - if the statistic requires an additional parameter
    • decrementStatistic

      void decrementStatistic​(Statistic statistic) throws java.lang.IllegalArgumentException
      Decrements the given statistic for this player.

      This is equivalent to the following code: decrementStatistic(Statistic, 1)

      Parameters:
      statistic - Statistic to decrement
      Throws:
      java.lang.IllegalArgumentException - if statistic is null
      java.lang.IllegalArgumentException - if the statistic requires an additional parameter
    • incrementStatistic

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

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

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

      int getStatistic​(Statistic statistic) throws java.lang.IllegalArgumentException
      Gets the value of the given statistic for this player.
      Parameters:
      statistic - Statistic to check
      Returns:
      the value of the given statistic
      Throws:
      java.lang.IllegalArgumentException - if statistic is null
      java.lang.IllegalArgumentException - if the statistic requires an additional parameter
    • incrementStatistic

      void incrementStatistic​(Statistic statistic, Material material) throws java.lang.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:
      java.lang.IllegalArgumentException - if statistic is null
      java.lang.IllegalArgumentException - if material is null
      java.lang.IllegalArgumentException - if the given parameter is not valid for the statistic
    • decrementStatistic

      void decrementStatistic​(Statistic statistic, Material material) throws java.lang.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:
      java.lang.IllegalArgumentException - if statistic is null
      java.lang.IllegalArgumentException - if material is null
      java.lang.IllegalArgumentException - if the given parameter is not valid for the statistic
    • getStatistic

      int getStatistic​(Statistic statistic, Material material) throws java.lang.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:
      java.lang.IllegalArgumentException - if statistic is null
      java.lang.IllegalArgumentException - if material is null
      java.lang.IllegalArgumentException - if the given parameter is not valid for the statistic
    • incrementStatistic

      void incrementStatistic​(Statistic statistic, Material material, int amount) throws java.lang.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:
      java.lang.IllegalArgumentException - if statistic is null
      java.lang.IllegalArgumentException - if material is null
      java.lang.IllegalArgumentException - if amount is negative
      java.lang.IllegalArgumentException - if the given parameter is not valid for the statistic
    • decrementStatistic

      void decrementStatistic​(Statistic statistic, Material material, int amount) throws java.lang.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:
      java.lang.IllegalArgumentException - if statistic is null
      java.lang.IllegalArgumentException - if material is null
      java.lang.IllegalArgumentException - if amount is negative
      java.lang.IllegalArgumentException - if the given parameter is not valid for the statistic
    • setStatistic

      void setStatistic​(Statistic statistic, Material material, int newValue) throws java.lang.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:
      java.lang.IllegalArgumentException - if statistic is null
      java.lang.IllegalArgumentException - if material is null
      java.lang.IllegalArgumentException - if newValue is negative
      java.lang.IllegalArgumentException - if the given parameter is not valid for the statistic
    • incrementStatistic

      void incrementStatistic​(Statistic statistic, EntityType entityType) throws java.lang.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:
      java.lang.IllegalArgumentException - if statistic is null
      java.lang.IllegalArgumentException - if entityType is null
      java.lang.IllegalArgumentException - if the given parameter is not valid for the statistic
    • decrementStatistic

      void decrementStatistic​(Statistic statistic, EntityType entityType) throws java.lang.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:
      java.lang.IllegalArgumentException - if statistic is null
      java.lang.IllegalArgumentException - if entityType is null
      java.lang.IllegalArgumentException - if the given parameter is not valid for the statistic
    • getStatistic

      int getStatistic​(Statistic statistic, EntityType entityType) throws java.lang.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:
      java.lang.IllegalArgumentException - if statistic is null
      java.lang.IllegalArgumentException - if entityType is null
      java.lang.IllegalArgumentException - if the given parameter is not valid for the statistic
    • incrementStatistic

      void incrementStatistic​(Statistic statistic, EntityType entityType, int amount) throws java.lang.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:
      java.lang.IllegalArgumentException - if statistic is null
      java.lang.IllegalArgumentException - if entityType is null
      java.lang.IllegalArgumentException - if amount is negative
      java.lang.IllegalArgumentException - if the given parameter is not valid for the statistic
    • decrementStatistic

      void decrementStatistic​(Statistic statistic, 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:
      java.lang.IllegalArgumentException - if statistic is null
      java.lang.IllegalArgumentException - if entityType is null
      java.lang.IllegalArgumentException - if amount is negative
      java.lang.IllegalArgumentException - if the given parameter is not valid for the statistic
    • setStatistic

      void setStatistic​(Statistic statistic, 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:
      java.lang.IllegalArgumentException - if statistic is null
      java.lang.IllegalArgumentException - if entityType is null
      java.lang.IllegalArgumentException - if newValue is negative
      java.lang.IllegalArgumentException - if the given parameter is not valid for the statistic
    • setPlayerTime

      void setPlayerTime​(long time, boolean relative)
      Sets the current time on the player's client. When relative is true the player's time will be kept synchronized to its world time with the specified offset.

      When using non relative time the player's time will stay fixed at the specified time parameter. It's up to the caller to continue updating the player's time. To restore player time to normal use resetPlayerTime().

      Parameters:
      time - The current player's perceived time or the player's time offset from the server time.
      relative - When true the player time is kept relative to its world time.
    • getPlayerTime

      long getPlayerTime()
      Returns the player's current timestamp.
      Returns:
      The player's time
    • getPlayerTimeOffset

      long getPlayerTimeOffset()
      Returns the player's current time offset relative to server time, or the current player's fixed time if the player's time is absolute.
      Returns:
      The player's time
    • isPlayerTimeRelative

      boolean isPlayerTimeRelative()
      Returns true if the player's time is relative to the server time, otherwise the player's time is absolute and will not change its current time unless done so with setPlayerTime().
      Returns:
      true if the player's time is relative to the server time.
    • resetPlayerTime

      void resetPlayerTime()
      Restores the normal condition where the player's time is synchronized with the server time.

      Equivalent to calling setPlayerTime(0, true).

    • setPlayerWeather

      void setPlayerWeather​(WeatherType type)
      Sets the type of weather the player will see. When used, the weather status of the player is locked until resetPlayerWeather() is used.
      Parameters:
      type - The WeatherType enum type the player should experience
    • getPlayerWeather

      WeatherType getPlayerWeather()
      Returns the type of weather the player is currently experiencing.
      Returns:
      The WeatherType that the player is currently experiencing or null if player is seeing server weather.
    • resetPlayerWeather

      void resetPlayerWeather()
      Restores the normal condition where the player's weather is controlled by server conditions.
    • giveExp

      void giveExp​(int amount)
      Gives the player the amount of experience specified.
      Parameters:
      amount - Exp amount to give
    • giveExpLevels

      void giveExpLevels​(int amount)
      Gives the player the amount of experience levels specified. Levels can be taken by specifying a negative amount.
      Parameters:
      amount - amount of experience levels to give or take
    • getExp

      float getExp()
      Gets the players current experience points towards the next level.

      This is a percentage value. 0 is "no progress" and 1 is "next level".

      Returns:
      Current experience points
    • setExp

      void setExp​(float exp)
      Sets the players current experience points towards the next level

      This is a percentage value. 0 is "no progress" and 1 is "next level".

      Parameters:
      exp - New experience points
    • getLevel

      int getLevel()
      Gets the players current experience level
      Returns:
      Current experience level
    • setLevel

      void setLevel​(int level)
      Sets the players current experience level
      Parameters:
      level - New experience level
    • getTotalExperience

      int getTotalExperience()
      Gets the players total experience points
      Returns:
      Current total experience points
    • setTotalExperience

      void setTotalExperience​(int exp)
      Sets the players current experience level
      Parameters:
      exp - New experience level
    • getExhaustion

      float getExhaustion()
      Gets the players current exhaustion level.

      Exhaustion controls how fast the food level drops. While you have a certain amount of exhaustion, your saturation will drop to zero, and then your food will drop to zero.

      Returns:
      Exhaustion level
    • setExhaustion

      void setExhaustion​(float value)
      Sets the players current exhaustion level
      Parameters:
      value - Exhaustion level
    • getSaturation

      float getSaturation()
      Gets the players current saturation level.

      Saturation is a buffer for food level. Your food level will not drop if you are saturated > 0.

      Returns:
      Saturation level
    • setSaturation

      void setSaturation​(float value)
      Sets the players current saturation level
      Parameters:
      value - Saturation level
    • getFoodLevel

      int getFoodLevel()
      Gets the players current food level
      Returns:
      Food level
    • setFoodLevel

      void setFoodLevel​(int value)
      Sets the players current food level
      Parameters:
      value - New food level
    • getBedSpawnLocation

      Location getBedSpawnLocation()
      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.
      Specified by:
      getBedSpawnLocation in interface OfflinePlayer
      Returns:
      Bed Spawn Location if bed exists, otherwise null.
    • setBedSpawnLocation

      void setBedSpawnLocation​(Location location)
      Sets the Location where the player will spawn at their bed.
      Parameters:
      location - where to set the respawn location
    • setBedSpawnLocation

      void setBedSpawnLocation​(Location location, boolean force)
      Sets the Location where the player will spawn at their bed.
      Parameters:
      location - where to set the respawn location
      force - whether to forcefully set the respawn location even if a valid bed is not present
    • getAllowFlight

      boolean getAllowFlight()
      Determines if the Player 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 Player is allowed to fly via jump key double-tap like in creative mode.
      Parameters:
      flight - If flight should be allowed.
    • hidePlayer

      void hidePlayer​(Player player)
      Hides a player from this player
      Parameters:
      player - Player to hide
    • showPlayer

      void showPlayer​(Player player)
      Allows this player to see a player that was previously hidden
      Parameters:
      player - Player to show
    • canSee

      boolean canSee​(Player player)
      Checks to see if a player has been hidden from this player
      Parameters:
      player - Player to check
      Returns:
      True if the provided player is not being hidden from this player
    • isOnGround

      @Deprecated boolean isOnGround()
      Deprecated.
      Inconsistent with Entity.isOnGround()
      Checks to see if this player is currently standing on a block. This information may not be reliable, as it is a state provided by the client, and may therefore not be accurate.
      Specified by:
      isOnGround in interface Entity
      Returns:
      True if the player standing on a solid block, else false.
    • 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

      void setFlySpeed​(float value) throws java.lang.IllegalArgumentException
      Sets the speed at which a client will fly. Negative values indicate reverse directions.
      Parameters:
      value - The new speed, from -1 to 1.
      Throws:
      java.lang.IllegalArgumentException - If new speed is less than -1 or greater than 1
    • setWalkSpeed

      void setWalkSpeed​(float value) throws java.lang.IllegalArgumentException
      Sets the speed at which a client will walk. Negative values indicate reverse directions.
      Parameters:
      value - The new speed, from -1 to 1.
      Throws:
      java.lang.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
    • setTexturePack

      @Deprecated void setTexturePack​(java.lang.String url)
      Deprecated.
      Minecraft no longer uses textures packs. Instead you should use setResourcePack(String).
      Request that the player's client download and switch texture packs.

      The player's client will download the new texture pack asynchronously in the background, and will automatically switch to it once the download is complete. If the client has downloaded and cached the same texture pack in the past, it will perform a quick timestamp check over the network to determine if the texture pack has changed and needs to be downloaded again. When this request is sent for the very first time from a given server, the client will first display a confirmation GUI to the player before proceeding with the download.

      Notes:

      • Players can disable server textures on their client, in which case this method will have no affect on them.
      • There is no concept of resetting texture packs back to default within Minecraft, so players will have to relog to do so.
      Parameters:
      url - The URL from which the client will download the texture pack. The string must contain only US-ASCII characters and should be encoded as per RFC 1738.
      Throws:
      java.lang.IllegalArgumentException - Thrown if the URL is null.
      java.lang.IllegalArgumentException - Thrown if the URL is too long.
    • setResourcePack

      void setResourcePack​(java.lang.String url)
      Request that the player's client download and switch resource packs.

      The player's client will download the new resource pack asynchronously in the background, and will automatically switch to it once the download is complete. If the client has downloaded and cached the same resource pack in the past, it will perform a quick timestamp check over the network to determine if the resource pack has changed and needs to be downloaded again. When this request is sent for the very first time from a given server, the client will first display a confirmation GUI to the player before proceeding with the download.

      Notes:

      • Players can disable server resources on their client, in which case this method will have no affect on them.
      • There is no concept of resetting resource packs back to default within Minecraft, so players will have to relog to do so.
      Parameters:
      url - The URL from which the client will download the resource pack. The string must contain only US-ASCII characters and should be encoded as per RFC 1738.
      Throws:
      java.lang.IllegalArgumentException - Thrown if the URL is null.
      java.lang.IllegalArgumentException - Thrown if the URL is too long. The length restriction is an implementation specific arbitrary value.
    • getScoreboard

      Scoreboard getScoreboard()
      Gets the Scoreboard displayed to this player
      Returns:
      The current scoreboard seen by this player
    • setScoreboard

      void setScoreboard​(Scoreboard scoreboard) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException
      Sets the player's visible Scoreboard.
      Parameters:
      scoreboard - New Scoreboard for the player
      Throws:
      java.lang.IllegalArgumentException - if scoreboard is null
      java.lang.IllegalArgumentException - if scoreboard was not created by the scoreboard manager
      java.lang.IllegalStateException - if this is a player that is not logged yet or has logged out
    • isHealthScaled

      boolean isHealthScaled()
      Gets if the client is displayed a 'scaled' health, that is, health on a scale from 0-getHealthScale().
      Returns:
      if client health display is scaled
      See Also:
      setHealthScaled(boolean)
    • setHealthScaled

      void setHealthScaled​(boolean scale)
      Sets if the client is displayed a 'scaled' health, that is, health on a scale from 0-getHealthScale().

      Displayed health follows a simple formula displayedHealth = getHealth() / getMaxHealth() * getHealthScale().

      Parameters:
      scale - if the client health display is scaled
    • setHealthScale

      void setHealthScale​(double scale) throws java.lang.IllegalArgumentException
      Sets the number to scale health to for the client; this will also setHealthScaled(true).

      Displayed health follows a simple formula displayedHealth = getHealth() / getMaxHealth() * getHealthScale().

      Parameters:
      scale - the number to scale health to
      Throws:
      java.lang.IllegalArgumentException - if scale is <0
      java.lang.IllegalArgumentException - if scale is Double.NaN
      java.lang.IllegalArgumentException - if scale is too high
    • getHealthScale

      double getHealthScale()
      Gets the number that health is scaled to for the client.
      Returns:
      the number that health would be scaled to for the client if HealthScaling is set to true
      See Also:
      setHealthScale(double), setHealthScaled(boolean)
    • getSpectatorTarget

      Entity getSpectatorTarget()
      Gets the entity which is followed by the camera when in GameMode.SPECTATOR.
      Returns:
      the followed entity, or null if not in spectator mode or not following a specific entity.
    • setSpectatorTarget

      void setSpectatorTarget​(Entity entity)
      Sets the entity which is followed by the camera when in GameMode.SPECTATOR.
      Parameters:
      entity - the entity to follow or null to reset
      Throws:
      java.lang.IllegalStateException - if the player is not in GameMode.SPECTATOR
    • sendTitle

      @Deprecated void sendTitle​(java.lang.String title, java.lang.String subtitle)
      Deprecated.
      API subject to change
      Sends a title and a subtitle message to the player. If either of these values are null, they will not be sent and the display will remain unchanged. If they are empty strings, the display will be updated as such. If the strings contain a new line, only the first line will be sent.
      Parameters:
      title - Title text
      subtitle - Subtitle text
    • resetTitle

      @Deprecated void resetTitle()
      Deprecated.
      API subject to change.
      Resets the title displayed to the player.
    • spigot

      Player.Spigot spigot()
      Specified by:
      spigot in interface Entity