001 package org.bukkit.entity; 002 003 import org.bukkit.GameMode; 004 import org.bukkit.Location; 005 import org.bukkit.inventory.Inventory; 006 import org.bukkit.inventory.InventoryHolder; 007 import org.bukkit.inventory.InventoryView; 008 import org.bukkit.inventory.ItemStack; 009 import org.bukkit.inventory.PlayerInventory; 010 import org.bukkit.permissions.Permissible; 011 012 /** 013 * Represents a human entity, such as an NPC or a player 014 */ 015 public interface HumanEntity extends LivingEntity, AnimalTamer, Permissible, InventoryHolder { 016 017 /** 018 * Returns the name of this player 019 * 020 * @return Player name 021 */ 022 public String getName(); 023 024 /** 025 * Get the player's inventory. 026 * 027 * @return The inventory of the player, this also contains the armor 028 * slots. 029 */ 030 public PlayerInventory getInventory(); 031 032 /** 033 * Get the player's EnderChest inventory 034 * 035 * @return The EnderChest of the player 036 */ 037 public Inventory getEnderChest(); 038 039 /** 040 * If the player currently has an inventory window open, this method will 041 * set a property of that window, such as the state of a progress bar. 042 * 043 * @param prop The property. 044 * @param value The value to set the property to. 045 * @return True if the property was successfully set. 046 */ 047 public boolean setWindowProperty(InventoryView.Property prop, int value); 048 049 /** 050 * Gets the inventory view the player is currently viewing. If they do not 051 * have an inventory window open, it returns their internal crafting view. 052 * 053 * @return The inventory view. 054 */ 055 public InventoryView getOpenInventory(); 056 057 /** 058 * Opens an inventory window with the specified inventory on the top and 059 * the player's inventory on the bottom. 060 * 061 * @param inventory The inventory to open 062 * @return The newly opened inventory view 063 */ 064 public InventoryView openInventory(Inventory inventory); 065 066 /** 067 * Opens an empty workbench inventory window with the player's inventory 068 * on the bottom. 069 * 070 * @param location The location to attach it to. If null, the player's 071 * location is used. 072 * @param force If false, and there is no workbench block at the location, 073 * no inventory will be opened and null will be returned. 074 * @return The newly opened inventory view, or null if it could not be 075 * opened. 076 */ 077 public InventoryView openWorkbench(Location location, boolean force); 078 079 /** 080 * Opens an empty enchanting inventory window with the player's inventory 081 * on the bottom. 082 * 083 * @param location The location to attach it to. If null, the player's 084 * location is used. 085 * @param force If false, and there is no enchanting table at the 086 * location, no inventory will be opened and null will be returned. 087 * @return The newly opened inventory view, or null if it could not be 088 * opened. 089 */ 090 public InventoryView openEnchanting(Location location, boolean force); 091 092 /** 093 * Opens an inventory window to the specified inventory view. 094 * 095 * @param inventory The view to open 096 */ 097 public void openInventory(InventoryView inventory); 098 099 /** 100 * Force-closes the currently open inventory view for this player, if any. 101 */ 102 public void closeInventory(); 103 104 /** 105 * Returns the ItemStack currently in your hand, can be empty. 106 * 107 * @return The ItemStack of the item you are currently holding. 108 */ 109 public ItemStack getItemInHand(); 110 111 /** 112 * Sets the item to the given ItemStack, this will replace whatever the 113 * user was holding. 114 * 115 * @param item The ItemStack which will end up in the hand 116 */ 117 public void setItemInHand(ItemStack item); 118 119 /** 120 * Returns the ItemStack currently on your cursor, can be empty. Will 121 * always be empty if the player currently has no open window. 122 * 123 * @return The ItemStack of the item you are currently moving around. 124 */ 125 public ItemStack getItemOnCursor(); 126 127 /** 128 * Sets the item to the given ItemStack, this will replace whatever the 129 * user was moving. Will always be empty if the player currently has no 130 * open window. 131 * 132 * @param item The ItemStack which will end up in the hand 133 */ 134 public void setItemOnCursor(ItemStack item); 135 136 /** 137 * Returns whether this player is slumbering. 138 * 139 * @return slumber state 140 */ 141 public boolean isSleeping(); 142 143 /** 144 * Get the sleep ticks of the player. This value may be capped. 145 * 146 * @return slumber ticks 147 */ 148 public int getSleepTicks(); 149 150 /** 151 * Gets this human's current {@link GameMode} 152 * 153 * @return Current game mode 154 */ 155 public GameMode getGameMode(); 156 157 /** 158 * Sets this human's current {@link GameMode} 159 * 160 * @param mode New game mode 161 */ 162 public void setGameMode(GameMode mode); 163 164 /** 165 * Check if the player is currently blocking (ie with a sword). 166 * 167 * @return Whether they are blocking. 168 */ 169 public boolean isBlocking(); 170 171 /** 172 * Get the total amount of experience required for the player to level 173 * 174 * @return Experience required to level up 175 */ 176 public int getExpToLevel(); 177 }