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

How to make a command execute many commands?

Discussion in 'Development' started by DanielYTK, Jan 27, 2017.

  1. DanielYTK

    DanielYTK Zombie

    Messages:
    227
    How to make a command execute many commands?
     
  2. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    Define execute many commands? Are you talking about subcommands, or executing other commands in your command?

    For the first option, check if $args[0] is a certain string, and continue if it is.
    PHP:
    if(strtolower($args[0]) === "example") {
       
    $sender->sendMessage("Working subcommand!");
    }
    For the second option, you can use
    PHP:
    $this->getServer()->dispatchCommand(new ConsoleCommandSender(), "Command to execute");
    Note that using dispatchCommand is considerably slower than implementing the code yourself, so try avoiding using that a lot.
     
    corytortoise likes this.
  3. DanielYTK

    DanielYTK Zombie

    Messages:
    227
  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.