PHP Interface pocketmine\inventory\Inventory

Show file Open project: iTXTech/Genisys Interface Usage Examples

Public Methods

Method Description
addItem ( $slots ) : Item[] Stores the given Items in the inventory. This will try to fill existing stacks and empty slots as well as it can.
all ( Item $item ) : Item[] Will return all the Items that has the same id and metadata (if not null).
canAddItem ( Item $item ) : boolean Checks if a given Item can be added to the inventory
clear ( integer $index ) : boolean Will clear a specific slot
clearAll ( ) Clears all the slots
close ( Player $who )
contains ( Item $item ) : boolean Checks if the inventory contains any Item with the same material data.
first ( Item $item ) : integer Will return the first slot has the same id and metadata (if not null) as the Item.
firstEmpty ( ) : integer Returns the first empty slot, or -1 if not found
getContents ( ) : Item[]
getHolder ( ) : pocketmine\inventory\InventoryHolder
getItem ( integer $index ) : Item
getMaxStackSize ( )
getName ( )
getSize ( )
getTitle ( )
getType ( ) : InventoryType
getViewers ( ) : Player[] Gets all the Players viewing the inventory Players will view their inventory at all times, even when not open.
onClose ( Player $who )
onOpen ( Player $who )
onSlotChange ( integer $index, Item $before, boolean $send )
open ( Player $who ) : boolean Tries to open the inventory to a player
remove ( Item $item ) Will remove all the Items that has the same id and metadata (if not null)
removeItem ( $slots ) : Item[] Removes the given Item from the inventory.
sendContents ( Player | Player[] $target )
sendSlot ( integer $index, Player | Player[] $target )
setContents ( array $items )
setItem ( integer $index, Item $item ) : boolean Puts an Item in a slot.
setMaxStackSize ( integer $size )

Method Details

addItem() public method

Returns the Items that did not fit.
public addItem ( $slots ) : Item[]
return pocketmine\item\Item[]

all() public method

Won't check amount
public all ( Item $item ) : Item[]
$item pocketmine\item\Item
return pocketmine\item\Item[]

canAddItem() public method

Checks if a given Item can be added to the inventory
public canAddItem ( Item $item ) : boolean
$item pocketmine\item\Item
return boolean

clear() public method

Will clear a specific slot
public clear ( integer $index ) : boolean
$index integer
return boolean

clearAll() public method

Clears all the slots
public clearAll ( )

close() public method

public close ( Player $who )
$who pocketmine\Player

contains() public method

It will check id, amount, and metadata (if not null)
public contains ( Item $item ) : boolean
$item pocketmine\item\Item
return boolean

first() public method

-1 if not found, will check amount
public first ( Item $item ) : integer
$item pocketmine\item\Item
return integer

firstEmpty() public method

Returns the first empty slot, or -1 if not found
public firstEmpty ( ) : integer
return integer

getContents() public method

public getContents ( ) : Item[]
return pocketmine\item\Item[]

getHolder() public method

public getHolder ( ) : pocketmine\inventory\InventoryHolder
return pocketmine\inventory\InventoryHolder

getItem() public method

public getItem ( integer $index ) : Item
$index integer
return pocketmine\item\Item

getMaxStackSize() public method

public getMaxStackSize ( )

getName() public method

public getName ( )

getSize() public method

public getSize ( )

getTitle() public method

public getTitle ( )

getType() public method

public getType ( ) : InventoryType
return InventoryType

getViewers() public method

Gets all the Players viewing the inventory Players will view their inventory at all times, even when not open.
public getViewers ( ) : Player[]
return pocketmine\Player[]

onClose() public method

public onClose ( Player $who )
$who pocketmine\Player

onOpen() public method

public onOpen ( Player $who )
$who pocketmine\Player

onSlotChange() public method

public onSlotChange ( integer $index, Item $before, boolean $send )
$index integer
$before pocketmine\item\Item
$send boolean

open() public method

Tries to open the inventory to a player
public open ( Player $who ) : boolean
$who pocketmine\Player
return boolean

remove() public method

Will remove all the Items that has the same id and metadata (if not null)
public remove ( Item $item )
$item pocketmine\item\Item

removeItem() public method

It will return the Items that couldn't be removed.
public removeItem ( $slots ) : Item[]
return pocketmine\item\Item[]

sendContents() public method

public sendContents ( Player | Player[] $target )
$target pocketmine\Player | pocketmine\Player[]

sendSlot() public method

public sendSlot ( integer $index, Player | Player[] $target )
$index integer
$target pocketmine\Player | pocketmine\Player[]

setContents() public method

public setContents ( array $items )
$items array

setItem() public method

If a plugin refuses the update or $index is invalid, it'll return false If a source Player is specified, it won't send a Inventory update to it
public setItem ( integer $index, Item $item ) : boolean
$index integer
$item pocketmine\item\Item
return boolean

setMaxStackSize() public method

public setMaxStackSize ( integer $size )
$size integer