Package org.bukkit.entity
Interface HumanEntity
- All Superinterfaces:
- AnimalTamer,- Attributable,- CommandSender,- Damageable,- Entity,- InventoryHolder,- LivingEntity,- Metadatable,- Nameable,- Permissible,- PersistentDataHolder,- ProjectileSource,- ServerOperator
- All Known Subinterfaces:
- Player
Represents a human entity, such as an NPC or a player
- 
Nested Class SummaryNested classes/interfaces inherited from interface org.bukkit.entity.EntityEntity.Spigot
- 
Method SummaryModifier and TypeMethodDescriptionvoidForce-closes the currently open inventory view for this player, if any.booleandiscoverRecipe(NamespacedKey recipe) Discover a recipe for this player such that it has not already been discovered.intdiscoverRecipes(Collection<NamespacedKey> recipes) Discover a collection of recipes for this player such that they have not already been discovered.booleandropItem(boolean dropAll) Make the entity drop the item in their hand.floatGets the current cooldown for a player's attack.Gets the location of the bed the player is currently sleeping inintgetCooldown(Material material) Get the cooldown time in ticks remaining for the specified material.Get an immutable set of recipes this entity has discovered.Get the player's EnderChest inventoryfloatGets the players current exhaustion level.intGet the total amount of experience required for the player to levelintGets the players current food levelGets this human's currentGameModeGet the player's inventory.Deprecated.Gets the item that the player is using (eating food, drawing back a bow, blocking, etc.)Returns the ItemStack currently on your cursor, can be empty.Gets the player's selected main handgetName()Returns the name of this playerGets the inventory view the player is currently viewing.intGet the regeneration rate (1 health per x ticks) of the HumanEntity when they have saturation and their food level is >= 20.floatGets the players current saturation level.Deprecated.There are currently no well defined semantics regarding serialized entities in Bukkit.Deprecated.There are currently no well defined semantics regarding serialized entities in Bukkit.intGet the sleep ticks of the player.intGet the starvation rate (1 health per x ticks) of the HumanEntity.intGet the regeneration rate (1 health per x ticks) of the HumanEntity when they have no saturation and their food level is >= 18.booleanhasCooldown(Material material) Check whether a cooldown is active on the specified material.booleanhasDiscoveredRecipe(NamespacedKey recipe) Check whether or not this entity has discovered the specified recipe.booleanCheck if the player is currently blocking (ie with a shield).booleanCheck if the player currently has their hand raised (ie about to begin blocking).openEnchanting(Location location, boolean force) Opens an empty enchanting inventory window with the player's inventory on the bottom.openInventory(Inventory inventory) Opens an inventory window with the specified inventory on the top and the player's inventory on the bottom.voidopenInventory(InventoryView inventory) Opens an inventory window to the specified inventory view.openMerchant(Villager trader, boolean force) Starts a trade between the player and the villager.openMerchant(Merchant merchant, boolean force) Starts a trade between the player and the merchant.openWorkbench(Location location, boolean force) Opens an empty workbench inventory window with the player's inventory on the bottom.voidsetCooldown(Material material, int ticks) Set a cooldown on the specified material for a certain amount of ticks.voidsetExhaustion(float value) Sets the players current exhaustion levelvoidsetFoodLevel(int value) Sets the players current food levelvoidsetGameMode(GameMode mode) Sets this human's currentGameModevoidsetItemInHand(ItemStack item) Deprecated.Humans may now dual wield in their off hand, use explicit methods inPlayerInventory.voidsetItemOnCursor(ItemStack item) Sets the item to the given ItemStack, this will replace whatever the user was moving.voidsetSaturatedRegenRate(int ticks) Set the regeneration rate (1 health per x ticks) of the HumanEntity when they have saturation and their food level is >= 20.voidsetSaturation(float value) Sets the players current saturation levelvoidsetShoulderEntityLeft(Entity entity) Deprecated.There are currently no well defined semantics regarding serialized entities in Bukkit.voidsetShoulderEntityRight(Entity entity) Deprecated.There are currently no well defined semantics regarding serialized entities in Bukkit.voidsetStarvationRate(int ticks) Get the starvation rate (1 health per x ticks) of the HumanEntity.voidsetUnsaturatedRegenRate(int ticks) Get the regeneration rate (1 health per x ticks) of the HumanEntity when they have no saturation and their food level is >= 18.booleansetWindowProperty(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.booleanAttempts to make the entity sleep at the given location.booleanundiscoverRecipe(NamespacedKey recipe) Undiscover a recipe for this player such that it has already been discovered.intundiscoverRecipes(Collection<NamespacedKey> recipes) Undiscover a collection of recipes for this player such that they have already been discovered.voidwakeup(boolean setSpawnLocation) Causes the player to wakeup if they are currently sleeping.Methods inherited from interface org.bukkit.entity.AnimalTamergetUniqueIdMethods inherited from interface org.bukkit.attribute.AttributablegetAttributeMethods inherited from interface org.bukkit.command.CommandSendersendMessage, sendMessage, sendMessage, sendMessageMethods inherited from interface org.bukkit.entity.Damageabledamage, damage, getAbsorptionAmount, getHealth, getMaxHealth, resetMaxHealth, setAbsorptionAmount, setHealth, setMaxHealthMethods inherited from interface org.bukkit.entity.EntityaddPassenger, addScoreboardTag, eject, getBoundingBox, getEntityId, getFacing, getFallDistance, getFireTicks, getFreezeTicks, getHeight, getLastDamageCause, getLocation, getLocation, getMaxFireTicks, getMaxFreezeTicks, getNearbyEntities, getPassenger, getPassengers, getPistonMoveReaction, getPortalCooldown, getPose, getScoreboardTags, getServer, getSpawnCategory, getTicksLived, getType, getUniqueId, getVehicle, getVelocity, getWidth, getWorld, hasGravity, isCustomNameVisible, isDead, isEmpty, isFrozen, isGlowing, isInsideVehicle, isInvulnerable, isInWater, isOnGround, isPersistent, isSilent, isValid, isVisualFire, leaveVehicle, playEffect, remove, removePassenger, removeScoreboardTag, setCustomNameVisible, setFallDistance, setFireTicks, setFreezeTicks, setGlowing, setGravity, setInvulnerable, setLastDamageCause, setPassenger, setPersistent, setPortalCooldown, setRotation, setSilent, setTicksLived, setVelocity, setVisualFire, spigot, teleport, teleport, teleport, teleportMethods inherited from interface org.bukkit.entity.LivingEntityaddPotionEffect, addPotionEffect, addPotionEffects, attack, getActivePotionEffects, getArrowCooldown, getArrowsInBody, getCanPickupItems, getCategory, getCollidableExemptions, getEquipment, getEyeHeight, getEyeHeight, getEyeLocation, getKiller, getLastDamage, getLastTwoTargetBlocks, getLeashHolder, getLineOfSight, getMaximumAir, getMaximumNoDamageTicks, getMemory, getNoDamageTicks, getPotionEffect, getRemainingAir, getRemoveWhenFarAway, getTargetBlock, getTargetBlockExact, getTargetBlockExact, hasAI, hasLineOfSight, hasPotionEffect, isClimbing, isCollidable, isGliding, isInvisible, isLeashed, isRiptiding, isSleeping, isSwimming, rayTraceBlocks, rayTraceBlocks, removePotionEffect, setAI, setArrowCooldown, setArrowsInBody, setCanPickupItems, setCollidable, setGliding, setInvisible, setLastDamage, setLeashHolder, setMaximumAir, setMaximumNoDamageTicks, setMemory, setNoDamageTicks, setRemainingAir, setRemoveWhenFarAway, setSwimming, swingMainHand, swingOffHandMethods inherited from interface org.bukkit.metadata.MetadatablegetMetadata, hasMetadata, removeMetadata, setMetadataMethods inherited from interface org.bukkit.NameablegetCustomName, setCustomNameMethods inherited from interface org.bukkit.permissions.PermissibleaddAttachment, addAttachment, addAttachment, addAttachment, getEffectivePermissions, hasPermission, hasPermission, isPermissionSet, isPermissionSet, recalculatePermissions, removeAttachmentMethods inherited from interface org.bukkit.persistence.PersistentDataHoldergetPersistentDataContainerMethods inherited from interface org.bukkit.projectiles.ProjectileSourcelaunchProjectile, launchProjectileMethods inherited from interface org.bukkit.permissions.ServerOperatorisOp, setOp
- 
Method Details- 
getNameReturns the name of this player- Specified by:
- getNamein interface- AnimalTamer
- Specified by:
- getNamein interface- CommandSender
- Returns:
- Player name
 
