From 2f9c8beccb0330b581755e2801b5ec98ddd31cc4 Mon Sep 17 00:00:00 2001 From: alejandroliu Date: Mon, 31 Oct 2016 13:42:17 +0100 Subject: [PATCH] 1.4.1 --- README.md | 6 ++ plugin.yml | 2 +- src/aliuly/scorched/Main.php | 7 +-- src/aliuly/scorched/PluginCallbackTask.php | 65 ++++++++++++++++++++++ 4 files changed, 75 insertions(+), 5 deletions(-) create mode 100644 src/aliuly/scorched/PluginCallbackTask.php diff --git a/README.md b/README.md index 42016d3..7d1f2df 100644 --- a/README.md +++ b/README.md @@ -147,9 +147,15 @@ Will generate an explosion out of nothing. Do not use this lightly. * scorched.cmd.dumdums - access to exploding arrows * scorched.cmd.akira - Create an explosion! +Todo +---- +* Shotgun : shoots multiple arrows in one go + Changes ------- +* 1.4.1 : CallbackTask + Removed CallbackTask deprecation message. * 1.4.0 : * Added /akira. * Make it so Mine and Arrow explosions can be caught by Anti-Grief diff --git a/plugin.yml b/plugin.yml index 77601bb..c89de42 100644 --- a/plugin.yml +++ b/plugin.yml @@ -4,7 +4,7 @@ load: POSTWORLD name: Scorched description: The Mother of All Mini-Games -version: 1.4.0 +version: 1.4.1 author: aliuly commands: diff --git a/src/aliuly/scorched/Main.php b/src/aliuly/scorched/Main.php index e845e87..6bf0ac0 100644 --- a/src/aliuly/scorched/Main.php +++ b/src/aliuly/scorched/Main.php @@ -20,7 +20,6 @@ use pocketmine\nbt\tag\Double; use pocketmine\nbt\tag\Enum; use pocketmine\nbt\tag\Float; -use pocketmine\scheduler\CallbackTask; use pocketmine\event\player\PlayerItemHeldEvent; use pocketmine\event\player\PlayerQuitEvent; @@ -184,7 +183,7 @@ public function onShoot(EntityShootBowEvent $e) { return; } // Since we are cancelling the event, we change the damage later - $this->getServer()->getScheduler()->scheduleDelayedTask(new CallbackTask([$this,"breakBow"],[$n]),5); + $this->getServer()->getScheduler()->scheduleDelayedTask(new PluginCallbackTask($this,[$this,"breakBow"],[$n]),5); } //echo "FORCE: ". $e->getForce()."\n"; //## DEBUG $this->fire($p,$this->shooters[$n][0],$this->shooters[$n][1]); @@ -300,11 +299,11 @@ private function cmdExplode(CommandSender $c,$args) { return false; } } - $this->getServer()->getScheduler()->scheduleDelayedTask(new CallbackTask([$this,"akira"],[$c->getName(),new Position($c->getX(),$c->getY(),$c->getZ(),$c->getLevel()),$magic,$yield]),$delay); + $this->getServer()->getScheduler()->scheduleDelayedTask(new PluginCallbackTask($this,[$this,"akira"],[$c->getName(),new Position($c->getX(),$c->getY(),$c->getZ(),$c->getLevel()),$magic,$yield]),$delay); $c->sendMessage("GET THE HECK OUT OF HERE!"); if ($delay > 40) { for ($i=1;$i<4;$i++) { - $this->getServer()->getScheduler()->scheduleDelayedTask(new CallbackTask([$this,"countdown"],[(4-$i)."..."]),($delay/4)*$i); + $this->getServer()->getScheduler()->scheduleDelayedTask(new PluginCallbackTask($this,[$this,"countdown"],[(4-$i)."..."]),($delay/4)*$i); } } return true; diff --git a/src/aliuly/scorched/PluginCallbackTask.php b/src/aliuly/scorched/PluginCallbackTask.php new file mode 100644 index 0000000..a72461c --- /dev/null +++ b/src/aliuly/scorched/PluginCallbackTask.php @@ -0,0 +1,65 @@ +callable = $callable; + $this->args = $args; + $this->args[] = $this; + } + + /** + * @return callable + */ + public function getCallable(){ + return $this->callable; + } + + public function onRun($currentTicks){ + $c = $this->callable; + $args = $this->args; + $args[] = $currentTicks; + $c(...$args); + } + +}