mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-08 02:42:58 +00:00
Promote some constructors
This commit is contained in:
@ -45,15 +45,14 @@ class FormattedCommandAlias extends Command{
|
||||
*/
|
||||
private const FORMAT_STRING_REGEX = '/\G\$(\$)?((?!0)+\d+)(-)?/';
|
||||
|
||||
/** @var string[] */
|
||||
private array $formatStrings = [];
|
||||
|
||||
/**
|
||||
* @param string[] $formatStrings
|
||||
*/
|
||||
public function __construct(string $alias, array $formatStrings){
|
||||
public function __construct(
|
||||
string $alias,
|
||||
private array $formatStrings
|
||||
){
|
||||
parent::__construct($alias);
|
||||
$this->formatStrings = $formatStrings;
|
||||
}
|
||||
|
||||
public function execute(CommandSender $sender, string $commandLabel, array $args){
|
||||
|
@ -26,23 +26,20 @@ namespace pocketmine\command;
|
||||
use pocketmine\command\utils\InvalidCommandSyntaxException;
|
||||
use pocketmine\plugin\Plugin;
|
||||
use pocketmine\plugin\PluginOwned;
|
||||
use pocketmine\plugin\PluginOwnedTrait;
|
||||
|
||||
final class PluginCommand extends Command implements PluginOwned{
|
||||
use PluginOwnedTrait;
|
||||
|
||||
private CommandExecutor $executor;
|
||||
|
||||
public function __construct(string $name, Plugin $owner, CommandExecutor $executor){
|
||||
public function __construct(
|
||||
string $name,
|
||||
private Plugin $owner,
|
||||
private CommandExecutor $executor
|
||||
){
|
||||
parent::__construct($name);
|
||||
$this->owningPlugin = $owner;
|
||||
$this->executor = $executor;
|
||||
$this->usageMessage = "";
|
||||
}
|
||||
|
||||
public function execute(CommandSender $sender, string $commandLabel, array $args){
|
||||
|
||||
if(!$this->owningPlugin->isEnabled()){
|
||||
if(!$this->owner->isEnabled()){
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -59,6 +56,10 @@ final class PluginCommand extends Command implements PluginOwned{
|
||||
return $success;
|
||||
}
|
||||
|
||||
public function getOwningPlugin() : Plugin{
|
||||
return $this->owner;
|
||||
}
|
||||
|
||||
public function getExecutor() : CommandExecutor{
|
||||
return $this->executor;
|
||||
}
|
||||
|
Reference in New Issue
Block a user