- 
getInventoryGet the player's inventory.- Specified by:
- getInventoryin interface- InventoryHolder
- Returns:
- The inventory of the player, this also contains the armor slots.
 
- 
getEnderChestGet the player's EnderChest inventory- Returns:
- The EnderChest of the player
 
- 
getMainHandGets the player's selected main hand- Returns:
- the players main hand
 
- 
setWindowPropertyIf 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.
 
- 
getOpenInventoryGets 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.
 
- 
openInventoryOpens 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
 
- 
openWorkbenchOpens 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.
 
- 
openEnchantingOpens 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.
 
- 
openInventoryOpens an inventory window to the specified inventory view.- Parameters:
- inventory- The view to open
 
- 
openMerchantStarts 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.
 
- 
openMerchantStarts 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.
 
- 
closeInventoryvoid closeInventory()Force-closes the currently open inventory view for this player, if any.
- 
getItemInHandDeprecated.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.
 
- 
setItemInHandDeprecated.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
 
- 
getItemOnCursorReturns 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.
 
- 
setItemOnCursorSets 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
 
- 
hasCooldownCheck whether a cooldown is active on the specified material.- Parameters:
- material- the material to check
- Returns:
- if a cooldown is active on the material
- Throws:
- IllegalArgumentException- if the material is not an item
 
