Interface HumanEntity

All Superinterfaces:
AnimalTamer, CommandSender, Damageable, Entity, InventoryHolder, LivingEntity, Metadatable, 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
  • Method Details

    • getName

      java.lang.String getName()
      Returns the name of this player
      Specified by:
      getName in interface AnimalTamer
      Specified by:
      getName in interface CommandSender
      Returns:
      Player name
    • getInventory

      PlayerInventory getInventory()
      Get the player's inventory.
      Specified by:
      getInventory in interface InventoryHolder
      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
    • 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
    • closeInventory

      void closeInventory()
      Force-closes the currently open inventory view for this player, if any.
    • getItemInHand

      ItemStack getItemInHand()
      Returns the ItemStack currently in your hand, can be empty.
      Returns:
      The ItemStack of the item you are currently holding.
    • setItemInHand

      void setItemInHand​(ItemStack item)
      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
    • 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
    • getGameMode

      GameMode getGameMode()
      Gets this human's current GameMode
      Returns:
      Current game mode
    • setGameMode

      void setGameMode​(GameMode mode)
      Sets this human's current GameMode
      Parameters:
      mode - New game mode
    • isBlocking

      boolean isBlocking()
      Check if the player is currently blocking (ie with a sword).
      Returns:
      Whether they are blocking.
    • getExpToLevel

      int getExpToLevel()
      Get the total amount of experience required for the player to level
      Returns:
      Experience required to level up