Package org.bukkit.entity
Interface HumanEntity
-
- All Superinterfaces:
AnimalTamer
,Attributable
,CommandSender
,Damageable
,Entity
,InventoryHolder
,LivingEntity
,Metadatable
,Nameable
,Permissible
,ProjectileSource
,ServerOperator
- All Known Subinterfaces:
Player
public interface HumanEntity extends LivingEntity, AnimalTamer, Permissible, InventoryHolder
Represents a human entity, such as an NPC or a player
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.bukkit.entity.Entity
Entity.Spigot
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description void
closeInventory()
Force-closes the currently open inventory view for this player, if any.boolean
discoverRecipe(NamespacedKey recipe)
Discover a recipe for this player such that it has not already been discovered.int
discoverRecipes(Collection<NamespacedKey> recipes)
Discover a collection of recipes for this player such that they have not already been discovered.int
getCooldown(Material material)
Get the cooldown time in ticks remaining for the specified material.Inventory
getEnderChest()
Get the player's EnderChest inventoryint
getExpToLevel()
Get the total amount of experience required for the player to levelGameMode
getGameMode()
Gets this human's currentGameMode
PlayerInventory
getInventory()
Get the player's inventory.ItemStack
getItemInHand()
Deprecated.Humans may now dual wield in their off hand, use explicit methods inPlayerInventory
.ItemStack
getItemOnCursor()
Returns the ItemStack currently on your cursor, can be empty.MainHand
getMainHand()
Gets the player's selected main handString
getName()
Returns the name of this playerInventoryView
getOpenInventory()
Gets the inventory view the player is currently viewing.Entity
getShoulderEntityLeft()
Deprecated.There are currently no well defined semantics regarding serialized entities in Bukkit.Entity
getShoulderEntityRight()
Deprecated.There are currently no well defined semantics regarding serialized entities in Bukkit.int
getSleepTicks()
Get the sleep ticks of the player.boolean
hasCooldown(Material material)
Check whether a cooldown is active on the specified material.boolean
isBlocking()
Check if the player is currently blocking (ie with a shield).boolean
isHandRaised()
Check if the player currently has their hand raised (ie about to begin blocking).boolean
isSleeping()
Returns whether this player is slumbering.InventoryView
openEnchanting(Location location, boolean force)
Opens an empty enchanting inventory window with the player's inventory on the bottom.InventoryView
openInventory(Inventory inventory)
Opens an inventory window with the specified inventory on the top and the player's inventory on the bottom.void
openInventory(InventoryView inventory)
Opens an inventory window to the specified inventory view.InventoryView
openMerchant(Villager trader, boolean force)
Starts a trade between the player and the villager.InventoryView
openMerchant(Merchant merchant, boolean force)
Starts a trade between the player and the merchant.InventoryView
openWorkbench(Location location, boolean force)
Opens an empty workbench inventory window with the player's inventory on the bottom.void
setCooldown(Material material, int ticks)
Set a cooldown on the specified material for a certain amount of ticks.void
setGameMode(GameMode mode)
Sets this human's currentGameMode
void
setItemInHand(ItemStack item)
Deprecated.Humans may now dual wield in their off hand, use explicit methods inPlayerInventory
.void
setItemOnCursor(ItemStack item)
Sets the item to the given ItemStack, this will replace whatever the user was moving.void
setShoulderEntityLeft(Entity entity)
Deprecated.There are currently no well defined semantics regarding serialized entities in Bukkit.void
setShoulderEntityRight(Entity entity)
Deprecated.There are currently no well defined semantics regarding serialized entities in Bukkit.boolean
setWindowProperty(InventoryView.Property prop, int value)
If the player currently has an inventory window open, this method will set a property of that window, such as the state of a progress bar.boolean
undiscoverRecipe(NamespacedKey recipe)
Undiscover a recipe for this player such that it has already been discovered.int
undiscoverRecipes(Collection<NamespacedKey> recipes)
Undiscover a collection of recipes for this player such that they have already been discovered.-
Methods inherited from interface org.bukkit.entity.AnimalTamer
getUniqueId
-
Methods inherited from interface org.bukkit.attribute.Attributable
getAttribute
-
Methods inherited from interface org.bukkit.command.CommandSender
sendMessage, sendMessage
-
Methods inherited from interface org.bukkit.entity.Damageable
damage, damage, getHealth, getMaxHealth, resetMaxHealth, setHealth, setMaxHealth
-
Methods inherited from interface org.bukkit.entity.Entity
addPassenger, addScoreboardTag, eject, getEntityId, getFacing, getFallDistance, getFireTicks, getHeight, getLastDamageCause, getLocation, getLocation, getMaxFireTicks, getNearbyEntities, getPassenger, getPassengers, getPistonMoveReaction, getPortalCooldown, getScoreboardTags, getServer, getTicksLived, getType, getUniqueId, getVehicle, getVelocity, getWidth, getWorld, hasGravity, isCustomNameVisible, isDead, isEmpty, isGlowing, isInsideVehicle, isInvulnerable, isOnGround, isPersistent, isSilent, isValid, leaveVehicle, playEffect, remove, removePassenger, removeScoreboardTag, setCustomNameVisible, setFallDistance, setFireTicks, setGlowing, setGravity, setInvulnerable, setLastDamageCause, setPassenger, setPersistent, setPortalCooldown, setSilent, setTicksLived, setVelocity, spigot, teleport, teleport, teleport, teleport
-
Methods inherited from interface org.bukkit.entity.LivingEntity
addPotionEffect, addPotionEffect, addPotionEffects, getActivePotionEffects, getCanPickupItems, getEquipment, getEyeHeight, getEyeHeight, getEyeLocation, getKiller, getLastDamage, getLastTwoTargetBlocks, getLeashHolder, getLineOfSight, getMaximumAir, getMaximumNoDamageTicks, getNoDamageTicks, getPotionEffect, getRemainingAir, getRemoveWhenFarAway, getTargetBlock, hasAI, hasLineOfSight, hasPotionEffect, isCollidable, isGliding, isLeashed, isRiptiding, isSwimming, removePotionEffect, setAI, setCanPickupItems, setCollidable, setGliding, setLastDamage, setLeashHolder, setMaximumAir, setMaximumNoDamageTicks, setNoDamageTicks, setRemainingAir, setRemoveWhenFarAway, setSwimming
-
Methods inherited from interface org.bukkit.metadata.Metadatable
getMetadata, hasMetadata, removeMetadata, setMetadata
-
Methods inherited from interface org.bukkit.Nameable
getCustomName, setCustomName
-
Methods inherited from interface org.bukkit.permissions.Permissible
addAttachment, addAttachment, addAttachment, addAttachment, getEffectivePermissions, hasPermission, hasPermission, isPermissionSet, isPermissionSet, recalculatePermissions, removeAttachment
-
Methods inherited from interface org.bukkit.projectiles.ProjectileSource
launchProjectile, launchProjectile
-
Methods inherited from interface org.bukkit.permissions.ServerOperator
isOp, setOp
-
-
-
-
Method Detail
-
getName
String getName()
Returns the name of this player- Specified by:
getName
in interfaceAnimalTamer
- Specified by:
getName
in interfaceCommandSender
- Returns:
- Player name
-
getInventory
PlayerInventory getInventory()
Get the player's inventory.- Specified by:
getInventory
in interfaceInventoryHolder
- Returns:
- The inventory of the player, this also contains the armor slots.
-
getEnderChest
Inventory getEnderChest()
Get the player's EnderChest inventory- Returns:
- The EnderChest of the player
-
getMainHand
MainHand getMainHand()
Gets the player's selected main hand- Returns:
- the players main hand
-
setWindowProperty
boolean setWindowProperty(InventoryView.Property prop, int value)
If the player currently has an inventory window open, this method will set a property of that window, such as the state of a progress bar.- Parameters:
prop
- The property.value
- The value to set the property to.- Returns:
- True if the property was successfully set.
-
getOpenInventory
InventoryView getOpenInventory()
Gets the inventory view the player is currently viewing. If they do not have an inventory window open, it returns their internal crafting view.- Returns:
- The inventory view.
-
openInventory
InventoryView openInventory(Inventory inventory)
Opens an inventory window with the specified inventory on the top and the player's inventory on the bottom.- Parameters:
inventory
- The inventory to open- Returns:
- The newly opened inventory view
-
openWorkbench
InventoryView openWorkbench(Location location, boolean force)
Opens an empty workbench inventory window with the player's inventory on the bottom.- Parameters:
location
- The location to attach it to. If null, the player's location is used.force
- If false, and there is no workbench block at the location, no inventory will be opened and null will be returned.- Returns:
- The newly opened inventory view, or null if it could not be opened.
-
openEnchanting
InventoryView openEnchanting(Location location, boolean force)
Opens an empty enchanting inventory window with the player's inventory on the bottom.- Parameters:
location
- The location to attach it to. If null, the player's location is used.force
- If false, and there is no enchanting table at the location, no inventory will be opened and null will be returned.- Returns:
- The newly opened inventory view, or null if it could not be opened.
-
openInventory
void openInventory(InventoryView inventory)
Opens an inventory window to the specified inventory view.- Parameters:
inventory
- The view to open
-
openMerchant
InventoryView openMerchant(Villager trader, boolean force)
Starts a trade between the player and the villager. Note that only one player may trade with a villager at once. You must use the force parameter for this.- Parameters:
trader
- The merchant to trade with. Cannot be null.force
- whether to force the trade even if another player is trading- Returns:
- The newly opened inventory view, or null if it could not be opened.
-
openMerchant
InventoryView openMerchant(Merchant merchant, boolean force)
Starts a trade between the player and the merchant. Note that only one player may trade with a merchant at once. You must use the force parameter for this.- Parameters:
merchant
- The merchant to trade with. Cannot be null.force
- whether to force the trade even if another player is trading- Returns:
- The newly opened inventory view, or null if it could not be opened.
-
closeInventory
void closeInventory()
Force-closes the currently open inventory view for this player, if any.
-
getItemInHand
@Deprecated ItemStack getItemInHand()
Deprecated.Humans may now dual wield in their off hand, use explicit methods inPlayerInventory
.Returns the ItemStack currently in your hand, can be empty.- Returns:
- The ItemStack of the item you are currently holding.
-
setItemInHand
@Deprecated void setItemInHand(ItemStack item)
Deprecated.Humans may now dual wield in their off hand, use explicit methods inPlayerInventory
.Sets the item to the given ItemStack, this will replace whatever the user was holding.- Parameters:
item
- The ItemStack which will end up in the hand
-
getItemOnCursor
ItemStack getItemOnCursor()
Returns the ItemStack currently on your cursor, can be empty. Will always be empty if the player currently has no open window.- Returns:
- The ItemStack of the item you are currently moving around.
-
setItemOnCursor
void setItemOnCursor(ItemStack item)
Sets the item to the given ItemStack, this will replace whatever the user was moving. Will always be empty if the player currently has no open window.- Parameters:
item
- The ItemStack which will end up in the hand
-
hasCooldown
boolean hasCooldown(Material material)
Check whether a cooldown is active on the specified material.- Parameters:
material
- the material to check- Returns:
- if a cooldown is active on the material
-
getCooldown
int getCooldown(Material material)
Get the cooldown time in ticks remaining for the specified material.- Parameters:
material
- the material to check- Returns:
- the remaining cooldown time in ticks
-
setCooldown
void setCooldown(Material material, int ticks)
Set a cooldown on the specified material for a certain amount of ticks. ticks. 0 ticks will result in the removal of the cooldown.Cooldowns are used by the server for items such as ender pearls and shields to prevent them from being used repeatedly.
Note that cooldowns will not by themselves stop an item from being used for attacking.
- Parameters:
material
- the material to set the cooldown forticks
- the amount of ticks to set or 0 to remove
-
isSleeping
boolean isSleeping()
Returns whether this player is slumbering.- Returns:
- slumber state
-
getSleepTicks
int getSleepTicks()
Get the sleep ticks of the player. This value may be capped.- Returns:
- slumber ticks
-
setGameMode
void setGameMode(GameMode mode)
Sets this human's currentGameMode
- Parameters:
mode
- New game mode
-
isBlocking
boolean isBlocking()
Check if the player is currently blocking (ie with a shield).- Returns:
- Whether they are blocking.
-
isHandRaised
boolean isHandRaised()
Check if the player currently has their hand raised (ie about to begin blocking).- Returns:
- Whether their hand is raised
-
getExpToLevel
int getExpToLevel()
Get the total amount of experience required for the player to level- Returns:
- Experience required to level up
-
discoverRecipe
boolean discoverRecipe(NamespacedKey recipe)
Discover a recipe for this player such that it has not already been discovered. This method will add the key's associated recipe to the player's recipe book.- Parameters:
recipe
- the key of the recipe to discover- Returns:
- whether or not the recipe was newly discovered
-
discoverRecipes
int discoverRecipes(Collection<NamespacedKey> recipes)
Discover a collection of recipes for this player such that they have not already been discovered. This method will add the keys' associated recipes to the player's recipe book. If a recipe in the provided collection has already been discovered, it will be silently ignored.- Parameters:
recipes
- the keys of the recipes to discover- Returns:
- the amount of newly discovered recipes where 0 indicates that
none were newly discovered and a number equal to
recipes.size()
indicates that all were new
-
undiscoverRecipe
boolean undiscoverRecipe(NamespacedKey recipe)
Undiscover a recipe for this player such that it has already been discovered. This method will remove the key's associated recipe from the player's recipe book.- Parameters:
recipe
- the key of the recipe to undiscover- Returns:
- whether or not the recipe was successfully undiscovered (i.e. it was previously discovered)
-
undiscoverRecipes
int undiscoverRecipes(Collection<NamespacedKey> recipes)
Undiscover a collection of recipes for this player such that they have already been discovered. This method will remove the keys' associated recipes from the player's recipe book. If a recipe in the provided collection has not yet been discovered, it will be silently ignored.- Parameters:
recipes
- the keys of the recipes to undiscover- Returns:
- the amount of undiscovered recipes where 0 indicates that none
were undiscovered and a number equal to
recipes.size()
indicates that all were undiscovered
-
getShoulderEntityLeft
@Deprecated Entity getShoulderEntityLeft()
Deprecated.There are currently no well defined semantics regarding serialized entities in Bukkit. Use with care.Gets the entity currently perched on the left shoulder or null if no entity.
The returned entity will not be spawned within the world, so most operations are invalid unless the entity is first spawned in.- Returns:
- left shoulder entity
-
setShoulderEntityLeft
@Deprecated void setShoulderEntityLeft(Entity entity)
Deprecated.There are currently no well defined semantics regarding serialized entities in Bukkit. Use with care.Sets the entity currently perched on the left shoulder, or null to remove. This method will remove the entity from the world.
Note that only a copy of the entity will be set to display on the shoulder.
Also note that the client will currently only renderParrot
entities.- Parameters:
entity
- left shoulder entity
-
getShoulderEntityRight
@Deprecated Entity getShoulderEntityRight()
Deprecated.There are currently no well defined semantics regarding serialized entities in Bukkit. Use with care.Gets the entity currently perched on the right shoulder or null if no entity.
The returned entity will not be spawned within the world, so most operations are invalid unless the entity is first spawned in.- Returns:
- right shoulder entity
-
setShoulderEntityRight
@Deprecated void setShoulderEntityRight(Entity entity)
Deprecated.There are currently no well defined semantics regarding serialized entities in Bukkit. Use with care.Sets the entity currently perched on the right shoulder, or null to remove. This method will remove the entity from the world.
Note that only a copy of the entity will be set to display on the shoulder.
Also note that the client will currently only renderParrot
entities.- Parameters:
entity
- right shoulder entity
-
-