- 
getCooldownGet the cooldown time in ticks remaining for the specified material.- Parameters:
- material- the material to check
- Returns:
- the remaining cooldown time in ticks
- Throws:
- IllegalArgumentException- if the material is not an item
 
- 
setCooldownSet 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 for
- ticks- the amount of ticks to set or 0 to remove
- Throws:
- IllegalArgumentException- if the material is not an item
 
- 
getSleepTicksint getSleepTicks()Get the sleep ticks of the player. This value may be capped.- Returns:
- slumber ticks
 
- 
sleepAttempts to make the entity sleep at the given location.
 The location must be in the current world and have a bed placed at the location. The game may also enforce other requirements such as proximity to bed, monsters, and dimension type if force is not set.- Parameters:
- location- the location of the bed
- force- whether to try and sleep at the location even if not normally possible
- Returns:
- whether the sleep was successful
 
- 
wakeupvoid wakeup(boolean setSpawnLocation) Causes the player to wakeup if they are currently sleeping.- Parameters:
- setSpawnLocation- whether to set their spawn location to the bed they are currently sleeping in
- Throws:
- IllegalStateException- if not sleeping
 
- 
getBedLocationGets the location of the bed the player is currently sleeping in- Returns:
- location
- Throws:
- IllegalStateException- if not sleeping
 
- 
getGameModeGets this human's currentGameMode- Returns:
- Current game mode
 
- 
setGameModeSets this human's currentGameMode- Parameters:
- mode- New game mode
 
- 
isBlockingboolean isBlocking()Check if the player is currently blocking (ie with a shield).- Returns:
- Whether they are blocking.
 
- 
isHandRaisedboolean isHandRaised()Check if the player currently has their hand raised (ie about to begin blocking).- Returns:
- Whether their hand is raised
 
