Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Test openning inventory
<?php
/**
* Test opening inventories
*
* @name OpenInv
* @main aliuly\openinv\OpenInventory
* @version 1.0.0
* @api 1.12.0
* @description Test open inventory plugin
* @author aliuly
*/
namespace aliuly\openinv{
use pocketmine\plugin\PluginBase;
use pocketmine\command\CommandExecutor;
use pocketmine\command\ConsoleCommandSender;
use pocketmine\command\CommandSender;
use pocketmine\command\Command;
use pocketmine\Player;
use pocketmine\command\PluginCommand;
class OpenInventory extends PluginBase implements CommandExecutor{
public function onEnable(){
$cmd = new PluginCommand("openinv",$this);
$cmd->setDescription("Open inventory demo");
$cmd->setUsage("/openinv");
$cmd->setExecutor($this);
$this->getServer()->getCommandMap()->register($this->getDescription()->getName(),$cmd);
}
public function onCommand(CommandSender $sender, Command $cmd, $label, array $args) {
if ($sender instanceof Player) {
$sender->sendMessage("Openning inventory");
$sender->getInventory()->open($sender);
return true;
}
$sender->sendMessage("Run in-game only");
return true;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.