Documentation

TemporaryInventory extends Inventory

Table of Contents

MAX_STACK  = 64
addItem()  : array<string|int, Item>
Stores the given Items in the inventory. This will try to fill existing stacks and empty slots as well as it can.
all()  : array<string|int, Item>
Will return all the Items that has the same id and metadata (if not null).
canAddItem()  : bool
Checks if a given Item can be added to the inventory
clear()  : void
Will clear a specific slot
clearAll()  : void
Clears all the slots
contains()  : bool
Checks if the inventory contains any Item with the same material data.
first()  : int
Returns the first slot number containing an item with the same ID, damage (if not any-damage), NBT (if not empty) and count >= to the count of the specified item stack.
firstEmpty()  : int
Returns the first empty slot, or -1 if not found
getAddableItemQuantity()  : int
Returns how many items from the given itemstack can be added to this inventory.
getContents()  : array<string|int, Item>
getItem()  : Item
getListeners()  : array<string|int, InventoryListener>|ObjectSet
getMaxStackSize()  : int
getSize()  : int
getViewers()  : array<string|int, Player>
Gets all the Players viewing the inventory Players will view their inventory at all times, even when not open.
isSlotEmpty()  : bool
Returns whether the given slot is empty.
onClose()  : void
onOpen()  : void
Called when a player opens this inventory.
remove()  : void
Will remove all the Items that has the same id and metadata (if not null)
removeItem()  : array<string|int, Item>
Removes the given Item from the inventory.
setContents()  : void
setItem()  : void
Puts an Item in a slot.
setMaxStackSize()  : void
slotExists()  : bool
Returns whether the specified slot exists in the inventory.
swap()  : void
Swaps the specified slots.

Constants

Methods

addItem()

Stores the given Items in the inventory. This will try to fill existing stacks and empty slots as well as it can.

public addItem(Item ...$slots) : array<string|int, Item>

Returns the Items that did not fit.

Parameters
$slots : Item
Return values
array<string|int, Item>

all()

Will return all the Items that has the same id and metadata (if not null).

public all(Item $item) : array<string|int, Item>

Won't check amount

Parameters
$item : Item
Return values
array<string|int, Item>

canAddItem()

Checks if a given Item can be added to the inventory

public canAddItem(Item $item) : bool
Parameters
$item : Item
Return values
bool

clear()

Will clear a specific slot

public clear(int $index) : void
Parameters
$index : int
Return values
void

clearAll()

Clears all the slots

public clearAll() : void
Return values
void

contains()

Checks if the inventory contains any Item with the same material data.

public contains(Item $item) : bool

It will check id, amount, and metadata (if not null)

Parameters
$item : Item
Return values
bool

first()

Returns the first slot number containing an item with the same ID, damage (if not any-damage), NBT (if not empty) and count >= to the count of the specified item stack.

public first(Item $item[, bool $exact = false ]) : int

If $exact is true, only items with equal ID, damage, NBT and count will match.

Parameters
$item : Item
$exact : bool = false
Return values
int

firstEmpty()

Returns the first empty slot, or -1 if not found

public firstEmpty() : int
Return values
int

getAddableItemQuantity()

Returns how many items from the given itemstack can be added to this inventory.

public getAddableItemQuantity(Item $item) : int
Parameters
$item : Item
Return values
int

getContents()

public getContents([bool $includeEmpty = false ]) : array<string|int, Item>
Parameters
$includeEmpty : bool = false
Return values
array<string|int, Item>

getItem()

public getItem(int $index) : Item
Parameters
$index : int
Return values
Item

getMaxStackSize()

public getMaxStackSize() : int
Return values
int

getSize()

public getSize() : int
Return values
int

getViewers()

Gets all the Players viewing the inventory Players will view their inventory at all times, even when not open.

public getViewers() : array<string|int, Player>
Return values
array<string|int, Player>

isSlotEmpty()

Returns whether the given slot is empty.

public isSlotEmpty(int $index) : bool
Parameters
$index : int
Return values
bool

onOpen()

Called when a player opens this inventory.

public onOpen(Player $who) : void
Parameters
$who : Player
Return values
void

remove()

Will remove all the Items that has the same id and metadata (if not null)

public remove(Item $item) : void
Parameters
$item : Item
Return values
void

removeItem()

Removes the given Item from the inventory.

public removeItem(Item ...$slots) : array<string|int, Item>

It will return the Items that couldn't be removed.

Parameters
$slots : Item
Return values
array<string|int, Item>

setContents()

public setContents(array<string|int, Item$items) : void
Parameters
$items : array<string|int, Item>
Return values
void

setItem()

Puts an Item in a slot.

public setItem(int $index, Item $item) : void
Parameters
$index : int
$item : Item
Return values
void

setMaxStackSize()

public setMaxStackSize(int $size) : void
Parameters
$size : int
Return values
void

slotExists()

Returns whether the specified slot exists in the inventory.

public slotExists(int $slot) : bool
Parameters
$slot : int
Return values
bool

swap()

Swaps the specified slots.

public swap(int $slot1, int $slot2) : void
Parameters
$slot1 : int
$slot2 : int
Return values
void

Search results