- refactored many try-catch clauses
- added todos for validating catching
This commit is contained in:
parent
10dfd6b0cb
commit
4197dc82ff
@ -191,12 +191,7 @@ class CallbackManager {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$callbacks = $this->maniaControl->client->executeCallbacks();
|
||||
} catch(\Exception $e) {
|
||||
trigger_error("Error reading server callbacks. " . $e->getMessage());
|
||||
return;
|
||||
}
|
||||
$callbacks = $this->maniaControl->client->executeCallbacks();
|
||||
|
||||
// Handle callbacks
|
||||
foreach($callbacks as $callback) {
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace ManiaControl;
|
||||
|
||||
use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
|
||||
/**
|
||||
* Chat utility class
|
||||
*
|
||||
@ -73,7 +74,8 @@ class Chat {
|
||||
} else {
|
||||
$this->maniaControl->client->chatSendServerMessage($chatMessage, $login);
|
||||
}
|
||||
} catch(\Exception $e) {
|
||||
} catch(Exception $e) {
|
||||
// TODO: is it even possible that an exception other than connection errors will be thrown? - remove try-catch?
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -14,6 +14,7 @@ use ManiaControl\Callbacks\CallbackManager;
|
||||
use ManiaControl\ManiaControl;
|
||||
use ManiaControl\Maps\MapManager;
|
||||
use ManiaControl\Players\Player;
|
||||
use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
|
||||
|
||||
/**
|
||||
* Class offering a Configurator for Script Settings
|
||||
@ -109,8 +110,11 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
|
||||
public function loadSettingsFromDatabase() {
|
||||
try {
|
||||
$scriptSettings = $this->maniaControl->client->getModeScriptSettings();
|
||||
} catch(\Exception $e) {
|
||||
return false;
|
||||
} catch(Exception $e) {
|
||||
if ($e->getMessage() == 'Not in script mode.') {
|
||||
return false;
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
|
||||
$mysqli = $this->maniaControl->database->mysqli;
|
||||
@ -137,7 +141,7 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
|
||||
|
||||
try {
|
||||
$this->maniaControl->client->setModeScriptSettings($loadedSettings);
|
||||
} catch(\Exception $e) {
|
||||
} catch(Exception $e) {
|
||||
trigger_error('Error occured: ' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
@ -160,19 +164,21 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
|
||||
|
||||
try {
|
||||
$scriptInfo = $this->maniaControl->client->getModeScriptInfo();
|
||||
} catch(\Exception $e) {
|
||||
// Not in script mode
|
||||
$label = new Label();
|
||||
$frame->add($label);
|
||||
$label->setText($e->getMessage());
|
||||
return $frame;
|
||||
} catch(Exception $e) {
|
||||
if ($e->getMessage() == 'Not in script mode.') {
|
||||
$label = new Label();
|
||||
$frame->add($label);
|
||||
$label->setText($e->getMessage());
|
||||
return $frame;
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
|
||||
$scriptParams = $scriptInfo->paramDescs;
|
||||
|
||||
try {
|
||||
$scriptSettings = $this->maniaControl->client->getModeScriptSettings();
|
||||
} catch(\Exception $e) {
|
||||
} catch(Exception $e) {
|
||||
//do nothing
|
||||
}
|
||||
|
||||
@ -303,8 +309,11 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
|
||||
|
||||
try {
|
||||
$scriptSettings = $this->maniaControl->client->getModeScriptSettings();
|
||||
} catch(\Exception $e) {
|
||||
return;
|
||||
} catch(Exception $e) {
|
||||
if ($e->getMessage() == 'Not in script mode.') {
|
||||
return;
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
|
||||
$prefixLength = strlen(self::ACTION_PREFIX_SETTING);
|
||||
@ -369,8 +378,11 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
|
||||
public function toggleBooleanSetting($setting, Player $player) {
|
||||
try {
|
||||
$scriptSettings = $this->maniaControl->client->getModeScriptSettings();
|
||||
} catch(\Exception $e) {
|
||||
return;
|
||||
} catch(Exception $e) {
|
||||
if ($e->getMessage() == 'Not in script mode.') {
|
||||
return;
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
|
||||
if (!isset($scriptSettings[$setting])) {
|
||||
@ -398,7 +410,7 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
|
||||
|
||||
try {
|
||||
$this->maniaControl->client->setModeScriptSettings($newSettings);
|
||||
} catch(\Exception $e) {
|
||||
} catch(Exception $e) {
|
||||
$this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $player->login);
|
||||
return false;
|
||||
}
|
||||
|
@ -100,25 +100,22 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener {
|
||||
return false;
|
||||
}
|
||||
$serverSettings = $this->maniaControl->client->getServerOptions()->toArray();
|
||||
while($row = $result->fetch_object()) {
|
||||
$applySettings = false;
|
||||
while ($row = $result->fetch_object()) {
|
||||
if (!isset($serverSettings[$row->settingName])) {
|
||||
continue;
|
||||
}
|
||||
$oldType = gettype($serverSettings[$row->settingName]);
|
||||
$serverSettings[$row->settingName] = $row->settingValue;
|
||||
settype($serverSettings[$row->settingName], $oldType);
|
||||
$applySettings = true;
|
||||
}
|
||||
$result->close();
|
||||
if (!$serverSettings) {
|
||||
if (!$applySettings) {
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
$this->maniaControl->client->setServerOptions($serverSettings);
|
||||
} catch(\Exception $e) {
|
||||
trigger_error('Error occured: ' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
$this->maniaControl->client->setServerOptions($serverSettings);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -325,13 +322,7 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener {
|
||||
if (!$newSettings) {
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
$this->maniaControl->client->setServerOptions($newSettings);
|
||||
} catch(\Exception $e) {
|
||||
trigger_error('Error occured: ' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
$this->maniaControl->client->setServerOptions($newSettings);
|
||||
|
||||
// Save Settings into Database
|
||||
$mysqli = $this->maniaControl->database->mysqli;
|
||||
|
@ -21,6 +21,7 @@ use ManiaControl\Settings\SettingManager;
|
||||
use ManiaControl\Statistics\StatisticManager;
|
||||
use ManiaControl\Update\UpdateManager;
|
||||
use Maniaplanet\DedicatedServer\Connection;
|
||||
use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
|
||||
|
||||
require_once __DIR__ . '/Maniaplanet/DedicatedServer/Connection.php';
|
||||
require_once __DIR__ . '/GbxDataFetcher/gbxdatafetcher.inc.php';
|
||||
@ -216,12 +217,11 @@ class ManiaControl implements CommandListener {
|
||||
// Hide manialinks
|
||||
try {
|
||||
$this->client->sendHideManialinkPage();
|
||||
|
||||
// Close the client connection
|
||||
$this->client->delete($this->server->ip, $this->server->port);
|
||||
} catch(\Exception $e) {
|
||||
//do nothing
|
||||
} catch(Exception $e) {
|
||||
}
|
||||
|
||||
// Close the client connection
|
||||
$this->client->delete($this->server->ip, $this->server->port);
|
||||
|
||||
$this->log('Quitting ManiaControl!');
|
||||
exit();
|
||||
@ -343,28 +343,19 @@ class ManiaControl implements CommandListener {
|
||||
|
||||
try {
|
||||
$this->client = Connection::factory($host, $port, self::CONNECT_TIMEOUT, $login, $pass);
|
||||
} catch(\Exception $e) {
|
||||
} catch(Exception $e) {
|
||||
// TODO: is it even needed to try-catch here? we will crash anyways
|
||||
trigger_error("Couldn't authenticate on server with user '{$login}'! " . $e->getMessage(), E_USER_ERROR);
|
||||
}
|
||||
|
||||
// Enable callback system
|
||||
try {
|
||||
$this->client->enableCallbacks(true);
|
||||
} catch(\Exception $e) {
|
||||
trigger_error("Couldn't enable callbacks! " . $e->getMessage(), E_USER_ERROR);
|
||||
}
|
||||
$this->client->enableCallbacks(true);
|
||||
|
||||
// Wait for server to be ready
|
||||
if (!$this->server->waitForStatus(4)) {
|
||||
trigger_error("Server couldn't get ready!", E_USER_ERROR);
|
||||
}
|
||||
|
||||
// Set api version
|
||||
/*
|
||||
* if(!$this->client->query('SetApiVersion', self::API_VERSION)) { trigger_error("Couldn't set API version '" . self::API_VERSION . "'! This
|
||||
* might cause problems. " . $this->getClientErrorText()); }
|
||||
*/
|
||||
|
||||
// Connect finished
|
||||
$this->log("Server Connection successfully established!");
|
||||
|
||||
@ -378,9 +369,11 @@ class ManiaControl implements CommandListener {
|
||||
|
||||
try {
|
||||
$scriptSettings = $this->client->getModeScriptSettings();
|
||||
} catch(\Exception $e) {
|
||||
trigger_error("Couldn't get mode script settings. " . $e->getMessage());
|
||||
return;
|
||||
} catch(Exception $e) {
|
||||
if ($e->getMessage() == 'Not in script mode.') {
|
||||
return;
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
|
||||
if (!array_key_exists('S_UseScriptCallbacks', $scriptSettings)) {
|
||||
@ -390,7 +383,7 @@ class ManiaControl implements CommandListener {
|
||||
$scriptSettings['S_UseScriptCallbacks'] = true;
|
||||
try {
|
||||
$this->client->setModeScriptSettings($scriptSettings);
|
||||
} catch(\Exception $e) {
|
||||
} catch(Exception $e) {
|
||||
trigger_error("Couldn't set mode script settings to enable script callbacks. " . $e->getMessage());
|
||||
return;
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ namespace ManiaControl\ManiaExchange;
|
||||
use ManiaControl\ManiaControl;
|
||||
use ManiaControl\Maps\Map;
|
||||
use ManiaControl\Maps\MapManager;
|
||||
use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
|
||||
|
||||
/**
|
||||
* Mania Exchange Info Searcher Class
|
||||
@ -285,7 +286,10 @@ class ManiaExchangeManager {
|
||||
$scriptInfos = $this->maniaControl->client->getModeScriptInfo();
|
||||
$mapTypes = $scriptInfos->compatibleMapTypes;
|
||||
$url .= '&mtype=' . $mapTypes;
|
||||
} catch(\Exception $e) {
|
||||
} catch(Exception $e) {
|
||||
if ($e->getMessage() != 'Not in script mode.') {
|
||||
throw $e;
|
||||
}
|
||||
//dont append map tpye
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@ use ManiaControl\Callbacks\CallbackListener;
|
||||
use ManiaControl\Callbacks\CallbackManager;
|
||||
use ManiaControl\ManiaControl;
|
||||
use ManiaControl\Players\Player;
|
||||
use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
|
||||
|
||||
/**
|
||||
* Manialink manager class
|
||||
@ -148,7 +149,8 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener
|
||||
|
||||
return $success;
|
||||
}
|
||||
} catch(\Exception $e) {
|
||||
} catch(Exception $e) {
|
||||
// TODO: only possible valid exception should be "wrong login" - throw others (like connection error)
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@ use ManiaControl\ManiaControl;
|
||||
use ManiaControl\Manialinks\IconManager;
|
||||
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
|
||||
use ManiaControl\Players\Player;
|
||||
use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
|
||||
|
||||
/**
|
||||
* Class offering commands to manage maps
|
||||
@ -106,7 +107,8 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
||||
} else {
|
||||
try {
|
||||
$mapIndex = $this->maniaControl->client->getNextMapIndex();
|
||||
} catch(\Exception $e) {
|
||||
} catch(Exception $e) {
|
||||
// TODO: is it even possible that an exception other than connection errors will be thrown? - remove try-catch?
|
||||
trigger_error("Error while Reading the next Map Index");
|
||||
$this->maniaControl->chat->sendError("Error while Reading next Map Inde");
|
||||
return;
|
||||
@ -190,7 +192,8 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
||||
|
||||
try {
|
||||
$this->maniaControl->client->nextMap();
|
||||
} catch(\Exception $e) {
|
||||
} catch(Exception $e) {
|
||||
// TODO: is it even possible that an exception other than connection errors will be thrown? - remove try-catch?
|
||||
$this->maniaControl->chat->sendError("Error while Skipping the Map");
|
||||
return;
|
||||
}
|
||||
@ -216,7 +219,8 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
||||
$this->maniaControl->log($message, true);
|
||||
try {
|
||||
$this->maniaControl->client->restartMap();
|
||||
} catch(\Exception $e) {
|
||||
} catch(Exception $e) {
|
||||
// TODO: is it even possible that an exception other than connection errors will be thrown? - remove try-catch?
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ use ManiaControl\Manialinks\IconManager;
|
||||
use ManiaControl\Manialinks\ManialinkManager;
|
||||
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
|
||||
use ManiaControl\Players\Player;
|
||||
use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
|
||||
|
||||
/**
|
||||
* MapList Widget Class
|
||||
@ -511,7 +512,8 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
case self::ACTION_SWITCH_MAP:
|
||||
try {
|
||||
$this->maniaControl->client->jumpToMapIndex($mapId);
|
||||
} catch(\Exception $e) {
|
||||
} catch(Exception $e) {
|
||||
// TODO: is it even possible that an exception other than connection errors will be thrown? - remove try-catch?
|
||||
$this->maniaControl->chat->sendError("Error while Jumping to Map Index");
|
||||
break;
|
||||
}
|
||||
@ -542,7 +544,8 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
try {
|
||||
$index = $this->maniaControl->mapManager->getMapIndex($map);
|
||||
$this->maniaControl->client->jumpToMapIndex($index);
|
||||
} catch(\Exception $e) {
|
||||
} catch(Exception $e) {
|
||||
// TODO: is it even possible that an exception other than connection errors will be thrown? - remove try-catch?
|
||||
$this->maniaControl->chat->sendError("Error while Switching Map");
|
||||
}
|
||||
});
|
||||
|
@ -12,6 +12,7 @@ use ManiaControl\ManiaExchange\ManiaExchangeList;
|
||||
use ManiaControl\ManiaExchange\ManiaExchangeManager;
|
||||
use ManiaControl\ManiaExchange\MXMapInfo;
|
||||
use ManiaControl\Players\Player;
|
||||
use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
|
||||
|
||||
/**
|
||||
* Manager for Maps
|
||||
@ -216,24 +217,13 @@ class MapManager implements CallbackListener {
|
||||
}
|
||||
|
||||
// Remove map
|
||||
try {
|
||||
$this->maniaControl->client->removeMap($map->fileName);
|
||||
} catch(\Exception $e) {
|
||||
trigger_error("Couldn't remove current map. " . $e->getMessage());
|
||||
$this->maniaControl->chat->sendError("Couldn't remove map.", $admin);
|
||||
return;
|
||||
}
|
||||
$this->maniaControl->client->removeMap($map->fileName);
|
||||
|
||||
if ($eraseFile) {
|
||||
// Check if ManiaControl can even write to the maps dir
|
||||
try {
|
||||
$mapDir = $this->maniaControl->client->getMapsDirectory();
|
||||
} catch(\Exception $e) {
|
||||
trigger_error("Couldn't get map directory. " . $e->getMessage());
|
||||
$this->maniaControl->chat->sendError("ManiaControl couldn't retrieve the maps directory.", $admin->login);
|
||||
return;
|
||||
}
|
||||
|
||||
$mapDir = $this->maniaControl->client->getMapsDirectory();
|
||||
|
||||
// Delete map file
|
||||
if (!@unlink($mapDir . $map->fileName)) {
|
||||
trigger_error("Couldn't remove Map '{$mapDir}{$map->fileName}'.");
|
||||
$this->maniaControl->chat->sendError("ManiaControl couldn't remove the MapFile.", $admin->login);
|
||||
@ -281,7 +271,7 @@ class MapManager implements CallbackListener {
|
||||
|
||||
try {
|
||||
$this->maniaControl->client->chooseNextMapList($mapArray);
|
||||
} catch(\Exception $e) {
|
||||
} catch(Exception $e) {
|
||||
trigger_error("Error while restructuring the Maplist. " . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
@ -307,7 +297,7 @@ class MapManager implements CallbackListener {
|
||||
|
||||
try {
|
||||
$this->maniaControl->client->chooseNextMapList($mapArray);
|
||||
} catch(\Exception $e) {
|
||||
} catch(Exception $e) {
|
||||
trigger_error("Couldn't shuffle mapList. " . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
@ -345,6 +335,7 @@ class MapManager implements CallbackListener {
|
||||
$map->authorZone = $mapFetcher->authorZone;
|
||||
$map->comment = $mapFetcher->comment;
|
||||
} catch(\Exception $e) {
|
||||
// TODO: replace \Exception with api exception class (?)
|
||||
trigger_error($e->getMessage());
|
||||
}
|
||||
}
|
||||
@ -355,14 +346,7 @@ class MapManager implements CallbackListener {
|
||||
* Updates the full Map list, needed on Init, addMap and on ShuffleMaps
|
||||
*/
|
||||
private function updateFullMapList() {
|
||||
|
||||
try {
|
||||
$maps = $this->maniaControl->client->getMapList(100, 0);
|
||||
} catch(\Exception $e) {
|
||||
trigger_error("Couldn't fetch mapList. " . $e->getMessage());
|
||||
return null;
|
||||
}
|
||||
|
||||
$maps = $this->maniaControl->client->getMapList(100, 0);
|
||||
$tempList = array();
|
||||
|
||||
foreach($maps as $rpcMap) {
|
||||
@ -388,12 +372,7 @@ class MapManager implements CallbackListener {
|
||||
* @return bool
|
||||
*/
|
||||
private function fetchCurrentMap() {
|
||||
try {
|
||||
$rpcMap = $this->maniaControl->client->getCurrentMapInfo();
|
||||
} catch(\Exception $e) {
|
||||
trigger_error("Couldn't fetch map info. " . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
$rpcMap = $this->maniaControl->client->getCurrentMapInfo();
|
||||
|
||||
if (array_key_exists($rpcMap->uId, $this->maps)) {
|
||||
$this->currentMap = $this->maps[$rpcMap->uId];
|
||||
@ -508,14 +487,7 @@ class MapManager implements CallbackListener {
|
||||
* @param bool $update
|
||||
*/
|
||||
public function addMapFromMx($mapId, $login, $update = false) {
|
||||
// Check if ManiaControl can even write to the maps dir
|
||||
try {
|
||||
$mapDir = $this->maniaControl->client->getMapsDirectory();
|
||||
} catch(\Exception $e) {
|
||||
trigger_error("Couldn't get map directory. " . $e->getMessage());
|
||||
$this->maniaControl->chat->sendError("ManiaControl couldn't retrieve the maps directory.", $login);
|
||||
return;
|
||||
}
|
||||
$mapDir = $this->maniaControl->client->getMapsDirectory();
|
||||
|
||||
if (is_numeric($mapId)) {
|
||||
// Check if map exists
|
||||
@ -590,7 +562,8 @@ class MapManager implements CallbackListener {
|
||||
} else {
|
||||
try {
|
||||
$this->maniaControl->client->writeFileFromString($mapFileName, $file);
|
||||
} catch(\Exception $e) {
|
||||
} catch(Exception $e) {
|
||||
// TODO: add check for error message - throw other stuff like connection errors
|
||||
$this->maniaControl->chat->sendError("Map is too big for a remote save.", $login);
|
||||
return;
|
||||
}
|
||||
@ -599,7 +572,7 @@ class MapManager implements CallbackListener {
|
||||
// Check for valid map
|
||||
try {
|
||||
$this->maniaControl->client->checkMapForCurrentServerParams($mapFileName);
|
||||
} catch(\Exception $e) {
|
||||
} catch(Exception $e) {
|
||||
trigger_error("Couldn't check if map is valid ('{$mapFileName}'). " . $e->getMessage());
|
||||
$this->maniaControl->chat->sendError('Wrong MapType or not validated!', $login);
|
||||
return;
|
||||
@ -608,7 +581,8 @@ class MapManager implements CallbackListener {
|
||||
// Add map to map list
|
||||
try {
|
||||
$this->maniaControl->client->insertMap($mapFileName);
|
||||
} catch(\Exception $e) {
|
||||
} catch(Exception $e) {
|
||||
// TODO: is it even possible that an exception other than connection errors will be thrown? - remove try-catch?
|
||||
$this->maniaControl->chat->sendError("Couldn't add map to match settings!", $login);
|
||||
return;
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ use ManiaControl\Commands\CommandListener;
|
||||
use ManiaControl\Formatter;
|
||||
use ManiaControl\ManiaControl;
|
||||
use ManiaControl\Players\Player;
|
||||
use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
|
||||
|
||||
/**
|
||||
* MapQueue Class
|
||||
@ -183,7 +184,8 @@ class MapQueue implements CallbackListener, CommandListener {
|
||||
|
||||
try {
|
||||
$this->maniaControl->client->chooseNextMap($map->fileName);
|
||||
} catch(\Exception $e) {
|
||||
} catch(Exception $e) {
|
||||
// TODO: is it even possible that an exception other than connection errors will be thrown? - remove try-catch?
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ use ManiaControl\Admin\AuthenticationManager;
|
||||
use ManiaControl\Formatter;
|
||||
use ManiaControl\ManiaControl;
|
||||
use ManiaControl\Manialinks\ManialinkManager;
|
||||
use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
|
||||
|
||||
/**
|
||||
* PlayerActions Class
|
||||
@ -84,8 +85,8 @@ class PlayerActions {
|
||||
|
||||
try {
|
||||
$this->maniaControl->client->forceSpectator($target->login, self::SPECTATOR_PLAYER);
|
||||
|
||||
} catch(\Exception $e) {
|
||||
} catch(Exception $e) {
|
||||
// TODO: only possible valid exception should be "wrong login" - throw others (like connection error)
|
||||
$this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $admin->login);
|
||||
return;
|
||||
}
|
||||
@ -93,7 +94,8 @@ class PlayerActions {
|
||||
if($userIsAbleToSelect) {
|
||||
try {
|
||||
$this->maniaControl->client->forceSpectator($target->login, self::SPECTATOR_USER_SELECTABLE);
|
||||
} catch(\Exception $e) {
|
||||
} catch(Exception $e) {
|
||||
// TODO: only possible valid exception should be "wrong login" - throw others (like connection error)
|
||||
$this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $admin->login);
|
||||
return;
|
||||
}
|
||||
@ -130,7 +132,8 @@ class PlayerActions {
|
||||
|
||||
try {
|
||||
$this->maniaControl->client->forcePlayerTeam($target->login, $teamId);
|
||||
} catch(\Exception $e) {
|
||||
} catch(Exception $e) {
|
||||
// TODO: only possible valid exceptions should be "wrong login" or "not in team mode" - throw others (like connection error)
|
||||
$this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $admin->login);
|
||||
return;
|
||||
}
|
||||
@ -167,7 +170,8 @@ class PlayerActions {
|
||||
|
||||
try {
|
||||
$this->maniaControl->client->forceSpectator($target->login, $spectatorState);
|
||||
} catch(\Exception $e) {
|
||||
} catch(Exception $e) {
|
||||
// TODO: only possible valid exception should be "wrong login" - throw others (like connection error)
|
||||
$this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $admin->login);
|
||||
return;
|
||||
}
|
||||
@ -181,7 +185,8 @@ class PlayerActions {
|
||||
// Free player slot
|
||||
try {
|
||||
$this->maniaControl->client->spectatorReleasePlayerSlot($target->login);
|
||||
} catch(\Exception $e) {
|
||||
} catch(Exception $e) {
|
||||
// TODO: only possible valid exception should be "wrong login" - throw others (like connection error)
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
@ -205,7 +210,8 @@ class PlayerActions {
|
||||
|
||||
try {
|
||||
$this->maniaControl->client->unIgnore($targetLogin);
|
||||
} catch(\Exception $e) {
|
||||
} catch(Exception $e) {
|
||||
// TODO: only possible valid exception should be "wrong login" - throw others (like connection error)
|
||||
$this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $adminLogin);
|
||||
return;
|
||||
}
|
||||
@ -232,12 +238,7 @@ class PlayerActions {
|
||||
|
||||
$target = $this->maniaControl->playerManager->getPlayer($targetLogin);
|
||||
|
||||
try {
|
||||
$this->maniaControl->client->ignore($targetLogin);
|
||||
} catch(\Exception $e) {
|
||||
$this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $admin->login);
|
||||
return;
|
||||
}
|
||||
$this->maniaControl->client->ignore($targetLogin);
|
||||
|
||||
$title = $this->maniaControl->authenticationManager->getAuthLevelName($admin->authLevel);
|
||||
$chatMessage = $title . ' $<' . $admin->nickname . '$> muted $<' . $target->nickname . '$>!';
|
||||
@ -349,7 +350,8 @@ class PlayerActions {
|
||||
} else {
|
||||
$this->maniaControl->client->kick($target->login, $message);
|
||||
}
|
||||
} catch(\Exception $e) {
|
||||
} catch(Exception $e) {
|
||||
// TODO: only possible valid exception should be "wrong login" - throw others (like connection error)
|
||||
$this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $admin->login);
|
||||
return;
|
||||
}
|
||||
@ -384,12 +386,7 @@ class PlayerActions {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$this->maniaControl->client->ban($target->login, $message);
|
||||
} catch(\Exception $e) {
|
||||
$this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $admin->login);
|
||||
return;
|
||||
}
|
||||
$this->maniaControl->client->ban($target->login, $message);
|
||||
|
||||
// Announce ban
|
||||
$title = $this->maniaControl->authenticationManager->getAuthLevelName($admin->authLevel);
|
||||
|
@ -10,6 +10,7 @@ use ManiaControl\Commands\CommandListener;
|
||||
use ManiaControl\ManiaControl;
|
||||
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
|
||||
use ManiaControl\Server\Server;
|
||||
use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
|
||||
|
||||
/**
|
||||
* Class offering various Admin Commands related to Players
|
||||
@ -105,7 +106,8 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
|
||||
|
||||
try {
|
||||
$this->maniaControl->client->autoTeamBalance();
|
||||
} catch(\Exception $e) {
|
||||
} catch(Exception $e) {
|
||||
// TODO: only catch 'not in team mode' exception - throw others (like connection error)
|
||||
$this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $player->login);
|
||||
return;
|
||||
}
|
||||
@ -267,15 +269,9 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
|
||||
if (isset($messageParts[1]) && is_numeric($messageParts[1])) {
|
||||
$amount = intval($messageParts[1]);
|
||||
}
|
||||
try {
|
||||
for($i = 0; $i < $amount; $i++) {
|
||||
$this->maniaControl->client->connectFakePlayer();
|
||||
}
|
||||
} catch(\Exception $e) {
|
||||
$this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $player->login);
|
||||
return;
|
||||
for ($i = 0; $i < $amount; $i++) {
|
||||
$this->maniaControl->client->connectFakePlayer();
|
||||
}
|
||||
|
||||
$this->maniaControl->chat->sendSuccess('Fake players connected!', $player->login);
|
||||
}
|
||||
|
||||
@ -290,14 +286,7 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
|
||||
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$this->maniaControl->client->disconnectFakePlayer('*');
|
||||
} catch(\Exception $e) {
|
||||
$this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $player->login);
|
||||
return;
|
||||
}
|
||||
|
||||
$this->maniaControl->client->disconnectFakePlayer('*');
|
||||
$this->maniaControl->chat->sendSuccess('Fake players disconnected!', $player->login);
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,7 @@ use ManiaControl\Formatter;
|
||||
use ManiaControl\ManiaControl;
|
||||
use ManiaControl\Manialinks\ManialinkManager;
|
||||
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
|
||||
use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
|
||||
|
||||
/**
|
||||
* PlayerList Widget Class
|
||||
@ -650,7 +651,8 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
try {
|
||||
$this->maniaControl->client->forceSpectator($adminLogin, PlayerActions::SPECTATOR_BUT_KEEP_SELECTABLE);
|
||||
$this->maniaControl->client->forceSpectatorTarget($adminLogin, $targetLogin, 1);
|
||||
} catch(\Exception $e) {
|
||||
} catch(Exception $e) {
|
||||
// TODO: only possible valid exception should be "wrong login" - throw others (like connection error)
|
||||
}
|
||||
break;
|
||||
case self::ACTION_OPEN_PLAYER_DETAILED:
|
||||
@ -721,8 +723,9 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
try {
|
||||
$this->maniaControl->client->forceSpectator($target->login, PlayerActions::SPECTATOR_BUT_KEEP_SELECTABLE);
|
||||
$this->maniaControl->client->spectatorReleasePlayerSlot($target->login);
|
||||
} catch(\Exception $e) {
|
||||
} catch(Exception $e) {
|
||||
//do nothing
|
||||
// TODO: only possible valid exception should be "wrong login" - throw others (like connection error)
|
||||
}
|
||||
});
|
||||
break;
|
||||
@ -745,7 +748,8 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
$message = '$39F You got kicked due a Public vote!$z ';
|
||||
try {
|
||||
$this->maniaControl->client->kick($target->login, $message);
|
||||
} catch(\Exception $e) {
|
||||
} catch(Exception $e) {
|
||||
// TODO: only possible valid exception should be "wrong login" - throw others (like connection error)
|
||||
$this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $target->login);
|
||||
return;
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ use ManiaControl\Callbacks\CallbackManager;
|
||||
use ManiaControl\ManiaControl;
|
||||
use ManiaControl\Players\Player;
|
||||
use Maniaplanet\DedicatedServer\Structures\SystemInfos;
|
||||
use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
|
||||
|
||||
/**
|
||||
* Class providing Information about theconnected ManiaPlanet Server
|
||||
@ -162,12 +163,7 @@ class Server implements CallbackListener {
|
||||
*/
|
||||
public function getDataDirectory() {
|
||||
if ($this->dataDirectory == '') {
|
||||
try {
|
||||
$this->dataDirectory = $this->maniaControl->client->gameDataDirectory();
|
||||
} catch(\Exception $e) {
|
||||
trigger_error("Couldn't get data directory. " . $e->getMessage());
|
||||
return null;
|
||||
}
|
||||
$this->dataDirectory = $this->maniaControl->client->gameDataDirectory();
|
||||
}
|
||||
return $this->dataDirectory;
|
||||
}
|
||||
@ -199,29 +195,12 @@ class Server implements CallbackListener {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Server Info
|
||||
* Get Server Player Info
|
||||
*
|
||||
* @param bool $detailed
|
||||
* @return array
|
||||
*/
|
||||
public function getInfo($detailed = false) {
|
||||
if ($detailed) {
|
||||
$login = $this->login;
|
||||
try {
|
||||
$info = $this->maniaControl->client->getDetailedPlayerInfo($login);
|
||||
} catch(\Exception $e) {
|
||||
trigger_error("Couldn't fetch detailed server info. " . $e->getMessage());
|
||||
return null;
|
||||
}
|
||||
return $info;
|
||||
}
|
||||
try {
|
||||
$info = $this->maniaControl->client->getMainServerPlayerInfo();
|
||||
} catch(\Exception $e) {
|
||||
trigger_error("Couldn't fetch server info. " . $e->getMessage());
|
||||
return null;
|
||||
}
|
||||
return $info;
|
||||
public function getInfo() {
|
||||
return $this->maniaControl->client->getMainServerPlayerInfo();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -230,14 +209,7 @@ class Server implements CallbackListener {
|
||||
* @return array
|
||||
*/
|
||||
public function getOptions() {
|
||||
try {
|
||||
$options = $this->maniaControl->client->getServerOptions();
|
||||
} catch(\Exception $e) {
|
||||
trigger_error("Couldn't fetch server options. " . $e->getMessage());
|
||||
return null;
|
||||
}
|
||||
|
||||
return $options;
|
||||
return $this->maniaControl->client->getServerOptions();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -246,13 +218,7 @@ class Server implements CallbackListener {
|
||||
* @return string
|
||||
*/
|
||||
public function getName() {
|
||||
try {
|
||||
$name = $this->maniaControl->client->getServerName();
|
||||
} catch(\Exception $e) {
|
||||
trigger_error("Couldn't fetch server name. " . $e->getMessage());
|
||||
return null;
|
||||
}
|
||||
return $name;
|
||||
return $this->maniaControl->client->getServerName();
|
||||
}
|
||||
|
||||
|
||||
@ -262,13 +228,7 @@ class Server implements CallbackListener {
|
||||
* @return string
|
||||
*/
|
||||
public function getVersion() {
|
||||
try {
|
||||
$version = $this->maniaControl->client->getVersion();
|
||||
} catch(\Exception $e) {
|
||||
trigger_error("Couldn't fetch server version. " . $e->getMessage());
|
||||
return null;
|
||||
}
|
||||
return $version;
|
||||
return $this->maniaControl->client->getVersion();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -277,14 +237,7 @@ class Server implements CallbackListener {
|
||||
* @return SystemInfos
|
||||
*/
|
||||
public function getSystemInfo() {
|
||||
try {
|
||||
$systemInfo = $this->maniaControl->client->getSystemInfo();
|
||||
} catch(\Exception $e) {
|
||||
trigger_error("Couldn't fetch server system info. " . $e->getMessage());
|
||||
return null;
|
||||
}
|
||||
|
||||
return $systemInfo;
|
||||
return $this->maniaControl->client->getSystemInfo();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -298,12 +251,7 @@ class Server implements CallbackListener {
|
||||
if (is_int($parseValue)) {
|
||||
$gameMode = $parseValue;
|
||||
} else {
|
||||
try {
|
||||
$gameMode = $this->maniaControl->client->getGameMode();
|
||||
} catch(\Exception $e) {
|
||||
trigger_error("Couldn't fetch current game mode. " . $e->getMessage());
|
||||
return null;
|
||||
}
|
||||
$gameMode = $this->maniaControl->client->getGameMode();
|
||||
}
|
||||
if ($stringValue) {
|
||||
switch($gameMode) {
|
||||
@ -337,7 +285,7 @@ class Server implements CallbackListener {
|
||||
public function getValidationReplay(Player $player) {
|
||||
try {
|
||||
$replay = $this->maniaControl->client->getValidationReplay($player->login);
|
||||
} catch(\Exception $e) {
|
||||
} catch(Exception $e) {
|
||||
trigger_error("Couldn't get validation replay of '{$player->login}'. " . $e->getMessage());
|
||||
return null;
|
||||
}
|
||||
@ -365,7 +313,7 @@ class Server implements CallbackListener {
|
||||
// Save ghost replay
|
||||
try {
|
||||
$this->maniaControl->client->saveBestGhostsReplay($player->login, $fileName);
|
||||
} catch(\Exception $e) {
|
||||
} catch(Exception $e) {
|
||||
trigger_error("Couldn't save ghost replay. " . $e->getMessage());
|
||||
return null;
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ use ManiaControl\Commands\CommandListener;
|
||||
use ManiaControl\ManiaControl;
|
||||
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
|
||||
use ManiaControl\Players\Player;
|
||||
use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
|
||||
|
||||
/**
|
||||
* Class offering various commands related to the dedicated server
|
||||
@ -105,8 +106,11 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
||||
//Check if Pause exists in current GameMode
|
||||
try {
|
||||
$scriptInfos = $this->maniaControl->client->getModeScriptInfo();
|
||||
} catch(\Exception $e) {
|
||||
return;
|
||||
} catch(Exception $e) {
|
||||
if ($e->getMessage() == 'Not in script mode.') {
|
||||
return;
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
$pauseExists = false;
|
||||
foreach($scriptInfos->commandDescs as $param) {
|
||||
@ -160,9 +164,12 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
||||
|
||||
try {
|
||||
$this->maniaControl->client->triggerModeScriptEvent('WarmUp_Extend', '10');
|
||||
} catch(\Exception $e) {
|
||||
$this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $player->login);
|
||||
return;
|
||||
} catch(Exception $e) {
|
||||
if ($e->getMessage() == 'Not in script mode.') {
|
||||
$this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $player->login);
|
||||
return;
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
|
||||
$this->maniaControl->chat->sendInformation('$<' . $player->nickname . '$> extended the WarmUp by 10 seconds!');
|
||||
@ -182,9 +189,12 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
||||
|
||||
try {
|
||||
$this->maniaControl->client->triggerModeScriptEvent('WarmUp_Stop', '');
|
||||
} catch(\Exception $e) {
|
||||
$this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $player->login);
|
||||
return;
|
||||
} catch(Exception $e) {
|
||||
if ($e->getMessage() == 'Not in script mode.') {
|
||||
$this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $player->login);
|
||||
return;
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
|
||||
$this->maniaControl->chat->sendInformation('$<' . $player->nickname . '$> stopped the WarmUp!');
|
||||
@ -202,9 +212,12 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
||||
}
|
||||
try {
|
||||
$this->maniaControl->client->sendModeScriptCommands(array('Command_ForceWarmUp' => True));
|
||||
} catch(\Exception $e) {
|
||||
$this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $player->login);
|
||||
return;
|
||||
} catch(Exception $e) {
|
||||
if ($e->getMessage() == 'Not in script mode.') {
|
||||
$this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $player->login);
|
||||
return;
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
|
||||
$this->maniaControl->chat->sendInformation('$<' . $player->nickname . '$> paused the Game!');
|
||||
@ -305,12 +318,7 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
||||
return;
|
||||
}
|
||||
$serverName = $params[1];
|
||||
try {
|
||||
$this->maniaControl->client->setServerName($serverName);
|
||||
} catch(\Exception $e) {
|
||||
$this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $player->login);
|
||||
return;
|
||||
}
|
||||
$this->maniaControl->client->setServerName($serverName);
|
||||
$this->maniaControl->chat->sendSuccess("Server name changed to: '{$serverName}'!", $player->login);
|
||||
}
|
||||
|
||||
@ -332,12 +340,7 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
||||
$password = $messageParts[1];
|
||||
$successMessage = "Password changed to: '{$password}'!";
|
||||
}
|
||||
try {
|
||||
$this->maniaControl->client->setServerPassword($password);
|
||||
} catch(\Exception $e) {
|
||||
$this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $player->login);
|
||||
return;
|
||||
}
|
||||
$this->maniaControl->client->setServerPassword($password);
|
||||
$this->maniaControl->chat->sendSuccess($successMessage, $player->login);
|
||||
}
|
||||
|
||||
@ -359,12 +362,7 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
||||
$password = $messageParts[1];
|
||||
$successMessage = "Spectator password changed to: '{$password}'!";
|
||||
}
|
||||
try {
|
||||
$this->maniaControl->client->setServerPasswordForSpectator($password);
|
||||
} catch(\Exception $e) {
|
||||
$this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $player->login);
|
||||
return;
|
||||
}
|
||||
$this->maniaControl->client->setServerPasswordForSpectator($password);
|
||||
$this->maniaControl->chat->sendSuccess($successMessage, $player->login);
|
||||
}
|
||||
|
||||
@ -394,13 +392,7 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
||||
$amount = 0;
|
||||
}
|
||||
|
||||
try {
|
||||
$this->maniaControl->client->setMaxPlayers($amount);
|
||||
} catch(\Exception $e) {
|
||||
$this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $player->login);
|
||||
return;
|
||||
}
|
||||
|
||||
$this->maniaControl->client->setMaxPlayers($amount);
|
||||
$this->maniaControl->chat->sendSuccess("Changed max players to: {$amount}", $player->login);
|
||||
}
|
||||
|
||||
@ -430,12 +422,7 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
||||
$amount = 0;
|
||||
}
|
||||
|
||||
try {
|
||||
$this->maniaControl->client->setMaxSpectators($amount);
|
||||
} catch(\Exception $e) {
|
||||
$this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $player->login);
|
||||
return;
|
||||
}
|
||||
$this->maniaControl->client->setMaxSpectators($amount);
|
||||
$this->maniaControl->chat->sendSuccess("Changed max spectators to: {$amount}", $player->login);
|
||||
}
|
||||
|
||||
@ -443,16 +430,9 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
||||
* Perform server shutdown
|
||||
*
|
||||
* @param string $login
|
||||
* @return bool
|
||||
*/
|
||||
private function shutdownServer($login = '#') {
|
||||
try {
|
||||
$this->maniaControl->client->stopServer();
|
||||
} catch(\Exception $e) {
|
||||
trigger_error("Server shutdown command from '{login}' failed. " . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
$this->maniaControl->client->stopServer();
|
||||
$this->maniaControl->quit("Server shutdown requested by '{$login}'");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ use ManiaControl\Callbacks\TimerListener;
|
||||
use ManiaControl\Formatter;
|
||||
use ManiaControl\ManiaControl;
|
||||
use ManiaControl\Update\UpdateManager;
|
||||
use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
|
||||
|
||||
/**
|
||||
* Class reports Usage
|
||||
@ -56,18 +57,18 @@ class UsageReporter implements TimerListener {
|
||||
$properties['ServerName'] = Formatter::stripDirtyCodes($this->maniaControl->server->getName());
|
||||
$properties['PlayerCount'] = $this->maniaControl->playerManager->getPlayerCount();
|
||||
|
||||
try {
|
||||
$maxPlayers = $this->maniaControl->client->getMaxPlayers();
|
||||
$properties['MaxPlayers'] = $maxPlayers["CurrentValue"];
|
||||
} catch(\Exception $e) {
|
||||
$properties['MaxPlayers'] = -1;
|
||||
}
|
||||
$maxPlayers = $this->maniaControl->client->getMaxPlayers();
|
||||
$properties['MaxPlayers'] = $maxPlayers["CurrentValue"];
|
||||
|
||||
try {
|
||||
$scriptName = $this->maniaControl->client->getScriptName();
|
||||
$properties['ScriptName'] = $scriptName["CurrentValue"];
|
||||
} catch(\Exception $e) {
|
||||
$properties['ScriptName'] = '';
|
||||
} catch(Exception $e) {
|
||||
if ($e->getMessage() == 'Not in script mode.') {
|
||||
$properties['ScriptName'] = '';
|
||||
} else {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
$json = json_encode($properties);
|
||||
|
@ -4,6 +4,7 @@ use ManiaControl\Commands\CommandListener;
|
||||
use ManiaControl\ManiaControl;
|
||||
use ManiaControl\Players\Player;
|
||||
use ManiaControl\Plugins\Plugin;
|
||||
use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
|
||||
|
||||
/**
|
||||
* ManiaControl Chat-Message Plugin
|
||||
@ -308,10 +309,11 @@ class ChatMessagePlugin implements CommandListener, Plugin {
|
||||
$msg = '$i$ff0 $<' . $player->nickname . '$>$s$39f chooses to boot back to the real world!';
|
||||
$this->maniaControl->chat->sendChat($msg, null, true);
|
||||
|
||||
$message = '$39F Thanks for Playing, please come back soon!$z ';
|
||||
$message = '$39F Thanks for Playing, see you around!$z';
|
||||
try {
|
||||
$this->maniaControl->client->kick($player->login, $message);
|
||||
} catch(\Exception $e) {
|
||||
} catch(Exception $e) {
|
||||
// TODO: only possible valid exception should be "wrong login" - throw others (like connection error)
|
||||
$this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $player->login);
|
||||
return;
|
||||
}
|
||||
@ -330,7 +332,8 @@ class ChatMessagePlugin implements CommandListener, Plugin {
|
||||
$message = '$39F Thanks for Playing, please come back soon!$z ';
|
||||
try {
|
||||
$this->maniaControl->client->kick($player->login, $message);
|
||||
} catch(\Exception $e) {
|
||||
} catch(Exception $e) {
|
||||
// TODO: only possible valid exception should be "wrong login" - throw others (like connection error)
|
||||
$this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $player->login);
|
||||
return;
|
||||
}
|
||||
@ -350,7 +353,8 @@ class ChatMessagePlugin implements CommandListener, Plugin {
|
||||
// force into spec
|
||||
try {
|
||||
$this->maniaControl->client->forceSpectator($player->login, 3);
|
||||
} catch(\Exception $e) {
|
||||
} catch(Exception $e) {
|
||||
// TODO: only possible valid exception should be "wrong login" - throw others (like connection error)
|
||||
$this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $player->login);
|
||||
return;
|
||||
}
|
||||
@ -358,7 +362,8 @@ class ChatMessagePlugin implements CommandListener, Plugin {
|
||||
// free player slot
|
||||
try {
|
||||
$this->maniaControl->client->spectatorReleasePlayerSlot($player->login);
|
||||
} catch(\Exception $e) {
|
||||
} catch(Exception $e) {
|
||||
// TODO: only possible valid exception should be "wrong login" - throw others (like connection error)
|
||||
//to nothing
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ use ManiaControl\Plugins\Plugin;
|
||||
use ManiaControl\Server\Server;
|
||||
use ManiaControl\Server\ServerCommands;
|
||||
use Maniaplanet\DedicatedServer\Structures\VoteRatio;
|
||||
use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
|
||||
|
||||
|
||||
/**
|
||||
@ -260,8 +261,12 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
||||
$itemQuad->setAction(self::ACTION_START_VOTE . 'pausegame');
|
||||
$this->addVoteMenuItem($itemQuad, 10, 'Vote for a pause of Current Game');
|
||||
}
|
||||
} catch(\Exception $e) {
|
||||
//do nothing
|
||||
} catch(Exception $e) {
|
||||
if ($e->getMessage() == 'Not in script mode.') {
|
||||
// Do nothing
|
||||
} else {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
//Menu SkipMap
|
||||
|
@ -16,6 +16,7 @@ use ManiaControl\ManiaControl;
|
||||
use ManiaControl\Players\Player;
|
||||
use ManiaControl\Players\PlayerManager;
|
||||
use ManiaControl\Plugins\Plugin;
|
||||
use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
|
||||
|
||||
/**
|
||||
* Donation plugin
|
||||
@ -335,7 +336,8 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
|
||||
$message = 'Donate ' . $amount . ' Planets to $<' . $receiverName . '$>?';
|
||||
try {
|
||||
$bill = $this->maniaControl->client->sendBill($player->login, $amount, $message, $receiver);
|
||||
} catch(\Exception $e) {
|
||||
} catch(Exception $e) {
|
||||
// TODO: handle errors like 'too few server planets' - throw other like connection errors
|
||||
trigger_error("Couldn't create donation of {$amount} planets from '{$player->login}' for '{$receiver}'. " . $e->getMessage());
|
||||
$this->maniaControl->chat->sendError("Creating donation failed.", $player->login);
|
||||
return false;
|
||||
@ -378,8 +380,8 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
|
||||
|
||||
try {
|
||||
$bill = $this->maniaControl->client->pay($receiver, $amount, $message);
|
||||
} catch(\Exception $e) {
|
||||
trigger_error("Couldn't retrieve server planets. " . $e->getMessage());
|
||||
} catch(Exception $e) {
|
||||
// TODO: handle errors like 'too few server planets' - throw other like connection errors
|
||||
trigger_error("Couldn't create payout of {$amount} planets by '{$player->login}' for '{$receiver}'. " . $e->getMessage());
|
||||
$this->maniaControl->chat->sendError("Creating payout failed.", $player->login);
|
||||
return false;
|
||||
@ -401,13 +403,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
|
||||
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
$planets = $this->maniaControl->client->getServerPlanets();
|
||||
} catch(\Exception $e) {
|
||||
trigger_error("Couldn't retrieve server planets. " . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
$planets = $this->maniaControl->client->getServerPlanets();
|
||||
$message = "This Server has {$planets} Planets!";
|
||||
return $this->maniaControl->chat->sendInformation($message, $player->login);
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ use ManiaControl\Callbacks\CallbackManager;
|
||||
use ManiaControl\Commands\CommandListener;
|
||||
use ManiaControl\Players\Player;
|
||||
use ManiaControl\Plugins\Plugin;
|
||||
use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
|
||||
|
||||
/**
|
||||
* ManiaControl Obstacle Plugin
|
||||
@ -128,8 +129,12 @@ class ObstaclePlugin implements CallbackListener, CommandListener, Plugin {
|
||||
$param = $player->login . ";" . $params[1] . ";";
|
||||
try{
|
||||
$this->maniaControl->client->triggerModeScriptEvent(self::CB_JUMPTO, $param);
|
||||
} catch(\Exception $e){
|
||||
trigger_error("Couldn't send jump callback for '{$player->login}'. " . $e->getMessage());
|
||||
} catch(Exception $e) {
|
||||
if ($e->getMessage() == 'Not in script mode.') {
|
||||
trigger_error("Couldn't send jump callback for '{$player->login}'. " . $e->getMessage());
|
||||
return;
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,7 @@ use ManiaControl\Manialinks\ManialinkPageAnswerListener;
|
||||
use ManiaControl\Players\Player;
|
||||
use ManiaControl\Players\PlayerManager;
|
||||
use ManiaControl\Plugins\Plugin;
|
||||
use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
|
||||
|
||||
/**
|
||||
* Queue plugin
|
||||
@ -289,14 +290,17 @@ class QueuePlugin implements CallbackListener, CommandListener, ManialinkPageAns
|
||||
if($this->maniaControl->client->getMaxPlayers()['CurrentValue'] > (count($this->maniaControl->playerManager->players) - count($this->spectators))) {
|
||||
try {
|
||||
$this->maniaControl->client->forceSpectator($player->login, 2);
|
||||
} catch(\Exception $e) {
|
||||
} catch(Exception $e) {
|
||||
// TODO: only possible valid exception should be "wrong login" - throw others (like connection error)
|
||||
$this->maniaControl->chat->sendError("Error while leaving the Queue", $player->login);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$this->maniaControl->client->forceSpectator($player->login, 0);
|
||||
} catch(\Exception $e) { }
|
||||
} catch(Exception $e) {
|
||||
// TODO: only possible valid exception should be "wrong login" - throw others (like connection error)
|
||||
}
|
||||
|
||||
$teams = array();
|
||||
/** @var Player $player */
|
||||
@ -319,7 +323,9 @@ class QueuePlugin implements CallbackListener, CommandListener, ManialinkPageAns
|
||||
|
||||
try {
|
||||
$this->maniaControl->client->forcePlayerTeam($player->login, $smallestTeam);
|
||||
} catch(\Exception $e) { }
|
||||
} catch(Exception $e) {
|
||||
// TODO: only possible valid exceptions should be "wrong login" or "not in team mode" - throw others (like connection error)
|
||||
}
|
||||
|
||||
if(isset($this->spectators[$player->login])) {
|
||||
unset($this->spectators[$player->login]);
|
||||
|
@ -15,6 +15,7 @@ use ManiaControl\Manialinks\ManialinkPageAnswerListener;
|
||||
use ManiaControl\Players\Player;
|
||||
use ManiaControl\Players\PlayerManager;
|
||||
use ManiaControl\Plugins\Plugin;
|
||||
use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
|
||||
|
||||
class SlotMachinePlugin implements Plugin, CallbackListener, ManialinkPageAnswerListener, TimerListener {
|
||||
/**
|
||||
@ -467,7 +468,8 @@ class SlotMachinePlugin implements Plugin, CallbackListener, ManialinkPageAnswer
|
||||
|
||||
try {
|
||||
$billId = $this->maniaControl->client->pay($player->login, (int)$balance, $message);
|
||||
} catch(\Exception $e) {
|
||||
} catch(Exception $e) {
|
||||
// TODO: handle errors like 'too few server planets' - throw other like connection errors
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user