Command: standardise permission checking

if subcommands had different permissions, the permissionMessage would not be used.
This commit is contained in:
Dylan K. Taylor
2021-08-04 20:29:07 +01:00
parent efb677d5d5
commit 71c6f69fd3
5 changed files with 18 additions and 41 deletions

View File

@ -57,9 +57,7 @@ class KillCommand extends VanillaCommand{
}
if(count($args) === 1){
if(!$sender->hasPermission(DefaultPermissionNames::COMMAND_KILL_OTHER)){
$sender->sendMessage($sender->getLanguage()->translateString(TextFormat::RED . "%" . KnownTranslationKeys::COMMANDS_GENERIC_PERMISSION));
if(!$this->testPermission($sender, DefaultPermissionNames::COMMAND_KILL_OTHER)){
return true;
}
@ -76,9 +74,7 @@ class KillCommand extends VanillaCommand{
}
if($sender instanceof Player){
if(!$sender->hasPermission(DefaultPermissionNames::COMMAND_KILL_SELF)){
$sender->sendMessage($sender->getLanguage()->translateString(TextFormat::RED . "%" . KnownTranslationKeys::COMMANDS_GENERIC_PERMISSION));
if(!$this->testPermission($sender, DefaultPermissionNames::COMMAND_KILL_SELF)){
return true;
}