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

Implamenting Commands in my plugin

Comments in 'Plugin Development' started by DunxandMinecraft, May 17, 2015.

  1. DunxandMinecraft
    Offline

    DunxandMinecraft Active Member

    Joined:
    Oct 26, 2014
    Posts:
    158
    Hello,

    I may have asked this a few weeks ago but I want to ask for help again. I'm creating a simple plugin and I put in the commands in my plugin.yml

    Code:
    commands:
    info:
      description: "Shows information about the server"
      usage: "/info"
      permission: myplugin.example
      quit:
      description: "Kicks player from server"
      usage: "/quit"
      permission: player.kick
      inv:
      description: "Lists all items in Player Iv"
      usage: "/inv"
      permission: inventory.BaseInventory
    And I need help. For the permission I don't know what it means.
    For the info I need it to show text to just one user
    For the quit I need it to kick the player that executed the command
    And the Inv I want it to display what is in the users inventory.
    Also I'm making the plugin on GitHub so you can access it here.

    Thanks for your help in advance.
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Indent your plugin.yml correctly, or it won't work.

    As for permissions, please read about the documentation for permission nodes.
    DunxandMinecraft likes this.
  3. DunxandMinecraft
    Offline

    DunxandMinecraft Active Member

    Joined:
    Oct 26, 2014
    Posts:
    158
    The documentation on docs.pocketmine.net?
  4. HotFireyDeath
    Offline

    HotFireyDeath Notable Member Plugin Developer

    Joined:
    Mar 19, 2015
    Posts:
    328
    Plugins:
    1
    Minecraft User:
    HotFireyDeath
    Code:
    commands:
      info:
        description: "Shows information about the server"
        usage: "/info"
        permission: pluginName.info
      quit:
        description: "Kicks player from server"
        usage: "/quit"
        permission: pluginName.kick
      inv:
        description: "Lists all items in Player Inventory"
        usage: "/inv"
        permission: pluginName.BaseInventory
    
    DunxandMinecraft and PixelGuy75 like this.
  5. DunxandMinecraft
    Offline

    DunxandMinecraft Active Member

    Joined:
    Oct 26, 2014
    Posts:
    158
    How can I set those perrs on my plugin?
  6. BlubberBoy333
    Offline

    BlubberBoy333 Active Member

    Joined:
    Aug 31, 2014
    Posts:
    177
    Minecraft User:
    Blubberboy333
    Have the command section of the plugin.yml file like what @HotFireyDeath said. Then make the permission section something like this:
    PHP:
    permissions:
      
    example:
      default: 
    false (false if you want nobody to use it)
      
    descriptionThis one will give the user to use all of the permissions
      children
    :
        
    example.command:
          default: 
    false
          description
    This one will let the user use all of the commands
          children
    :
            
    example.command.info:
              default: 
    true (true if you want everyone to use it)
              
    descriptionAllows the player to run the info command
            example
    .command.quit:
              default: 
    op (op if you only want ops to use it)
             
    descriptionAllows the player to run the quit command
           example
    .command.inv:
             default: 
    op
             description
    Allows the player to run the inv command
    And to make the permissions work in your plugin have this:
    PHP:
    public function onCommand(CommandSender $senderCommand $command$label, array $args){
        if(
    strtolower($command->getName()) === "info"){
            if(
    $sender->hasPermission("example.command.info")){
                
    //It will run the code here is the sender has the permission node
            
    }else{
                
    //If the sender doesn't have permission, it will run this code
            
    }
        }elseif(
    strtolower($command->getName()) === "quit"){
            
    // Same thing here, and same for the other command
        
    }
    }
  7. DunxandMinecraft
    Offline

    DunxandMinecraft Active Member

    Joined:
    Oct 26, 2014
    Posts:
    158
    How do I specify the message? And by the way can you please help me on the Git
  8. BlubberBoy333
    Offline

    BlubberBoy333 Active Member

    Joined:
    Aug 31, 2014
    Posts:
    177
    Minecraft User:
    Blubberboy333
    Do you mean sending a player a message?
    A Github page for the plugin you're making? Do you have one?
    Last edited: May 17, 2015
  9. DunxandMinecraft
    Offline

    DunxandMinecraft Active Member

    Joined:
    Oct 26, 2014
    Posts:
    158
    1. Yes 2.the github.com is in the first post
  10. HotFireyDeath
    Offline

    HotFireyDeath Notable Member Plugin Developer

    Joined:
    Mar 19, 2015
    Posts:
    328
    Plugins:
    1
    Minecraft User:
    HotFireyDeath
    Specify the permission messages?
    Code:
    $sender->sendMessage("Blah Blah");
    
  11. DunxandMinecraft
    Offline

    DunxandMinecraft Active Member

    Joined:
    Oct 26, 2014
    Posts:
    158
    I can't understand this. Please contribute and create a pull request on the Git.
  12. DunxandMinecraft
    Offline

    DunxandMinecraft Active Member

    Joined:
    Oct 26, 2014
    Posts:
    158

Share This Page

Advertisement