mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-30 23:29:54 +00:00
Added PluginBase::getCommand()
This commit is contained in:
parent
605231251a
commit
2385b94ba3
@ -28,6 +28,7 @@ namespace PocketMine;
|
|||||||
use PocketMine\Block\Block;
|
use PocketMine\Block\Block;
|
||||||
use PocketMine\Command\CommandSender;
|
use PocketMine\Command\CommandSender;
|
||||||
use PocketMine\Command\ConsoleCommandSender;
|
use PocketMine\Command\ConsoleCommandSender;
|
||||||
|
use PocketMine\Command\PluginCommand;
|
||||||
use PocketMine\Command\SimpleCommandMap;
|
use PocketMine\Command\SimpleCommandMap;
|
||||||
use PocketMine\Entity\Entity;
|
use PocketMine\Entity\Entity;
|
||||||
use PocketMine\Event\Event;
|
use PocketMine\Event\Event;
|
||||||
@ -373,6 +374,19 @@ class Server{
|
|||||||
$this->properties->set($variable, $value == true ? "1" : "0");
|
$this->properties->set($variable, $value == true ? "1" : "0");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $name
|
||||||
|
*
|
||||||
|
* @return PluginCommand
|
||||||
|
*/
|
||||||
|
public function getPluginCommand($name){
|
||||||
|
if(($command = $this->commandMap->getCommand($name)) instanceof PluginCommand){
|
||||||
|
return $command;
|
||||||
|
}else{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Server
|
* @return Server
|
||||||
*/
|
*/
|
||||||
|
@ -24,6 +24,7 @@ namespace PocketMine\Plugin;
|
|||||||
use PocketMine\Command\Command;
|
use PocketMine\Command\Command;
|
||||||
use PocketMine\Command\CommandExecutor;
|
use PocketMine\Command\CommandExecutor;
|
||||||
use PocketMine\Command\CommandSender;
|
use PocketMine\Command\CommandSender;
|
||||||
|
use PocketMine\Command\PluginCommand;
|
||||||
use PocketMine\Server;
|
use PocketMine\Server;
|
||||||
use PocketMine\Utils\Config;
|
use PocketMine\Utils\Config;
|
||||||
|
|
||||||
@ -125,15 +126,23 @@ abstract class PluginBase implements Plugin, CommandExecutor{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO
|
|
||||||
public function getCommand($name){
|
public function getCommand($name){
|
||||||
$this->get
|
$command = $this->getServer()->getPluginCommand($name);
|
||||||
}*/
|
if($command === null or $command->getPlugin() !== $this){
|
||||||
|
$command = $this->getServer()->getPluginCommand(strtolower($this->description->getName()) . ":" . $name);
|
||||||
|
}
|
||||||
|
|
||||||
|
if($command instanceof PluginCommand and $command->getPlugin() === $this){
|
||||||
|
return $command;
|
||||||
|
}else{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function isPhar(){
|
protected function isPhar(){
|
||||||
return $this->description instanceof \PharFileInfo;
|
return $this->description instanceof \PharFileInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user