Promote some constructors

This commit is contained in:
Dylan K. Taylor
2022-05-17 22:34:58 +01:00
parent 8e767da29e
commit d4b7f66e15
30 changed files with 144 additions and 218 deletions

View File

@ -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){

View File

@ -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;
}