From 19da092c7b3a0b61a4fa47a61191e4b27eb100fa Mon Sep 17 00:00:00 2001 From: CookieCode Date: Mon, 29 Jan 2018 02:14:08 +0100 Subject: [PATCH 1/2] API Update --- plugin.yml | 2 +- src/LDX/TimeCommander/Main.php | 29 +++++++++++++----------- src/LDX/TimeCommander/TimeCommand.php | 32 ++++++++++++++------------- 3 files changed, 34 insertions(+), 29 deletions(-) diff --git a/plugin.yml b/plugin.yml index 94a0392..3849767 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,7 +1,7 @@ name: TimeCommander main: LDX\TimeCommander\Main version: 2.1 -api: [1.0.0, 2.0.0] +api: [3.0.0, 3.0.0-ALPHA6, 3.0.0-ALPHA7, 3.0.0-ALPHA8, 3.0.0-ALPHA9, 3.0.0-ALPHA10] author: LDX load: POSTWORLD website: https://github.com/LDX-MCPE/TimeCommander diff --git a/src/LDX/TimeCommander/Main.php b/src/LDX/TimeCommander/Main.php index 144a062..5232191 100644 --- a/src/LDX/TimeCommander/Main.php +++ b/src/LDX/TimeCommander/Main.php @@ -1,5 +1,6 @@ saveDefaultConfig(); - $c = $this->getConfig()->getAll(); - foreach ($c["Commands"] as $i) { - $this->getServer()->getScheduler()->scheduleRepeatingTask(new TimeCommand($this,$i["Command"]),$i["Time"] * 1200); - } - } - public function runCommand($cmd) { - $this->getServer()->dispatchCommand(new ConsoleCommandSender(),$cmd); - } -} -?> + +class Main extends PluginBase{ + + public function onEnable(){ + $this->saveDefaultConfig(); + $c = $this->getConfig()->getAll(); + foreach ($c["Commands"] as $i) { + $this->getServer()->getScheduler()->scheduleRepeatingTask(new TimeCommand($this,$i["Command"]),$i["Time"] * 1200); + } + } + + public function runCommand($cmd) { + $this->getServer()->dispatchCommand(new ConsoleCommandSender(),$cmd); + } +} \ No newline at end of file diff --git a/src/LDX/TimeCommander/TimeCommand.php b/src/LDX/TimeCommander/TimeCommand.php index 517b07d..b188eb0 100644 --- a/src/LDX/TimeCommander/TimeCommand.php +++ b/src/LDX/TimeCommander/TimeCommand.php @@ -1,20 +1,22 @@ plugin = $plugin; - $this->cmd = $cmd; - $this->start = false; - parent::__construct($plugin); - } - public function onRun($ticks) { - if($this->start) { - $this->plugin->runCommand($this->cmd); - } else { - $this->start = true; - } - } -} -?> + public function __construct($plugin,$cmd) { + $this->plugin = $plugin; + $this->cmd = $cmd; + $this->start = false; + parent::__construct($plugin); + } + + public function onRun(int $currentTick) { + if($this->start) { + $this->plugin->runCommand($this->cmd); + }else{ + $this->start = true; + } + } +} \ No newline at end of file From 70c46303b17bcbf88a836f1672252f98ccbe51f4 Mon Sep 17 00:00:00 2001 From: Cookie Date: Mon, 16 Mar 2020 22:14:48 +0100 Subject: [PATCH 2/2] API Update --- plugin.yml | 2 +- src/LDX/TimeCommander/Main.php | 2 +- src/LDX/TimeCommander/TimeCommand.php | 5 ++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/plugin.yml b/plugin.yml index 3849767..50e3d33 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,7 +1,7 @@ name: TimeCommander main: LDX\TimeCommander\Main version: 2.1 -api: [3.0.0, 3.0.0-ALPHA6, 3.0.0-ALPHA7, 3.0.0-ALPHA8, 3.0.0-ALPHA9, 3.0.0-ALPHA10] +api: [3.0.0] author: LDX load: POSTWORLD website: https://github.com/LDX-MCPE/TimeCommander diff --git a/src/LDX/TimeCommander/Main.php b/src/LDX/TimeCommander/Main.php index 5232191..9e19cef 100644 --- a/src/LDX/TimeCommander/Main.php +++ b/src/LDX/TimeCommander/Main.php @@ -15,7 +15,7 @@ public function onEnable(){ $this->saveDefaultConfig(); $c = $this->getConfig()->getAll(); foreach ($c["Commands"] as $i) { - $this->getServer()->getScheduler()->scheduleRepeatingTask(new TimeCommand($this,$i["Command"]),$i["Time"] * 1200); + $this->getScheduler()->scheduleRepeatingTask(new TimeCommand($this,$i["Command"]),$i["Time"] * 1200); } } diff --git a/src/LDX/TimeCommander/TimeCommand.php b/src/LDX/TimeCommander/TimeCommand.php index b188eb0..b1aded6 100644 --- a/src/LDX/TimeCommander/TimeCommand.php +++ b/src/LDX/TimeCommander/TimeCommand.php @@ -1,15 +1,14 @@ plugin = $plugin; $this->cmd = $cmd; $this->start = false; - parent::__construct($plugin); } public function onRun(int $currentTick) {