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

Solved how to add permission node for plugin

Discussion in 'Help' started by mmm545, May 5, 2020.

  1. mmm545

    mmm545 Baby Zombie

    Messages:
    152
    GitHub:
    mmm545
    So i just made a simple plugin and it works. (added a command that does nothing) and it loads with no problems. but the permission node doesn't exist and i don't how to add it.
    i used devtools to make the .phar file.
    PHP:
    <?php

    namespace mmm545\MyPlugin;
     
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\Server;
    use 
    pocketmine\Player;
    use 
    pocketmine\command\Command;
    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\utils\TextFormat;

        class 
    Main extends PluginBase{
            public function 
    onCommand(CommandSender $senderCommand $commandstring $label, array $args) : bool{
            switch(
    $command->getName()){
                case 
    "test":
                        
    //will add code later
                
    break;
            }
            return 
    true;
        }
    }
    yml file:
    Code:
    name: MyPlugin
    version: 1.0
    main: mmm545\MyPlugin\Main
    api: 3.11.5
    commands:
     test:
      description: Just a test.
    ...
    how can i add it?
    Thanks
    Here is a .zip file:
     

    Attached Files:

  2. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    Add it to the plugin.yml like so:
    Code:
    name: MyPlugin
    version: 1.0
    main: mmm545\MyPlugin\Main
    api: 3.11.5
    commands:
     test:
      description: Just a test.
      permission: myplugin.test
    
    permissions:
     myplugin:
      default: false
      children:
       myplugin.test:
        default: op
     
  3. HiToLaKhanh

    HiToLaKhanh Spider Jockey

    Messages:
    25
    GitHub:
    HiToLaKhanh
    PHP:
    if($sender->hasPermission("myplugin.test")){
        
    //add some thing here
    }
    but first add permission like that reply
     
  4. mmm545

    mmm545 Baby Zombie

    Messages:
    152
    GitHub:
    mmm545
    Thank you guys will try that
     
  5. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    Jesus please start reading the original post and other replies before replying. I'm not hating you for trying to help, but please.
     
  6. mmm545

    mmm545 Baby Zombie

    Messages:
    152
    GitHub:
    mmm545
    how to add a description for the permission node??
    Edit: nvm i figured it out
     
  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.