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

Send command to console

Comments in 'Plugin Development' started by mamayadesu, Feb 28, 2015.

Thread Status:
Not open for further replies.
  1. mamayadesu
    Offline

    mamayadesu Active Member Plugin Developer

    Joined:
    Sep 19, 2013
    Posts:
    146
    Plugins:
    4
    Minecraft User:
    mamayadesu
    How I can send command to console?

    In old API:
    PHP:
    $this->api->console->run("command");
    but in new api it doesn't works.
  2. mclab
    Offline

    mclab Active Member

    Joined:
    Dec 24, 2014
    Posts:
    49
    Minecraft User:
    Dragonflex
    use pocketmine\command\ConsoleCommandSender;
    $cmd = "say Hello";
    $this->getServer()->dispatchCommand(new ConsoleCommandSender(),$cmd);
    LDX likes this.
  3. mamayadesu
    Offline

    mamayadesu Active Member Plugin Developer

    Joined:
    Sep 19, 2013
    Posts:
    146
    Plugins:
    4
    Minecraft User:
    mamayadesu
    thank you
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Try not to dispatch commands directly; it's slow. Try calling that command directly, or even execute its code.
  5. EvolSoft
    Offline

    EvolSoft Notable Member Plugin Developer

    Joined:
    Sep 10, 2014
    Posts:
    821
    Plugins:
    15
    Minecraft User:
    Flavius12
    Yes, the new API is totally different from the old
Thread Status:
Not open for further replies.

Share This Page

Advertisement