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

UI not showing

Discussion in 'Development' started by Aenteritas, Jul 25, 2018.

  1. Aenteritas

    Aenteritas Silverfish

    Messages:
    22
    PHP:
    <?php

    namespace Aenteritas;

    use 
    pocketmine\Server;
    use 
    pocketmine\Player;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\command\Command;
    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\utils\Config;
    use 
    pocketmine\event\player\PlayerExhaustEvent;
    use 
    pocketmine\event\player\PlayerChatEvent;
    use 
    pocketmine\event\player\PlayerJoinEvent;
    use 
    pocketmine\event\Cancellable;

    class 
    Main extends PluginBase implements Listener {
       
        public function 
    onEnable(){
         
    $this->getServer()->getPluginManager()->registerEvents($this$this);
            
    $this->getLogger()->info("aktiviert!");
        }
       
        public function 
    onJoin(PlayerJoinEvent $event){
            
    $player $event->getPlayer();
           
            
    $event->setJoinMessage(null);
            
    $this->openMyForm($player);
        }
       
        public function 
    openMyForm($player){
            
    $api $this->getServer()->getPluginManager()->getPlugin("FormAPI");
            
    $form $api->createSimpleForm(function (Player $playerint $data null){
                
    $result $data;
                if(
    $result === null){
                    return 
    true;
                }
                switch(
    $result){
                    case 
    0:
                        
    $player->sendMessage("§7[§eLord§bTown§7] §4Wir können dich nicht teleportieren, da der Server §7(§eCityBuild§7) §4offline ist! (Error-38273)");
                    break;
                   
                    case 
    1:
                        
    $player->sendMessage("§7[§eLord§bTown§7] §4Wir können dich nicht teleportieren, da der Server §7(§bTNTRun§7) §4 offline ist! (Error-38279)");
                    break;
                }
               
            });
           
            
    $form->setTitle("§l§eNavigator");
            
    $form->setContent("Willkommen auf §eLord§bTown§r! Bitte wähle nun aus, was Du Spielen willst!");
            
    $form->addButton("§eCityBuild §7[§2ONLINE§7]");
            
    $form->addButton("§bTNTRun §7[§4OFFLINE§7]");
            
    $form->sendToPlayer($player);
            return 
    $form;
        }
       
    }

    ?>
    When i join the server, nothing happens (no UI is showing and no output in console).

    What is wrong?
    I also have FormAPI installed.
     
    Last edited: Jul 25, 2018
  2. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    What output should you have in the console? One thing I noticed is
    PHP:
      $form $api->createSimpleForm(function (Player $playerint $data null){ 
    only has a single closing ), with 2 opening (, which should throw a syntax error.
     
  3. azk_

    azk_ Spider Jockey

    Messages:
    49
    Because there is a PlayerJoinEvent bug exist. You need to send your form with delay
     
  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.