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
-
Constructor Summary
ConstructorsConstructorDescriptionInventoryMock(@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 TypeMethodDescription@Nullable org.bukkit.inventory.ItemStackaddItem(@NotNull org.bukkit.inventory.ItemStack item) Adds a single item to the inventory.addItem(org.bukkit.inventory.ItemStack... items) all(@NotNull org.bukkit.Material material) all(org.bukkit.inventory.ItemStack item) voidassertContainsAny(@NotNull org.bukkit.inventory.ItemStack item) Asserts that the inventory contains at least one itemstack that is compatible with the given itemstack.voidassertContainsAtLeast(@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.voidassertTrueForAll(@NotNull Predicate<org.bukkit.inventory.ItemStack> condition) Asserts that a certain condition is true for all items, evennulls, in this inventory.voidassertTrueForNonNulls(@NotNull Predicate<org.bukkit.inventory.ItemStack> condition) Assets that a certain condition is true for all items in this inventory that aren't null.voidassertTrueForSome(@NotNull Predicate<org.bukkit.inventory.ItemStack> condition) Asserts that a certain condition is true for at least one item in this inventory.voidclear()voidclear(int index) intclose()booleancontains(org.bukkit.inventory.ItemStack item) booleancontains(org.bukkit.inventory.ItemStack item, int amount) booleancontains(org.bukkit.Material material) booleancontains(org.bukkit.Material material, int amount) booleancontainsAtLeast(org.bukkit.inventory.ItemStack item, int amount) intfirst(@NotNull org.bukkit.inventory.ItemStack item) intfirst(@NotNull org.bukkit.Material material) intorg.bukkit.inventory.ItemStack[]org.bukkit.inventory.InventoryHolder@Nullable org.bukkit.inventory.InventoryHoldergetHolder(boolean useSnapshot) org.bukkit.inventory.ItemStackgetItem(int index) org.bukkit.LocationintintgetNumberOfItems(@NotNull org.bukkit.inventory.ItemStack item) Get the number of times a certain item is in the inventory.intgetSize()@NotNull org.bukkit.inventory.Inventoryorg.bukkit.inventory.ItemStack[]org.bukkit.event.inventory.InventoryTypegetType()List<org.bukkit.entity.HumanEntity>booleanisEmpty()ListIterator<org.bukkit.inventory.ItemStack>iterator()ListIterator<org.bukkit.inventory.ItemStack>iterator(int index) voidremove(@NotNull org.bukkit.inventory.ItemStack item) voidremove(@NotNull org.bukkit.Material material) removeItem(org.bukkit.inventory.ItemStack... items) removeItemAnySlot(@NotNull org.bukkit.inventory.ItemStack... items) voidsetContents(org.bukkit.inventory.ItemStack[] items) voidsetItem(int index, org.bukkit.inventory.ItemStack item) voidsetMaxStackSize(int size) voidsetStorageContents(org.bukkit.inventory.ItemStack[] items) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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
Asserts that a certain condition is true for all items, evennulls, 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:
getSizein interfaceorg.bukkit.inventory.Inventory
-
getItem
public org.bukkit.inventory.ItemStack getItem(int index) - Specified by:
getItemin interfaceorg.bukkit.inventory.Inventory
-
setItem
public void setItem(int index, org.bukkit.inventory.ItemStack item) - Specified by:
setItemin interfaceorg.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:
addItemin interfaceorg.bukkit.inventory.Inventory- Throws:
IllegalArgumentException
-
getContents
public org.bukkit.inventory.ItemStack[] getContents()- Specified by:
getContentsin interfaceorg.bukkit.inventory.Inventory
-
setContents
public void setContents(org.bukkit.inventory.ItemStack[] items) - Specified by:
setContentsin interfaceorg.bukkit.inventory.Inventory
-
getHolder
public org.bukkit.inventory.InventoryHolder getHolder()- Specified by:
getHolderin interfaceorg.bukkit.inventory.Inventory
-
getHolder
@Nullable public @Nullable org.bukkit.inventory.InventoryHolder getHolder(boolean useSnapshot) - Specified by:
getHolderin interfaceorg.bukkit.inventory.Inventory
-
iterator
-
getType
public org.bukkit.event.inventory.InventoryType getType()- Specified by:
getTypein interfaceorg.bukkit.inventory.Inventory
-
getMaxStackSize
public int getMaxStackSize()- Specified by:
getMaxStackSizein interfaceorg.bukkit.inventory.Inventory
-
setMaxStackSize
public void setMaxStackSize(int size) - Specified by:
setMaxStackSizein interfaceorg.bukkit.inventory.Inventory
-
removeItem
public HashMap<Integer,org.bukkit.inventory.ItemStack> removeItem(org.bukkit.inventory.ItemStack... items) throws IllegalArgumentException - Specified by:
removeItemin interfaceorg.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:
removeItemAnySlotin interfaceorg.bukkit.inventory.Inventory- Throws:
IllegalArgumentException
-
getStorageContents
public org.bukkit.inventory.ItemStack[] getStorageContents()- Specified by:
getStorageContentsin interfaceorg.bukkit.inventory.Inventory
-
setStorageContents
public void setStorageContents(org.bukkit.inventory.ItemStack[] items) throws IllegalArgumentException - Specified by:
setStorageContentsin interfaceorg.bukkit.inventory.Inventory- Throws:
IllegalArgumentException
-
contains
- Specified by:
containsin interfaceorg.bukkit.inventory.Inventory- Throws:
IllegalArgumentException
-
contains
public boolean contains(org.bukkit.inventory.ItemStack item) - Specified by:
containsin interfaceorg.bukkit.inventory.Inventory
-
contains
- Specified by:
containsin interfaceorg.bukkit.inventory.Inventory- Throws:
IllegalArgumentException
-
contains
public boolean contains(org.bukkit.inventory.ItemStack item, int amount) - Specified by:
containsin interfaceorg.bukkit.inventory.Inventory
-
containsAtLeast
public boolean containsAtLeast(org.bukkit.inventory.ItemStack item, int amount) - Specified by:
containsAtLeastin interfaceorg.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:
allin interfaceorg.bukkit.inventory.Inventory- Throws:
IllegalArgumentException
-
all
@NotNull public @NotNull HashMap<Integer,? extends org.bukkit.inventory.ItemStack> all(org.bukkit.inventory.ItemStack item) - Specified by:
allin interfaceorg.bukkit.inventory.Inventory
-
first
- Specified by:
firstin interfaceorg.bukkit.inventory.Inventory- Throws:
IllegalArgumentException
-
first
public int first(@NotNull @NotNull org.bukkit.inventory.ItemStack item) - Specified by:
firstin interfaceorg.bukkit.inventory.Inventory
-
firstEmpty
public int firstEmpty()- Specified by:
firstEmptyin interfaceorg.bukkit.inventory.Inventory
-
remove
- Specified by:
removein interfaceorg.bukkit.inventory.Inventory- Throws:
IllegalArgumentException
-
remove
public void remove(@NotNull @NotNull org.bukkit.inventory.ItemStack item) - Specified by:
removein interfaceorg.bukkit.inventory.Inventory
-
clear
public void clear(int index) - Specified by:
clearin interfaceorg.bukkit.inventory.Inventory
-
clear
public void clear()- Specified by:
clearin interfaceorg.bukkit.inventory.Inventory
-
close
public int close()- Specified by:
closein interfaceorg.bukkit.inventory.Inventory
-
getViewers
- Specified by:
getViewersin interfaceorg.bukkit.inventory.Inventory
-
iterator
- Specified by:
iteratorin interfaceorg.bukkit.inventory.Inventory
-
getLocation
public org.bukkit.Location getLocation()- Specified by:
getLocationin interfaceorg.bukkit.inventory.Inventory
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceorg.bukkit.inventory.Inventory
-
getSnapshot
@NotNull public @NotNull org.bukkit.inventory.Inventory getSnapshot()
-