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

Solved Help with FormAPI

Discussion in 'Development' started by Khaled, Feb 8, 2018.

  1. Khaled

    Khaled Slime

    Messages:
    81
    GitHub:
    xXKHaLeD098Xx
    Guys please help i 'm getting mad and this is my 5/6 attempt to make formapi work
    PHP:
    <?php

    namespace flyui;

    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\command\{
        
    Command,
        
    CommandSender
    };
    use 
    jojoe77777\FormAPI;
    use 
    pocketmine\{
        
    Player,
        
    Server
    };
    use 
    pocketmine\event\Listener;

    class 
    FlyUI extends PluginBase implements Listener {
       
        public function 
    onEnable(){
            
    $this->getServer()->getPluginManager()->registerEvents($this$this);
        }
       
        public function 
    onCommand(CommandSender $playerCommand $cmdstring $label, array $args) : bool{
            if(
    strtolower($cmd->getName() == "flyui")){
                if(
    $player->hasPermission("flyui.dragonsmp")){
                    
    $this->flyui($player);
                    return 
    true;
                }
            }
        }
       
        public function 
    flyui(Player $player){
            
    $api $this->getServer()->getPluginManager()->getPlugin("FormAPI");
            if(
    $api === null || $api->isDisabled()){
                return 
    true;
            }
            
    $form $api->createSimpleForm(function(Player $player, array $data){
                
    $result $data[0];
                if(
    $result === null){
                    return 
    true;
                }
                switch(
    $result){
                    case 
    0:
                    
    $player->setAllowFlight(true);
                    
    $player->sendMessage("Fly On");
                    return 
    true;
                    case 
    1:
                    
    $player->setAllowFlight(false);
                    
    $player->sendMessage("Fly Off");
                }
            });
            
    $form->setTitle("FlyUI");
            
    $form->setContent("Select On or Off");
            
    $form->addButton("On");
            
    $form->addButton("Off");
            
    $form->sendToPlayer($player);
        }
    }
    ?>
    and this is the plugin.yml:
    Code:
    ---
    name: FlyUIKhaled098yt
    version: 1.0
    api: [3.0.0-ALPHA10]
    main: flyui\FlyUI
    author: Khaled
    
    commands:
      flyui:
        description: Fly UI
    permissions:
      flyui.dragonsmp:
        description: Permission FlyUI
    But when i pit the plugin in the Plugins folder and restart the server the plugin doesnt even show up.
     
  2. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    If the plugin doesn't even show up, it has nothing to do with FormAPI.

    Also, make sure you add this line in plugin.yml if you use FormAPI:

    Code:
    depend: FormAPI
     
    xXNiceAssassinlo YT likes this.
  3. TwistedAsylumMC

    TwistedAsylumMC Slime

    Messages:
    96
    GitHub:
    twistedasylummc
    make sure to add break; in ur cases
     
  4. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    You don't need to break if you returned. I don't know why everyone can't even understand this basic concept in flow of control.
     
  5. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    ctrl+c ctrl+v
     
  6. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    jasonwynn10 likes this.
  7. Khaled

    Khaled Slime

    Messages:
    81
    GitHub:
    xXKHaLeD098Xx
    K but it doesnt show up anyway so what do i have to?
     
  8. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    This has something to do with your environment setup. Do you have DevTools installed? Where did you put your plugin folder? Is your plugin.yml placed correctly?
     
  9. Daniktheboss

    Daniktheboss Baby Zombie

    Messages:
    144
    GitHub:
    daniktheboss
    You dont need the '---' on the top of the file.
     
  10. Khaled

    Khaled Slime

    Messages:
    81
    GitHub:
    xXKHaLeD098Xx
    Everything is set up correctly and transformed it into phar but when i put it in the Plugins folder its just like i didnt put anything in it
     
  11. Khaled

    Khaled Slime

    Messages:
    81
    GitHub:
    xXKHaLeD098Xx
    But i can put another plugins and it works
     
  12. Khaled

    Khaled Slime

    Messages:
    81
    GitHub:
    xXKHaLeD098Xx
    I removed it and still the same thing
     
  13. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    That means you did something wrong when transforming it to a phar.
     
    EdwardHamHam likes this.
  14. xXNiceAssassinlo YT

    xXNiceAssassinlo YT Zombie Pigman

    Messages:
    499
    GitHub:
    xXNiceYT
  15. xXNiceAssassinlo YT

    xXNiceAssassinlo YT Zombie Pigman

    Messages:
    499
    GitHub:
    xXNiceYT
    You can use it if u want too
     
  16. xXNiceAssassinlo YT

    xXNiceAssassinlo YT Zombie Pigman

    Messages:
    499
    GitHub:
    xXNiceYT
    Any error?
     
  17. Khaled

    Khaled Slime

    Messages:
    81
    GitHub:
    xXKHaLeD098Xx
    Nope no thing, Can you make a FlyUI plugin for me and try it?
     
  18. xXNiceAssassinlo YT

    xXNiceAssassinlo YT Zombie Pigman

    Messages:
    499
    GitHub:
    xXNiceYT
    Sure
     
  19. Khaled

    Khaled Slime

    Messages:
    81
    GitHub:
    xXKHaLeD098Xx
    It's Okay I figured it out
     
  20. Khaled

    Khaled Slime

    Messages:
    81
    GitHub:
    xXKHaLeD098Xx
    Guys it solved the problem was from my dumb device
     
  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.