removed double prefix on custom prefix

This commit is contained in:
kremsy 2014-08-11 19:24:21 +02:00
parent a316ffc9df
commit 08a4710c1d
2 changed files with 25 additions and 35 deletions

View File

@ -50,7 +50,6 @@
<option name="ALIGN_MULTILINE_EXTENDS_LIST" value="true" /> <option name="ALIGN_MULTILINE_EXTENDS_LIST" value="true" />
<option name="ALIGN_MULTILINE_ARRAY_INITIALIZER_EXPRESSION" value="true" /> <option name="ALIGN_MULTILINE_ARRAY_INITIALIZER_EXPRESSION" value="true" />
<option name="METHOD_PARAMETERS_WRAP" value="1" /> <option name="METHOD_PARAMETERS_WRAP" value="1" />
<option name="METHOD_CALL_CHAIN_WRAP" value="2" />
<option name="BINARY_OPERATION_SIGN_ON_NEXT_LINE" value="true" /> <option name="BINARY_OPERATION_SIGN_ON_NEXT_LINE" value="true" />
<option name="IF_BRACE_FORCE" value="3" /> <option name="IF_BRACE_FORCE" value="3" />
<option name="DOWHILE_BRACE_FORCE" value="3" /> <option name="DOWHILE_BRACE_FORCE" value="3" />

View File

