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

Execute command as console.

Comments in 'Plugin Development' started by Legoboy0215, Jul 9, 2015.

  1. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,747
    Minecraft User:
    Legoboy0215
    How would I execute an command as console?
  2. PixelGuy75
    Offline

    PixelGuy75 Notable Member Plugin Developer

    Joined:
    Feb 9, 2014
    Posts:
    316
    Plugins:
    2
    Minecraft User:
    PixelGuy75
    Look at the code for JoinCommands.
  3. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,747
    Minecraft User:
    Legoboy0215
    I did, but
    PHP:
    $command "lagg clearall";
    $this->getServer()->dispatchCommand(new ConsoleCommandSender(), $command))
    Would this work?
  4. Radix
    Offline

    Radix Active Member

    Joined:
    Jul 2, 2015
    Posts:
    211
    Minecraft User:
    Dicks123
    I believe thats the right syntax!
  5. Radix
    Offline

    Radix Active Member

    Joined:
    Jul 2, 2015
    Posts:
    211
    Minecraft User:
    Dicks123
    Was Wondering if you could do

    PHP:
    //$command = "lagg clearall"; instead do

    $command = array("lag clearall","say Welcome to the server");
    $this->getServer()->dispatchCommand(new ConsoleCommandSender(), $command[0]))
    Legoboy0215 likes this.
  6. PixelGuy75
    Offline

    PixelGuy75 Notable Member Plugin Developer

    Joined:
    Feb 9, 2014
    Posts:
    316
    Plugins:
    2
    Minecraft User:
    PixelGuy75
    That would work also!
    Radix and Legoboy0215 like this.
  7. Radix
    Offline

    Radix Active Member

    Joined:
    Jul 2, 2015
    Posts:
    211
    Minecraft User:
    Dicks123
    I was just implying that he would run more than one command.
  8. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    If you know what the command is, avoid directly dispatching command. Use some API functions and implement that yourself.

Share This Page

Advertisement