changed direct public access of maniacontrol properties to using getter methods

This commit is contained in:
Steffen Schröder
2014-08-03 01:34:18 +02:00
parent e560919096
commit 4d3dc92ad5
64 changed files with 2337 additions and 2055 deletions

View File

@ -38,12 +38,12 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis
public function __construct(ManiaControl $maniaControl) {
$this->maniaControl = $maniaControl;
// Register for callbacks
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer');
// Callbacks
$this->maniaControl->getCallbackManager()->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer');
// Register for chat commands
$this->maniaControl->commandManager->registerCommandListener('checkpluginsupdate', $this, 'handle_CheckPluginsUpdate', true, 'Check for Plugin Updates.');
$this->maniaControl->commandManager->registerCommandListener('pluginsupdate', $this, 'handle_PluginsUpdate', true, 'Perform the Plugin Updates.');
// Chat commands
$this->maniaControl->getCommandManager()->registerCommandListener('checkpluginsupdate', $this, 'handle_CheckPluginsUpdate', true, 'Check for Plugin Updates.');
$this->maniaControl->getCommandManager()->registerCommandListener('pluginsupdate', $this, 'handle_PluginsUpdate', true, 'Perform the Plugin Updates.');
}
/**
@ -53,8 +53,8 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis
* @param Player $player
*/
public function handle_CheckPluginsUpdate(array $chatCallback, Player $player) {
if (!$this->maniaControl->authenticationManager->checkPermission($player, UpdateManager::SETTING_PERMISSION_UPDATECHECK)) {
$this->maniaControl->authenticationManager->sendNotAllowed($player);
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, UpdateManager::SETTING_PERMISSION_UPDATECHECK)) {
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
return;
}
@ -69,22 +69,22 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis
public function checkPluginsUpdate(Player $player = null) {
$message = 'Checking Plugins for newer Versions...';
if ($player) {
$this->maniaControl->chat->sendInformation($message, $player);
$this->maniaControl->getChat()->sendInformation($message, $player);
}
$this->maniaControl->log($message);
$this->maniaControl->pluginManager->fetchPluginList(function ($data, $error) use (&$player) {
$this->maniaControl->getPluginManager()->fetchPluginList(function ($data, $error) use (&$player) {
if (!$data || $error) {
$message = 'Error while checking Plugins for newer Versions!';
if ($player) {
$this->maniaControl->chat->sendError($message, $player);
$this->maniaControl->getChat()->sendError($message, $player);
}
$this->maniaControl->log($message);
return;
}
$pluginsData = $this->parsePluginsData($data);
$pluginClasses = $this->maniaControl->pluginManager->getPluginClasses();
$pluginClasses = $this->maniaControl->getPluginManager()->getPluginClasses();
$pluginUpdates = array();
foreach ($pluginClasses as $pluginClass) {
@ -100,7 +100,7 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis
$pluginUpdates[$pluginId] = $pluginData;
$message = "There is an Update of '{$pluginData->pluginName}' available! ('{$pluginClass}' - Version {$pluginData->version})";
if ($player) {
$this->maniaControl->chat->sendSuccess($message, $player);
$this->maniaControl->getChat()->sendSuccess($message, $player);
}
$this->maniaControl->log($message);
}
@ -109,14 +109,14 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis
if (empty($pluginUpdates)) {
$message = 'Plugins Update Check completed: All Plugins are up-to-date!';
if ($player) {
$this->maniaControl->chat->sendSuccess($message, $player);
$this->maniaControl->getChat()->sendSuccess($message, $player);
}
$this->maniaControl->log($message);
} else {
$updatesCount = count($pluginUpdates);
$message = "Plugins Update Check completed: There are {$updatesCount} Updates available!";
if ($player) {
$this->maniaControl->chat->sendSuccess($message, $player);
$this->maniaControl->getChat()->sendSuccess($message, $player);
}
$this->maniaControl->log($message);
}
@ -148,8 +148,8 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis
* @param Player $player
*/
public function handle_PluginsUpdate(array $chatCallback, Player $player) {
if (!$this->maniaControl->authenticationManager->checkPermission($player, UpdateManager::SETTING_PERMISSION_UPDATE)) {
$this->maniaControl->authenticationManager->sendNotAllowed($player);
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, UpdateManager::SETTING_PERMISSION_UPDATE)) {
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
return;
}
@ -166,7 +166,7 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis
if (empty($pluginsUpdates)) {
$message = 'There are no Plugin Updates available!';
if ($player) {
$this->maniaControl->chat->sendInformation($message, $player);
$this->maniaControl->getChat()->sendInformation($message, $player);
}
$this->maniaControl->log($message);
return;
@ -174,15 +174,15 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis
$message = "Starting Plugins Updating...";
if ($player) {
$this->maniaControl->chat->sendInformation($message, $player);
$this->maniaControl->getChat()->sendInformation($message, $player);
}
$this->maniaControl->log($message);
$performBackup = $this->maniaControl->settingManager->getSettingValue($this->maniaControl->updateManager, UpdateManager::SETTING_PERFORM_BACKUPS);
$performBackup = $this->maniaControl->getSettingManager()->getSettingValue($this->maniaControl->getUpdateManager(), UpdateManager::SETTING_PERFORM_BACKUPS);
if ($performBackup && !BackupUtil::performPluginsBackup()) {
$message = 'Creating Backup before Plugins Update failed!';
if ($player) {
$this->maniaControl->chat->sendError($message, $player);
$this->maniaControl->getChat()->sendError($message, $player);
}
$this->maniaControl->log($message);
}
@ -209,7 +209,7 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis
$pluginsUpdates = $this->parsePluginsData($pluginData);
$updates = array();
$pluginClasses = $this->maniaControl->pluginManager->getPluginClasses();
$pluginClasses = $this->maniaControl->getPluginManager()->getPluginClasses();
foreach ($pluginClasses as $pluginClass) {
/** @var Plugin $pluginClass */
$pluginId = $pluginClass::getId();
@ -237,13 +237,13 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis
* @param bool $update
*/
private function installPlugin(PluginUpdateData $pluginUpdateData, Player $player = null, $update = false) {
$this->maniaControl->fileReader->loadFile($pluginUpdateData->url, function ($updateFileContent, $error) use (
$this->maniaControl->getFileReader()->loadFile($pluginUpdateData->url, function ($updateFileContent, $error) use (
&$pluginUpdateData, &$player, &$update
) {
if (!$updateFileContent || $error) {
$message = "Error loading Update Data for '{$pluginUpdateData->pluginName}': {$error}!";
if ($player) {
$this->maniaControl->chat->sendInformation($message, $player);
$this->maniaControl->getChat()->sendInformation($message, $player);
}
$this->maniaControl->log($message);
return;
@ -255,7 +255,7 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis
$message = "Now {$actionVerb} '{$pluginUpdateData->pluginName}'...";
if ($player) {
$this->maniaControl->chat->sendInformation($message, $player);
$this->maniaControl->getChat()->sendInformation($message, $player);
}
$this->maniaControl->log($message);
@ -266,7 +266,7 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis
if (!$bytes || $bytes <= 0) {
$message = "Plugin {$actionNoun} failed: Couldn't save {$actionNoun} Zip!";
if ($player) {
$this->maniaControl->chat->sendError($message, $player);
$this->maniaControl->getChat()->sendError($message, $player);
}
trigger_error($message);
return;
@ -277,7 +277,7 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis
if ($result !== true) {
$message = "Plugin {$actionNoun} failed: Couldn't open {$actionNoun} Zip! ({$result})";
if ($player) {
$this->maniaControl->chat->sendError($message, $player);
$this->maniaControl->getChat()->sendError($message, $player);
}
trigger_error($message);
return;
@ -294,26 +294,26 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis
}
$message = "Successfully {$actionVerbDone} '{$pluginUpdateData->pluginName}'!{$messageExtra}";
if ($player) {
$this->maniaControl->chat->sendSuccess($message, $player);
$this->maniaControl->getChat()->sendSuccess($message, $player);
}
$this->maniaControl->log($message);
if (!$update) {
$newPluginClasses = $this->maniaControl->pluginManager->loadPlugins();
$newPluginClasses = $this->maniaControl->getPluginManager()->loadPlugins();
if (empty($newPluginClasses)) {
$message = "Loading fresh installed Plugin '{$pluginUpdateData->pluginName}' failed!";
if ($player) {
$this->maniaControl->chat->sendError($message, $player);
$this->maniaControl->getChat()->sendError($message, $player);
}
$this->maniaControl->log($message);
} else {
$message = "Successfully loaded fresh installed Plugin '{$pluginUpdateData->pluginName}'!";
if ($player) {
$this->maniaControl->chat->sendSuccess($message, $player);
$this->maniaControl->getChat()->sendSuccess($message, $player);
}
$this->maniaControl->log($message);
$this->maniaControl->configurator->showMenu($player, InstallMenu::getTitle());
$this->maniaControl->getConfigurator()->showMenu($player, InstallMenu::getTitle());
}
}
});
@ -333,7 +333,7 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis
}
$login = $callback[1][1];
$player = $this->maniaControl->playerManager->getPlayer($login);
$player = $this->maniaControl->getPlayerManager()->getPlayer($login);
if ($update) {
$pluginClass = substr($actionId, strlen(PluginMenu::ACTION_PREFIX_UPDATEPLUGIN));
@ -345,24 +345,24 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis
$this->installPlugin($pluginUpdateData, $player, true);
} else {
$message = 'Error loading Plugin Update Data!';
$this->maniaControl->chat->sendError($message, $player);
$this->maniaControl->getChat()->sendError($message, $player);
}
}
} else {
$pluginId = substr($actionId, strlen(InstallMenu::ACTION_PREFIX_INSTALL_PLUGIN));
$url = ManiaControl::URL_WEBSERVICE . 'plugins/' . $pluginId;
$this->maniaControl->fileReader->loadFile($url, function ($data, $error) use (&$player) {
$this->maniaControl->getFileReader()->loadFile($url, function ($data, $error) use (&$player) {
if ($error || !$data) {
$message = "Error loading Plugin Install Data! {$error}";
$this->maniaControl->chat->sendError($message, $player);
$this->maniaControl->getChat()->sendError($message, $player);
return;
}
$data = json_decode($data);
if (!$data) {
$message = "Error loading Plugin Install Data! {$error}";
$this->maniaControl->chat->sendError($message, $player);
$this->maniaControl->getChat()->sendError($message, $player);
return;
}