Added Help command

This commit is contained in:
Shoghi Cervantes
2014-03-26 20:11:53 +01:00
parent 76438e78d2
commit 9fe68003eb
11 changed files with 150 additions and 78 deletions

View File

@ -26,6 +26,7 @@
namespace PocketMine;
use PocketMine\Block\Block;
use PocketMine\Command\CommandSender;
use PocketMine\Command\ConsoleCommandSender;
use PocketMine\Command\SimpleCommandMap;
use PocketMine\Entity\Entity;
@ -281,6 +282,13 @@ class Server{
return $this->interface;
}
/**
* @return SimpleCommandMap
*/
public function getCommandMap(){
return $this->commandMap;
}
/**
* @param string $variable
* @param string $defaultValue
@ -497,10 +505,32 @@ class Server{
public function checkConsole(){
if(($line = $this->console->getLine()) !== null){
$this->commandMap->dispatch($this->consoleSender, $line);
$this->dispatchCommand($this->consoleSender, $line);
}
}
/**
* Executes a command from a CommandSender
*
* @param CommandSender $sender
* @param string $commandLine
*
* @return bool
*/
public function dispatchCommand(CommandSender $sender, $commandLine){
if($this->commandMap->dispatch($sender, $commandLine)){
return true;
}
if($sender instanceof Player){
$sender->sendMessage("Unknown command. Type \"/help\" for help.");
}else{
$sender->sendMessage("Unknown command. Type \"help\" for help.");
}
return false;
}
/**
* Starts the PocketMine-MP server and starts processing ticks and packets
*/