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

Help: commands with perms

Comments in 'Plugin Development' started by tankisu01, Feb 9, 2016.

  1. tankisu01
    Offline

    tankisu01 New Member

    Joined:
    Aug 20, 2015
    Posts:
    15
    Minecraft User:
    SuperPuperSteve
    Hello!

    Please help. I need to create a plugin that has a command /broadcast. Only players with permission "broadcast" are allowed to execute this command.
    Command /broadcast broadcasts to server chat each argument that player provided ("/broadcast blah blah" will show "blah blah").

    Sorry for bad english
  2. MichaelM04
    Offline

    MichaelM04 Active Member Plugin Developer

    Joined:
    Nov 12, 2015
    Posts:
    213
    Plugins:
    1
    Minecraft User:
    Michael
    PHP:
    Plugin.Yml
    name
    Whatever
    author
    Your_Name
    description
    A Plugin that does something
    version
    1.3.9
    main
    Example\Example
    api
    1.0.0
    commands
    :
      
    broadcast:
        
    description: use of /broadcast command
        permission
    broadcast.command
    permissions
    :
      
    broadcast.command:
        default: 
    op
        description
    "Allow use of /broadcast command"
    you'll also if you haven't already done it add the
    PHP:
    if($p instance of player && ($p->haspermission("broadcast.command")){
    to the commands code
    Last edited: Feb 9, 2016
  3. tankisu01
    Offline

    tankisu01 New Member

    Joined:
    Aug 20, 2015
    Posts:
    15
    Minecraft User:
    SuperPuperSteve
    Well, how to get all $args provided by player?
  4. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    You can also set permission by code.
    PHP:
    $this->getCommand($command)->setPermission($permission);
    http://php.net/manual/en/function.implode.php
    PHP:
    implode(" "$args);
  5. Vaivez66
    Offline

    Vaivez66 Notable Member Plugin Developer

    Joined:
    Jun 10, 2015
    Posts:
    402
    Plugins:
    2
    It's instanceof, not instance of, and you forgot one ')' in your code
    PocketKiller and applqpak like this.
  6. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    And Player class should be Player, not player, it's case sensitive.
    PocketKiller and Vaivez66 like this.
  7. Vaivez66
    Offline

    Vaivez66 Notable Member Plugin Developer

    Joined:
    Jun 10, 2015
    Posts:
    402
    Plugins:
    2
    I think class name is case-insensitive...
  8. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Class names are case insensitive, but if your filesystem is case sensitive, your use statement has to be of the correct case. Either way, it is bad practice to have class names starting with lowercase, declaration or references.
    AndrewBit likes this.
  9. MichaelM04
    Offline

    MichaelM04 Active Member Plugin Developer

    Joined:
    Nov 12, 2015
    Posts:
    213
    Plugins:
    1
    Minecraft User:
    Michael
    it was just a example I figured they could figure out the rest they seem to be a little experienced with code

Share This Page

Advertisement