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

Send console command

Discussion in 'Development' started by RZ302, Jun 12, 2022.

  1. RZ302

    RZ302 Creeper

    Messages:
    4
    Hello there,
    I am just trying to get a command that forwards the entered command to console like this:
    Code:
    /example <command>
    I got that working some time ago for API 3.0.0,
    but now the class pocketmine\command\ConsoleCommandSender seems to be gone.

    Therefore my code:
    PHP:
    $this->getServer()->dispatchCommand(new ConsoleCommandSender(), trim(implode(" "$args)));
    results in the following error.
    Code:
    Error: "Class "pocketmine\command\ConsoleCommandSender" not found" (EXCEPTION) in "plugins/(plugin)/src/(author)/(plugin)/Main" at line (line)
     
  2. RZ302

    RZ302 Creeper

    Messages:
    4
    In case someone reading this didn't get what I'm asking for:
    How could I change my code to now implement such a command using up-to-date versions of Pocketmine?
     
  3. BloodyJohnRus

    BloodyJohnRus Silverfish

    Messages:
    19
    GitHub:
    GDSHNIK
    You wrongly imported ConsoleCommandSender

    This is right:
    PHP:
    use pocketmine\console\ConsoleCommandSender;
     
  4. RZ302

    RZ302 Creeper

    Messages:
    4
    No... No I did not. That exact same line is where it belongs.
    But as you can see here: https://github.com/pmmp/PocketMine-MP/tree/stable/src/command
    There is no class ConsoleCommandSender there anymore.
     
  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.