Resolve Crash on //unban without login

This commit is contained in:
Alexander Nell 2020-05-11 17:19:35 +02:00
parent 7354ed278c
commit 9a259d7913

View File

@ -628,7 +628,7 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
//Todo Validate (Problem: Not connected player isFakePlayer) //Todo Validate (Problem: Not connected player isFakePlayer)
if ($target->isOfficial && $target->isFakePlayer()) { if ($target->isOfficial && $target->isFakePlayer()) {
$this->maniaControl->getChat()->sendError('It is not possible to Ban a bot', $admin); $this->maniaControl->getChat()->sendError('It is not possible to Ban a bot!', $admin);
return; return;
} }
@ -661,6 +661,17 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
return; return;
} }
$target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin);
if (!$target) {
return;
}
//Todo Validate (Problem: Not connected player isFakePlayer)
if ($target->isOfficial && $target->isFakePlayer()) {
$this->maniaControl->getChat()->sendError('It is not possible to unban a bot!', $admin);
return;
}
try { try {
$this->maniaControl->getClient()->unBan($targetLogin); $this->maniaControl->getClient()->unBan($targetLogin);
} catch (NotInListException $e) { } catch (NotInListException $e) {