cleanup, exception handling

This commit is contained in:
kremsy
2014-01-20 20:51:03 +01:00
committed by Steffen Schröder
parent 796d46f199
commit a17037c3cb
13 changed files with 190 additions and 134 deletions

View File

@ -3,6 +3,7 @@
use ManiaControl\Commands\CommandListener;
use ManiaControl\ManiaControl;
use ManiaControl\Players\Player;
use ManiaControl\Plugins\Plugin;
use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
/**
@ -300,9 +301,10 @@ class ChatMessagePlugin implements CommandListener, Plugin {
$this->maniaControl->chat->sendChat($msg, null, true);
$message = '$39F Thanks for Playing, please come back soon!$z';
$success = $this->maniaControl->client->kick($player->login, $message);
if(!$success) {
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $player->login);
try {
$this->maniaControl->client->kick($player->login, $message);
} catch(Exception $e) {
$this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $player->login);
return;
}
}
@ -318,9 +320,10 @@ class ChatMessagePlugin implements CommandListener, Plugin {
$this->maniaControl->chat->sendChat($msg, null, true);
$message = '$39F Thanks for Playing, please come back soon!$z';
$success = $this->maniaControl->client->kick($player->login, $message);
if(!$success) {
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $player->login);
try {
$this->maniaControl->client->kick($player->login, $message);
} catch(Exception $e) {
$this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $player->login);
return;
}
}
@ -337,9 +340,10 @@ class ChatMessagePlugin implements CommandListener, Plugin {
if($this->maniaControl->settingManager->getSetting($this, self::SETTING_AFK_FORCE_SPEC)) {
// force into spec
$success = $this->maniaControl->client->forceSpectator($player->login, 3);
if(!$success) {
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $player->login);
try {
$this->maniaControl->client->forceSpectator($player->login, 3);
} catch(Exception $e) {
$this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $player->login);
return;
}
@ -347,6 +351,7 @@ class ChatMessagePlugin implements CommandListener, Plugin {
try {
$this->maniaControl->client->spectatorReleasePlayerSlot($player->login);
} catch(Exception $e) {
//to nothing
}
}
}