1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

make UI plugin

Discussion in 'Development' started by amirTBM, Mar 1, 2020.

  1. amirTBM

    amirTBM Spider Jockey

    Messages:
    27
    GitHub:
    we
    Hi how can i make a UI plugin that can run cmd and do some think from pl config? for example making UI skyblock plugin
     
  2. Notjblus

    Notjblus Spider Jockey

    Messages:
    28
    GitHub:
    JblusItsMe
    PHP:
    <?php

    namespace ..\..\..\..;

    use ...\
    Main;

    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\command\PluginCommand;
    use 
    pocketmine\Player;

    use 
    jojoe77777\FormAPI;
    use 
    jojoe77777\FormAPI\SimpleForm;

    class 
    SkyBlock extends PluginCommand {

         
    /** @var Main $plugin */
         
    private $plugin;

         const 
    PREFIX "§l§f[§l§2SKYBLOCK §f]§r ";
         const 
    ADD "§3Clic me";

         public function 
    __construct(Main $plugin) {
              
    parent::__construct("sb"$plugin);
              
    $this->setDescription("§2Skybloc UI");
              
    $this->plugin $plugin;
         }

         public function 
    execute(CommandSender $senderstring $commandLabel, array $args) {
              if(
    $sender instanceof Player) {
                   
    $api $this->plugin->getServer()->getPluginManager()->getPlugin("FormAPI");

                   if(
    $api === null || $api->isDisabled()) {
                        return 
    true;
                   }

                   
    $form $api->createSimpleForm(function(Player $sender$data) {
                        
    $result $data;

                        if(
    $result === null) {
                             return;
                        }
                        switch(
    $result) {
                             case 
    0// Button 1
                                  
    $this->plugin->getServer()->dispatchCommand($sender"Your skyblock command");
                             break;
                        }
                   });
                   
    $form->setTitle(self::PREFIX);
                   
    $form->setContent("Your content");
                   
    $form->addButton("§2Button 1 \n " self::ADD);
                   
    $form->sendToPlayer($sender);
              } else {
                   
    $this->plugin->getLogger()->info("You cannot use this command in the console.");
              }
         }
    }
     
  3. amirTBM

    amirTBM Spider Jockey

    Messages:
    27
    GitHub:
    we
    tnx but i want to learn how to make a new form not a portable config
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.