Do not load playerdata from disk just to op/deop/whitelist/dewhitelist

this is an impressively dumb idea.
the playerdata is not used here in any capacity so it doesn't make sense to load it, especially considering that it takes a significant amount of time.
This commit is contained in:
Dylan K. Taylor
2020-11-27 18:06:59 +00:00
parent 5142281cfa
commit 5e44d5f75e
3 changed files with 8 additions and 10 deletions

View File

@@ -57,12 +57,11 @@ class OpCommand extends VanillaCommand{
throw new InvalidCommandSyntaxException();
}
$player = $sender->getServer()->getOfflinePlayer($name);
Command::broadcastCommandMessage($sender, new TranslationContainer("commands.op.success", [$player->getName()]));
if($player instanceof Player){
$sender->getServer()->addOp($name);
if(($player = $sender->getServer()->getPlayerExact($name)) !== null){
$player->sendMessage(TextFormat::GRAY . "You are now op!");
}
$player->setOp(true);
Command::broadcastCommandMessage($sender, new TranslationContainer("commands.op.success", [$name]));
return true;
}
}