Skip to content
This repository has been archived by the owner on Jul 11, 2018. It is now read-only.

Commit

Permalink
1.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
alejandroliu committed Oct 31, 2016
1 parent cc779df commit 2f9c8be
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 5 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 3 additions & 4 deletions src/aliuly/scorched/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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]);
Expand Down Expand Up @@ -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;
Expand Down
65 changes: 65 additions & 0 deletions src/aliuly/scorched/PluginCallbackTask.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php

/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
*
*
*/
namespace aliuly\scorched;

use pocketmine\scheduler\PluginTask;
use pocketmine\plugin\Plugin;

/**
* Allows the creation of simple callbacks with extra data
* The last parameter in the callback will be this object
*
*/
class PluginCallbackTask extends PluginTask{

/** @var callable */
protected $callable;

/** @var array */
protected $args;

/**
* @param Plugin $owner
* @param callable $callable
* @param array $args
*/
public function __construct(Plugin $owner, callable $callable, array $args = []){
parent::__construct($owner);
$this->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);
}

}

0 comments on commit 2f9c8be

Please sign in to comment.