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_ARRAY_INITIALIZER_EXPRESSION" value="true" />
<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="IF_BRACE_FORCE" value="3" />
<option name="DOWHILE_BRACE_FORCE" value="3" />

View File

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