https://github.com/plugins-pocketminemp/inventorymenuapi
A simple inventory menu api for PocketMine-MP
https://github.com/plugins-pocketminemp/inventorymenuapi
Last synced: about 1 month ago
JSON representation
A simple inventory menu api for PocketMine-MP
- Host: GitHub
- URL: https://github.com/plugins-pocketminemp/inventorymenuapi
- Owner: Plugins-PocketMineMP
- Created: 2020-07-10T07:35:48.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-06-13T14:19:03.000Z (almost 4 years ago)
- Last Synced: 2024-05-21T05:19:44.954Z (about 1 year ago)
- Language: PHP
- Size: 6.84 KB
- Stars: 3
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# InventoryMenuAPI
A simple inventory menu api for PocketMine-MP# How to use?
* Get normal chest
```php
$inv = \alvin0319\InventoryMenuAPI\InventoryMenuAPI::createChest("CHEST_NAME");
```* Get Double chest
```php
$inv = alvin0319\InventoryMenuAPI\InventoryMenuAPI::createDoubleChest("CHEST_NAME");
```* Handle Transaction
```php
/** @var \alvin0319\InventoryMenuAPI\inventory\InventoryBase $inv */
$inv->setTransactionHandler(function(\pocketmine\Player $player, \pocketmine\item\Item $input, \pocketmine\item\Item $output, int $slot, &$cancelled) : void{
echo "Player {$player->getName()} put the item {$input} and took the item {$output} out of slot {$slot}.";
});
```
* What is `&$cancelled`?`$cancelled` is used to cancel a transaction.
If `$cancelled = true;` the transaction is canceled, and if you do nothing or `$cancelled = false;` the transaction is not canceled.
* Handle opening inventory
```php
/** @var \alvin0319\InventoryMenuAPI\inventory\InventoryBase $inv */
$inv->setOpenHandler(function(\pocketmine\Player $player) : void{
echo "{$player->getName()} has just opened inventory!";
});
```* Handle closing inventory
```php
/** @var \alvin0319\InventoryMenuAPI\inventory\InventoryBase $inv */
$inv->setCloseHandler(function(\pocketmine\Player $player) : void{
echo "{$player->getName()} has just closed inventory!";
});
```* Send inventory
```php
/** @var \alvin0319\InventoryMenuAPI\inventory\InventoryBase $inv */
/** @var \pocketmine\Player $player */
$inv->send($player);
```