From 987a6e635e34b858f742ccb5e37901c7d3667584 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Pueyo Date: Wed, 26 Dec 2012 13:33:43 +0100 Subject: [PATCH] Implemented Plugin Interface --- classes/API/PluginAPI.php | 7 +++++++ example/ExamplePlugin.php | 6 +++++- example/ReactorAsWater.php | 7 +++++-- example/SpawnChanger.php | 6 +++++- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/classes/API/PluginAPI.php b/classes/API/PluginAPI.php index db4d1af02..e7a70f4fd 100644 --- a/classes/API/PluginAPI.php +++ b/classes/API/PluginAPI.php @@ -160,4 +160,11 @@ class PluginAPI extends stdClass{ } } } +} + + +interface Plugin{ + public function __construct($api, $server = false); + public function init(); + public function __destruct(); } \ No newline at end of file diff --git a/example/ExamplePlugin.php b/example/ExamplePlugin.php index 754f069ec..ca277d8f8 100644 --- a/example/ExamplePlugin.php +++ b/example/ExamplePlugin.php @@ -9,7 +9,7 @@ class=ExamplePlugin */ -class ExamplePlugin{ +class ExamplePlugin implements Plugin{ private $api; public function __construct($api, $server = false){ $this->api = $api; @@ -19,6 +19,10 @@ class ExamplePlugin{ $this->api->console->register("example", "Example command", array($this, "handleCommand")); } + public function __destruct(){ + + } + public function handleCommand($cmd, $arg){ switch($cmd){ case "example": diff --git a/example/ReactorAsWater.php b/example/ReactorAsWater.php index 701b00ee6..3f2adb0cb 100644 --- a/example/ReactorAsWater.php +++ b/example/ReactorAsWater.php @@ -10,7 +10,7 @@ class=ReactorAsWater */ -class ReactorAsWater{ +class ReactorAsWater implements Plugin{ private $api; public function __construct($api, $server = false){ $this->api = $api; @@ -20,7 +20,10 @@ class ReactorAsWater{ $this->api->addHandler("player.block.action", array($this, "handle"), 15); //Priority higher that API $this->api->addHandler("player.equipment.change", array($this, "handle"), 15); } - + + public function __destruct(){ + + } public function handle(&$data, $event){ switch($event){ diff --git a/example/SpawnChanger.php b/example/SpawnChanger.php index f07a7df93..c7889824f 100644 --- a/example/SpawnChanger.php +++ b/example/SpawnChanger.php @@ -10,7 +10,7 @@ class=SpawnChanger */ -class SpawnChanger{ +class SpawnChanger implements Plugin{ private $api, $config, $path; public function __construct($api, $server = false){ $this->api = $api; @@ -37,6 +37,10 @@ class SpawnChanger{ $this->api->console->register("spawn", "Teleports to spawn", array($this, "command")); } + public function __destruct(){ + + } + public function command($cmd, $args){ switch($cmd){ case "spawnchanger":