diff --git a/plugin.yml b/plugin.yml index 94a0392..50e3d33 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] 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..9e19cef 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->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..b1aded6 100644 --- a/src/LDX/TimeCommander/TimeCommand.php +++ b/src/LDX/TimeCommander/TimeCommand.php @@ -1,20 +1,21 @@ 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; - } - } -} -?> + +class TimeCommand extends Task { + public function __construct($plugin,$cmd) { + $this->plugin = $plugin; + $this->cmd = $cmd; + $this->start = false; + } + + public function onRun(int $currentTick) { + if($this->start) { + $this->plugin->runCommand($this->cmd); + }else{ + $this->start = true; + } + } +} \ No newline at end of file