Class InventoryMock
java.lang.Object
be.seeseemelk.mockbukkit.inventory.InventoryMock
- Direct Known Subclasses:
AbstractHorseInventoryMock,AnvilInventoryMock,BarrelInventoryMock,BeaconInventoryMock,BrewerInventoryMock,CartographyInventoryMock,ChestInventoryMock,DispenserInventoryMock,DropperInventoryMock,EnchantingInventoryMock,EnderChestInventoryMock,FurnaceInventoryMock,GrindstoneInventoryMock,HopperInventoryMock,LecternInventoryMock,LoomInventoryMock,PlayerInventoryMock,ShulkerBoxInventoryMock,SimpleInventoryMock,SmithingInventoryMock,StonecutterInventoryMock,WorkbenchInventoryMock
-
Constructor Summary
ConstructorsConstructorDescriptionInventoryMock(@Nullable InventoryHolder holder, int size, @NotNull InventoryType type) InventoryMock(@Nullable InventoryHolder holder, @NotNull InventoryType type) -
Method Summary
Modifier and TypeMethodDescription@Nullable ItemStackAdds a single item to the inventory.voidaddViewer(@NotNull HumanEntity viewer) Adds a viewer to this inventory.voidaddViewers(@NotNull List<HumanEntity> viewers) Adds the given viewers to this inventory.voidaddViewers(@NotNull HumanEntity... viewers) Adds the given viewers to this inventory.voidassertContainsAny(@NotNull ItemStack item) Asserts that the inventory contains at least one itemstack that is compatible with the given itemstack.voidassertContainsAtLeast(@NotNull 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<ItemStack> condition) Asserts that a certain condition is true for all items, evennulls, in this inventory.voidassertTrueForNonNulls(@NotNull Predicate<ItemStack> condition) Assets that a certain condition is true for all items in this inventory that aren't null.voidassertTrueForSome(@NotNull Predicate<ItemStack> condition) Asserts that a certain condition is true for at least one item in this inventory.voidclear()voidclear(int index) intclose()booleanbooleanbooleanbooleanbooleancontainsAtLeast(@NotNull ItemStack item, int amount) intintintItemStack @NotNull []@Nullable InventoryHolder@Nullable InventoryHoldergetHolder(boolean useSnapshot) getItem(int index) intintgetNumberOfItems(@NotNull ItemStack item) Get the number of times a certain item is in the inventory.intgetSize()@NotNull InventoryItemStack @NotNull []@NotNull InventoryTypegetType()@NotNull List<HumanEntity>booleanisEmpty()@NotNull ListIterator<ItemStack>iterator()@NotNull ListIterator<ItemStack>iterator(int index) voidvoidremoveItem(ItemStack... items) removeItemAnySlot(@NotNull ItemStack... items) voidremoveViewer(@NotNull HumanEntity viewer) Removes a viewer from this inventory.voidsetContents(ItemStack @NotNull [] items) voidvoidsetMaxStackSize(int size) voidsetStorageContents(ItemStack @NotNull [] 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 InventoryHolder holder, int size, @NotNull @NotNull InventoryType type) -
InventoryMock
public InventoryMock(@Nullable @Nullable InventoryHolder holder, @NotNull @NotNull 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
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
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
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
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
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.
-
addViewer
Adds a viewer to this inventory.- Parameters:
viewer- The viewer to add.
-
addViewers
Adds the given viewers to this inventory.- Parameters:
viewers- The viewers to add.
-
addViewers
Adds the given viewers to this inventory.- Parameters:
viewers- TheListof viewers to add.
-
removeViewer
Removes a viewer from this inventory.- Parameters:
viewer- The viewer to remove.
-
getSize
public int getSize() -
getItem
-
setItem
-
addItem
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
@NotNull public @NotNull HashMap<Integer,ItemStack> addItem(ItemStack @NotNull ... items) throws IllegalArgumentException - Specified by:
addItemin interfaceInventory- Throws:
IllegalArgumentException
-
getContents
- Specified by:
getContentsin interfaceInventory
-
setContents
- Specified by:
setContentsin interfaceInventory
-
getHolder
-
getHolder
-
iterator
-
getType
-
getMaxStackSize
public int getMaxStackSize()- Specified by:
getMaxStackSizein interfaceInventory
-
setMaxStackSize
public void setMaxStackSize(int size) - Specified by:
setMaxStackSizein interfaceInventory
-
removeItem
@NotNull public @NotNull HashMap<Integer,ItemStack> removeItem(ItemStack... items) throws IllegalArgumentException - Specified by:
removeItemin interfaceInventory- Throws:
IllegalArgumentException
-
removeItemAnySlot
@NotNull public @NotNull HashMap<Integer,ItemStack> removeItemAnySlot(@NotNull @NotNull ItemStack... items) throws IllegalArgumentException - Specified by:
removeItemAnySlotin interfaceInventory- Throws:
IllegalArgumentException
-
getStorageContents
- Specified by:
getStorageContentsin interfaceInventory
-
setStorageContents
- Specified by:
setStorageContentsin interfaceInventory- Throws:
IllegalArgumentException
-
contains
- Specified by:
containsin interfaceInventory- Throws:
IllegalArgumentException
-
contains
-
contains
public boolean contains(@Nullable @Nullable Material material, int amount) throws IllegalArgumentException - Specified by:
containsin interfaceInventory- Throws:
IllegalArgumentException
-
contains
-
containsAtLeast
- Specified by:
containsAtLeastin interfaceInventory
-
all
@NotNull public @NotNull HashMap<Integer,? extends ItemStack> all(@NotNull @NotNull Material material) throws IllegalArgumentException - Specified by:
allin interfaceInventory- Throws:
IllegalArgumentException
-
all
-
first
- Specified by:
firstin interfaceInventory- Throws:
IllegalArgumentException
-
first
-
firstEmpty
public int firstEmpty()- Specified by:
firstEmptyin interfaceInventory
-
remove
- Specified by:
removein interfaceInventory- Throws:
IllegalArgumentException
-
remove
-
clear
public void clear(int index) -
clear
public void clear() -
close
public int close() -
getViewers
- Specified by:
getViewersin interfaceInventory
-
iterator
-
getLocation
- Specified by:
getLocationin interfaceInventory
-
isEmpty
public boolean isEmpty() -
getSnapshot
-