fixed chatmessageplugin

This commit is contained in:
kremsy 2014-01-16 22:28:30 +01:00 committed by Steffen Schröder
parent 62398b719a
commit 90124a4c9a

View File

@ -5,6 +5,7 @@ namespace ManiaControl\Plugins;
use ManiaControl\Commands\CommandListener; use ManiaControl\Commands\CommandListener;
use ManiaControl\ManiaControl; use ManiaControl\ManiaControl;
use ManiaControl\Players\Player; use ManiaControl\Players\Player;
use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
/** /**
* ManiaControl Chat-Message Plugin * ManiaControl Chat-Message Plugin
@ -96,8 +97,7 @@ class ChatMessagePlugin implements CommandListener, Plugin {
if(isset($command[1])) { if(isset($command[1])) {
$msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iHello $z$<' . $this->getTarget($command[1]) . '$>$i!'; $msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iHello $z$<' . $this->getTarget($command[1]) . '$>$i!';
} } else {
else {
$msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iHello All!'; $msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iHello All!';
} }
$this->maniaControl->chat->sendChat($msg, null, false); $this->maniaControl->chat->sendChat($msg, null, false);
@ -114,8 +114,7 @@ class ChatMessagePlugin implements CommandListener, Plugin {
if(isset($command[1])) { if(isset($command[1])) {
$msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iBye $z$<' . $this->getTarget($command[1]) . '$>$i!'; $msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iBye $z$<' . $this->getTarget($command[1]) . '$>$i!';
} } else {
else {
$msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iI have to go... Bye All!'; $msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iI have to go... Bye All!';
} }
@ -133,8 +132,7 @@ class ChatMessagePlugin implements CommandListener, Plugin {
if(isset($command[1])) { if(isset($command[1])) {
$msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iThanks $z$<' . $this->getTarget($command[1]) . '$>$i!'; $msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iThanks $z$<' . $this->getTarget($command[1]) . '$>$i!';
} } else {
else {
$msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iThanks All!'; $msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iThanks All!';
} }
@ -152,8 +150,7 @@ class ChatMessagePlugin implements CommandListener, Plugin {
if(isset($command[1])) { if(isset($command[1])) {
$msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iGood Game $z$<' . $this->getTarget($command[1]) . '$>$i!'; $msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iGood Game $z$<' . $this->getTarget($command[1]) . '$>$i!';
} } else {
else {
$msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iGood Game All!'; $msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iGood Game All!';
} }
@ -171,8 +168,7 @@ class ChatMessagePlugin implements CommandListener, Plugin {
if(isset($command[1])) { if(isset($command[1])) {
$msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iGood Luck $z$<' . $this->getTarget($command[1]) . '$>$i!'; $msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iGood Luck $z$<' . $this->getTarget($command[1]) . '$>$i!';
} } else {
else {
$msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iGood Luck All!'; $msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iGood Luck All!';
} }
@ -190,8 +186,7 @@ class ChatMessagePlugin implements CommandListener, Plugin {
if(isset($command[1])) { if(isset($command[1])) {
$msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iHave Fun $z$<' . $this->getTarget($command[1]) . '$>$i!'; $msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iHave Fun $z$<' . $this->getTarget($command[1]) . '$>$i!';
} } else {
else {
$msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iHave Fun All!'; $msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iHave Fun All!';
} }
@ -209,8 +204,7 @@ class ChatMessagePlugin implements CommandListener, Plugin {
if(isset($command[1])) { if(isset($command[1])) {
$msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iGood Luck and Have Fun $z$<' . $this->getTarget($command[1]) . '$>$i!'; $msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iGood Luck and Have Fun $z$<' . $this->getTarget($command[1]) . '$>$i!';
} } else {
else {
$msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iGood Luck and Have Fun All!'; $msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iGood Luck and Have Fun All!';
} }
@ -228,8 +222,7 @@ class ChatMessagePlugin implements CommandListener, Plugin {
if(isset($command[1])) { if(isset($command[1])) {
$msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iNice Shot $z$<' . $this->getTarget($command[1]) . '$>$i!'; $msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iNice Shot $z$<' . $this->getTarget($command[1]) . '$>$i!';
} } else {
else {
$msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iNice Shot!'; $msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iNice Shot!';
} }
@ -247,8 +240,7 @@ class ChatMessagePlugin implements CommandListener, Plugin {
if(isset($command[1])) { if(isset($command[1])) {
$msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iNice One $z$<' . $this->getTarget($command[1]) . '$>$i!'; $msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iNice One $z$<' . $this->getTarget($command[1]) . '$>$i!';
} } else {
else {
$msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iNice One!'; $msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iNice One!';
} }
@ -310,7 +302,7 @@ class ChatMessagePlugin implements CommandListener, Plugin {
$this->maniaControl->chat->sendChat($msg, null, true); $this->maniaControl->chat->sendChat($msg, null, true);
$message = '$39F Thanks for Playing, please come back soon!$z'; $message = '$39F Thanks for Playing, please come back soon!$z';
$success = $this->maniaControl->client->query('Kick', $player->login, $message); $success = $this->maniaControl->client->kick($player->login, $message);
if(!$success) { if(!$success) {
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $player->login); $this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $player->login);
return; return;
@ -328,7 +320,7 @@ class ChatMessagePlugin implements CommandListener, Plugin {
$this->maniaControl->chat->sendChat($msg, null, true); $this->maniaControl->chat->sendChat($msg, null, true);
$message = '$39F Thanks for Playing, please come back soon!$z'; $message = '$39F Thanks for Playing, please come back soon!$z';
$success = $this->maniaControl->client->query('Kick', $player->login, $message); $success = $this->maniaControl->client->kick($player->login, $message);
if(!$success) { if(!$success) {
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $player->login); $this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $player->login);
return; return;
@ -347,14 +339,17 @@ class ChatMessagePlugin implements CommandListener, Plugin {
if($this->maniaControl->settingManager->getSetting($this, self::SETTING_AFK_FORCE_SPEC)) { if($this->maniaControl->settingManager->getSetting($this, self::SETTING_AFK_FORCE_SPEC)) {
// force into spec // force into spec
$success = $this->maniaControl->client->query('ForceSpectator', $player->login, 3); $success = $this->maniaControl->client->forceSpectator($player->login, 3);
if(!$success) { if(!$success) {
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $player->login); $this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $player->login);
return; return;
} }
// free player slot // free player slot
$this->maniaControl->client->query('SpectatorReleasePlayerSlot', $player->login); try {
$this->maniaControl->client->spectatorReleasePlayerSlot($player->login);
} catch(Exception $e) {
}
} }
} }
@ -375,7 +370,9 @@ class ChatMessagePlugin implements CommandListener, Plugin {
$pid++; $pid++;
} }
if ($login == 'lj') return $player->nickname; if($login == 'lj') {
return $player->nickname;
}
return $login; return $login;
} }