Advertisement
LA_

Untitled

LA_
May 21st, 2024
677
0
1 day
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.57 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. namespace SimpleUI;
  5.  
  6. use pocketmine\player\Player;
  7. use pocketmine\plugin\PluginBase;
  8.  
  9. use pocketmine\command\CommandSender;
  10. use pocketmine\command\Command;
  11.  
  12. use jojoe77777\FormAPI;
  13. use jojoe77777\formapi\SimpleForm;
  14.  
  15.  
  16. class Main extends PluginBase{
  17.  
  18. public function onEnable():void{
  19.  
  20.     }
  21.  
  22.  
  23.     public function onCommand(CommandSender $sender, Command $command, string $label, array $args):bool{
  24.  
  25.         if($command->getName() == "ui"){
  26.             if($sender instanceof Player){
  27.                 $this->onSimpleForm($sender);
  28.             }
  29.         }
  30.         return true;
  31.     }
  32.  
  33.     public function onSimpleForm(Player $player):void{
  34.         $form = new SimpleForm(function (Player $player, $data) {
  35.             if(!isset($data)){
  36.                 return;
  37.             }
  38.  
  39.             switch ($data){
  40.                 case 0:
  41.                     $inv = $player->getInventory();
  42.                     $inv->setItem(0, VanillaItems::DIAMOND()->setCount(30));
  43.                     $player->sendMessage("Now you have diamonds in your inventory");
  44.                     break;
  45.                 case 1:
  46.                     $inv = $player->getInventory();
  47.                     $inv->setItem(1, VanillaItems::BLEACH()->setCount(30));
  48.                     $player->sendMessage("Now you have bleach in your inventory");
  49.                     break;
  50.  
  51.             }
  52.  
  53.         });
  54.         $form->setTitle("Simple Form");
  55.         $form->setContent("Test");
  56.         $form->addButton("Diamond");
  57.         $form->addButton("Cancel");
  58.         $player->sendForm($form);
  59. }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement