Class InventoryMock

java.lang.Object
be.seeseemelk.mockbukkit.inventory.InventoryMock
All Implemented Interfaces:
Iterable<org.bukkit.inventory.ItemStack>, org.bukkit.inventory.Inventory
Direct Known Subclasses:
BarrelInventoryMock, ChestInventoryMock, DispenserInventoryMock, DropperInventoryMock, EnderChestInventoryMock, GrindstoneInventoryMock, HopperInventoryMock, LecternInventoryMock, PlayerInventoryMock, ShulkerBoxInventoryMock, SimpleInventoryMock

public class InventoryMock extends Object implements org.bukkit.inventory.Inventory
  • Constructor Summary

    Constructors
    Constructor
    Description
    InventoryMock(@Nullable org.bukkit.inventory.InventoryHolder holder, int size, @NotNull org.bukkit.event.inventory.InventoryType type)
     
    InventoryMock(@Nullable org.bukkit.inventory.InventoryHolder holder, @NotNull org.bukkit.event.inventory.InventoryType type)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    @Nullable org.bukkit.inventory.ItemStack
    addItem(@NotNull org.bukkit.inventory.ItemStack item)
    Adds a single item to the inventory.
    HashMap<Integer,org.bukkit.inventory.ItemStack>
    addItem(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(org.bukkit.inventory.ItemStack item)
     
    void
    assertContainsAny(@NotNull org.bukkit.inventory.ItemStack item)
    Asserts that the inventory contains at least one itemstack that is compatible with the given itemstack.
    void
    assertContainsAtLeast(@NotNull org.bukkit.inventory.ItemStack item, int amount)
    Asserts that the inventory contains at least a specific amount of items that are compatible with the given itemstack.
    void
    assertTrueForAll(@NotNull Predicate<org.bukkit.inventory.ItemStack> condition)
    Asserts that a certain condition is true for all items, even nulls, in this inventory.
    void
    assertTrueForNonNulls(@NotNull Predicate<org.bukkit.inventory.ItemStack> condition)
    Assets that a certain condition is true for all items in this inventory that aren't null.
    void
    assertTrueForSome(@NotNull Predicate<org.bukkit.inventory.ItemStack> condition)
    Asserts that a certain condition is true for at least one item in this inventory.
    void
     
    void
    clear(int index)
     
    int
     
    boolean
    contains(org.bukkit.inventory.ItemStack item)
     
    boolean
    contains(org.bukkit.inventory.ItemStack item, int amount)
     
    boolean
    contains(org.bukkit.Material material)
     
    boolean
    contains(org.bukkit.Material material, int amount)
     
    boolean
    containsAtLeast(org.bukkit.inventory.ItemStack item, int amount)
     
    int
    first(@NotNull org.bukkit.inventory.ItemStack item)
     
    int
    first(@NotNull org.bukkit.Material material)
     
    int
     
    org.bukkit.inventory.ItemStack[]
     
    org.bukkit.inventory.InventoryHolder
     
    @Nullable org.bukkit.inventory.InventoryHolder
    getHolder(boolean useSnapshot)
     
    org.bukkit.inventory.ItemStack
    getItem(int index)
     
    org.bukkit.Location
     
    int
     
    int
    getNumberOfItems(@NotNull org.bukkit.inventory.ItemStack item)
    Get the number of times a certain item is in the inventory.
    int
     
    @NotNull org.bukkit.inventory.Inventory
     
    org.bukkit.inventory.ItemStack[]
     
    org.bukkit.event.inventory.InventoryType
     
    List<org.bukkit.entity.HumanEntity>
     
    boolean
     
    ListIterator<org.bukkit.inventory.ItemStack>
     
    ListIterator<org.bukkit.inventory.ItemStack>
    iterator(int index)
     
    void
    remove(@NotNull org.bukkit.inventory.ItemStack item)
     
    void
    remove(@NotNull org.bukkit.Material material)
     
    HashMap<Integer,org.bukkit.inventory.ItemStack>
    removeItem(org.bukkit.inventory.ItemStack... items)
     
    @NotNull HashMap<Integer,org.bukkit.inventory.ItemStack>
    removeItemAnySlot(@NotNull org.bukkit.inventory.ItemStack... items)
     
    void
    setContents(org.bukkit.inventory.ItemStack[] items)
     
    void
    setItem(int index, org.bukkit.inventory.ItemStack item)
     
    void
    setMaxStackSize(int size)
     
    void
    setStorageContents(org.bukkit.inventory.ItemStack[] 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

    • InventoryMock

      public InventoryMock(@Nullable @Nullable org.bukkit.inventory.InventoryHolder holder, int size, @NotNull @NotNull org.bukkit.event.inventory.InventoryType type)
    • InventoryMock

      public InventoryMock(@Nullable @Nullable org.bukkit.inventory.InventoryHolder holder, @NotNull @NotNull org.bukkit.event.inventory.InventoryType type)
  • Method Details

    • assertTrueForAll

      public void assertTrueForAll(@NotNull @NotNull Predicate<org.bukkit.inventory.ItemStack> condition)
      Asserts that a certain condition is true for all items, even nulls, in this inventory.
      Parameters:
      condition - The condition to check for.
    • assertTrueForNonNulls

      public void assertTrueForNonNulls(@NotNull @NotNull Predicate<org.bukkit.inventory.ItemStack> condition)
      Assets that a certain condition is true for all items in this inventory that aren't null.
      Parameters:
      condition - The condition to check for.
    • assertTrueForSome

      public void assertTrueForSome(@NotNull @NotNull Predicate<org.bukkit.inventory.ItemStack> condition)
      Asserts that a certain condition is true for at least one item in this inventory. It will skip any null items.
      Parameters:
      condition - The condition to check for.
    • assertContainsAny

      public void assertContainsAny(@NotNull @NotNull org.bukkit.inventory.ItemStack item)
      Asserts that the inventory contains at least one itemstack that is compatible with the given itemstack.
      Parameters:
      item - The itemstack to compare everything to.
    • assertContainsAtLeast

      public void assertContainsAtLeast(@NotNull @NotNull org.bukkit.inventory.ItemStack item, int amount)
      Asserts that the inventory contains at least a specific amount of items that are compatible with the given itemstack.
      Parameters:
      item - The itemstack to search for.
      amount - The minimum amount of items that one should have.
    • getNumberOfItems

      public int getNumberOfItems(@NotNull @NotNull org.bukkit.inventory.ItemStack item)
      Get the number of times a certain item is in the inventory.
      Parameters:
      item - The item to check for.
      Returns:
      The number of times the item is present in this inventory.
    • getSize

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

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

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

      @Nullable public @Nullable org.bukkit.inventory.ItemStack addItem(@NotNull @NotNull org.bukkit.inventory.ItemStack item)
      Adds a single item to the inventory. Returns whatever item it couldn't add.
      Parameters:
      item - The item to add.
      Returns:
      The remaining stack that couldn't be added. If it's empty it just returns null.
    • addItem

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

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

      public void setContents(org.bukkit.inventory.ItemStack[] items)
      Specified by:
      setContents in interface org.bukkit.inventory.Inventory
    • getHolder

      public 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

      public 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>
    • getType

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

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

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

      public HashMap<Integer,org.bukkit.inventory.ItemStack> removeItem(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
    • getStorageContents

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

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

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

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

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

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

      public boolean containsAtLeast(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(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
    • 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

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

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

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

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

      @NotNull public @NotNull org.bukkit.inventory.Inventory getSnapshot()