Package net.glowstone.inventory
Class GlowPlayerInventory
java.lang.Object
net.glowstone.inventory.GlowInventory
net.glowstone.inventory.GlowPlayerInventory
- All Implemented Interfaces:
Iterable<org.bukkit.inventory.ItemStack>,org.bukkit.inventory.EntityEquipment,org.bukkit.inventory.Inventory,org.bukkit.inventory.PlayerInventory
public class GlowPlayerInventory
extends GlowInventory
implements org.bukkit.inventory.PlayerInventory, org.bukkit.inventory.EntityEquipment
An Inventory representing the items a player is holding.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates the instance for the given player's inventory. -
Method Summary
Modifier and TypeMethodDescriptionintclear(org.bukkit.Material type, org.bukkit.material.MaterialData data) Remove all matching items from the inventory.intconsumeItemInHand(org.bukkit.inventory.EquipmentSlot slot) Consumes an item in a hand slot.intconsumeItemInHand(org.bukkit.inventory.EquipmentSlot slot, boolean wholeStack) Consumes an item in a hand slot.intConsumes an item in the main hand slot.intconsumeItemInMainHand(boolean wholeStack) Consumes an item or the full stack in the main hand slot.org.bukkit.inventory.ItemStack[]org.bukkit.inventory.ItemStackgetBoots()floatorg.bukkit.inventory.ItemStackfloatThe crafting inventory.Tracker for inventory drags by this player.floatgetDropChance(@NotNull org.bukkit.inventory.EquipmentSlot equipmentSlot) org.bukkit.inventory.ItemStack[]intThe current held item slot.org.bukkit.inventory.ItemStackfloatorg.bukkit.entity.HumanEntityThe owner of this inventory.@NotNull org.bukkit.inventory.ItemStackgetItem(org.bukkit.inventory.EquipmentSlot slot) @NotNull org.bukkit.inventory.ItemStackDeprecated.float@NotNull org.bukkit.inventory.ItemStackfloat@NotNull org.bukkit.inventory.ItemStackfloatorg.bukkit.inventory.ItemStackfloatorg.bukkit.Locationorg.bukkit.inventory.ItemStack[]voidhandleShiftClick(GlowPlayer player, org.bukkit.inventory.InventoryView view, int clickedSlot, org.bukkit.inventory.ItemStack clickedItem) Handle a shift click in this inventory by the specified player.booleanitemPlaceAllowed(int slot, org.bukkit.inventory.ItemStack stack) Check whether it is allowed for a player to insert the given ItemStack at the slot, regardless of the slot's current contents.voidsetArmorContents(org.bukkit.inventory.ItemStack[] items) voidsetBoots(@Nullable org.bukkit.inventory.ItemStack itemStack, boolean silent) voidsetBoots(org.bukkit.inventory.ItemStack boots) voidsetBootsDropChance(float chance) voidsetChestplate(@Nullable org.bukkit.inventory.ItemStack itemStack, boolean silent) voidsetChestplate(org.bukkit.inventory.ItemStack chestplate) voidsetChestplateDropChance(float chance) voidsetDropChance(@NotNull org.bukkit.inventory.EquipmentSlot equipmentSlot, float v) voidsetExtraContents(org.bukkit.inventory.ItemStack[] items) voidsetHeldItemSlot(int slot) voidsetHelmet(@Nullable org.bukkit.inventory.ItemStack itemStack, boolean silent) voidsetHelmet(org.bukkit.inventory.ItemStack helmet) voidsetHelmetDropChance(float chance) voidsetItem(@NotNull org.bukkit.inventory.EquipmentSlot slot, @Nullable org.bukkit.inventory.ItemStack item, boolean silent) voidsetItem(org.bukkit.inventory.EquipmentSlot slot, org.bukkit.inventory.ItemStack item) voidsetItemInHand(org.bukkit.inventory.ItemStack item) Deprecated.voidsetItemInHandDropChance(float chance) voidsetItemInMainHand(@Nullable org.bukkit.inventory.ItemStack itemStack, boolean silent) voidsetItemInMainHand(org.bukkit.inventory.ItemStack item) voidsetItemInMainHandDropChance(float chance) voidsetItemInOffHand(@Nullable org.bukkit.inventory.ItemStack itemStack, boolean silent) voidsetItemInOffHand(org.bukkit.inventory.ItemStack item) voidsetItemInOffHandDropChance(float chance) voidsetLeggings(@Nullable org.bukkit.inventory.ItemStack itemStack, boolean silent) voidsetLeggings(org.bukkit.inventory.ItemStack leggings) voidsetLeggingsDropChance(float chance) voidsetRawHeldItemSlot(int slot) Sets which hotbar slot is the main-hand item.voidsetStorageContents(org.bukkit.inventory.ItemStack[] items) Methods inherited from class net.glowstone.inventory.GlowInventory
addItem, addItemStack, addViewer, all, all, clear, clear, close, consumeItem, consumeItem, contains, contains, contains, contains, containsAtLeast, first, first, firstEmpty, getContents, getHolder, getItem, getMaxStackSize, getRawSlots, getSize, getSlot, getSlots, getSlotType, getTitle, getType, getViewers, getViewersSet, initialize, isEmpty, itemShiftClickAllowed, iterator, iterator, remove, remove, removeItem, removeItemAnySlot, removeItemStack, removeViewer, setContents, setItem, setMaxStackSize, setTitle, toString, tryToFillSlotsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.bukkit.inventory.EntityEquipment
clearMethods inherited from interface org.bukkit.inventory.Inventory
addItem, all, all, clear, clear, close, contains, contains, contains, contains, containsAtLeast, first, first, firstEmpty, getContents, getHolder, getItem, getMaxStackSize, getSize, getType, getViewers, isEmpty, iterator, iterator, remove, remove, removeItem, removeItemAnySlot, setContents, setMaxStackSizeMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface org.bukkit.inventory.PlayerInventory
setItem
-
Constructor Details
-
GlowPlayerInventory
Creates the instance for the given player's inventory.- Parameters:
owner- the player who owns this inventory
-
-
Method Details
-
setRawHeldItemSlot
public void setRawHeldItemSlot(int slot) Sets which hotbar slot is the main-hand item.- Parameters:
slot- the slot number, starting with 0 (1 less than the default keyboard shortcut)
-
itemPlaceAllowed
public boolean itemPlaceAllowed(int slot, org.bukkit.inventory.ItemStack stack) Description copied from class:GlowInventoryCheck whether it is allowed for a player to insert the given ItemStack at the slot, regardless of the slot's current contents.Should return false for crafting output slots or armor slots which cannot accept the given item.
- Overrides:
itemPlaceAllowedin classGlowInventory- Parameters:
slot- The slot number.stack- The stack to add.- Returns:
- Whether the stack can be added there.
-
handleShiftClick
public void handleShiftClick(GlowPlayer player, org.bukkit.inventory.InventoryView view, int clickedSlot, org.bukkit.inventory.ItemStack clickedItem) Description copied from class:GlowInventoryHandle a shift click in this inventory by the specified player.The default implementation distributes items from the right to the left and from the bottom to the top.
- Overrides:
handleShiftClickin classGlowInventory- Parameters:
player- The player who clickedview- The inventory view in which was clickedclickedSlot- The slot in the viewclickedItem- The item at which was clicked
-
getHolder
public org.bukkit.entity.HumanEntity getHolder()Description copied from class:GlowInventoryThe owner of this inventory.- Specified by:
getHolderin interfaceorg.bukkit.inventory.EntityEquipment- Specified by:
getHolderin interfaceorg.bukkit.inventory.Inventory- Specified by:
getHolderin interfaceorg.bukkit.inventory.PlayerInventory- Overrides:
getHolderin classGlowInventory
-
getDropChance
public float getDropChance(@NotNull @NotNull org.bukkit.inventory.EquipmentSlot equipmentSlot) - Specified by:
getDropChancein interfaceorg.bukkit.inventory.EntityEquipment
-
setDropChance
public void setDropChance(@NotNull @NotNull org.bukkit.inventory.EquipmentSlot equipmentSlot, float v) - Specified by:
setDropChancein interfaceorg.bukkit.inventory.EntityEquipment
-
getItem
@NotNull public @NotNull org.bukkit.inventory.ItemStack getItem(org.bukkit.inventory.EquipmentSlot slot) - Specified by:
getItemin interfaceorg.bukkit.inventory.EntityEquipment- Specified by:
getItemin interfaceorg.bukkit.inventory.PlayerInventory
-
setItem
public void setItem(org.bukkit.inventory.EquipmentSlot slot, org.bukkit.inventory.ItemStack item) - Specified by:
setItemin interfaceorg.bukkit.inventory.EntityEquipment- Specified by:
setItemin interfaceorg.bukkit.inventory.PlayerInventory
-
setItem
public void setItem(@NotNull @NotNull org.bukkit.inventory.EquipmentSlot slot, @Nullable @Nullable org.bukkit.inventory.ItemStack item, boolean silent) - Specified by:
setItemin interfaceorg.bukkit.inventory.EntityEquipment
-
getStorageContents
public org.bukkit.inventory.ItemStack[] getStorageContents()- Specified by:
getStorageContentsin interfaceorg.bukkit.inventory.Inventory- Overrides:
getStorageContentsin classGlowInventory
-
setStorageContents
public void setStorageContents(org.bukkit.inventory.ItemStack[] items) throws IllegalArgumentException - Specified by:
setStorageContentsin interfaceorg.bukkit.inventory.Inventory- Overrides:
setStorageContentsin classGlowInventory- Throws:
IllegalArgumentException
-
getArmorContents
public org.bukkit.inventory.ItemStack[] getArmorContents()- Specified by:
getArmorContentsin interfaceorg.bukkit.inventory.EntityEquipment- Specified by:
getArmorContentsin interfaceorg.bukkit.inventory.PlayerInventory
-
setArmorContents
public void setArmorContents(org.bukkit.inventory.ItemStack[] items) - Specified by:
setArmorContentsin interfaceorg.bukkit.inventory.EntityEquipment- Specified by:
setArmorContentsin interfaceorg.bukkit.inventory.PlayerInventory
-
getExtraContents
public org.bukkit.inventory.ItemStack[] getExtraContents()- Specified by:
getExtraContentsin interfaceorg.bukkit.inventory.PlayerInventory
-
setExtraContents
public void setExtraContents(org.bukkit.inventory.ItemStack[] items) - Specified by:
setExtraContentsin interfaceorg.bukkit.inventory.PlayerInventory
-
getHelmet
public org.bukkit.inventory.ItemStack getHelmet()- Specified by:
getHelmetin interfaceorg.bukkit.inventory.EntityEquipment- Specified by:
getHelmetin interfaceorg.bukkit.inventory.PlayerInventory
-
setHelmet
public void setHelmet(org.bukkit.inventory.ItemStack helmet) - Specified by:
setHelmetin interfaceorg.bukkit.inventory.EntityEquipment- Specified by:
setHelmetin interfaceorg.bukkit.inventory.PlayerInventory
-
setHelmet
public void setHelmet(@Nullable @Nullable org.bukkit.inventory.ItemStack itemStack, boolean silent) - Specified by:
setHelmetin interfaceorg.bukkit.inventory.EntityEquipment
-
getChestplate
public org.bukkit.inventory.ItemStack getChestplate()- Specified by:
getChestplatein interfaceorg.bukkit.inventory.EntityEquipment- Specified by:
getChestplatein interfaceorg.bukkit.inventory.PlayerInventory
-
setChestplate
public void setChestplate(org.bukkit.inventory.ItemStack chestplate) - Specified by:
setChestplatein interfaceorg.bukkit.inventory.EntityEquipment- Specified by:
setChestplatein interfaceorg.bukkit.inventory.PlayerInventory
-
setChestplate
public void setChestplate(@Nullable @Nullable org.bukkit.inventory.ItemStack itemStack, boolean silent) - Specified by:
setChestplatein interfaceorg.bukkit.inventory.EntityEquipment
-
getLeggings
public org.bukkit.inventory.ItemStack getLeggings()- Specified by:
getLeggingsin interfaceorg.bukkit.inventory.EntityEquipment- Specified by:
getLeggingsin interfaceorg.bukkit.inventory.PlayerInventory
-
setLeggings
public void setLeggings(org.bukkit.inventory.ItemStack leggings) - Specified by:
setLeggingsin interfaceorg.bukkit.inventory.EntityEquipment- Specified by:
setLeggingsin interfaceorg.bukkit.inventory.PlayerInventory
-
setLeggings
public void setLeggings(@Nullable @Nullable org.bukkit.inventory.ItemStack itemStack, boolean silent) - Specified by:
setLeggingsin interfaceorg.bukkit.inventory.EntityEquipment
-
getBoots
public org.bukkit.inventory.ItemStack getBoots()- Specified by:
getBootsin interfaceorg.bukkit.inventory.EntityEquipment- Specified by:
getBootsin interfaceorg.bukkit.inventory.PlayerInventory
-
setBoots
public void setBoots(org.bukkit.inventory.ItemStack boots) - Specified by:
setBootsin interfaceorg.bukkit.inventory.EntityEquipment- Specified by:
setBootsin interfaceorg.bukkit.inventory.PlayerInventory
-
setBoots
public void setBoots(@Nullable @Nullable org.bukkit.inventory.ItemStack itemStack, boolean silent) - Specified by:
setBootsin interfaceorg.bukkit.inventory.EntityEquipment
-
getItemInMainHand
@NotNull public @NotNull org.bukkit.inventory.ItemStack getItemInMainHand()- Specified by:
getItemInMainHandin interfaceorg.bukkit.inventory.EntityEquipment- Specified by:
getItemInMainHandin interfaceorg.bukkit.inventory.PlayerInventory
-
setItemInMainHand
public void setItemInMainHand(org.bukkit.inventory.ItemStack item) - Specified by:
setItemInMainHandin interfaceorg.bukkit.inventory.EntityEquipment- Specified by:
setItemInMainHandin interfaceorg.bukkit.inventory.PlayerInventory
-
setItemInMainHand
public void setItemInMainHand(@Nullable @Nullable org.bukkit.inventory.ItemStack itemStack, boolean silent) - Specified by:
setItemInMainHandin interfaceorg.bukkit.inventory.EntityEquipment
-
getItemInOffHand
@NotNull public @NotNull org.bukkit.inventory.ItemStack getItemInOffHand()- Specified by:
getItemInOffHandin interfaceorg.bukkit.inventory.EntityEquipment- Specified by:
getItemInOffHandin interfaceorg.bukkit.inventory.PlayerInventory
-
setItemInOffHand
public void setItemInOffHand(org.bukkit.inventory.ItemStack item) - Specified by:
setItemInOffHandin interfaceorg.bukkit.inventory.EntityEquipment- Specified by:
setItemInOffHandin interfaceorg.bukkit.inventory.PlayerInventory
-
setItemInOffHand
public void setItemInOffHand(@Nullable @Nullable org.bukkit.inventory.ItemStack itemStack, boolean silent) - Specified by:
setItemInOffHandin interfaceorg.bukkit.inventory.EntityEquipment
-
getItemInHand
Deprecated.- Specified by:
getItemInHandin interfaceorg.bukkit.inventory.EntityEquipment- Specified by:
getItemInHandin interfaceorg.bukkit.inventory.PlayerInventory
-
setItemInHand
Deprecated.- Specified by:
setItemInHandin interfaceorg.bukkit.inventory.EntityEquipment- Specified by:
setItemInHandin interfaceorg.bukkit.inventory.PlayerInventory
-
setHeldItemSlot
public void setHeldItemSlot(int slot) - Specified by:
setHeldItemSlotin interfaceorg.bukkit.inventory.PlayerInventory
-
getLocation
public org.bukkit.Location getLocation()- Specified by:
getLocationin interfaceorg.bukkit.inventory.Inventory- Overrides:
getLocationin classGlowInventory
-
clear
public int clear(org.bukkit.Material type, org.bukkit.material.MaterialData data) Remove all matching items from the inventory.- Parameters:
type- the item to remove, or null to remove everythingdata- the data value to match on, or null to match all data values- Returns:
- the number of items (not stacks) removed
-
getItemInHandDropChance
public float getItemInHandDropChance()- Specified by:
getItemInHandDropChancein interfaceorg.bukkit.inventory.EntityEquipment
-
setItemInHandDropChance
public void setItemInHandDropChance(float chance) - Specified by:
setItemInHandDropChancein interfaceorg.bukkit.inventory.EntityEquipment
-
getItemInMainHandDropChance
public float getItemInMainHandDropChance()- Specified by:
getItemInMainHandDropChancein interfaceorg.bukkit.inventory.EntityEquipment
-
setItemInMainHandDropChance
public void setItemInMainHandDropChance(float chance) - Specified by:
setItemInMainHandDropChancein interfaceorg.bukkit.inventory.EntityEquipment
-
getItemInOffHandDropChance
public float getItemInOffHandDropChance()- Specified by:
getItemInOffHandDropChancein interfaceorg.bukkit.inventory.EntityEquipment
-
setItemInOffHandDropChance
public void setItemInOffHandDropChance(float chance) - Specified by:
setItemInOffHandDropChancein interfaceorg.bukkit.inventory.EntityEquipment
-
getHelmetDropChance
public float getHelmetDropChance()- Specified by:
getHelmetDropChancein interfaceorg.bukkit.inventory.EntityEquipment
-
setHelmetDropChance
public void setHelmetDropChance(float chance) - Specified by:
setHelmetDropChancein interfaceorg.bukkit.inventory.EntityEquipment
-
getChestplateDropChance
public float getChestplateDropChance()- Specified by:
getChestplateDropChancein interfaceorg.bukkit.inventory.EntityEquipment
-
setChestplateDropChance
public void setChestplateDropChance(float chance) - Specified by:
setChestplateDropChancein interfaceorg.bukkit.inventory.EntityEquipment
-
getLeggingsDropChance
public float getLeggingsDropChance()- Specified by:
getLeggingsDropChancein interfaceorg.bukkit.inventory.EntityEquipment
-
setLeggingsDropChance
public void setLeggingsDropChance(float chance) - Specified by:
setLeggingsDropChancein interfaceorg.bukkit.inventory.EntityEquipment
-
getBootsDropChance
public float getBootsDropChance()- Specified by:
getBootsDropChancein interfaceorg.bukkit.inventory.EntityEquipment
-
setBootsDropChance
public void setBootsDropChance(float chance) - Specified by:
setBootsDropChancein interfaceorg.bukkit.inventory.EntityEquipment
-
consumeItemInMainHand
public int consumeItemInMainHand(boolean wholeStack) Consumes an item or the full stack in the main hand slot.- Parameters:
wholeStack- True if we should remove the complete stack.- Returns:
- The number of item really consumed.
-
consumeItemInMainHand
public int consumeItemInMainHand()Consumes an item in the main hand slot.- Returns:
- The number of item really consumed.
-
consumeItemInHand
public int consumeItemInHand(org.bukkit.inventory.EquipmentSlot slot) Consumes an item in a hand slot.- Parameters:
slot- Thehand slotto consume, which must be eitherEquipmentSlot.HANDorEquipmentSlot.OFF_HAND.- Returns:
- The number of item really consumed.
-
consumeItemInHand
public int consumeItemInHand(org.bukkit.inventory.EquipmentSlot slot, boolean wholeStack) Consumes an item in a hand slot.- Parameters:
slot- Thehand slotto consume, which must be eitherEquipmentSlot.HANDorEquipmentSlot.OFF_HAND.wholeStack- True if we should remove the complete stack.- Returns:
- The number of item really consumed.
-
getCraftingInventory
The crafting inventory.- Returns:
- The GlowCraftingInventory attached to this player
-
getDragTracker
Tracker for inventory drags by this player.- Returns:
- The DragTracker.
-
getHeldItemSlot
public int getHeldItemSlot()The current held item slot.- Specified by:
getHeldItemSlotin interfaceorg.bukkit.inventory.PlayerInventory
-