add a setting to hide chat messages
This commit is contained in:
@@ -69,6 +69,10 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
|
|||||||
const SETTING_PERMISSION_KICK_PLAYER = 'Kick Player';
|
const SETTING_PERMISSION_KICK_PLAYER = 'Kick Player';
|
||||||
const SETTING_PERMISSION_BAN_PLAYER = 'Ban Player';
|
const SETTING_PERMISSION_BAN_PLAYER = 'Ban Player';
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Settings Constants
|
||||||
|
*/
|
||||||
|
const SETTING_SEND_MESSAGES_TO_ADMINS_ONLY = 'Send chat messages to admin only';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Private properties
|
* Private properties
|
||||||
@@ -93,6 +97,10 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
|
|||||||
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_FORCE_PLAYER_TEAM, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_FORCE_PLAYER_TEAM, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||||
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_FORCE_PLAYER_SPEC, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_FORCE_PLAYER_SPEC, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||||
|
|
||||||
|
// Settings
|
||||||
|
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_SEND_MESSAGES_TO_ADMINS_ONLY, false);
|
||||||
|
|
||||||
|
|
||||||
// Echo Warn Command (Usage: sendEcho json_encode("player" => "loginName")
|
// Echo Warn Command (Usage: sendEcho json_encode("player" => "loginName")
|
||||||
$this->maniaControl->getEchoManager()->registerEchoListener(self::ECHO_WARN_PLAYER, $this, function ($params) {
|
$this->maniaControl->getEchoManager()->registerEchoListener(self::ECHO_WARN_PLAYER, $this, function ($params) {
|
||||||
$this->warnPlayer(null, $params->player, false);
|
$this->warnPlayer(null, $params->player, false);
|
||||||
@@ -186,6 +194,7 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
|
|||||||
}
|
}
|
||||||
$target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin);
|
$target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin);
|
||||||
if (!$target) {
|
if (!$target) {
|
||||||
|
if ($calledByAdmin) $this->maniaControl->getChat()->sendError('Player not found', $adminLogin);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,7 +250,11 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($message) {
|
if ($message) {
|
||||||
|
if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_SEND_MESSAGES_TO_ADMINS_ONLY)) {
|
||||||
|
$this->maniaControl->getChat()->sendInformationToAdmins($message);
|
||||||
|
} else {
|
||||||
$this->maniaControl->getChat()->sendInformation($message);
|
$this->maniaControl->getChat()->sendInformation($message);
|
||||||
|
}
|
||||||
Logger::logInfo($message, true);
|
Logger::logInfo($message, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -270,6 +283,7 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
|
|||||||
|
|
||||||
$target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin);
|
$target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin);
|
||||||
if (!$target) {
|
if (!$target) {
|
||||||
|
if ($calledByAdmin) $this->maniaControl->getChat()->sendError('Player not found', $adminLogin);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -312,8 +326,12 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_SEND_MESSAGES_TO_ADMINS_ONLY)) {
|
||||||
|
$this->maniaControl->getChat()->sendInformationToAdmins($message);
|
||||||
|
} else {
|
||||||
$this->maniaControl->getChat()->sendInformation($message);
|
$this->maniaControl->getChat()->sendInformation($message);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -344,10 +362,17 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
|
|||||||
|
|
||||||
$target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin);
|
$target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin);
|
||||||
|
|
||||||
if (!$target || $target->isSpectator) {
|
if (!$target) {
|
||||||
|
if ($calledByAdmin) $this->maniaControl->getChat()->sendError('Player not found', $adminLogin);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($target->isSpectator) {
|
||||||
|
if ($calledByAdmin) $this->maniaControl->getChat()->sendError('Player is already spectator', $adminLogin);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->maniaControl->getClient()->forceSpectator($target->login, $spectatorState);
|
$this->maniaControl->getClient()->forceSpectator($target->login, $spectatorState);
|
||||||
} catch (ServerOptionsException $e) {
|
} catch (ServerOptionsException $e) {
|
||||||
@@ -406,6 +431,7 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
|
|||||||
|
|
||||||
$target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin);
|
$target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin);
|
||||||
if (!$target) {
|
if (!$target) {
|
||||||
|
if ($calledByAdmin) $this->maniaControl->getChat()->sendError('Player not found', $adminLogin);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -434,7 +460,11 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_SEND_MESSAGES_TO_ADMINS_ONLY)) {
|
||||||
|
$this->maniaControl->getChat()->sendInformationToAdmins($message);
|
||||||
|
} else {
|
||||||
$this->maniaControl->getChat()->sendInformation($message);
|
$this->maniaControl->getChat()->sendInformation($message);
|
||||||
|
}
|
||||||
Logger::logInfo($message, true);
|
Logger::logInfo($message, true);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -460,6 +490,7 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
|
|||||||
|
|
||||||
$target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin);
|
$target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin);
|
||||||
if (!$target) {
|
if (!$target) {
|
||||||
|
if ($calledByAdmin) $this->maniaControl->getChat()->sendError('Player not found', $adminLogin);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -493,7 +524,11 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_SEND_MESSAGES_TO_ADMINS_ONLY)) {
|
||||||
|
$this->maniaControl->getChat()->sendInformationToAdmins($message);
|
||||||
|
} else {
|
||||||
$this->maniaControl->getChat()->sendInformation($message);
|
$this->maniaControl->getChat()->sendInformation($message);
|
||||||
|
}
|
||||||
Logger::logInfo($message, true);
|
Logger::logInfo($message, true);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -519,6 +554,7 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
|
|||||||
|
|
||||||
$target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin);
|
$target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin);
|
||||||
if (!$target) {
|
if (!$target) {
|
||||||
|
if ($calledByAdmin) $this->maniaControl->getChat()->sendError('Player not found', $adminLogin);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -596,7 +632,11 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_SEND_MESSAGES_TO_ADMINS_ONLY)) {
|
||||||
|
$this->maniaControl->getChat()->sendInformationToAdmins($message);
|
||||||
|
} else {
|
||||||
$this->maniaControl->getChat()->sendInformation($message);
|
$this->maniaControl->getChat()->sendInformation($message);
|
||||||
|
}
|
||||||
Logger::log($message, true);
|
Logger::log($message, true);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -624,6 +664,7 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
|
|||||||
|
|
||||||
$target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin);
|
$target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin);
|
||||||
if (!$target) {
|
if (!$target) {
|
||||||
|
if ($calledByAdmin) $this->maniaControl->getChat()->sendError('Player not found', $adminLogin);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -662,7 +703,11 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_SEND_MESSAGES_TO_ADMINS_ONLY)) {
|
||||||
|
$this->maniaControl->getChat()->sendInformationToAdmins($message);
|
||||||
|
} else {
|
||||||
$this->maniaControl->getChat()->sendInformation($message);
|
$this->maniaControl->getChat()->sendInformation($message);
|
||||||
|
}
|
||||||
Logger::logInfo($message, true);
|
Logger::logInfo($message, true);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -686,6 +731,7 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
|
|||||||
|
|
||||||
$target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin);
|
$target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin);
|
||||||
if (!$target) {
|
if (!$target) {
|
||||||
|
$this->maniaControl->getChat()->sendError('Player not found', $adminLogin);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -710,7 +756,11 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
|
|||||||
$admin,
|
$admin,
|
||||||
$target
|
$target
|
||||||
);
|
);
|
||||||
|
if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_SEND_MESSAGES_TO_ADMINS_ONLY)) {
|
||||||
|
$this->maniaControl->getChat()->sendInformationToAdmins($message);
|
||||||
|
} else {
|
||||||
$this->maniaControl->getChat()->sendInformation($message);
|
$this->maniaControl->getChat()->sendInformation($message);
|
||||||
|
}
|
||||||
Logger::logInfo($message, true);
|
Logger::logInfo($message, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -730,6 +780,7 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
|
|||||||
|
|
||||||
$target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin);
|
$target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin);
|
||||||
if (!$target) {
|
if (!$target) {
|
||||||
|
$this->maniaControl->getChat()->sendError('Player not found', $adminLogin);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -752,7 +803,11 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
|
|||||||
$admin,
|
$admin,
|
||||||
$target
|
$target
|
||||||
);
|
);
|
||||||
|
if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_SEND_MESSAGES_TO_ADMINS_ONLY)) {
|
||||||
|
$this->maniaControl->getChat()->sendInformationToAdmins($message);
|
||||||
|
} else {
|
||||||
$this->maniaControl->getChat()->sendInformation($message);
|
$this->maniaControl->getChat()->sendInformation($message);
|
||||||
|
}
|
||||||
Logger::logInfo($message, true);
|
Logger::logInfo($message, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -781,6 +836,7 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
|
|||||||
$admin = $this->maniaControl->getPlayerManager()->getPlayer($adminLogin);
|
$admin = $this->maniaControl->getPlayerManager()->getPlayer($adminLogin);
|
||||||
$target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin);
|
$target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin);
|
||||||
if (!$admin || !$target) {
|
if (!$admin || !$target) {
|
||||||
|
$this->maniaControl->getChat()->sendError('Player not found', $adminLogin);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -807,7 +863,11 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
|
|||||||
$admin,
|
$admin,
|
||||||
$target
|
$target
|
||||||
);
|
);
|
||||||
|
if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_SEND_MESSAGES_TO_ADMINS_ONLY)) {
|
||||||
|
$this->maniaControl->getChat()->sendInformationToAdmins($message);
|
||||||
|
} else {
|
||||||
$this->maniaControl->getChat()->sendInformation($message);
|
$this->maniaControl->getChat()->sendInformation($message);
|
||||||
|
}
|
||||||
Logger::logInfo($message, true);
|
Logger::logInfo($message, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -822,6 +882,7 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
|
|||||||
$admin = $this->maniaControl->getPlayerManager()->getPlayer($adminLogin);
|
$admin = $this->maniaControl->getPlayerManager()->getPlayer($adminLogin);
|
||||||
$target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin);
|
$target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin);
|
||||||
if (!$admin || !$target) {
|
if (!$admin || !$target) {
|
||||||
|
$this->maniaControl->getChat()->sendError('Player not found', $adminLogin);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -847,7 +908,11 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
|
|||||||
$admin,
|
$admin,
|
||||||
$target
|
$target
|
||||||
);
|
);
|
||||||
|
if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_SEND_MESSAGES_TO_ADMINS_ONLY)) {
|
||||||
|
$this->maniaControl->getChat()->sendInformationToAdmins($message);
|
||||||
|
} else {
|
||||||
$this->maniaControl->getChat()->sendInformation($message);
|
$this->maniaControl->getChat()->sendInformation($message);
|
||||||
|
}
|
||||||
Logger::logInfo($message, true);
|
Logger::logInfo($message, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user