From 7510778e5957e3a1fccd1100189e5012aed0b8a8 Mon Sep 17 00:00:00 2001 From: Falkirks Date: Tue, 18 Aug 2015 10:44:59 -0700 Subject: [PATCH] Added support for block metadata --- plugin.yml | 4 ++-- src/minereset/MineReset.php | 7 ++++++- src/minereset/MineResetTask.php | 12 +++++++++++- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/plugin.yml b/plugin.yml index bb0d1b2..f828459 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,6 +1,6 @@ name: MineReset main: minereset\MineReset -version: 2.0.3 +version: 2.1 author: Falk api: [1.0.0] load: POSTWORLD @@ -23,4 +23,4 @@ permissions: minereset.command.reset: description: Reset mines minereset.command.destroy: - description: Remove old mines \ No newline at end of file + description: Remove mines \ No newline at end of file diff --git a/src/minereset/MineReset.php b/src/minereset/MineReset.php index 840ebfa..9b769a6 100644 --- a/src/minereset/MineReset.php +++ b/src/minereset/MineReset.php @@ -88,7 +88,12 @@ public function onCommand(CommandSender $sender, Command $cmd, $label, array $ar $save = []; foreach ($sets as $key => $item) { if ( $key & 1 ) { - $save[$sets[$key-1]] = $item; + if(isset($save[$sets[$key-1]])){ + $save[$sets[$key-1]] += $item; + } + else { + $save[$sets[$key - 1]] = $item; + } } } $this->mines[$args[1]]->setData($save); diff --git a/src/minereset/MineResetTask.php b/src/minereset/MineResetTask.php index 43e3912..5e7507c 100644 --- a/src/minereset/MineResetTask.php +++ b/src/minereset/MineResetTask.php @@ -37,6 +37,14 @@ public function onRun(){ } $sum = []; $id = array_keys(unserialize($this->ratioData)); + for($i = 0; $i < count($id); $i++){ + $blockId = explode(":", $id[$i]); + if(!isset($blockId[1])){ + $blockId[1] = 0; + } + $id[$i] = $blockId; + } + $m = array_values(unserialize($this->ratioData)); $sum[0] = $m[0]; for ($l = 1; $l < count($m); $l++) $sum[$l] = $sum[$l - 1] + $m[$l]; @@ -48,7 +56,9 @@ public function onRun(){ for ($l = 0; $l < count($sum); $l++) { if ($a <= $sum[$l]) { $hash = Level::chunkHash($x >> 4, $z >> 4); - if(isset($chunks[$hash])) $chunks[$hash]->setBlock($x & 0x0f, $y & 0x7f, $z & 0x0f, $id[$l] & 0xff, 0); + if(isset($chunks[$hash])){ + $chunks[$hash]->setBlock($x & 0x0f, $y & 0x7f, $z & 0x0f, $id[$l][0] & 0xff, $id[$l][1] & 0xff); + } $l = count($sum); } }