1. Go to this page and download the library: Download muqsit/invmenu library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
$menu->setListener(function(InvMenuTransaction $transaction) : InvMenuTransactionResult{
if($transaction->getItemClicked()->getId() === ItemIds::APPLE){
$player->sendMessage("You cannot take apples out of that inventory.");
return $transaction->discard();
}
return $transaction->continue();
});
$menu->setListener(function(InvMenuTransaction $transaction) : InvMenuTransactionResult{
// do something
return $transaction->discard();
});
$menu->setListener(InvMenu::readonly());
$menu->setListener(InvMenu::readonly(function(DeterministicInvMenuTransaction $transaction) : void{
// do something
}));
/**
* @param Player $player the player who closed the inventory.
*
* @param Inventory $inventory the inventory instance closed by the player.
*/
Closure(Player $player, Inventory $inventory) : void;
/** @var Player $player */
$player->removeCurrentWindow();
public const TYPE_DISPENSER = "myplugin:dispenser";
protected function onEnable() : void{
InvMenuHandler::getTypeRegistry()->register(self::TYPE_DISPENSER, InvMenuTypeBuilders::BLOCK_ACTOR_FIXED()
->setBlock(BlockFactory::getInstance()->get(BlockLegacyIds::DISPENSER, 0))
->setBlockActorId("Dispenser")
->setSize(9)
->setNetworkWindowType(WindowTypes::DISPENSER)
->build());
}
$menu = InvMenu::create(self::TYPE_DISPENSER);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.