diff --git a/application/core/ManiaControl.php b/application/core/ManiaControl.php index 5e49ccf5..d0a52a68 100644 --- a/application/core/ManiaControl.php +++ b/application/core/ManiaControl.php @@ -285,9 +285,6 @@ class ManiaControl implements CommandListener { public function run() { $this->log('Starting ManiaControl v' . self::VERSION . '!'); - // Load plugins - $this->pluginManager->loadPlugins(); - // Connect to server $this->connect(); @@ -297,6 +294,9 @@ class ManiaControl implements CommandListener { // OnInit callback $this->callbackManager->triggerCallback(CallbackManager::CB_MC_ONINIT, array(CallbackManager::CB_MC_ONINIT)); + // Load plugins + $this->pluginManager->loadPlugins(); + // Announce ManiaControl $this->chat->sendInformation('ManiaControl v' . self::VERSION . ' successfully started!'); diff --git a/application/plugins/CustomVotes.php b/application/plugins/CustomVotes.php index 69eb01fb..22ecaa2e 100644 --- a/application/plugins/CustomVotes.php +++ b/application/plugins/CustomVotes.php @@ -101,7 +101,6 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP $this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer'); $this->maniaControl->callbackManager->registerCallbackListener(self::CB_CUSTOM_VOTE_FINISHED, $this, 'handleVoteFinished'); - $this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_ONINIT, $this, 'handleOnInit'); $this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERJOINED, $this, 'handlePlayerConnect'); //Settings @@ -127,6 +126,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP $this->defineVote("restartmap", "Restart Map"); $this->defineVote("pausegame", "Pause Game"); + $this->constructMenu(); return true; } @@ -183,7 +183,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP * * @param array $callback */ - public function handleOnInit(array $callback) { + private function constructMenu() { // Menu RestartMap $itemQuad = new Quad_UIConstruction_Buttons(); $itemQuad->setSubStyle($itemQuad::SUBSTYLE_Reload); diff --git a/application/plugins/Donations.php b/application/plugins/Donations.php index a019e984..828bc577 100644 --- a/application/plugins/Donations.php +++ b/application/plugins/Donations.php @@ -66,7 +66,6 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin { // Register for callbacks $this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_BILLUPDATED, $this, 'handleBillUpdated'); - $this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_ONINIT, $this, 'handleOnInit'); $this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERJOINED, $this, 'handlePlayerConnect'); $this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer'); @@ -81,6 +80,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin { $this->maniaControl->settingManager->initSetting($this, self::SETTING_DONATION_VALUES, "20,50,100,500,1000,2000"); $this->maniaControl->settingManager->initSetting($this, self::SETTING_MIN_AMOUNT_SHOWN, 100); + $this->displayWidget(); return true; } @@ -139,11 +139,11 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin { } /** - * Handle ManiaControl OnInit callback + * Handle ManiaControl OnStartup * * @param array $callback */ - public function handleOnInit(array $callback) { + public function displayWidget() { if($this->maniaControl->settingManager->getSetting($this, self::SETTING_DONATE_WIDGET_ACTIVATED)) { $this->displayDonateWidget(); } diff --git a/application/plugins/Karma.php b/application/plugins/Karma.php index ad104ebe..41f81159 100644 --- a/application/plugins/Karma.php +++ b/application/plugins/Karma.php @@ -64,7 +64,6 @@ class KarmaPlugin implements CallbackListener, Plugin { $this->maniaControl->settingManager->initSetting($this, self::SETTING_WIDGET_HEIGHT, 12.); // Register for callbacks - $this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_ONINIT, $this, 'handleOnInit'); $this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_BEGINMAP, $this, 'handleBeginMap'); $this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_1_SECOND, $this, 'handle1Second'); $this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERCONNECT, $this, 'handlePlayerConnect'); @@ -73,6 +72,7 @@ class KarmaPlugin implements CallbackListener, Plugin { // Define player stats $this->maniaControl->statisticManager->defineStatMetaData(self::STAT_PLAYER_MAPVOTES); + $this->updateManialink = true; return true; } @@ -181,15 +181,6 @@ class KarmaPlugin implements CallbackListener, Plugin { } } - /** - * Handle ManiaControl OnInit callback - * - * @param array $callback - */ - public function handleOnInit(array $callback) { - $this->updateManialink = true; - } - /** * Handle BeginMap ManiaControl callback * @@ -233,10 +224,10 @@ class KarmaPlugin implements CallbackListener, Plugin { } $countPositive = substr_count($message, '+'); $countNegative = substr_count($message, '-'); - if ($countPositive <= 0 && $countNegative <= 0) { + if($countPositive <= 0 && $countNegative <= 0) { return; - } - $vote = $countPositive - $countNegative; + } + $vote = $countPositive - $countNegative; $success = $this->handleVote($player, $vote); if(!$success) { $this->maniaControl->chat->sendError('Error occurred.', $player->login); @@ -271,10 +262,10 @@ class KarmaPlugin implements CallbackListener, Plugin { $vote /= $voteHigh; // Save vote - $map = $this->maniaControl->mapManager->getCurrentMap(); + $map = $this->maniaControl->mapManager->getCurrentMap(); $voted = $this->getPlayerVote($player, $map); - if(!$voted){ + if(!$voted) { $this->maniaControl->statisticManager->incrementStat(self::STAT_PLAYER_MAPVOTES, $player, $this->maniaControl->server->index); } diff --git a/application/plugins/WidgetPlugin.php b/application/plugins/WidgetPlugin.php index c21e84cf..cc84106c 100644 --- a/application/plugins/WidgetPlugin.php +++ b/application/plugins/WidgetPlugin.php @@ -86,7 +86,6 @@ class WidgetPlugin implements CallbackListener, Plugin { $this->maniaControl->manialinkManager->customUIManager->setChallengeInfoVisible(false); // Register for callbacks - $this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_ONINIT, $this, 'handleOnInit'); $this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_BEGINMAP, $this, 'handleOnBeginMap'); $this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_ENDMAP, $this, 'handleOnEndMap'); $this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERJOINED, $this, 'handlePlayerConnect'); @@ -116,6 +115,8 @@ class WidgetPlugin implements CallbackListener, Plugin { $this->maniaControl->settingManager->initSetting($this, self::SETTING_CLOCK_WIDGET_POSY, 90 - 11); $this->maniaControl->settingManager->initSetting($this, self::SETTING_CLOCK_WIDGET_WIDTH, 10); $this->maniaControl->settingManager->initSetting($this, self::SETTING_CLOCK_WIDGET_HEIGHT, 5.5); + + $this->displayWidgets(); return true; } @@ -128,11 +129,11 @@ class WidgetPlugin implements CallbackListener, Plugin { } /** - * Handle ManiaControl OnInit callback + * Displays the Widgets onLoad * * @param array $callback */ - public function handleOnInit(array $callback) { + private function displayWidgets() { // Display Map Widget if($this->maniaControl->settingManager->getSetting($this, self::SETTING_MAP_WIDGET_ACTIVATED)) { $this->displayMapWidget();