Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace SimpleUI;
- use pocketmine\player\Player;
- use pocketmine\plugin\PluginBase;
- use pocketmine\command\CommandSender;
- use pocketmine\command\Command;
- use jojoe77777\FormAPI;
- use jojoe77777\formapi\SimpleForm;
- class Main extends PluginBase{
- public function onEnable():void{
- }
- public function onCommand(CommandSender $sender, Command $command, string $label, array $args):bool{
- if($command->getName() == "ui"){
- if($sender instanceof Player){
- $this->onSimpleForm($sender);
- }
- }
- return true;
- }
- public function onSimpleForm(Player $player):void{
- $form = new SimpleForm(function (Player $player, $data) {
- if(!isset($data)){
- return;
- }
- switch ($data){
- case 0:
- $inv = $player->getInventory();
- $inv->setItem(0, VanillaItems::DIAMOND()->setCount(30));
- $player->sendMessage("Now you have diamonds in your inventory");
- break;
- case 1:
- $inv = $player->getInventory();
- $inv->setItem(1, VanillaItems::BLEACH()->setCount(30));
- $player->sendMessage("Now you have bleach in your inventory");
- break;
- }
- });
- $form->setTitle("Simple Form");
- $form->setContent("Test");
- $form->addButton("Diamond");
- $form->addButton("Cancel");
- $player->sendForm($form);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement