Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

I have a question for developing a plugin

Comments in 'Plugin Development' started by Minsung, Mar 5, 2015.

  1. Minsung
    Offline

    Minsung New Member

    Joined:
    Feb 28, 2015
    Posts:
    3
    Minecraft User:
    Minsung_9
    Um.. I have a question..
    how to use a pocketmine\command\CommandMap::register(); ...
    Please give me to do that...
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    PHP:
    namespace your\name\space;
    use 
    pocketmine\command as cmd;

    class 
    MyCommand extends cmd\Command implements cmd\PluginIdentifiableCommand{
      private 
    $plugin;
      public function 
    __construct(MainClass $plugin){
        
    parent::__construct("cmdname""description""usage", ["aliases"]);
        
    $this->setPermission("your.command.permission.node");
        
    $this->plugin $plugin;
      }
      public function 
    getPlugin(){
        return 
    $this->plugin;
      }
      public function 
    execute(cmd\CommandSender $sender$label, array $args){
        
    // your code here
      
    }
    }
    PHP:
    namespace your\name\space;
    use 
    pocketmine\plugin\PluginBase;

    class 
    MainClass extends PluginBase{
      public function 
    onEnable(){
        
    $this->getServer()->getCommandMap()->register(new MyCommand($this));
      }
    }
    Angelo Vidrio, Falk and iksaku like this.
  3. Minsung
    Offline

    Minsung New Member

    Joined:
    Feb 28, 2015
    Posts:
    3
    Minecraft User:
    Minsung_9
    Thank you, sir!

Share This Page

Advertisement