From 35a72328941644b622432aedc0238468c90076e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20Schro=CC=88der?= Date: Tue, 3 Dec 2013 18:50:30 +0100 Subject: [PATCH] improved metadata properties of plugin class --- application/core/Plugins/Plugin.php | 53 ++++++----------------------- application/plugins/Chatlog.php | 9 ++--- application/plugins/Donations.php | 12 ++++--- application/plugins/Endurance.php | 8 ++--- application/plugins/Karma.php | 9 ++--- application/plugins/Obstacle.php | 8 ++--- 6 files changed, 36 insertions(+), 63 deletions(-) diff --git a/application/core/Plugins/Plugin.php b/application/core/Plugins/Plugin.php index 52d3a006..7ee87352 100644 --- a/application/core/Plugins/Plugin.php +++ b/application/core/Plugins/Plugin.php @@ -10,15 +10,18 @@ use ManiaControl\ManiaControl; * @author steeffeen & kremsy */ abstract class Plugin { + /** + * Plugin Metadata + */ + public static $name = 'undefined'; + public static $version = 'undefined'; + public static $author = 'undefined'; + public static $description = 'undefined'; /** - * Private properties + * Protected properties */ protected $maniaControl = null; - protected $name = 'undefined'; - protected $version = 'undefined'; - protected $author = 'undefined'; - protected $description = 'undefined'; /** * Create a new plugin @@ -29,48 +32,12 @@ abstract class Plugin { /** * Get class name as string - * + * * @return string */ - public static function getClass() { + public static final function getClass() { return __CLASS__; } - - /** - * Get plugin author - * - * @return string - */ - public function getAuthor() { - return $this->author; - } - - /** - * Get plugin version - * - * @return float - */ - public function getVersion() { - return $this->version; - } - - /** - * Get plugin name - * - * @return string - */ - public function getName() { - return $this->name; - } - - /** - * Get plugin description - * - * @return string - */ - public function getDescription() { - return $this->description; - } } ?> diff --git a/application/plugins/Chatlog.php b/application/plugins/Chatlog.php index 3939c389..b88fa37e 100644 --- a/application/plugins/Chatlog.php +++ b/application/plugins/Chatlog.php @@ -32,10 +32,11 @@ class ChatlogPlugin extends Plugin implements CallbackListener { public function __construct(ManiaControl $maniaControl) { $this->maniaControl = $maniaControl; - $this->name = 'Chatlog Plugin'; - $this->version = self::VERSION; - $this->author = 'steeffeen'; - $this->description = 'Plugin logging the chat messages of the server.'; + // Plugin details + self::$name = 'Chatlog Plugin'; + self::$version = self::VERSION; + self::$author = 'steeffeen'; + self::$description = 'Plugin logging the chat messages of the server.'; // Init settings $this->maniaControl->settingManager->initSetting($this, self::SETTING_FOLDERNAME, 'logs'); diff --git a/application/plugins/Donations.php b/application/plugins/Donations.php index bbc550af..ca767fc1 100644 --- a/application/plugins/Donations.php +++ b/application/plugins/Donations.php @@ -32,14 +32,18 @@ class DonationPlugin extends Plugin implements CallbackListener, CommandListener public function __construct(ManiaControl $maniaControl) { $this->maniaControl = $maniaControl; - $this->author = 'steeffeen'; - $this->name = 'Donation Plugin'; - $this->version = self::VERSION; - $this->description = 'DonationPlugin commands like /donate, /pay and /getplanets and a donation widget.'; + // Plugin details + self::$author = 'steeffeen'; + self::$name = 'Donation Plugin'; + self::$version = self::VERSION; + self::$description = 'DonationPlugin commands like /donate, /pay and /getplanets and a donation widget.'; + // Register for commands $this->maniaControl->commandManager->registerCommandListener('donate', $this, 'command_Donate'); $this->maniaControl->commandManager->registerCommandListener('/pay', $this, 'command_Pay'); $this->maniaControl->commandManager->registerCommandListener('/getplanets', $this, 'command_GetPlanets'); + + // Register for callbacks $this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_BILLUPDATED, $this, 'handleBillUpdated'); } diff --git a/application/plugins/Endurance.php b/application/plugins/Endurance.php index f9cf75a8..709fd841 100644 --- a/application/plugins/Endurance.php +++ b/application/plugins/Endurance.php @@ -31,10 +31,10 @@ class EndurancePlugin extends Plugin implements CallbackListener { $this->maniaControl = $maniaControl; // Plugin information - $this->name = 'Endurance Plugin'; - $this->version = self::VERSION; - $this->author = 'steeffeen'; - $this->description = "Plugin enabling Support for the TM Game Mode 'Endurance' by TGYoshi."; + self::$name = 'Endurance Plugin'; + self::$version = self::VERSION; + self::$author = 'steeffeen'; + self::$description = "Plugin enabling Support for the TM Game Mode 'Endurance' by TGYoshi."; // Register for callbacks $this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_ONINIT, $this, 'callback_OnInit'); diff --git a/application/plugins/Karma.php b/application/plugins/Karma.php index a8f34b7b..1242de7e 100644 --- a/application/plugins/Karma.php +++ b/application/plugins/Karma.php @@ -47,10 +47,11 @@ class KarmaPlugin extends Plugin implements CallbackListener { public function __construct(ManiaControl $maniaControl) { $this->maniaControl = $maniaControl; - $this->name = 'Karma Plugin'; - $this->author = 'steeffeen'; - $this->version = self::VERSION; - $this->description = 'Plugin offering Karma Voting for Maps.'; + // Plugin details + self::$name = 'Karma Plugin'; + self::$author = 'steeffeen'; + self::$version = self::VERSION; + self::$description = 'Plugin offering Karma Voting for Maps.'; // Init database $this->initTables(); diff --git a/application/plugins/Obstacle.php b/application/plugins/Obstacle.php index 252bf342..47f6ea77 100644 --- a/application/plugins/Obstacle.php +++ b/application/plugins/Obstacle.php @@ -29,10 +29,10 @@ class ObstaclePlugin extends Plugin implements CallbackListener, CommandListener $this->maniaControl = $maniaControl; // Plugin details - $this->name = 'Obstacle Plugin'; - $this->version = self::VERSION; - $this->author = 'steeffeen'; - $this->description = 'Plugin offering various Commands for the ShootMania Obstacle Game Mode.'; + self::$name = 'Obstacle Plugin'; + self::$version = self::VERSION; + self::$author = 'steeffeen'; + self::$description = 'Plugin offering various Commands for the ShootMania Obstacle Game Mode.'; // Init settings $this->maniaControl->settingManager->initSetting($this, self::SETTING_JUMPTOAUTHLEVEL,