@ -38,16 +38,11 @@ class Chat {
$this->maniaControl = $maniaControl; $this->maniaControl = $maniaControl;
// Settings // Settings
$this->maniaControl->getSettingManager() $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_PREFIX, '» ');
->initSetting($this, self::SETTING_PREFIX, '» '); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_FORMAT_INFORMATION, '$fff');
$this->maniaControl->getSettingManager() $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_FORMAT_SUCCESS, '$0f0');
->initSetting($this, self::SETTING_FORMAT_INFORMATION, '$fff'); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_FORMAT_ERROR, '$f30');
$this->maniaControl->getSettingManager() $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_FORMAT_USAGEINFO, '$f80');
->initSetting($this, self::SETTING_FORMAT_SUCCESS, '$0f0');
$this->maniaControl->getSettingManager()
->initSetting($this, self::SETTING_FORMAT_ERROR, '$f30');
$this->maniaControl->getSettingManager()
->initSetting($this, self::SETTING_FORMAT_USAGEINFO, '$f80');
} }
/** /**
@ -59,8 +54,7 @@ class Chat {
* @return bool * @return bool
*/ */
public function sendInformation($message, $login = null, $prefix = true) { public function sendInformation($message, $login = null, $prefix = true) {
$format = $this->maniaControl->getSettingManager() $format = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_FORMAT_INFORMATION);
->getSettingValue($this, self::SETTING_FORMAT_INFORMATION);
return $this->sendChat($format . $message, $login, $prefix); return $this->sendChat($format . $message, $login, $prefix);
} }
@ -78,18 +72,23 @@ class Chat {
} }
if (!$login) { if (!$login) {
$prefix = $this->getPrefix($prefix); if ($prefix === true) {
$chatMessage = '$<$z$ff0' . str_replace(' ', '', $prefix) . $prefix . $message . '$>'; //use double prefix
$this->maniaControl->getClient() $prefix = $this->getPrefix($prefix);
->chatSendServerMessage($chatMessage); $chatMessage = '$<$z$ff0' . str_replace(' ', '', $prefix) . $prefix . $message . '$>';
} else {
//don't use double Prefix, when a custom Prefix is set
$prefix = $this->getPrefix($prefix);
$chatMessage = '$<$z$ff0' . $prefix . $message . '$>';
}
$this->maniaControl->getClient()->chatSendServerMessage($chatMessage);
} else { } else {
$chatMessage = '$<$z$ff0' . $this->getPrefix($prefix) . $message . '$>'; $chatMessage = '$<$z$ff0' . $this->getPrefix($prefix) . $message . '$>';
if (!is_array($login)) { if (!is_array($login)) {
$login = Player::parseLogin($login); $login = Player::parseLogin($login);
} }
try { try {
$this->maniaControl->getClient() $this->maniaControl->getClient()->chatSendServerMessage($chatMessage, $login);
->chatSendServerMessage($chatMessage, $login);
} catch (UnknownPlayerException $e) { } catch (UnknownPlayerException $e) {
} }
} }
@ -107,8 +106,7 @@ class Chat {
return $prefix; return $prefix;
} }
if ($prefix === true) { if ($prefix === true) {
return $this->maniaControl->getSettingManager() return $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_PREFIX);
->getSettingValue($this, self::SETTING_PREFIX);
} }
return ''; return '';
} }
@ -121,8 +119,7 @@ class Chat {
* @param bool $prefix * @param bool $prefix
*/ */
public function sendErrorToAdmins($message, $minLevel = AuthenticationManager::AUTH_LEVEL_MODERATOR, $prefix = true) { public function sendErrorToAdmins($message, $minLevel = AuthenticationManager::AUTH_LEVEL_MODERATOR, $prefix = true) {
$format = $this->maniaControl->getSettingManager() $format = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_FORMAT_ERROR);
->getSettingValue($this, self::SETTING_FORMAT_ERROR);
$this->sendMessageToAdmins($format . $message, $minLevel, $prefix); $this->sendMessageToAdmins($format . $message, $minLevel, $prefix);
} }
@ -135,8 +132,7 @@ class Chat {
* @return bool * @return bool
*/ */
public function sendMessageToAdmins($message, $minLevel = AuthenticationManager::AUTH_LEVEL_MODERATOR, $prefix = true) { public function sendMessageToAdmins($message, $minLevel = AuthenticationManager::AUTH_LEVEL_MODERATOR, $prefix = true) {
$admins = $this->maniaControl->getAuthenticationManager() $admins = $this->maniaControl->getAuthenticationManager()->getConnectedAdmins($minLevel);
->getConnectedAdmins($minLevel);
return $this->sendChat($message, $admins, $prefix); return $this->sendChat($message, $admins, $prefix);
} }
@ -149,8 +145,7 @@ class Chat {
* @return bool * @return bool
*/ */
public function sendSuccess($message, $login = null, $prefix = true) { public function sendSuccess($message, $login = null, $prefix = true) {
$format = $this->maniaControl->getSettingManager() $format = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_FORMAT_SUCCESS);
->getSettingValue($this, self::SETTING_FORMAT_SUCCESS);
return $this->sendChat($format . $message, $login, $prefix); return $this->sendChat($format . $message, $login, $prefix);
} }
@ -163,8 +158,7 @@ class Chat {
* @return bool * @return bool
*/ */
public function sendSuccessToAdmins($message, $minLevel = AuthenticationManager::AUTH_LEVEL_MODERATOR, $prefix = true) { public function sendSuccessToAdmins($message, $minLevel = AuthenticationManager::AUTH_LEVEL_MODERATOR, $prefix = true) {
$format = $this->maniaControl->getSettingManager() $format = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_FORMAT_SUCCESS);
->getSettingValue($this, self::SETTING_FORMAT_SUCCESS);
return $this->sendMessageToAdmins($format . $message, $minLevel, $prefix); return $this->sendMessageToAdmins($format . $message, $minLevel, $prefix);
} }
@ -189,8 +183,7 @@ class Chat {
* @return bool * @return bool
*/ */
public function sendError($message, $login = null, $prefix = true) { public function sendError($message, $login = null, $prefix = true) {
$format = $this->maniaControl->getSettingManager() $format = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_FORMAT_ERROR);
->getSettingValue($this, self::SETTING_FORMAT_ERROR);
return $this->sendChat($format . $message, $login, $prefix); return $this->sendChat($format . $message, $login, $prefix);
} }
@ -203,8 +196,7 @@ class Chat {
*/ */
public function sendExceptionToAdmins(\Exception $exception, $minLevel = AuthenticationManager::AUTH_LEVEL_MODERATOR, public function sendExceptionToAdmins(\Exception $exception, $minLevel = AuthenticationManager::AUTH_LEVEL_MODERATOR,
$prefix = true) { $prefix = true) {
$format = $this->maniaControl->getSettingManager() $format = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_FORMAT_ERROR);
->getSettingValue($this, self::SETTING_FORMAT_ERROR);
$message = $format . "Exception: '{$exception->getMessage()}' ({$exception->getCode()})"; $message = $format . "Exception: '{$exception->getMessage()}' ({$exception->getCode()})";
$this->sendMessageToAdmins($message, $minLevel, $prefix); $this->sendMessageToAdmins($message, $minLevel, $prefix);
} }
@ -218,8 +210,7 @@ class Chat {
* @return bool * @return bool
*/ */
public function sendUsageInfo($message, $login = null, $prefix = false) { public function sendUsageInfo($message, $login = null, $prefix = false) {
$format = $this->maniaControl->getSettingManager() $format = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_FORMAT_USAGEINFO);
->getSettingValue($this, self::SETTING_FORMAT_USAGEINFO);
return $this->sendChat($format . $message, $login, $prefix); return $this->sendChat($format . $message, $login, $prefix);
} }
} }