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

Why cant use ConsoleCommandSender

Comments in 'Plugin Development' started by Heroata, Apr 10, 2016.

  1. Heroata
    Offline

    Heroata New Member

    Joined:
    Dec 15, 2013
    Posts:
    31
    Minecraft User:
    Heroata
    PHP:
    $command "a command";
    $this->getServer()->dispatchCommand(new ConsoleCommandSender($command));

    What I'm missing?

    Output
    Code:
    Call to undefined method AndrOyuN\test\test\CommandTests::getServer()
    
  2. TryoneLegendZzz
    Offline

    TryoneLegendZzz Active Member

    Joined:
    May 31, 2015
    Posts:
    201
    Minecraft User:
    SavionLegendZzz
    Is this in your Main class?
  3. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Where it says that you can't use ConsoleCommandSender?

    You're probably out of PluginBase context
  4. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    PHP:
    $this->getServer()->dispatchCommand(new ConsoleCommandSender(), $command);
    Also, this is not your PluginBase
  5. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Dude, I said that :D
  6. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Yes, but his code was wrong too, which I corrected ^^
    Vaivez66 likes this.
  7. Heroata
    Offline

    Heroata New Member

    Joined:
    Dec 15, 2013
    Posts:
    31
    Minecraft User:
    Heroata
    understood ^^ But now getting

    Code:
    Warning: Missing argument 2 for pocketmine\Server::dispatchCommand(), called in /home/ataberk/server/server/plugins/PhpProject1/src/AndrOyuN/test/test.php on line 76 and defined in phar:///home/ataberk/server/server/PocketMine-MP.phar/src/pocketmine/Server__64bit.php on line 1876
    
    Notice: Undefined variable: commandLine in phar:///home/ataberk/server/server/PocketMine-MP.phar/src/pocketmine/Server__64bit.php on line 1877
    [20:54:24] [Server thread/INFO]: Unknown command. Try /help for a list of commands
    
    output :/


    Edit: code

    PHP:
                    $command "me sea";
                    
    $this->getServer()->dispatchCommand(new ConsoleCommandSender($command));
              
  8. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Read the errors! It says you're missing second paramater!

Share This Page

Advertisement