Use CommandExecutor by default on plugins :P

This commit is contained in:
Shoghi Cervantes 2014-04-05 21:44:29 +02:00
parent 711519d4ff
commit 4098252ec7
3 changed files with 15 additions and 8 deletions

View File

@ -39,11 +39,7 @@ class PluginCommand extends Command implements PluginIdentifiableCommand{
public function __construct($name, Plugin $owner){ public function __construct($name, Plugin $owner){
parent::__construct($name); parent::__construct($name);
$this->owningPlugin = $owner; $this->owningPlugin = $owner;
if(!($owner instanceof CommandExecutor)){
trigger_error("Plugin does not implement CommandExecutor", E_USER_WARNING);
}else{
$this->executor = $owner; $this->executor = $owner;
}
$this->usageMessage = ""; $this->usageMessage = "";
} }

View File

@ -23,13 +23,14 @@
* Plugin related classes * Plugin related classes
*/ */
namespace pocketmine\plugin; namespace pocketmine\plugin;
use pocketmine\command\CommandExecutor;
/** /**
* It is recommended to use PluginBase for the actual plugin * It is recommended to use PluginBase for the actual plugin
* *
*/ */
interface Plugin{ interface Plugin extends CommandExecutor{
/** /**
* Called when the plugin is loaded, before calling onEnable() * Called when the plugin is loaded, before calling onEnable()

View File

@ -22,9 +22,7 @@
namespace pocketmine\plugin; namespace pocketmine\plugin;
use pocketmine\command\Command; use pocketmine\command\Command;
use pocketmine\command\CommandExecutor;
use pocketmine\command\CommandSender; use pocketmine\command\CommandSender;
use pocketmine\command\PluginCommand;
use pocketmine\command\PluginIdentifiableCommand; use pocketmine\command\PluginIdentifiableCommand;
use pocketmine\Server; use pocketmine\Server;
use pocketmine\utils\Config; use pocketmine\utils\Config;
@ -152,6 +150,18 @@ abstract class PluginBase implements Plugin{
} }
} }
/**
* @param CommandSender $sender
* @param Command $command
* @param string $label
* @param array $args
*
* @return bool
*/
public function onCommand(CommandSender $sender, Command $command, $label, array $args){
return false;
}
/** /**
* @return bool * @return bool
*/ */