- 
getItemInUseGets the item that the player is using (eating food, drawing back a bow, blocking, etc.)- Returns:
- the item being used by the player, or null if they are not using an item
 
- 
getExpToLevelint getExpToLevel()Get the total amount of experience required for the player to level- Returns:
- Experience required to level up
 
- 
getAttackCooldownfloat getAttackCooldown()Gets the current cooldown for a player's attack. This is used to calculate damage, with 1.0 representing a fully charged attack and 0.0 representing a non-charged attack- Returns:
- A float between 0.0-1.0 representing the progress of the charge
 
- 
discoverRecipeDiscover 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
 
- 
discoverRecipesDiscover 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
 
- 
undiscoverRecipeUndiscover 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)
 
- 
undiscoverRecipesUndiscover 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
 
- 
hasDiscoveredRecipeCheck whether or not this entity has discovered the specified recipe.- Parameters:
- recipe- the key of the recipe to check
- Returns:
- true if discovered, false otherwise
 
- 
getDiscoveredRecipesGet an immutable set of recipes this entity has discovered.- Returns:
- all discovered recipes
 
- 
getShoulderEntityLeftDeprecated.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
 
- 
setShoulderEntityLeftDeprecated.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 renderParrotentities.- Parameters:
- entity- left shoulder entity
 
- 
getShoulderEntityRightDeprecated.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
 
- 
setShoulderEntityRightDeprecated.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 renderParrotentities.- Parameters:
- entity- right shoulder entity
 
- 
dropItemboolean dropItem(boolean dropAll) Make the entity drop the item in their hand.
 This will force the entity to drop the item they are holding with an option to drop the entireItemStackor just 1 of the items.- Parameters:
- dropAll- True to drop entire stack, false to drop 1 of the stack
- Returns:
- True if item was dropped successfully
 
- 
getExhaustionfloat 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
 
- 
setExhaustionvoid setExhaustion(float value) Sets the players current exhaustion level- Parameters:
- value- Exhaustion level
 
- 
getSaturationfloat 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
 
- 
setSaturationvoid setSaturation(float value) Sets the players current saturation level- Parameters:
- value- Saturation level
 
- 
getFoodLevelint getFoodLevel()Gets the players current food level- Returns:
- Food level
 
- 
setFoodLevelvoid setFoodLevel(int value) Sets the players current food level- Parameters:
- value- New food level
 
- 
getSaturatedRegenRateint getSaturatedRegenRate()Get the regeneration rate (1 health per x ticks) of the HumanEntity when they have saturation and their food level is >= 20. Default is 10.- Returns:
- the regeneration rate
 
- 
setSaturatedRegenRatevoid setSaturatedRegenRate(int ticks) Set the regeneration rate (1 health per x ticks) of the HumanEntity when they have saturation and their food level is >= 20. Default is 10. Not affected if the world's difficulty is peaceful.- Parameters:
- ticks- the amount of ticks to gain 1 health.
 
- 
getUnsaturatedRegenRateint getUnsaturatedRegenRate()Get the regeneration rate (1 health per x ticks) of the HumanEntity when they have no saturation and their food level is >= 18. Default is 80.- Returns:
- the regeneration rate
 
- 
setUnsaturatedRegenRatevoid setUnsaturatedRegenRate(int ticks) Get the regeneration rate (1 health per x ticks) of the HumanEntity when they have no saturation and their food level is >= 18. Default is 80. Not affected if the world's difficulty is peaceful.- Parameters:
- ticks- the amount of ticks to gain 1 health.
 
- 
getStarvationRateint getStarvationRate()Get the starvation rate (1 health per x ticks) of the HumanEntity. Default is 80.- Returns:
- the starvation rate
 
- 
setStarvationRatevoid setStarvationRate(int ticks) Get the starvation rate (1 health per x ticks) of the HumanEntity. Default is 80.- Parameters:
- ticks- the amount of ticks to lose 1 health
 
 
- 
PlayerInventory.