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

Creating commands with on command()

Comments in 'Plugin Development' started by Hotshot_9930, May 10, 2015.

  1. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    OK so I'm creating a plugin, but it has multiple commands. They work but when one of them is used the other one is used also. For example if I had two commands called "hello" and "hey". If I run /hey, /hello would be run also. How do I make one run without the other one being run?
    I have both of them under the same public function onCommand()
    Do they need to be under seperatre public functions?
    Any help would be greatly appreciated :)
    Legoboy0215 likes this.
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    You should check the name of the second parameter (Command) of onCommand.
    PHP:
    public function onCommand(CommandSender $issuerCommand $com$lbl, array $params){
      if(
    $com->getName() === "name1") {
        
    $issuer->sendMessage("You ran /name1");
        return 
    true;
      }
      if(
    $com->getName() === "name2") {
        
    $issuer->sendMessage("You ran /name2");
        return 
    true;
      }
      return 
    false;
    }
    RekkuzaRage likes this.
  3. EvolSoft
    Offline

    EvolSoft Notable Member Plugin Developer

    Joined:
    Sep 10, 2014
    Posts:
    821
    Plugins:
    15
    Minecraft User:
    Flavius12
    It seems that the YAML parser doesn't find the file.
    What is the value of $this->data variable?
  4. iJoshuaHD
    Offline

    iJoshuaHD Notable Member Plugin Developer

    Joined:
    Nov 7, 2013
    Posts:
    1,201
    Plugins:
    4
    Minecraft User:
    iJoshuaHD
    var_dump($this->data); pls share result.

Share This Page

Advertisement