Class Displayable

java.lang.Object
me.totalfreedom.display.Displayable
All Implemented Interfaces:
Iterable<org.bukkit.inventory.ItemStack>, org.bukkit.inventory.Inventory, org.bukkit.inventory.InventoryHolder

public final class Displayable extends Object implements org.bukkit.inventory.Inventory, org.bukkit.inventory.InventoryHolder
A class that represents an inventory that can be displayed to players. This class also represents the inventory holder which contains the inventory.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Displayable(int size)
    Creates a new Displayable inventory with the given size.
  • Method Summary

    Modifier and Type
    Method
    Description
    @NotNull HashMap<Integer,org.bukkit.inventory.ItemStack>
    addItem(@NotNull org.bukkit.inventory.ItemStack... items)
     
    @NotNull HashMap<Integer,? extends org.bukkit.inventory.ItemStack>
    all(@NotNull org.bukkit.Material material)
     
    @NotNull HashMap<Integer,? extends org.bukkit.inventory.ItemStack>
    all(@Nullable org.bukkit.inventory.ItemStack item)
     
    void
     
    void
    clear(int index)
     
    int
     
    boolean
    contains(@NotNull org.bukkit.Material material)
     
    boolean
    contains(@NotNull org.bukkit.Material material, int amount)
     
    boolean
    contains(@Nullable org.bukkit.inventory.ItemStack item)
     
    boolean
    contains(@Nullable org.bukkit.inventory.ItemStack item, int amount)
     
    boolean
    containsAtLeast(@Nullable org.bukkit.inventory.ItemStack item, int amount)
     
    int
    first(@NotNull org.bukkit.inventory.ItemStack item)
     
    int
    first(@NotNull org.bukkit.Material material)
     
    int
     
    @Nullable org.bukkit.inventory.ItemStack @NotNull []
     
    @Nullable org.bukkit.inventory.InventoryHolder
     
    @Nullable org.bukkit.inventory.InventoryHolder
    getHolder(boolean useSnapshot)
     
    @NotNull org.bukkit.inventory.Inventory
     
    @Nullable org.bukkit.inventory.ItemStack
    getItem(int index)
     
    @Nullable org.bukkit.Location
     
    int
     
    int
     
    @Nullable org.bukkit.inventory.ItemStack @NotNull []
     
    @NotNull org.bukkit.event.inventory.InventoryType
     
    @NotNull List<org.bukkit.entity.HumanEntity>
     
    boolean
     
    @NotNull ListIterator<org.bukkit.inventory.ItemStack>
     
    @NotNull ListIterator<org.bukkit.inventory.ItemStack>
    iterator(int index)
     
    void
    remove(@NotNull org.bukkit.inventory.ItemStack item)
     
    void
    remove(@NotNull org.bukkit.Material material)
     
    @NotNull HashMap<Integer,org.bukkit.inventory.ItemStack>
    removeItem(@NotNull org.bukkit.inventory.ItemStack... items)
     
    @NotNull HashMap<Integer,org.bukkit.inventory.ItemStack>
    removeItemAnySlot(@NotNull org.bukkit.inventory.ItemStack... items)
     
    void
    setContents(@Nullable org.bukkit.inventory.ItemStack @NotNull [] items)
     
    void
    setItem(int index, @Nullable org.bukkit.inventory.ItemStack item)
     
    void
    setMaxStackSize(int size)
    Deprecated.
    This method is not supported by Displayable inventories.
    void
    setStorageContents(@Nullable org.bukkit.inventory.ItemStack @NotNull [] items)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.lang.Iterable

    forEach, spliterator
  • Constructor Details

    • Displayable

      protected Displayable(int size)
      Creates a new Displayable inventory with the given size. You are free to supply any size you want, but it will always be rounded up to the next multiple of 9. The maximum size allowed is 54. Any number higher than that will be rounded down to 54.
      Parameters:
      size - The size of the inventory.
  • Method Details

    • getSize

      public int getSize()
      Specified by:
      getSize in interface org.bukkit.inventory.Inventory
    • getMaxStackSize

      public int getMaxStackSize()
      Specified by:
      getMaxStackSize in interface org.bukkit.inventory.Inventory
    • setMaxStackSize

      @Deprecated(since="1.19.4") public void setMaxStackSize(int size)
      Deprecated.
      This method is not supported by Displayable inventories.
      Specified by:
      setMaxStackSize in interface org.bukkit.inventory.Inventory
      Parameters:
      size - The new maximum stack size for items in this inventory.
    • getItem

      @Nullable public @Nullable org.bukkit.inventory.ItemStack getItem(int index)
      Specified by:
      getItem in interface org.bukkit.inventory.Inventory
    • setItem

      public void setItem(int index, @Nullable @Nullable org.bukkit.inventory.ItemStack item)
      Specified by:
      setItem in interface org.bukkit.inventory.Inventory
    • addItem

      @NotNull public @NotNull HashMap<Integer,org.bukkit.inventory.ItemStack> addItem(@NotNull @NotNull org.bukkit.inventory.ItemStack... items) throws IllegalArgumentException
      Specified by:
      addItem in interface org.bukkit.inventory.Inventory
      Throws:
      IllegalArgumentException
    • removeItem

      @NotNull public @NotNull HashMap<Integer,org.bukkit.inventory.ItemStack> removeItem(@NotNull @NotNull org.bukkit.inventory.ItemStack... items) throws IllegalArgumentException
      Specified by:
      removeItem in interface org.bukkit.inventory.Inventory
      Throws:
      IllegalArgumentException
    • removeItemAnySlot

      @NotNull public @NotNull HashMap<Integer,org.bukkit.inventory.ItemStack> removeItemAnySlot(@NotNull @NotNull org.bukkit.inventory.ItemStack... items) throws IllegalArgumentException
      Specified by:
      removeItemAnySlot in interface org.bukkit.inventory.Inventory
      Throws:
      IllegalArgumentException
    • getContents

      @Nullable public @Nullable org.bukkit.inventory.ItemStack @NotNull [] getContents()
      Specified by:
      getContents in interface org.bukkit.inventory.Inventory
    • setContents

      public void setContents(@Nullable @Nullable org.bukkit.inventory.ItemStack @NotNull [] items) throws IllegalArgumentException
      Specified by:
      setContents in interface org.bukkit.inventory.Inventory
      Throws:
      IllegalArgumentException
    • getStorageContents

      @Nullable public @Nullable org.bukkit.inventory.ItemStack @NotNull [] getStorageContents()
      Specified by:
      getStorageContents in interface org.bukkit.inventory.Inventory
    • setStorageContents

      public void setStorageContents(@Nullable @Nullable org.bukkit.inventory.ItemStack @NotNull [] items) throws IllegalArgumentException
      Specified by:
      setStorageContents in interface org.bukkit.inventory.Inventory
      Throws:
      IllegalArgumentException
    • contains

      public boolean contains(@NotNull @NotNull org.bukkit.Material material) throws IllegalArgumentException
      Specified by:
      contains in interface org.bukkit.inventory.Inventory
      Throws:
      IllegalArgumentException
    • contains

      public boolean contains(@Nullable @Nullable org.bukkit.inventory.ItemStack item)
      Specified by:
      contains in interface org.bukkit.inventory.Inventory
    • contains

      public boolean contains(@NotNull @NotNull org.bukkit.Material material, int amount) throws IllegalArgumentException
      Specified by:
      contains in interface org.bukkit.inventory.Inventory
      Throws:
      IllegalArgumentException
    • contains

      public boolean contains(@Nullable @Nullable org.bukkit.inventory.ItemStack item, int amount)
      Specified by:
      contains in interface org.bukkit.inventory.Inventory
    • containsAtLeast

      public boolean containsAtLeast(@Nullable @Nullable org.bukkit.inventory.ItemStack item, int amount)
      Specified by:
      containsAtLeast in interface org.bukkit.inventory.Inventory
    • all

      @NotNull public @NotNull HashMap<Integer,? extends org.bukkit.inventory.ItemStack> all(@NotNull @NotNull org.bukkit.Material material) throws IllegalArgumentException
      Specified by:
      all in interface org.bukkit.inventory.Inventory
      Throws:
      IllegalArgumentException
    • all

      @NotNull public @NotNull HashMap<Integer,? extends org.bukkit.inventory.ItemStack> all(@Nullable @Nullable org.bukkit.inventory.ItemStack item)
      Specified by:
      all in interface org.bukkit.inventory.Inventory
    • first

      public int first(@NotNull @NotNull org.bukkit.Material material) throws IllegalArgumentException
      Specified by:
      first in interface org.bukkit.inventory.Inventory
      Throws:
      IllegalArgumentException
    • first

      public int first(@NotNull @NotNull org.bukkit.inventory.ItemStack item)
      Specified by:
      first in interface org.bukkit.inventory.Inventory
    • firstEmpty

      public int firstEmpty()
      Specified by:
      firstEmpty in interface org.bukkit.inventory.Inventory
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface org.bukkit.inventory.Inventory
    • remove

      public void remove(@NotNull @NotNull org.bukkit.Material material) throws IllegalArgumentException
      Specified by:
      remove in interface org.bukkit.inventory.Inventory
      Throws:
      IllegalArgumentException
    • remove

      public void remove(@NotNull @NotNull org.bukkit.inventory.ItemStack item)
      Specified by:
      remove in interface org.bukkit.inventory.Inventory
    • clear

      public void clear(int index)
      Specified by:
      clear in interface org.bukkit.inventory.Inventory
    • clear

      public void clear()
      Specified by:
      clear in interface org.bukkit.inventory.Inventory
    • close

      public int close()
      Specified by:
      close in interface org.bukkit.inventory.Inventory
    • getViewers

      @NotNull public @NotNull List<org.bukkit.entity.HumanEntity> getViewers()
      Specified by:
      getViewers in interface org.bukkit.inventory.Inventory
    • getType

      @NotNull public @NotNull org.bukkit.event.inventory.InventoryType getType()
      Specified by:
      getType in interface org.bukkit.inventory.Inventory
    • getHolder

      @Nullable public @Nullable org.bukkit.inventory.InventoryHolder getHolder()
      Specified by:
      getHolder in interface org.bukkit.inventory.Inventory
    • getHolder

      @Nullable public @Nullable org.bukkit.inventory.InventoryHolder getHolder(boolean useSnapshot)
      Specified by:
      getHolder in interface org.bukkit.inventory.Inventory
    • iterator

      @NotNull public @NotNull ListIterator<org.bukkit.inventory.ItemStack> iterator()
      Specified by:
      iterator in interface org.bukkit.inventory.Inventory
      Specified by:
      iterator in interface Iterable<org.bukkit.inventory.ItemStack>
    • iterator

      @NotNull public @NotNull ListIterator<org.bukkit.inventory.ItemStack> iterator(int index)
      Specified by:
      iterator in interface org.bukkit.inventory.Inventory
    • getLocation

      @Nullable public @Nullable org.bukkit.Location getLocation()
      Specified by:
      getLocation in interface org.bukkit.inventory.Inventory
    • getInventory

      @NotNull public @NotNull org.bukkit.inventory.Inventory getInventory()
      Specified by:
      getInventory in interface org.bukkit.inventory.InventoryHolder