some todo resolves

This commit is contained in:
kremsy 2014-03-01 11:11:50 +01:00 committed by Steffen Schröder
parent 5dcc8e865c
commit 7c4a038722
15 changed files with 66 additions and 90 deletions

View File

@ -10,6 +10,7 @@ use FML\Controls\Quads\Quad_Icons64x64_1;
use FML\ManiaLink; use FML\ManiaLink;
use FML\Script\Script; use FML\Script\Script;
use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\CallbackListener;
use ManiaControl\Callbacks\CallbackManager;
use ManiaControl\ManiaControl; use ManiaControl\ManiaControl;
use ManiaControl\Manialinks\ManialinkPageAnswerListener; use ManiaControl\Manialinks\ManialinkPageAnswerListener;
use ManiaControl\Players\Player; use ManiaControl\Players\Player;
@ -53,7 +54,7 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
$this->maniaControl->settingManager->initSetting($this, self::SETTING_MENU_ITEMSIZE, 6.); $this->maniaControl->settingManager->initSetting($this, self::SETTING_MENU_ITEMSIZE, 6.);
// Register for callbacks // Register for callbacks
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_ONINIT, $this, 'handleOnInit'); $this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_AFTERINIT, $this, 'handleAfterInit');
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerJoined'); $this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerJoined');
$this->maniaControl->callbackManager->registerCallbackListener(AuthenticationManager::CB_AUTH_LEVEL_CHANGED, $this, 'handlePlayerJoined'); $this->maniaControl->callbackManager->registerCallbackListener(AuthenticationManager::CB_AUTH_LEVEL_CHANGED, $this, 'handlePlayerJoined');
} }
@ -122,9 +123,9 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
} }
/** /**
* Handle ManiaControl OnInit callback * Handle ManiaControl AfterInit callback
*/ */
public function handleOnInit() { public function handleAfterInit() {
$this->initCompleted = true; $this->initCompleted = true;
$this->rebuildAndShowMenu(); $this->rebuildAndShowMenu();
} }

View File

@ -2,7 +2,6 @@
namespace ManiaControl; namespace ManiaControl;
use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
/** /**
* Chat utility class * Chat utility class
* *
@ -68,16 +67,11 @@ class Chat {
return false; return false;
} }
$chatMessage = '$z$<' . $this->getPrefix($prefix) . $message . '$>$z'; $chatMessage = '$z$<' . $this->getPrefix($prefix) . $message . '$>$z';
try {
if ($login === null) { if ($login === null) {
$this->maniaControl->client->chatSendServerMessage($chatMessage); $this->maniaControl->client->chatSendServerMessage($chatMessage);
} else { } else {
$this->maniaControl->client->chatSendServerMessage($chatMessage, $login); $this->maniaControl->client->chatSendServerMessage($chatMessage, $login);
} }
} 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; return true;
} }

View File

@ -6,6 +6,7 @@ use FML\Controls\Frame;
use FML\Controls\Quad; use FML\Controls\Quad;
use FML\ManiaLink; use FML\ManiaLink;
use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\CallbackListener;
use ManiaControl\Callbacks\CallbackManager;
use ManiaControl\ManiaControl; use ManiaControl\ManiaControl;
use ManiaControl\Players\PlayerManager; use ManiaControl\Players\PlayerManager;
use ManiaControl\Players\Player; use ManiaControl\Players\Player;
@ -47,7 +48,7 @@ class IconManager implements CallbackListener {
$this->addDefaultIcons(); $this->addDefaultIcons();
// Register for callbacks // Register for callbacks
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_ONINIT, $this, 'handleOnInit'); $this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_AFTERINIT, $this, 'handleAfterInit');
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerConnect'); $this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerConnect');
} }
@ -88,7 +89,7 @@ class IconManager implements CallbackListener {
/** /**
* Handle OnInit Callback * Handle OnInit Callback
*/ */
public function handleOnInit() { public function handleAfterInit() {
$this->preloadIcons(); $this->preloadIcons();
} }

View File

