Fix Chat::formatMessage issues after tests

This commit is contained in:
Alexander Nell 2020-06-22 04:53:31 +02:00
parent 9abadac932
commit 566f77801f
4 changed files with 36 additions and 34 deletions

View File

@ -119,7 +119,7 @@ class MapQueue implements CallbackListener, CommandListener, UsageInformationAbl
return; 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)) { if ($admin && empty($this->queuedMaps)) {
$this->maniaControl->getChat()->sendError($messagePrefix . 'There are no maps in the jukebox!', $admin); $this->maniaControl->getChat()->sendError($messagePrefix . 'There are no maps in the jukebox!', $admin);
return; return;
@ -131,8 +131,7 @@ class MapQueue implements CallbackListener, CommandListener, UsageInformationAbl
if ($admin) { if ($admin) {
$title = $admin->getAuthLevelName(); $title = $admin->getAuthLevelName();
$message = $this->maniaControl->getChat()->formatMessage( $message = $this->maniaControl->getChat()->formatMessage(
$messagePrefix . '%s %s cleared the Map-Queue!', "{$messagePrefix}{$title} %s cleared the Map-Queue!",
$title,
$admin $admin
); );
$this->maniaControl->getChat()->sendInformation($message); $this->maniaControl->getChat()->sendInformation($message);

View File

@ -211,9 +211,9 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
if ($teamName) { if ($teamName) {
if ($calledByAdmin) { if ($calledByAdmin) {
$title = $admin->getAuthLevelName();
$message = $this->maniaControl->getChat()->formatMessage( $message = $this->maniaControl->getChat()->formatMessage(
'%s %s forced %s into the %s-Team!', "{$title} %s forced %s into the %s-Team!",
$admin->getAuthLevelName(),
$admin, $admin,
$target, $target,
$teamName $teamName
@ -284,9 +284,9 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
// Announce force // Announce force
if ($displayAnnouncement) { if ($displayAnnouncement) {
if ($calledByAdmin) { if ($calledByAdmin) {
$title = $admin->getAuthLevelName();
$message = $this->maniaControl->getChat()->formatMessage( $message = $this->maniaControl->getChat()->formatMessage(
'%s %s forced %s to Play!', "{$title} %s forced %s to Play!",
$admin->getAuthLevelName(),
$admin, $admin,
$target $target
); );
@ -341,9 +341,9 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
} }
if ($calledByAdmin) { if ($calledByAdmin) {
$title = $admin->getAuthLevelName();
$message = $this->maniaControl->getChat()->formatMessage( $message = $this->maniaControl->getChat()->formatMessage(
'%s %s forced %s to Spectator!', "{$title} %s forced %s to Spectator!",
$admin->getAuthLevelName(),
$admin, $admin,
$target $target
); );
@ -397,16 +397,16 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
} catch (NotInListException $e) { } catch (NotInListException $e) {
$message = $this->maniaControl->getChat()->formatMessage( $message = $this->maniaControl->getChat()->formatMessage(
'%s is not muted!', '%s is not muted!',
$player $targetLogin
); );
$this->maniaControl->getChat()->sendError($message, $adminLogin); $this->maniaControl->getChat()->sendError($message, $adminLogin);
return false; return false;
} }
if ($calledByAdmin) { if ($calledByAdmin) {
$title = $admin->getAuthLevelName();
$message = $this->maniaControl->getChat()->formatMessage( $message = $this->maniaControl->getChat()->formatMessage(
'%s %s un-muted %s!', "{$title} %s un-muted %s!",
$admin->getAuthLevelName(),
$admin, $admin,
$target $target
); );
@ -451,16 +451,19 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
} catch (AlreadyInListException $e) { } catch (AlreadyInListException $e) {
$message = $this->maniaControl->getChat()->formatMessage( $message = $this->maniaControl->getChat()->formatMessage(
'%s is already muted!', '%s is already muted!',
$player $targetLogin
); );
$this->maniaControl->getChat()->sendError($message, $adminLogin); $this->maniaControl->getChat()->sendError($message, $adminLogin);
return false; return false;
} catch (UnknownPlayerException $e) {
$this->maniaControl->getChat()->sendException($e, $adminLogin);
return false;
} }
if ($calledByAdmin) { if ($calledByAdmin) {
$title = $admin->getAuthLevelName();
$message = $this->maniaControl->getChat()->formatMessage( $message = $this->maniaControl->getChat()->formatMessage(
'%s %s muted %s!', "{$title} %s muted %s!",
$admin->getAuthLevelName(),
$admin, $admin,
$target $target
); );
@ -559,9 +562,9 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
$this->maniaControl->getManialinkManager()->displayWidget($maniaLink, $target); $this->maniaControl->getManialinkManager()->displayWidget($maniaLink, $target);
if ($calledByAdmin) { if ($calledByAdmin) {
$title = $admin->getAuthLevelName();
$message = $this->maniaControl->getChat()->formatMessage( $message = $this->maniaControl->getChat()->formatMessage(
'%s %s warned %s!', "{$title} %s warned %s!",
$admin->getAuthLevelName(),
$admin, $admin,
$target $target
); );
@ -623,9 +626,9 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
} }
if ($calledByAdmin) { if ($calledByAdmin) {
$title = $admin->getAuthLevelName();
$message = $this->maniaControl->getChat()->formatMessage( $message = $this->maniaControl->getChat()->formatMessage(
'%s %s kicked %s!', "{$title} %s kicked %s!",
$admin->getAuthLevelName(),
$admin, $admin,
$target $target
); );
@ -676,9 +679,9 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
return; return;
} }
$title = $admin->getAuthLevelName();
$message = $this->maniaControl->getChat()->formatMessage( $message = $this->maniaControl->getChat()->formatMessage(
'%s %s banned %s!', "{$title} %s banned %s!",
$admin->getAuthLevelName(),
$admin, $admin,
$target $target
); );
@ -718,9 +721,9 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
return; return;
} }
$title = $admin->getAuthLevelName();
$message = $this->maniaControl->getChat()->formatMessage( $message = $this->maniaControl->getChat()->formatMessage(
'%s %s unbanned %s!', "{$title} %s unbanned %s!",
$admin->getAuthLevelName(),
$admin, $admin,
$target $target
); );
@ -745,7 +748,6 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
* Grants the Player an Authorization Level * Grants the Player an Authorization Level
* *
* @api * @api
* @deprecated
* @param string $adminLogin * @param string $adminLogin
* @param string $targetLogin * @param string $targetLogin
* @param int $authLevel * @param int $authLevel
@ -774,9 +776,9 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
return; return;
} }
$title = $admin->getAuthLevelName();
$message = $this->maniaControl->getChat()->formatMessage( $message = $this->maniaControl->getChat()->formatMessage(
"%s %s added %s as {$authLevelName}!", "{$title} %s added %s as {$authLevelName}!",
$admin->getAuthLevelName(),
$admin, $admin,
$target $target
); );
@ -814,9 +816,9 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
return; return;
} }
$title = $admin->getAuthLevelName();
$message = $this->maniaControl->getChat()->formatMessage( $message = $this->maniaControl->getChat()->formatMessage(
"%s %s revoked the Rights of %s!", "{$title} %s revoked the Rights of %s!",
$admin->getAuthLevelName(),
$admin, $admin,
$target $target
); );

View File

@ -503,20 +503,21 @@ class PlayerManager implements CallbackListener, TimerListener, CommunicationLis
$color = $this->maniaControl->getColorManager()->getColorByPlayer($player); $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()) { if (!$player->isSpectator && $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_JOIN_LEAVE_MESSAGES) && !$player->isFakePlayer()) {
$message = $this->maniaControl->getChat()->formatMessage( $message = $this->maniaControl->getChat()->formatMessage(
"{$color}{$authName} %s Nation: %s joined!", "{$color}{$authName} %s Nation: %s joined!",
$player, $player,
$player->getCountry() $nation
); );
$this->maniaControl->getChat()->sendChat($message); $this->maniaControl->getChat()->sendChat($message);
} else if ($player->isSpectator && $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_JOIN_LEAVE_MESSAGES_SPECTATOR)) { } else if ($player->isSpectator && $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_JOIN_LEAVE_MESSAGES_SPECTATOR)) {
$message = $this->maniaControl->getChat()->formatMessage( $message = $this->maniaControl->getChat()->formatMessage(
"{$color}{$authName} %s Nation: %s joined as Spectator!", "{$color}{$authName} %s Nation: %s joined as Spectator!",
$player, $player,
$player->getCountry() $nation
); );
$this->maniaControl->getChat()->sendChat($message); $this->maniaControl->getChat()->sendChat($message);
} }

View File

@ -592,8 +592,8 @@ class LocalRecordsPlugin implements CallbackListener, CallQueueListener, Command
$timeDiff = $oldRecord->time - $newRecord->time; $timeDiff = $oldRecord->time - $newRecord->time;
$message .= $this->maniaControl->getChat()->formatMessage( $message .= $this->maniaControl->getChat()->formatMessage(
' (%s%s)', ' (%s%s)',
($improvedRank ? '$ff0'.$oldRecord->rank.'. ' : ''), ($improvedRank ? '$ff0' . $oldRecord->rank . '. ' : ''),
'-'.Formatter::formatTime($timeDiff) '-' . Formatter::formatTime($timeDiff)
); );
} }