From 566f77801f1b8cf3f76d2628037678401f138684 Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Mon, 22 Jun 2020 04:53:31 +0200 Subject: [PATCH] Fix Chat::formatMessage issues after tests --- core/Maps/MapQueue.php | 5 +-- core/Players/PlayerActions.php | 54 ++++++++++++++------------- core/Players/PlayerManager.php | 7 ++-- plugins/MCTeam/LocalRecordsPlugin.php | 4 +- 4 files changed, 36 insertions(+), 34 deletions(-) diff --git a/core/Maps/MapQueue.php b/core/Maps/MapQueue.php index c8984ed1..18b9e4d0 100644 --- a/core/Maps/MapQueue.php +++ b/core/Maps/MapQueue.php @@ -119,7 +119,7 @@ class MapQueue implements CallbackListener, CommandListener, UsageInformationAbl return; } - $messagePrefix = $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MESSAGE_FORMAT); + $messagePrefix = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MESSAGE_FORMAT); if ($admin && empty($this->queuedMaps)) { $this->maniaControl->getChat()->sendError($messagePrefix . 'There are no maps in the jukebox!', $admin); return; @@ -131,8 +131,7 @@ class MapQueue implements CallbackListener, CommandListener, UsageInformationAbl if ($admin) { $title = $admin->getAuthLevelName(); $message = $this->maniaControl->getChat()->formatMessage( - $messagePrefix . '%s %s cleared the Map-Queue!', - $title, + "{$messagePrefix}{$title} %s cleared the Map-Queue!", $admin ); $this->maniaControl->getChat()->sendInformation($message); diff --git a/core/Players/PlayerActions.php b/core/Players/PlayerActions.php index f437b914..c11cc2a5 100644 --- a/core/Players/PlayerActions.php +++ b/core/Players/PlayerActions.php @@ -211,9 +211,9 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma if ($teamName) { if ($calledByAdmin) { + $title = $admin->getAuthLevelName(); $message = $this->maniaControl->getChat()->formatMessage( - '%s %s forced %s into the %s-Team!', - $admin->getAuthLevelName(), + "{$title} %s forced %s into the %s-Team!", $admin, $target, $teamName @@ -284,9 +284,9 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma // Announce force if ($displayAnnouncement) { if ($calledByAdmin) { + $title = $admin->getAuthLevelName(); $message = $this->maniaControl->getChat()->formatMessage( - '%s %s forced %s to Play!', - $admin->getAuthLevelName(), + "{$title} %s forced %s to Play!", $admin, $target ); @@ -341,9 +341,9 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma } if ($calledByAdmin) { + $title = $admin->getAuthLevelName(); $message = $this->maniaControl->getChat()->formatMessage( - '%s %s forced %s to Spectator!', - $admin->getAuthLevelName(), + "{$title} %s forced %s to Spectator!", $admin, $target ); @@ -397,16 +397,16 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma } catch (NotInListException $e) { $message = $this->maniaControl->getChat()->formatMessage( '%s is not muted!', - $player + $targetLogin ); $this->maniaControl->getChat()->sendError($message, $adminLogin); return false; } if ($calledByAdmin) { + $title = $admin->getAuthLevelName(); $message = $this->maniaControl->getChat()->formatMessage( - '%s %s un-muted %s!', - $admin->getAuthLevelName(), + "{$title} %s un-muted %s!", $admin, $target ); @@ -451,16 +451,19 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma } catch (AlreadyInListException $e) { $message = $this->maniaControl->getChat()->formatMessage( '%s is already muted!', - $player + $targetLogin ); $this->maniaControl->getChat()->sendError($message, $adminLogin); return false; + } catch (UnknownPlayerException $e) { + $this->maniaControl->getChat()->sendException($e, $adminLogin); + return false; } if ($calledByAdmin) { + $title = $admin->getAuthLevelName(); $message = $this->maniaControl->getChat()->formatMessage( - '%s %s muted %s!', - $admin->getAuthLevelName(), + "{$title} %s muted %s!", $admin, $target ); @@ -559,9 +562,9 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma $this->maniaControl->getManialinkManager()->displayWidget($maniaLink, $target); if ($calledByAdmin) { + $title = $admin->getAuthLevelName(); $message = $this->maniaControl->getChat()->formatMessage( - '%s %s warned %s!', - $admin->getAuthLevelName(), + "{$title} %s warned %s!", $admin, $target ); @@ -623,9 +626,9 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma } if ($calledByAdmin) { + $title = $admin->getAuthLevelName(); $message = $this->maniaControl->getChat()->formatMessage( - '%s %s kicked %s!', - $admin->getAuthLevelName(), + "{$title} %s kicked %s!", $admin, $target ); @@ -676,9 +679,9 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma return; } + $title = $admin->getAuthLevelName(); $message = $this->maniaControl->getChat()->formatMessage( - '%s %s banned %s!', - $admin->getAuthLevelName(), + "{$title} %s banned %s!", $admin, $target ); @@ -717,10 +720,10 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma $this->maniaControl->getChat()->sendError('This player is not Banned!', $admin); return; } - + + $title = $admin->getAuthLevelName(); $message = $this->maniaControl->getChat()->formatMessage( - '%s %s unbanned %s!', - $admin->getAuthLevelName(), + "{$title} %s unbanned %s!", $admin, $target ); @@ -745,7 +748,6 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma * Grants the Player an Authorization Level * * @api - * @deprecated * @param string $adminLogin * @param string $targetLogin * @param int $authLevel @@ -774,9 +776,9 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma return; } + $title = $admin->getAuthLevelName(); $message = $this->maniaControl->getChat()->formatMessage( - "%s %s added %s as {$authLevelName}!", - $admin->getAuthLevelName(), + "{$title} %s added %s as {$authLevelName}!", $admin, $target ); @@ -814,9 +816,9 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma return; } + $title = $admin->getAuthLevelName(); $message = $this->maniaControl->getChat()->formatMessage( - "%s %s revoked the Rights of %s!", - $admin->getAuthLevelName(), + "{$title} %s revoked the Rights of %s!", $admin, $target ); diff --git a/core/Players/PlayerManager.php b/core/Players/PlayerManager.php index 72b9bf22..e4f7032c 100644 --- a/core/Players/PlayerManager.php +++ b/core/Players/PlayerManager.php @@ -503,20 +503,21 @@ class PlayerManager implements CallbackListener, TimerListener, CommunicationLis $color = $this->maniaControl->getColorManager()->getColorByPlayer($player); } - $authName = $player->getAuthLeveName(); + $authName = $player->getAuthLevelName(); + $nation = $player->getCountry(); if (!$player->isSpectator && $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_JOIN_LEAVE_MESSAGES) && !$player->isFakePlayer()) { $message = $this->maniaControl->getChat()->formatMessage( "{$color}{$authName} %s Nation: %s joined!", $player, - $player->getCountry() + $nation ); $this->maniaControl->getChat()->sendChat($message); } else if ($player->isSpectator && $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_JOIN_LEAVE_MESSAGES_SPECTATOR)) { $message = $this->maniaControl->getChat()->formatMessage( "{$color}{$authName} %s Nation: %s joined as Spectator!", $player, - $player->getCountry() + $nation ); $this->maniaControl->getChat()->sendChat($message); } diff --git a/plugins/MCTeam/LocalRecordsPlugin.php b/plugins/MCTeam/LocalRecordsPlugin.php index 5d8dafec..27d15f80 100644 --- a/plugins/MCTeam/LocalRecordsPlugin.php +++ b/plugins/MCTeam/LocalRecordsPlugin.php @@ -592,8 +592,8 @@ class LocalRecordsPlugin implements CallbackListener, CallQueueListener, Command $timeDiff = $oldRecord->time - $newRecord->time; $message .= $this->maniaControl->getChat()->formatMessage( ' (%s%s)', - ($improvedRank ? '$ff0'.$oldRecord->rank.'. ' : ''), - '-'.Formatter::formatTime($timeDiff) + ($improvedRank ? '$ff0' . $oldRecord->rank . '. ' : ''), + '-' . Formatter::formatTime($timeDiff) ); }