@ -11,7 +11,6 @@ use ManiaControl\ManiaControl;
use ManiaControl\Manialinks\IconManager; use ManiaControl\Manialinks\IconManager;
use ManiaControl\Manialinks\ManialinkPageAnswerListener; use ManiaControl\Manialinks\ManialinkPageAnswerListener;
use ManiaControl\Players\Player; use ManiaControl\Players\Player;
use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
/** /**
* Class offering commands to manage maps * Class offering commands to manage maps
@ -105,14 +104,8 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
$map = $nextQueued[1]; $map = $nextQueued[1];
$this->maniaControl->chat->sendInformation("Next map is $<" . $map->name . "$> from $<" . $map->authorNick . "$> requested by $<" . $requester->nickname . "$>.", $player->login); $this->maniaControl->chat->sendInformation("Next map is $<" . $map->name . "$> from $<" . $map->authorNick . "$> requested by $<" . $requester->nickname . "$>.", $player->login);
} else { } else {
try {
$mapIndex = $this->maniaControl->client->getNextMapIndex(); $mapIndex = $this->maniaControl->client->getNextMapIndex();
} 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;
}
$maps = $this->maniaControl->mapManager->getMaps(); $maps = $this->maniaControl->mapManager->getMaps();
$map = $maps[$mapIndex]; $map = $maps[$mapIndex];
$this->maniaControl->chat->sendInformation("Next map is $<" . $map->name . "$> from $<" . $map->authorNick . "$>.", $player->login); $this->maniaControl->chat->sendInformation("Next map is $<" . $map->name . "$> from $<" . $map->authorNick . "$>.", $player->login);
@ -190,13 +183,7 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
return; return;
} }
try {
$this->maniaControl->client->nextMap(); $this->maniaControl->client->nextMap();
} 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;
}
$message = '$<' . $player->nickname . '$> skipped the current Map!'; $message = '$<' . $player->nickname . '$> skipped the current Map!';
$this->maniaControl->chat->sendSuccess($message); $this->maniaControl->chat->sendSuccess($message);
@ -217,12 +204,8 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
$message = '$<' . $player->nickname . '$> restarted the current Map!'; $message = '$<' . $player->nickname . '$> restarted the current Map!';
$this->maniaControl->chat->sendSuccess($message); $this->maniaControl->chat->sendSuccess($message);
$this->maniaControl->log($message, true); $this->maniaControl->log($message, true);
try {
$this->maniaControl->client->restartMap(); $this->maniaControl->client->restartMap();
} catch(Exception $e) {
// TODO: is it even possible that an exception other than connection errors will be thrown? - remove try-catch?
//do nothing
}
} }
/** /**

View File

@ -545,23 +545,21 @@ class MapManager implements CallbackListener {
public function addMapFromMx($mapId, $login, $update = false) { public function addMapFromMx($mapId, $login, $update = false) {
if (is_numeric($mapId)) { if (is_numeric($mapId)) {
// Check if map exists // Check if map exists
$this->maniaControl->mapManager->mxManager->getMapInfo($mapId, function (MXMapInfo $mapInfo) use ($login) { $this->maniaControl->mapManager->mxManager->getMapInfo($mapId, function (MXMapInfo $mapInfo) use (&$login, &$update) {
if (!$mapInfo || !isset($mapInfo->uploaded)) { if (!$mapInfo || !isset($mapInfo->uploaded)) {
// Invalid id // Invalid id
$this->maniaControl->chat->sendError('Invalid MX-Id!', $login); $this->maniaControl->chat->sendError('Invalid MX-Id!', $login);
return; return;
} }
//Download the file //Download the file
$function = function ($file, $error) use (&$login, &$mapInfo, &$mapDir, &$update) { $this->maniaControl->fileReader->loadFile($mapInfo->downloadurl, function ($file, $error) use (&$login, &$mapInfo, &$mapDir, &$update) {
if (!$file) { if (!$file) {
// Download error // Download error
$this->maniaControl->chat->sendError('Download failed!', $login); $this->maniaControl->chat->sendError('Download failed!', $login);
return; return;
} }
$this->processMapFile($file, $mapInfo, $mapDir, $login, $update); $this->processMapFile($file, $mapInfo, $mapDir, $login, $update);
}; });
$this->maniaControl->fileReader->loadFile($mapInfo->downloadurl, $function);
}); });
} }
} }

View File

@ -87,6 +87,7 @@ class PlayerActions {
$this->maniaControl->client->forceSpectator($target->login, self::SPECTATOR_PLAYER); $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) // TODO: only possible valid exception should be "wrong login" - throw others (like connection error)
$this->maniaControl->errorHandler->triggerDebugNotice("PlayerActions Debug Line 90: " . $e->getMessage());
$this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $admin->login); $this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $admin->login);
return; return;
} }
@ -96,6 +97,7 @@ class PlayerActions {
$this->maniaControl->client->forceSpectator($target->login, self::SPECTATOR_USER_SELECTABLE); $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) // TODO: only possible valid exception should be "wrong login" - throw others (like connection error)
$this->maniaControl->errorHandler->triggerDebugNotice("PlayerActions Debug Line 100: " . $e->getMessage());
$this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $admin->login); $this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $admin->login);
return; return;
} }
@ -178,6 +180,7 @@ class PlayerActions {
try { try {
$this->maniaControl->client->spectatorReleasePlayerSlot($target->login); $this->maniaControl->client->spectatorReleasePlayerSlot($target->login);
} catch(Exception $e) { } catch(Exception $e) {
$this->maniaControl->errorHandler->triggerDebugNotice("PlayerActions Debug Line 183: " . $e->getMessage());
// TODO: only possible valid exception should be "wrong login" - throw others (like connection error) // TODO: only possible valid exception should be "wrong login" - throw others (like connection error)
//do nothing //do nothing
} }
@ -348,6 +351,7 @@ class PlayerActions {
} }
} catch(Exception $e) { } catch(Exception $e) {
// TODO: only possible valid exception should be "wrong login" - throw others (like connection error) // TODO: only possible valid exception should be "wrong login" - throw others (like connection error)
$this->maniaControl->errorHandler->triggerDebugNotice("PlayerActions Debug Line 354: " . $e->getMessage());
$this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $admin->login); $this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $admin->login);
return; return;
} }

View File

@ -107,6 +107,7 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
try { try {
$this->maniaControl->client->autoTeamBalance(); $this->maniaControl->client->autoTeamBalance();
} catch(Exception $e) { } catch(Exception $e) {
$this->maniaControl->errorHandler->triggerDebugNotice("PlayerCommands Debug Line 110: " . $e->getMessage());
// TODO: only catch 'not in team mode' exception - throw others (like connection error) // TODO: only catch 'not in team mode' exception - throw others (like connection error)
$this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $player->login); $this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $player->login);
return; return;

View File

@ -650,6 +650,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
$this->maniaControl->client->forceSpectator($adminLogin, PlayerActions::SPECTATOR_BUT_KEEP_SELECTABLE); $this->maniaControl->client->forceSpectator($adminLogin, PlayerActions::SPECTATOR_BUT_KEEP_SELECTABLE);
$this->maniaControl->client->forceSpectatorTarget($adminLogin, $targetLogin, 1); $this->maniaControl->client->forceSpectatorTarget($adminLogin, $targetLogin, 1);
} catch(Exception $e) { } catch(Exception $e) {
$this->maniaControl->errorHandler->triggerDebugNotice("PlayerList Debug Line 653: " . $e->getMessage());
// TODO: only possible valid exception should be "wrong login" - throw others (like connection error) // TODO: only possible valid exception should be "wrong login" - throw others (like connection error)
} }
break; break;
@ -724,6 +725,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
} catch(Exception $e) { } catch(Exception $e) {
//do nothing //do nothing
// TODO: only possible valid exception should be "wrong login" - throw others (like connection error) // TODO: only possible valid exception should be "wrong login" - throw others (like connection error)
$this->maniaControl->errorHandler->triggerDebugNotice("PlayerList Debug Line 727: " . $e->getMessage());
} }
}); });
break; break;
@ -747,6 +749,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
try { try {
$this->maniaControl->client->kick($target->login, $message); $this->maniaControl->client->kick($target->login, $message);
} catch(Exception $e) { } catch(Exception $e) {
$this->maniaControl->errorHandler->triggerDebugNotice("PlayerList Debug Line 751: " . $e->getMessage());
// TODO: only possible valid exception should be "wrong login" - throw others (like connection error) // TODO: only possible valid exception should be "wrong login" - throw others (like connection error)
$this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $target->login); $this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $target->login);
return; return;

View File

@ -20,7 +20,6 @@ class PlayerManager implements CallbackListener {
*/ */
const CB_PLAYERCONNECT = 'PlayerManagerCallback.PlayerConnect'; const CB_PLAYERCONNECT = 'PlayerManagerCallback.PlayerConnect';
const CB_PLAYERDISCONNECT = 'PlayerManagerCallback.PlayerDisconnect'; const CB_PLAYERDISCONNECT = 'PlayerManagerCallback.PlayerDisconnect';
const CB_ONINIT = 'PlayerManagerCallback.OnInit';
const CB_PLAYERINFOCHANGED = 'PlayerManagerCallback.PlayerInfoChanged'; const CB_PLAYERINFOCHANGED = 'PlayerManagerCallback.PlayerInfoChanged';
const TABLE_PLAYERS = 'mc_players'; const TABLE_PLAYERS = 'mc_players';
const SETTING_JOIN_LEAVE_MESSAGES = 'Enable Join & Leave Messages'; const SETTING_JOIN_LEAVE_MESSAGES = 'Enable Join & Leave Messages';
@ -135,10 +134,6 @@ class PlayerManager implements CallbackListener {
$player->hasJoinedGame = true; $player->hasJoinedGame = true;
$this->addPlayer($player); $this->addPlayer($player);
} }
// Trigger own callback
// TODO: what for?
$this->maniaControl->callbackManager->triggerCallback(self::CB_ONINIT);
} }
/** /**

View File

@ -30,14 +30,14 @@ class RankingManager implements CallbackListener {
* *
* @param \ManiaControl\ManiaControl $maniaControl * @param \ManiaControl\ManiaControl $maniaControl
*/ */
public function __construct(ManiaControl $maniaControl) { //TODO statistic wins public function __construct(ManiaControl $maniaControl) {
$this->maniaControl = $maniaControl; $this->maniaControl = $maniaControl;
//Register Callbacks //Register Callbacks
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_MODESCRIPTCALLBACK, $this, 'handleCallbacks'); $this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_MODESCRIPTCALLBACK, $this, 'handleCallbacks');
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_MODESCRIPTCALLBACKARRAY, $this, 'handleCallbacks'); $this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_MODESCRIPTCALLBACKARRAY, $this, 'handleCallbacks');
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_ONINIT, $this, 'onInit'); $this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_ONINIT, $this, 'onInit');
//TODO won message at end of the map (disable as setting) //TODO won message at end of the map (disable as setting) (and public announce only all %50 (setting) players)
} }
/** /**

View File

@ -60,7 +60,7 @@ class StatisticCollector implements CallbackListener {
* *
* @param \ManiaControl\ManiaControl $maniaControl * @param \ManiaControl\ManiaControl $maniaControl
*/ */
public function __construct(ManiaControl $maniaControl) { //TODO statistic wins public function __construct(ManiaControl $maniaControl) {
$this->maniaControl = $maniaControl; $this->maniaControl = $maniaControl;
//Register Callbacks //Register Callbacks

View File

@ -313,6 +313,7 @@ class ChatMessagePlugin implements CommandListener, Plugin {
try { try {
$this->maniaControl->client->kick($player->login, $message); $this->maniaControl->client->kick($player->login, $message);
} catch(Exception $e) { } catch(Exception $e) {
$this->maniaControl->errorHandler->triggerDebugNotice("ChatMessagePlugin Debug Line 316: " . $e->getMessage());
// TODO: only possible valid exception should be "wrong login" - throw others (like connection error) // TODO: only possible valid exception should be "wrong login" - throw others (like connection error)
$this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $player->login); $this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $player->login);
return; return;
@ -333,6 +334,7 @@ class ChatMessagePlugin implements CommandListener, Plugin {
try { try {
$this->maniaControl->client->kick($player->login, $message); $this->maniaControl->client->kick($player->login, $message);
} catch(Exception $e) { } catch(Exception $e) {
$this->maniaControl->errorHandler->triggerDebugNotice("ChatMessagePlugin Debug Line " . $e->getLine() . ": " . $e->getMessage());
// TODO: only possible valid exception should be "wrong login" - throw others (like connection error) // TODO: only possible valid exception should be "wrong login" - throw others (like connection error)
$this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $player->login); $this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $player->login);
return; return;
@ -354,6 +356,7 @@ class ChatMessagePlugin implements CommandListener, Plugin {
try { try {
$this->maniaControl->client->forceSpectator($player->login, 3); $this->maniaControl->client->forceSpectator($player->login, 3);
} catch(Exception $e) { } catch(Exception $e) {
$this->maniaControl->errorHandler->triggerDebugNotice("ChatMessagePlugin Debug Line " . $e->getLine() . ": " . $e->getMessage());
// TODO: only possible valid exception should be "wrong login" - throw others (like connection error) // TODO: only possible valid exception should be "wrong login" - throw others (like connection error)
$this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $player->login); $this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $player->login);
return; return;
@ -363,6 +366,7 @@ class ChatMessagePlugin implements CommandListener, Plugin {
try { try {
$this->maniaControl->client->spectatorReleasePlayerSlot($player->login); $this->maniaControl->client->spectatorReleasePlayerSlot($player->login);
} catch(Exception $e) { } catch(Exception $e) {
$this->maniaControl->errorHandler->triggerDebugNotice("ChatMessagePlugin Debug Line " . $e->getLine() . ": " . $e->getMessage());
// TODO: only possible valid exception should be "wrong login" - throw others (like connection error) // TODO: only possible valid exception should be "wrong login" - throw others (like connection error)
//to nothing //to nothing
} }
@ -386,7 +390,7 @@ class ChatMessagePlugin implements CommandListener, Plugin {
$pid++; $pid++;
} }
if ($login == 'lj') { if ($login == 'lj' && $pid > 1) {
return $player->nickname; return $player->nickname;
} }
@ -435,6 +439,6 @@ class ChatMessagePlugin implements CommandListener, Plugin {
* @return string * @return string
*/ */
public static function getDescription() { public static function getDescription() {
return null; return "Plugin offers various Chat-Commands like /gg /hi /afk /rq...";
} }
} }

View File

@ -1,10 +1,7 @@
<?php <?php
use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\CallbackListener;
use ManiaControl\Callbacks\CallbackManager;
use ManiaControl\Commands\CommandListener; use ManiaControl\Commands\CommandListener;
use ManiaControl\ManiaControl; use ManiaControl\ManiaControl;
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
use ManiaControl\Manialinks\ManialinkManager;
use ManiaControl\Players\Player; use ManiaControl\Players\Player;
use ManiaControl\Players\PlayerManager; use ManiaControl\Players\PlayerManager;
use ManiaControl\Plugins\Plugin; use ManiaControl\Plugins\Plugin;
@ -26,6 +23,7 @@ class DynamicPointlimitPlugin implements CallbackListener, CommandListener, Plug
const DYNPNT_OFFSET = 'Pointlimit offset'; const DYNPNT_OFFSET = 'Pointlimit offset';
const DYNPNT_MIN = 'Minimum pointlimit'; const DYNPNT_MIN = 'Minimum pointlimit';
const DYNPNT_MAX = 'Maximum pointlimit'; const DYNPNT_MAX = 'Maximum pointlimit';
const ACCEPT_OTHER_MODES = 'Activate in Other mode as Royal';
/** /**
* Prepares the Plugin * Prepares the Plugin
@ -34,7 +32,11 @@ class DynamicPointlimitPlugin implements CallbackListener, CommandListener, Plug
* @return mixed * @return mixed
*/ */
public static function prepare(ManiaControl $maniaControl) { public static function prepare(ManiaControl $maniaControl) {
// TODO: Implement prepare() method. $maniaControl->settingManager->initSetting(get_class(), self::ACCEPT_OTHER_MODES, false);
$maniaControl->settingManager->initSetting(get_class(), self::DYNPNT_MULTIPLIER, 10);
$maniaControl->settingManager->initSetting(get_class(), self::DYNPNT_OFFSET, 0);
$maniaControl->settingManager->initSetting(get_class(), self::DYNPNT_MIN, 30);
$maniaControl->settingManager->initSetting(get_class(), self::DYNPNT_MAX, 200);
} }
/** /**
@ -56,13 +58,9 @@ class DynamicPointlimitPlugin implements CallbackListener, CommandListener, Plug
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'changePointlimit'); $this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'changePointlimit');
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERDISCONNECT, $this, 'changePointlimit'); $this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERDISCONNECT, $this, 'changePointlimit');
$this->maniaControl->settingManager->initSetting($this, self::DYNPNT_MULTIPLIER, 10); $allowOthers = $this->maniaControl->settingManager->getSetting($this, self::ACCEPT_OTHER_MODES);
$this->maniaControl->settingManager->initSetting($this, self::DYNPNT_OFFSET, 0); if (!$allowOthers && $this->maniaControl->server->titleId != 'SMStormRoyal@nadeolabs') {
$this->maniaControl->settingManager->initSetting($this, self::DYNPNT_MIN, 30); $error = 'This plugin only supports Royal (check Settings)!';
$this->maniaControl->settingManager->initSetting($this, self::DYNPNT_MAX, 200);
if($this->maniaControl->server->titleId != 'SMStormRoyal@nadeolabs') {
$error = 'This plugin only supports Royal!';
throw new Exception($error); throw new Exception($error);
} }
} }
@ -74,7 +72,7 @@ class DynamicPointlimitPlugin implements CallbackListener, CommandListener, Plug
$this->maniaControl->manialinkManager->unregisterManialinkPageAnswerListener($this); $this->maniaControl->manialinkManager->unregisterManialinkPageAnswerListener($this);
$this->maniaControl->callbackManager->unregisterCallbackListener($this); $this->maniaControl->callbackManager->unregisterCallbackListener($this);
$this->maniaControl = null; unset($this->maniaControl);
} }
/** /**
@ -133,7 +131,7 @@ class DynamicPointlimitPlugin implements CallbackListener, CommandListener, Plug
/** @var Player $player */ /** @var Player $player */
foreach($this->maniaControl->playerManager->getPlayers() as $player) { foreach($this->maniaControl->playerManager->getPlayers() as $player) {
if($player->isSpectator) { if ($player->isSpectator) {
$numberOfSpectators++; $numberOfSpectators++;
} else { } else {
$numberOfPlayers++; $numberOfPlayers++;
@ -144,10 +142,12 @@ class DynamicPointlimitPlugin implements CallbackListener, CommandListener, Plug
$min_value = $this->maniaControl->settingManager->getSetting($this, self::DYNPNT_MIN); $min_value = $this->maniaControl->settingManager->getSetting($this, self::DYNPNT_MIN);
$max_value = $this->maniaControl->settingManager->getSetting($this, self::DYNPNT_MAX); $max_value = $this->maniaControl->settingManager->getSetting($this, self::DYNPNT_MAX);
if($pointlimit < $min_value) if ($pointlimit < $min_value) {
$pointlimit = $min_value; $pointlimit = $min_value;
if($pointlimit > $max_value) }
if ($pointlimit > $max_value) {
$pointlimit = $max_value; $pointlimit = $max_value;
}
$this->maniaControl->client->setModeScriptSettings(array('S_MapPointsLimit' => $pointlimit)); $this->maniaControl->client->setModeScriptSettings(array('S_MapPointsLimit' => $pointlimit));
} }

View File

@ -203,7 +203,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
// Loop players // Loop players
foreach($players as $login => $player) { foreach($players as $login => $player) {
// Get player vote // Get player vote
$vote = $this->getPlayerVote($player, $map); //TODO what is this for, vote nowhere used? //$vote = $this->getPlayerVote($player, $map); //TODO what is this for, vote nowhere used?
// Adjust manialink for player's vote // Adjust manialink for player's vote
$votesFrame = $this->manialink->votesFrame; $votesFrame = $this->manialink->votesFrame;

View File

@ -6,7 +6,6 @@ use FML\Controls\Quad;
use FML\Controls\Quads\Quad_Icons64x64_1; use FML\Controls\Quads\Quad_Icons64x64_1;
use FML\ManiaLink; use FML\ManiaLink;
use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\CallbackListener;
use ManiaControl\Callbacks\CallbackManager;
use ManiaControl\Callbacks\TimerListener; use ManiaControl\Callbacks\TimerListener;
use ManiaControl\Commands\CommandListener; use ManiaControl\Commands\CommandListener;
use ManiaControl\ManiaControl; use ManiaControl\ManiaControl;
@ -52,13 +51,19 @@ class TeamSpeakPlugin implements CallbackListener, CommandListener, ManialinkPag
private $refreshInterval = 90; private $refreshInterval = 90;
/** /**
* Prepares the Plugin * Prepares the Plugin (Init Settings)
* *
* @param ManiaControl $maniaControl * @param ManiaControl $maniaControl
* @return mixed * @return mixed
*/ */
public static function prepare(ManiaControl $maniaControl) { public static function prepare(ManiaControl $maniaControl) {
// TODO: Implement prepare() method. $maniaControl->settingManager->initSetting(get_class(), self::TEAMSPEAK_SID, 1);
$maniaControl->settingManager->initSetting(get_class(), self::TEAMSPEAK_SERVERHOST, 'ts3.somehoster.com');
$maniaControl->settingManager->initSetting(get_class(), self::TEAMSPEAK_SERVERPORT, 9987);
$maniaControl->settingManager->initSetting(get_class(), self::TEAMSPEAK_QUERYHOST, '');
$maniaControl->settingManager->initSetting(get_class(), self::TEAMSPEAK_QUERYPORT, 10011);
$maniaControl->settingManager->initSetting(get_class(), self::TEAMSPEAK_QUERYUSER, '');
$maniaControl->settingManager->initSetting(get_class(), self::TEAMSPEAK_QUERYPASS, '');
} }
/** /**
@ -69,7 +74,6 @@ class TeamSpeakPlugin implements CallbackListener, CommandListener, ManialinkPag
*/ */
public function load(ManiaControl $maniaControl) { public function load(ManiaControl $maniaControl) {
$this->maniaControl = $maniaControl; $this->maniaControl = $maniaControl;
$this->addConfigs();
$this->checkConfig(); $this->checkConfig();
$this->refreshTime = time(); $this->refreshTime = time();
@ -82,18 +86,6 @@ class TeamSpeakPlugin implements CallbackListener, CommandListener, ManialinkPag
$this->addToMenu(); $this->addToMenu();
} }
/**
* Function used to add the configuration options to the settings manager.
*/
private function addConfigs() {
$this->maniaControl->settingManager->initSetting($this, self::TEAMSPEAK_SID, 1);
$this->maniaControl->settingManager->initSetting($this, self::TEAMSPEAK_SERVERHOST, 'ts3.somehoster.com');
$this->maniaControl->settingManager->initSetting($this, self::TEAMSPEAK_SERVERPORT, 9987);
$this->maniaControl->settingManager->initSetting($this, self::TEAMSPEAK_QUERYHOST, '');
$this->maniaControl->settingManager->initSetting($this, self::TEAMSPEAK_QUERYPORT, 10011);
$this->maniaControl->settingManager->initSetting($this, self::TEAMSPEAK_QUERYUSER, '');
$this->maniaControl->settingManager->initSetting($this, self::TEAMSPEAK_QUERYPASS, '');
}
/** /**
* Function used to check certain configuration options to check if they can be used. * Function used to check certain configuration options to check if they can be used.