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 Details

    • GlowPlayerInventory

      public GlowPlayerInventory(GlowHumanEntity owner)
      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: GlowInventory
      Check 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:
      itemPlaceAllowed in class GlowInventory
      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: GlowInventory
      Handle 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:
      handleShiftClick in class GlowInventory
      Parameters:
      player - The player who clicked
      view - The inventory view in which was clicked
      clickedSlot - The slot in the view
      clickedItem - The item at which was clicked
    • getHolder

      public org.bukkit.entity.HumanEntity getHolder()
      Description copied from class: GlowInventory
      The owner of this inventory.
      Specified by:
      getHolder in interface org.bukkit.inventory.EntityEquipment
      Specified by:
      getHolder in interface org.bukkit.inventory.Inventory
      Specified by:
      getHolder in interface org.bukkit.inventory.PlayerInventory
      Overrides:
      getHolder in class GlowInventory
    • getDropChance

      public float getDropChance(@NotNull @NotNull org.bukkit.inventory.EquipmentSlot equipmentSlot)
      Specified by:
      getDropChance in interface org.bukkit.inventory.EntityEquipment
    • setDropChance

      public void setDropChance(@NotNull @NotNull org.bukkit.inventory.EquipmentSlot equipmentSlot, float v)
      Specified by:
      setDropChance in interface org.bukkit.inventory.EntityEquipment
    • getItem

      @NotNull public @NotNull org.bukkit.inventory.ItemStack getItem(org.bukkit.inventory.EquipmentSlot slot)
      Specified by:
      getItem in interface org.bukkit.inventory.EntityEquipment
      Specified by:
      getItem in interface org.bukkit.inventory.PlayerInventory
    • setItem

      public void setItem(org.bukkit.inventory.EquipmentSlot slot, org.bukkit.inventory.ItemStack item)
      Specified by:
      setItem in interface org.bukkit.inventory.EntityEquipment
      Specified by:
      setItem in interface org.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:
      setItem in interface org.bukkit.inventory.EntityEquipment
    • getStorageContents

      public org.bukkit.inventory.ItemStack[] getStorageContents()
      Specified by:
      getStorageContents in interface org.bukkit.inventory.Inventory
      Overrides:
      getStorageContents in class GlowInventory
    • setStorageContents

      public void setStorageContents(org.bukkit.inventory.ItemStack[] items) throws IllegalArgumentException
      Specified by:
      setStorageContents in interface org.bukkit.inventory.Inventory
      Overrides:
      setStorageContents in class GlowInventory
      Throws:
      IllegalArgumentException
    • getArmorContents

      public org.bukkit.inventory.ItemStack[] getArmorContents()
      Specified by:
      getArmorContents in interface org.bukkit.inventory.EntityEquipment
      Specified by:
      getArmorContents in interface org.bukkit.inventory.PlayerInventory
    • setArmorContents

      public void setArmorContents(org.bukkit.inventory.ItemStack[] items)
      Specified by:
      setArmorContents in interface org.bukkit.inventory.EntityEquipment
      Specified by:
      setArmorContents in interface org.bukkit.inventory.PlayerInventory
    • getExtraContents

      public org.bukkit.inventory.ItemStack[] getExtraContents()
      Specified by:
      getExtraContents in interface org.bukkit.inventory.PlayerInventory
    • setExtraContents

      public void setExtraContents(org.bukkit.inventory.ItemStack[] items)
      Specified by:
      setExtraContents in interface org.bukkit.inventory.PlayerInventory
    • getHelmet

      public org.bukkit.inventory.ItemStack getHelmet()
      Specified by:
      getHelmet in interface org.bukkit.inventory.EntityEquipment
      Specified by:
      getHelmet in interface org.bukkit.inventory.PlayerInventory
    • setHelmet

      public void setHelmet(org.bukkit.inventory.ItemStack helmet)
      Specified by:
      setHelmet in interface org.bukkit.inventory.EntityEquipment
      Specified by:
      setHelmet in interface org.bukkit.inventory.PlayerInventory
    • setHelmet

      public void setHelmet(@Nullable @Nullable org.bukkit.inventory.ItemStack itemStack, boolean silent)
      Specified by:
      setHelmet in interface org.bukkit.inventory.EntityEquipment
    • getChestplate

      public org.bukkit.inventory.ItemStack getChestplate()
      Specified by:
      getChestplate in interface org.bukkit.inventory.EntityEquipment
      Specified by:
      getChestplate in interface org.bukkit.inventory.PlayerInventory
    • setChestplate

      public void setChestplate(org.bukkit.inventory.ItemStack chestplate)
      Specified by:
      setChestplate in interface org.bukkit.inventory.EntityEquipment
      Specified by:
      setChestplate in interface org.bukkit.inventory.PlayerInventory
    • setChestplate

      public void setChestplate(@Nullable @Nullable org.bukkit.inventory.ItemStack itemStack, boolean silent)
      Specified by:
      setChestplate in interface org.bukkit.inventory.EntityEquipment
    • getLeggings

      public org.bukkit.inventory.ItemStack getLeggings()
      Specified by:
      getLeggings in interface org.bukkit.inventory.EntityEquipment
      Specified by:
      getLeggings in interface org.bukkit.inventory.PlayerInventory
    • setLeggings

      public void setLeggings(org.bukkit.inventory.ItemStack leggings)
      Specified by:
      setLeggings in interface org.bukkit.inventory.EntityEquipment
      Specified by:
      setLeggings in interface org.bukkit.inventory.PlayerInventory
    • setLeggings

      public void setLeggings(@Nullable @Nullable org.bukkit.inventory.ItemStack itemStack, boolean silent)
      Specified by:
      setLeggings in interface org.bukkit.inventory.EntityEquipment
    • getBoots

      public org.bukkit.inventory.ItemStack getBoots()
      Specified by:
      getBoots in interface org.bukkit.inventory.EntityEquipment
      Specified by:
      getBoots in interface org.bukkit.inventory.PlayerInventory
    • setBoots

      public void setBoots(org.bukkit.inventory.ItemStack boots)
      Specified by:
      setBoots in interface org.bukkit.inventory.EntityEquipment
      Specified by:
      setBoots in interface org.bukkit.inventory.PlayerInventory
    • setBoots

      public void setBoots(@Nullable @Nullable org.bukkit.inventory.ItemStack itemStack, boolean silent)
      Specified by:
      setBoots in interface org.bukkit.inventory.EntityEquipment
    • getItemInMainHand

      @NotNull public @NotNull org.bukkit.inventory.ItemStack getItemInMainHand()
      Specified by:
      getItemInMainHand in interface org.bukkit.inventory.EntityEquipment
      Specified by:
      getItemInMainHand in interface org.bukkit.inventory.PlayerInventory
    • setItemInMainHand

      public void setItemInMainHand(org.bukkit.inventory.ItemStack item)
      Specified by:
      setItemInMainHand in interface org.bukkit.inventory.EntityEquipment
      Specified by:
      setItemInMainHand in interface org.bukkit.inventory.PlayerInventory
    • setItemInMainHand

      public void setItemInMainHand(@Nullable @Nullable org.bukkit.inventory.ItemStack itemStack, boolean silent)
      Specified by:
      setItemInMainHand in interface org.bukkit.inventory.EntityEquipment
    • getItemInOffHand

      @NotNull public @NotNull org.bukkit.inventory.ItemStack getItemInOffHand()
      Specified by:
      getItemInOffHand in interface org.bukkit.inventory.EntityEquipment
      Specified by:
      getItemInOffHand in interface org.bukkit.inventory.PlayerInventory
    • setItemInOffHand

      public void setItemInOffHand(org.bukkit.inventory.ItemStack item)
      Specified by:
      setItemInOffHand in interface org.bukkit.inventory.EntityEquipment
      Specified by:
      setItemInOffHand in interface org.bukkit.inventory.PlayerInventory
    • setItemInOffHand

      public void setItemInOffHand(@Nullable @Nullable org.bukkit.inventory.ItemStack itemStack, boolean silent)
      Specified by:
      setItemInOffHand in interface org.bukkit.inventory.EntityEquipment
    • getItemInHand

      @Deprecated @NotNull public @NotNull org.bukkit.inventory.ItemStack getItemInHand()
      Deprecated.
      Specified by:
      getItemInHand in interface org.bukkit.inventory.EntityEquipment
      Specified by:
      getItemInHand in interface org.bukkit.inventory.PlayerInventory
    • setItemInHand

      @Deprecated public void setItemInHand(org.bukkit.inventory.ItemStack item)
      Deprecated.
      Specified by:
      setItemInHand in interface org.bukkit.inventory.EntityEquipment
      Specified by:
      setItemInHand in interface org.bukkit.inventory.PlayerInventory
    • setHeldItemSlot

      public void setHeldItemSlot(int slot)
      Specified by:
      setHeldItemSlot in interface org.bukkit.inventory.PlayerInventory
    • getLocation

      public org.bukkit.Location getLocation()
      Specified by:
      getLocation in interface org.bukkit.inventory.Inventory
      Overrides:
      getLocation in class GlowInventory
    • 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 everything
      data - 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:
      getItemInHandDropChance in interface org.bukkit.inventory.EntityEquipment
    • setItemInHandDropChance

      public void setItemInHandDropChance(float chance)
      Specified by:
      setItemInHandDropChance in interface org.bukkit.inventory.EntityEquipment
    • getItemInMainHandDropChance

      public float getItemInMainHandDropChance()
      Specified by:
      getItemInMainHandDropChance in interface org.bukkit.inventory.EntityEquipment
    • setItemInMainHandDropChance

      public void setItemInMainHandDropChance(float chance)
      Specified by:
      setItemInMainHandDropChance in interface org.bukkit.inventory.EntityEquipment
    • getItemInOffHandDropChance

      public float getItemInOffHandDropChance()
      Specified by:
      getItemInOffHandDropChance in interface org.bukkit.inventory.EntityEquipment
    • setItemInOffHandDropChance

      public void setItemInOffHandDropChance(float chance)
      Specified by:
      setItemInOffHandDropChance in interface org.bukkit.inventory.EntityEquipment
    • getHelmetDropChance

      public float getHelmetDropChance()
      Specified by:
      getHelmetDropChance in interface org.bukkit.inventory.EntityEquipment
    • setHelmetDropChance

      public void setHelmetDropChance(float chance)
      Specified by:
      setHelmetDropChance in interface org.bukkit.inventory.EntityEquipment
    • getChestplateDropChance

      public float getChestplateDropChance()
      Specified by:
      getChestplateDropChance in interface org.bukkit.inventory.EntityEquipment
    • setChestplateDropChance

      public void setChestplateDropChance(float chance)
      Specified by:
      setChestplateDropChance in interface org.bukkit.inventory.EntityEquipment
    • getLeggingsDropChance

      public float getLeggingsDropChance()
      Specified by:
      getLeggingsDropChance in interface org.bukkit.inventory.EntityEquipment
    • setLeggingsDropChance

      public void setLeggingsDropChance(float chance)
      Specified by:
      setLeggingsDropChance in interface org.bukkit.inventory.EntityEquipment
    • getBootsDropChance

      public float getBootsDropChance()
      Specified by:
      getBootsDropChance in interface org.bukkit.inventory.EntityEquipment
    • setBootsDropChance

      public void setBootsDropChance(float chance)
      Specified by:
      setBootsDropChance in interface org.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 - The hand slot to consume, which must be either EquipmentSlot.HAND or EquipmentSlot.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 - The hand slot to consume, which must be either EquipmentSlot.HAND or EquipmentSlot.OFF_HAND.
      wholeStack - True if we should remove the complete stack.
      Returns:
      The number of item really consumed.
    • getCraftingInventory

      public GlowCraftingInventory getCraftingInventory()
      The crafting inventory.
      Returns:
      The GlowCraftingInventory attached to this player
    • getDragTracker

      public DragTracker getDragTracker()
      Tracker for inventory drags by this player.
      Returns:
      The DragTracker.
    • getHeldItemSlot

      public int getHeldItemSlot()
      The current held item slot.
      Specified by:
      getHeldItemSlot in interface org.bukkit.inventory.PlayerInventory