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

Dis-functional Commands

Discussion in 'Plugin Help' started by neb16, Apr 28, 2019.

  1. neb16

    neb16 Witch

    Messages:
    71
    GitHub:
    developerneb101
    Hey, so I am working on adding commands to my plugin and this is what I have so far:

    PHP:
    public function onCommand(CommandSender $senderCommand $commandstring $label, array $args): bool{
     

      if (
    strtolower($command->getName()) == "test") {
        if (
    $sender->hasPermission("test.test")) {
            if (
    $sender instanceof Player) {
              
    $sender->sendMessage("test works!");
            } else {
                
    $sender->sendMessage(TextFormat::RED "IN-GAME ONLY!");
            }
        } else {
            
    $sender->sendMessage(TextFormat::RED "No permissions");
            return 
    false;
        }
    }

     }
    I could have sworn I did this right, but for some reason when I use /test, nothing shows up and it gives me the use /help message.

    Did I do something wrong? Any help will be greatly appreciated!
     
  2. Mr174

    Mr174 Baby Zombie

    Messages:
    187
    GitHub:
    mr174
    Ok i don't do my commands this way BUT...
    I believe when you do it this way you have to register it in the plugin.yml
    EXAMPLE:
    commands:
    test:
    description: test
    Also you're missing a return statement.
     
    HimbeersaftLP likes this.
  3. neb16

    neb16 Witch

    Messages:
    71
    GitHub:
    developerneb101

    Hmm that's funny. I did that and it didnt work. What do you use?
     
  4. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
  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.