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

Server::dispatchCommand() as Console?

Comments in 'Plugin Development' started by Samueljh1, Feb 9, 2015.

  1. Samueljh1
    Offline

    Samueljh1 Active Member Plugin Developer

    Joined:
    Jan 9, 2015
    Posts:
    316
    Plugins:
    5
    Minecraft User:
    Samueljh1_
    Hi, I was wondering if there is a way to do:

    PHP:
    Server::dispatchCommand($sender$cmd);
    As the Console?

    This function requires a Player object and I don't believe there is a way to get the console as a player. Is there a way or is there a separate function that allows you to do this?

    Thanks ;)
  2. Falk
    Offline

    Falk Staff Member Global Moderator

    Joined:
    Sep 2, 2013
    Posts:
    1,710
    Plugins:
    22
    Minecraft User:
    Falkirknh
    It doesn't require a Player object, it requires a CommandSender. You can use
    PHP:
    $this->getServer()->dispatchCommand(new ConsoleCommandSender(), $cmd);
    abxyHD and EvolSoft like this.
  3. Samueljh1
    Offline

    Samueljh1 Active Member Plugin Developer

    Joined:
    Jan 9, 2015
    Posts:
    316
    Plugins:
    5
    Minecraft User:
    Samueljh1_
    Thanks! :)
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    $sender doesn't expect a Player. It expects a CommandSender.
    Andrey Nazarchuk and EvolSoft like this.
  5. Samueljh1
    Offline

    Samueljh1 Active Member Plugin Developer

    Joined:
    Jan 9, 2015
    Posts:
    316
    Plugins:
    5
    Minecraft User:
    Samueljh1_
    Lol @Falk said that like 2 minutes ago xD
    EvolSoft and PEMapModder like this.
  6. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Read the docs or the source >_<

Share This Page

Advertisement