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

Sends message three times instead of one

Comments in 'Plugin Development' started by Primus, Apr 15, 2015.

  1. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    13:39:57 [INFO] [SVIP] You can't do that.
    13:39:57 [INFO] [SVIP] You can't do that.
    13:39:57 [INFO] [SVIP] You can't do that.
    13:39:57 [INFO] Usage: /vipheal

    And this happening even i send it as VIP and from MCPE!

    here's the code:
    PHP:
    public function onCommand(CommandSender $senderCommand $command$label, array $args){
        switch(
    $command->getName()){
            case 
    "vipheal":
                
    $name $sender->getName();
        if(
    in_array($name$this->getConfig()->get("vips"), true) && $sender instanceof Player){
            
    $sender->setHealth($sender->getMaxHealth());
        }
        else{
            
    $sender->sendMessage(TextFormat::RED."[SVIP] You can't do that.");
        }

  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    either because you aren't VIP or you didn't check case-insensitively.
  3. EvolSoft
    Offline

    EvolSoft Notable Member Plugin Developer

    Joined:
    Sep 10, 2014
    Posts:
    821
    Plugins:
    15
    Minecraft User:
    Flavius12
    I think it's because you forgot return true and break in your onCommand function
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    1. After returning, break is dead code that won't be run.
    2. You don't need to break or return. Returning a boolean is something a plugin should do, but not doing it won't break the plugin, just send the usage message.

Share This Page

Advertisement