From 0ddadbebfd00857232780e42d254f6313f8359f5 Mon Sep 17 00:00:00 2001 From: jasonwynn10 Date: Mon, 18 Dec 2017 17:49:41 -0500 Subject: [PATCH 01/22] Updated CrossOnlineCount for NBT API changes Updated BlockTypeCorrector...It works now! --- BlockTypeCorrector/plugin.yml | 3 +- BlockTypeCorrector/resources/config.yml | 74 +++++------ .../src/jasonwynn10/corrector/Corrector.php | 52 -------- .../src/jasonwynn10/corrector/Main.php | 121 +++++++++++++++--- .../src/jasonwynn10/CrossOnlineCount/Main.php | 19 ++- 5 files changed, 147 insertions(+), 122 deletions(-) delete mode 100644 BlockTypeCorrector/src/jasonwynn10/corrector/Corrector.php diff --git a/BlockTypeCorrector/plugin.yml b/BlockTypeCorrector/plugin.yml index 7fa7785..8585a09 100644 --- a/BlockTypeCorrector/plugin.yml +++ b/BlockTypeCorrector/plugin.yml @@ -5,5 +5,6 @@ author: "jasonwynn10" version: 0.2.0 api: - 3.0.0 - - 3.0.0-ALPHA7 + - 3.0.0-ALPHA9 + - 3.0.0-ALPHA10 load: STARTUP diff --git a/BlockTypeCorrector/resources/config.yml b/BlockTypeCorrector/resources/config.yml index 982fd90..3fc3af4 100644 --- a/BlockTypeCorrector/resources/config.yml +++ b/BlockTypeCorrector/resources/config.yml @@ -1,38 +1,38 @@ -BlocksPerTick: 256 blocks: - "243:0": "3:2" - "2:0": "31:1" - "43:6": "43:7" - "44:6": "44:7" - "337:0": "82:0" - "405:0": "112:0" - "372:0": "115:0" - "126:0": "158:0" - "126:1": "158:1" - "126:8": "158:8" - "125:0": "157:0" - "85:1": "188:0" - "85:2": "189:0" - "85:3": "190:0" - "85:5": "191:0" - "85:4": "192:0" - "208:0": "198:0" - "240:0": "199:0" - "201:2": "202:0" - "44:7": "205:0" - "244:0": "207:0" - "198:0": "208:0" - "115:0": "214:0" - "466:0": "322:1" - "422:0": "410:0" - "457:0": "434:0" - "458:0": "435:0" - "459:0": "436:0" - "445:0": "450:0" - "143:1": "143:5" - "77:1": "77:5" - "77:4": "77:2" - "96:4": "96:15" - "96:5": "96:14" - "96:6": "96:13" - "96:7": "96:12" \ No newline at end of file + "243:0": "3:2" + "2:0": "31:1" + "43:6": "43:7" + "44:6": "44:7" + "337:0": "82:0" + "405:0": "112:0" + "372:0": "115:0" + "126:0": "158:0" + "126:1": "158:1" + "126:8": "158:8" + "125:0": "157:0" + "85:1": "188:0" + "85:2": "189:0" + "85:3": "190:0" + "85:5": "191:0" + "85:4": "192:0" + "208:0": "198:0" + "240:0": "199:0" + "201:2": "202:0" + "44:7": "205:0" + "244:0": "207:0" + "198:0": "208:0" + "115:0": "214:0" + "466:0": "322:1" + "422:0": "410:0" + "457:0": "434:0" + "458:0": "435:0" + "459:0": "436:0" + "445:0": "450:0" + "143:1": "143:5" + "77:1": "77:5" + "77:4": "77:2" + "96:4": "96:15" + "96:5": "96:14" + "96:6": "96:13" + "96:7": "96:12" + "188:0": "85:1" diff --git a/BlockTypeCorrector/src/jasonwynn10/corrector/Corrector.php b/BlockTypeCorrector/src/jasonwynn10/corrector/Corrector.php deleted file mode 100644 index a7ac5e7..0000000 --- a/BlockTypeCorrector/src/jasonwynn10/corrector/Corrector.php +++ /dev/null @@ -1,52 +0,0 @@ -level = $level; - $this->bpt = $plugin->getConfig()->get("BlocksPerTick",256); - $this->blockTypes = $plugin->getConfig()->get("blocks", []); - $plugin->getLogger()->info("CORRECTOR STARTING"); - } - public function onRun(int $currentTick) { - $this->getOwner()->getLogger()->info("CORRECTOR STARTED"); - $blocks = 0; - $height = $this->level->getProvider()->getWorldHeight(); - foreach($this->level->getChunks() as $chunk) { - if(!$chunk->isPopulated() or !$chunk->isGenerated()) { - continue; - } - $this->getOwner()->getLogger()->info("CORRECTOR found chunk to fix"); - for($x = 0; $x <= 16; $x++) { - for($z = 0; $z <= 16; $z++) { - for($y = 0; $y <= $height; $y++) { - if($blocks < $this->bpt) { - $pos = new Vector3(($chunk->getX() << 4) + $x, $y, ($chunk->getZ() << 4) + $z); - $block = $this->level->getBlock($pos); - if(array_key_exists("{$block->getId()}:{$block->getDamage()}", $this->blockTypes)) { - $arr = explode(":",$this->blockTypes["{$block->getId()}:{$block->getDamage()}"]); - $chunk->setBlock($x, $y, $z, (int)$arr[0], (int)$arr[1]); - $this->getOwner()->getLogger()->info("CORRECTOR fixed a block!"); - $blocks++; - } - }else{ - $this->getOwner()->getServer()->getScheduler()->scheduleDelayedTask($this, 1); - } - } - } - } - } - } -} diff --git a/BlockTypeCorrector/src/jasonwynn10/corrector/Main.php b/BlockTypeCorrector/src/jasonwynn10/corrector/Main.php index a3cf449..c518496 100644 --- a/BlockTypeCorrector/src/jasonwynn10/corrector/Main.php +++ b/BlockTypeCorrector/src/jasonwynn10/corrector/Main.php @@ -1,31 +1,110 @@ getServer()->getPluginManager()->registerEvents($this, $this); - $this->saveDefaultConfig(); - foreach ($this->getServer()->getLevels() as $level) { - $this->getServer()->getScheduler()->scheduleTask(new Corrector($this, $level)); - } - } - public function onTap(PlayerInteractEvent $ev) { - $this->getLogger()->info("TAPPED"); - $block = $ev->getBlock(); - $this->getLogger()->info("ID: ".$block->getId().":".$block->getDamage()); - if(array_key_exists("{$block->getId()}:{$block->getDamage()}", $this->getConfig()->get("blocks", []))) { - $arr = explode(":", $this->getConfig()->get("blocks", [])["{$block->getId()}:{$block->getDamage()}"]); - $newBlock = Block::get((int)$arr[0], (int)$arr[1]); - $ev->getPlayer()->getLevel()->setBlock($block, $newBlock,false, true); - $this->getLogger()->info("FIXED"); - $this->getLogger()->info("ID: ".$newBlock->getId().":".$newBlock->getDamage()); - }else{ - $this->getLogger()->info("KEY doesn't exist!"); - } - } + /** @var string[] $blockTypes */ + private $blockTypes = []; + + public function onEnable() : void { + $this->getServer()->getPluginManager()->registerEvents($this, $this); + $this->saveDefaultConfig(); + $this->blockTypes = $this->getConfig()->get("blocks", []); + } + + /** + * @priority MONITOR + * @ignoreCancelled false + * + * @param ChunkLoadEvent $ev + */ + public function onChunkLoad(ChunkLoadEvent $ev) : void { + $chunk = $ev->getChunk(); + if(isset($chunk->fixed)) + return; + $level = $ev->getLevel(); + for($x = 0; $x <= 16; $x++) { + for($z = 0; $z <= 16; $z++) { + for($y = 0; $y <= $chunk->getHeight(); $y++) { + $block = $level->getBlock(new Vector3(($chunk->getX() << 4) + $x, $y, ($chunk->getZ() << 4) + $z)); + $key = "{$block->getId()}:{$block->getDamage()}"; + if(array_key_exists($key, $this->blockTypes)) { + $arr = explode(":",$this->blockTypes[$key]); + $chunk->setBlock($x, $y, $z, (int)$arr[0], (int)($arr[1] ?? 0)); + } + } + } + } + $chunk->setChanged(); + $chunk->fixed = true; + } + + /** + * @priority MONITOR + * @ignoreCancelled false + * + * @param PlayerInteractEvent $ev + */ + public function onTap(PlayerInteractEvent $ev) : void { + if($ev->getPlayer()->getName() !== "jasonwynn10") + return; + $this->getLogger()->info("TAPPED"); + $block = $ev->getBlock(); + $this->getLogger()->info("ID: ".$block->getId().":".$block->getDamage()); + if(array_key_exists("{$block->getId()}:{$block->getDamage()}", $this->getConfig()->get("blocks", []))) { + $arr = explode(":", $this->getConfig()->get("blocks", [])["{$block->getId()}:{$block->getDamage()}"]); + $newBlock = Block::get((int)$arr[0], (int)$arr[1]); + $ev->getPlayer()->getLevel()->setBlock($block, $newBlock,false, false); + $this->getLogger()->info("FIXED"); + $this->getLogger()->info("ID: ".$newBlock->getId().":".$newBlock->getDamage()); + }else{ + $this->getLogger()->info("KEY doesn't exist! Attempting backup method"); + $this->fixBlockIds($block); + } + } + + public function fixBlockIds(Block $block) : void { + $replace = null; + switch($block->getId()) { + case 126: + $replace = Block::get(Block::WOODEN_SLAB, $block->getDamage()); + break; + case 95: + $replace = Block::get(Block::GLASS); + break; + case 160: + $replace = Block::get(Block::GLASS_PANE); + break; + case 125: + $replace = Block::get(Block::DOUBLE_WOODEN_SLAB, $block->getDamage()); + break; + case 188: + $replace = Block::get(Block::FENCE, 1); + break; + case 189: + $replace = Block::get(Block::FENCE, 2); + break; + case 190: + $replace = Block::get(Block::FENCE, 3); + break; + case 191: + $replace = Block::get(Block::FENCE, 5); + break; + case 192: + $replace = Block::get(Block::FENCE, 4); + break; + default: + break; + } + if(isset($replace)) { + $block->getLevel()->setBlock($block, $replace, false, false); + } + } } \ No newline at end of file diff --git a/CrossOnlineCount/src/jasonwynn10/CrossOnlineCount/Main.php b/CrossOnlineCount/src/jasonwynn10/CrossOnlineCount/Main.php index b815e47..53b644c 100644 --- a/CrossOnlineCount/src/jasonwynn10/CrossOnlineCount/Main.php +++ b/CrossOnlineCount/src/jasonwynn10/CrossOnlineCount/Main.php @@ -1,16 +1,13 @@ getEntity(); $lines = explode("\n", $entity->getNameTag()); if($this->isValidIP($lines[0]) or $this->is_valid_domain_name($lines[0])) { - $entity->namedtag->server = new StringTag("server", $lines[0]); + $entity->namedtag->setString("server", $lines[0]); $this->update(); } } @@ -55,8 +52,8 @@ public function onSlapperCreate(SlapperCreationEvent $ev) { */ public function onSlapperDelete(SlapperDeletionEvent $ev) { $entity = $ev->getEntity(); - if(isset($entity->namedtag->server)) { - unset($entity->namedtag->server); + if($entity->namedtag->getString("server")) { + $entity->namedtag->removeTag("server"); } } @@ -66,10 +63,10 @@ public function onSlapperDelete(SlapperDeletionEvent $ev) { public function update() { foreach($this->getServer()->getLevels() as $level) { foreach($level->getEntities() as $entity) { - if(isset($entity->namedtag->server)) { - $server = explode(":", $entity->namedtag->server->getValue()); + if($entity->namedtag->getString("server")) { + $server = explode(":", $entity->namedtag->getString("server","")); try { - $queryData = PMQuery::query($server[0], $server[1]); + $queryData = PMQuery::query($server[0], $server[1]); //TODO make async $online = (int) $queryData['num']; $lines = explode("\n", $entity->getNameTag()); From b2a47a54dd4f3b96f3a9c50adc889e7102568196 Mon Sep 17 00:00:00 2001 From: jasonwynn10 Date: Wed, 3 Jan 2018 23:16:01 -0500 Subject: [PATCH 02/22] Another NBT fix for CrossOnlineCount --- CrossOnlineCount/src/jasonwynn10/CrossOnlineCount/Main.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CrossOnlineCount/src/jasonwynn10/CrossOnlineCount/Main.php b/CrossOnlineCount/src/jasonwynn10/CrossOnlineCount/Main.php index 53b644c..ed2f749 100644 --- a/CrossOnlineCount/src/jasonwynn10/CrossOnlineCount/Main.php +++ b/CrossOnlineCount/src/jasonwynn10/CrossOnlineCount/Main.php @@ -21,9 +21,9 @@ public function onEnable() { public function onDisable() { foreach($this->getServer()->getLevels() as $level) { foreach($level->getEntities() as $entity) { - if(isset($entity->namedtag->server)) { + if($entity->namedtag->getString("server")) { $lines = explode("\n", $entity->getNameTag()); - $lines[0] = $entity->namedtag->server->getValue(); + $lines[0] = $entity->namedtag->getString("server", ""); $nametag = implode("\n", $lines); $entity->setNameTag($nametag); } From 90c9eec850ee288e9a7a230e7f4a36bcc4b18e15 Mon Sep 17 00:00:00 2001 From: jasonwynn10 Date: Wed, 3 Jan 2018 23:45:22 -0500 Subject: [PATCH 03/22] Move some hard-coded block ids to the config --- BlockTypeCorrector/resources/config.yml | 7 +++++++ .../src/jasonwynn10/corrector/Main.php | 21 ------------------- 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/BlockTypeCorrector/resources/config.yml b/BlockTypeCorrector/resources/config.yml index 3fc3af4..62b9c6b 100644 --- a/BlockTypeCorrector/resources/config.yml +++ b/BlockTypeCorrector/resources/config.yml @@ -36,3 +36,10 @@ blocks: "96:6": "96:13" "96:7": "96:12" "188:0": "85:1" + "95:0": "20:0" + "160:0": "102:0" + "188:0": "85:1" + "189:0": "85:2" + "190:0": "85:3" + "191:0": "85:5" + "192:0": "85:4" \ No newline at end of file diff --git a/BlockTypeCorrector/src/jasonwynn10/corrector/Main.php b/BlockTypeCorrector/src/jasonwynn10/corrector/Main.php index c518496..3d533a2 100644 --- a/BlockTypeCorrector/src/jasonwynn10/corrector/Main.php +++ b/BlockTypeCorrector/src/jasonwynn10/corrector/Main.php @@ -76,30 +76,9 @@ public function fixBlockIds(Block $block) : void { case 126: $replace = Block::get(Block::WOODEN_SLAB, $block->getDamage()); break; - case 95: - $replace = Block::get(Block::GLASS); - break; - case 160: - $replace = Block::get(Block::GLASS_PANE); - break; case 125: $replace = Block::get(Block::DOUBLE_WOODEN_SLAB, $block->getDamage()); break; - case 188: - $replace = Block::get(Block::FENCE, 1); - break; - case 189: - $replace = Block::get(Block::FENCE, 2); - break; - case 190: - $replace = Block::get(Block::FENCE, 3); - break; - case 191: - $replace = Block::get(Block::FENCE, 5); - break; - case 192: - $replace = Block::get(Block::FENCE, 4); - break; default: break; } From edab30860a9b0e7e19a16ee77ed5c3848a26ee0c Mon Sep 17 00:00:00 2001 From: poggit-bot Date: Wed, 3 Jan 2018 23:59:17 -0500 Subject: [PATCH 04/22] Create .poggit.yml Poggit-CI is enabled for this repo by @jasonwynn10 Visit the Poggit-CI page for this repo at https://poggit.pmmp.io/ci/jasonwynn10/Other-Plugins --- .poggit.yml | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 .poggit.yml diff --git a/.poggit.yml b/.poggit.yml new file mode 100644 index 0000000..1ef482e --- /dev/null +++ b/.poggit.yml @@ -0,0 +1,87 @@ +--- # Poggit-CI Manifest. Open the CI at https://poggit.pmmp.io/ci/jasonwynn10/Other-Plugins +branches: +- master +projects: + 2vs2: + path: 2vs2/ + AirSneakBoots: + path: AirSneakBoots/ + BanClientId: + path: BanClientId/ + BasketBall: + path: BasketBall/ + BlockTypeCorrector: + path: BlockTypeCorrector/ + BuildZone: + path: BuildZone/ + ChunkLoaders: + path: ChunkLoaders/ + CrateKeys: + path: CrateKeys/ + Cratechest: + path: Cratechest/ + CrossOnlineCount: + path: CrossOnlineCount/ + CustomAlerts: + path: CustomAlerts/ + Elytra: + path: Elytra/ + ExplodableUnbreakables: + path: ExplodableUnbreakables/ + Farms: + path: Farms/ + GlowstoneCircleWorld: + path: GlowstoneCircleWorld/ + HiddenUnHidden: + path: HiddenUnHidden/ + HubTP: + path: HubTP/ + Infinity-Stone: + path: Infinity-Stone/ + LateCommands: + path: LateCommands/ + MeteorRain: + path: MeteorRain/ + MoreCommands: + path: MoreCommands/ + Multi-Inv: + path: Multi-Inv/ + NameTagMods: + path: NameTagMods/ + NoPvpFlight: + path: NoPvpFlight/ + PeacefulSpawn: + path: PeacefulSpawn/ + PerWorldChat: + path: PerWorldChat/ + PlayerResizer: + path: PlayerResizer/ + PlayersLifetime: + path: PlayersLifetime/ + PrizeCode: + path: PrizeCode/ + PureChatExtras: + path: PureChatExtras/ + RandomEnchant: + path: RandomEnchant/ + SafeFly: + path: SafeFly/ + Sleep4All: + path: Sleep4All/ + TimeCommander: + path: TimeCommander/ + UHC: + path: UHC/ + VIPfly: + path: VIPfly/ + ViperKits: + path: ViperKits/ + WarpPads: + path: WarpPads/ + WorldEdit: + path: WorldEdit/ + WorldMerge: + path: WorldMerge/ + WorldShift: + path: WorldShift/ +... From 8f9651f6e5a79c7877adef6570b82ac8df6e162d Mon Sep 17 00:00:00 2001 From: jasonwynn10 Date: Fri, 5 Jan 2018 17:11:37 -0500 Subject: [PATCH 05/22] Fixed #6 --- .../src/jasonwynn10/CrossOnlineCount/Main.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CrossOnlineCount/src/jasonwynn10/CrossOnlineCount/Main.php b/CrossOnlineCount/src/jasonwynn10/CrossOnlineCount/Main.php index ed2f749..8442a5e 100644 --- a/CrossOnlineCount/src/jasonwynn10/CrossOnlineCount/Main.php +++ b/CrossOnlineCount/src/jasonwynn10/CrossOnlineCount/Main.php @@ -21,7 +21,7 @@ public function onEnable() { public function onDisable() { foreach($this->getServer()->getLevels() as $level) { foreach($level->getEntities() as $entity) { - if($entity->namedtag->getString("server")) { + if(!empty($entity->namedtag->getString("server", ""))) { $lines = explode("\n", $entity->getNameTag()); $lines[0] = $entity->namedtag->getString("server", ""); $nametag = implode("\n", $lines); @@ -52,7 +52,7 @@ public function onSlapperCreate(SlapperCreationEvent $ev) { */ public function onSlapperDelete(SlapperDeletionEvent $ev) { $entity = $ev->getEntity(); - if($entity->namedtag->getString("server")) { + if(!empty($entity->namedtag->getString("server", ""))) { $entity->namedtag->removeTag("server"); } } @@ -63,8 +63,8 @@ public function onSlapperDelete(SlapperDeletionEvent $ev) { public function update() { foreach($this->getServer()->getLevels() as $level) { foreach($level->getEntities() as $entity) { - if($entity->namedtag->getString("server")) { - $server = explode(":", $entity->namedtag->getString("server","")); + if(!empty($entity->namedtag->getString("server", ""))) { + $server = explode(":", $entity->namedtag->getString("server", "")); try { $queryData = PMQuery::query($server[0], $server[1]); //TODO make async $online = (int) $queryData['num']; From 9eb0fb6fb5cf2d74e0d638815e19bfb75c156fe4 Mon Sep 17 00:00:00 2001 From: jasonwynn10 Date: Sat, 6 Jan 2018 16:32:53 -0500 Subject: [PATCH 06/22] Updated BanClientId to ALPHA10 Removed poggit branch restriction --- .poggit.yml | 2 -- BanClientId/plugin.yml | 2 +- BanClientId/src/jasonwynn10/Bancid/Main.php | 8 ++++---- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/.poggit.yml b/.poggit.yml index 1ef482e..6475a22 100644 --- a/.poggit.yml +++ b/.poggit.yml @@ -1,6 +1,4 @@ --- # Poggit-CI Manifest. Open the CI at https://poggit.pmmp.io/ci/jasonwynn10/Other-Plugins -branches: -- master projects: 2vs2: path: 2vs2/ diff --git a/BanClientId/plugin.yml b/BanClientId/plugin.yml index 9b19b23..bbb01ca 100644 --- a/BanClientId/plugin.yml +++ b/BanClientId/plugin.yml @@ -3,7 +3,7 @@ author: "jasonwynn10" version: 0.1.0 api: - 3.0.0 - - 3.0.0-ALPHA7 + - 3.0.0-ALPHA10 main: jasonwynn10\Main description: "A plugin that allows banning client Ids" commands: diff --git a/BanClientId/src/jasonwynn10/Bancid/Main.php b/BanClientId/src/jasonwynn10/Bancid/Main.php index 1b8bc46..7c1ddd8 100644 --- a/BanClientId/src/jasonwynn10/Bancid/Main.php +++ b/BanClientId/src/jasonwynn10/Bancid/Main.php @@ -28,7 +28,7 @@ public function onCommand(CommandSender $sender, Command $command, string $label if (isset($args[0])) { if(($player = $this->getServer()->getPlayer($args[0])) instanceof Player) { $name = $player->getName(); - $id = $player->getClientId(); + $id = $player->getUniqueId(); $banned = $this->getConfig()->get("Banned", []); $times = $this->getConfig()->get("Times", []); $banned[$name] = $id; @@ -71,7 +71,7 @@ public function onCommand(CommandSender $sender, Command $command, string $label if(isset($args[0]) and isset($args[1])) { if(($player = $this->getServer()->getPlayer($args[0])) instanceof Player and is_int($args[1])) { $name = $player->getName(); - $id = $player->getClientId(); + $id = $player->getUniqueId(); $banned = $this->getConfig()->get("Banned", []); $times = $this->getConfig()->get("Times", []); $banned[$name] = $id; @@ -95,12 +95,12 @@ public function onPreLogin(PlayerPreLoginEvent $ev) { foreach($this->getConfig()->get("Banned", []) as $name => $id) { foreach ($this->getConfig()->get("Times", []) as $key => $time) { if($key === $id) { - if($p->getClientId() === $id) { + if($p->getUniqueId() === $id) { $ev->setKickMessage("You are banned for {$time} more minutes!"); $ev->setCancelled(); } }else{ - if($p->getClientId() === $id) { + if($p->getUniqueId() === $id) { $ev->setKickMessage("You have been banned!"); $ev->setCancelled(); } From dcb1f8d7a0838538ff172a110eedef539d443a74 Mon Sep 17 00:00:00 2001 From: jasonwynn10 Date: Wed, 24 Jan 2018 19:23:08 +0000 Subject: [PATCH 07/22] Make sure CrossOnlineCount compiles corectly --- .poggit.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.poggit.yml b/.poggit.yml index 6475a22..ce67b6d 100644 --- a/.poggit.yml +++ b/.poggit.yml @@ -20,6 +20,11 @@ projects: path: Cratechest/ CrossOnlineCount: path: CrossOnlineCount/ + libs: + - src: Falkirks/spoondetector/spoondetector + version: ^0.0.0 + - src: jasonwynn10/libpmquery/libpmquery + version: ^0.0.1 CustomAlerts: path: CustomAlerts/ Elytra: From 560cc182e5c22e96bb2c4e81046fd4af93d898ba Mon Sep 17 00:00:00 2001 From: jasonwynn10 Date: Tue, 6 Mar 2018 10:00:52 -0500 Subject: [PATCH 08/22] Start Enchantment UI --- EnchantmentUI/plugin.yml | 8 +++ EnchantmentUI/src/jasonwynn10/EnchUI/Main.php | 71 +++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 EnchantmentUI/plugin.yml create mode 100644 EnchantmentUI/src/jasonwynn10/EnchUI/Main.php diff --git a/EnchantmentUI/plugin.yml b/EnchantmentUI/plugin.yml new file mode 100644 index 0000000..1a6b1a9 --- /dev/null +++ b/EnchantmentUI/plugin.yml @@ -0,0 +1,8 @@ +name: EnchantmentUI +main: jasonwynn10\EnchUI\Main +version: 0.1.0 +api: 3.0.0-ALPHA11 +description: "A commissioned Enchantment shop plugin" +author: "jasonwynn10" +depend: +- FormAPI \ No newline at end of file diff --git a/EnchantmentUI/src/jasonwynn10/EnchUI/Main.php b/EnchantmentUI/src/jasonwynn10/EnchUI/Main.php new file mode 100644 index 0000000..13ece2d --- /dev/null +++ b/EnchantmentUI/src/jasonwynn10/EnchUI/Main.php @@ -0,0 +1,71 @@ +getServer()->getPluginManager()->getPlugin("FormAPI"); + $form = $formsAPI->createSimpleForm(function(Player $player, $data) use (&$dataStore) { + + $dataStore[$player->getName()][] = $data[0]; + + /** @var FormAPI $formsAPI */ + $formsAPI = Server::getInstance()->getPluginManager()->getPlugin("FormAPI"); + $form = $formsAPI->createCustomForm(function(Player $player, $data) use (&$dataStore) { + + var_dump($data); //TODO remove + $dataStore[$player->getName()][] = (int) $data[""]; + + /** @var FormAPI $formsAPI */ + $formsAPI = Server::getInstance()->getPluginManager()->getPlugin("FormAPI"); + + $economy = EconomyAPI::getInstance(); + $money = $economy->myMoney($player); + if($money - $dataStore[$player->getName()][3] < 0) { + $form = $formsAPI->createSimpleForm(); + $form->setTitle("Enchantment Shop"); + $form->setContent("You don't have enough money to buy that!"); + } + else { + $form = $formsAPI->createModalForm(function(Player $player, $data) use (&$dataStore) { + + var_dump($data); //TODO remove + if($data) { + $economy = EconomyAPI::getInstance(); + $economy->reduceMoney($player, $dataStore[$player->getName()][2], false, "EnchantmentShop"); + $player->getInventory()->getItemInHand()->addEnchantment(new EnchantmentInstance(CustomEnchants::getEnchantmentByName($dataStore[$player->getName()][0]), $dataStore[$player->getName()][1])); + } + }); + $form->setTitle("Enchantment Shop"); + $form->setContent("Do you accept your charge of " . $economy->getConfig()->get("monetary-unit", "$") . $dataStore[$player->getName()][2] . "?"); + } + }); + $form->setTitle("Enchantment Shop"); + $maxLevel = (int) (((int) EconomyAPI::getInstance()->getConfig()->get("max-money", 9999999999)) / 5000000); + $form->addSlider("Enchantment Level", 1, $maxLevel); + }); + $form->setTitle("Enchantment Shop"); + $form->setContent("Choose an enchantment to add to your item"); + + /** @noinspection PhpUnhandledExceptionInspection */ + $class = new \ReflectionClass(CustomEnchants::class); + /** @var Enchantment[] $enchantments */ + $enchantments = $class->getStaticPropertyValue("enchantments", []); + foreach($enchantments as $enchantment) { + $form->addButton($enchantment->getName()); + } + } +} \ No newline at end of file From 35abf72dc8fb378a7cdcf567ee70b626d9857076 Mon Sep 17 00:00:00 2001 From: jasonwynn10 Date: Tue, 6 Mar 2018 10:34:48 -0500 Subject: [PATCH 09/22] Add command for testing --- EnchantmentUI/plugin.yml | 13 +++++++++++-- EnchantmentUI/src/jasonwynn10/EnchUI/Main.php | 17 +++++++++++++++-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/EnchantmentUI/plugin.yml b/EnchantmentUI/plugin.yml index 1a6b1a9..7c34ae7 100644 --- a/EnchantmentUI/plugin.yml +++ b/EnchantmentUI/plugin.yml @@ -2,7 +2,16 @@ name: EnchantmentUI main: jasonwynn10\EnchUI\Main version: 0.1.0 api: 3.0.0-ALPHA11 -description: "A commissioned Enchantment shop plugin" +description: "A commissioned Enchantment Shop plugin" author: "jasonwynn10" depend: -- FormAPI \ No newline at end of file + - FormAPI +commands: + enchantmentshop: + description: "Opens the Enchantment Shop" + permission: "enchantmentshop.cmd" + usage: "/enchshop" + alias: ["enchshop"] +permissions: + enchantmentshop.cmd: + default: true \ No newline at end of file diff --git a/EnchantmentUI/src/jasonwynn10/EnchUI/Main.php b/EnchantmentUI/src/jasonwynn10/EnchUI/Main.php index 13ece2d..b5b90a5 100644 --- a/EnchantmentUI/src/jasonwynn10/EnchUI/Main.php +++ b/EnchantmentUI/src/jasonwynn10/EnchUI/Main.php @@ -3,8 +3,11 @@ namespace jasonwynn10\EnchUI; use jojoe77777\FormAPI\FormAPI; +use jojoe77777\FormAPI\SimpleForm; use onebone\economyapi\EconomyAPI; use PiggyCustomEnchants\CustomEnchants\CustomEnchants; +use pocketmine\command\Command; +use pocketmine\command\CommandSender; use pocketmine\event\Listener; use pocketmine\item\enchantment\Enchantment; use pocketmine\item\enchantment\EnchantmentInstance; @@ -13,6 +16,9 @@ use pocketmine\Server; class Main extends PluginBase implements Listener { + /** @var SimpleForm $form */ + private $form; + public function onEnable() { $dataStore = []; @@ -38,8 +44,7 @@ public function onEnable() { $form = $formsAPI->createSimpleForm(); $form->setTitle("Enchantment Shop"); $form->setContent("You don't have enough money to buy that!"); - } - else { + }else { $form = $formsAPI->createModalForm(function(Player $player, $data) use (&$dataStore) { var_dump($data); //TODO remove @@ -67,5 +72,13 @@ public function onEnable() { foreach($enchantments as $enchantment) { $form->addButton($enchantment->getName()); } + $this->form = $form; + } + + public function onCommand(CommandSender $sender, Command $command, string $label, array $args) : bool { + if($sender instanceof Player) { + $this->form->sendToPlayer($sender); + } + return true; } } \ No newline at end of file From b8d55cc610cd3c2f1d2a2eaa12de004617d3b3c1 Mon Sep 17 00:00:00 2001 From: jasonwynn10 Date: Tue, 6 Mar 2018 17:30:08 -0500 Subject: [PATCH 10/22] Finished EnchantmentUI --- EnchantmentUI/plugin.yml | 2 + EnchantmentUI/src/jasonwynn10/EnchUI/Main.php | 163 ++++++++++++------ 2 files changed, 115 insertions(+), 50 deletions(-) diff --git a/EnchantmentUI/plugin.yml b/EnchantmentUI/plugin.yml index 7c34ae7..f47dda0 100644 --- a/EnchantmentUI/plugin.yml +++ b/EnchantmentUI/plugin.yml @@ -6,6 +6,8 @@ description: "A commissioned Enchantment Shop plugin" author: "jasonwynn10" depend: - FormAPI + - PiggyCustomEnchants + - EconomyAPI commands: enchantmentshop: description: "Opens the Enchantment Shop" diff --git a/EnchantmentUI/src/jasonwynn10/EnchUI/Main.php b/EnchantmentUI/src/jasonwynn10/EnchUI/Main.php index b5b90a5..457abf4 100644 --- a/EnchantmentUI/src/jasonwynn10/EnchUI/Main.php +++ b/EnchantmentUI/src/jasonwynn10/EnchUI/Main.php @@ -3,7 +3,6 @@ namespace jasonwynn10\EnchUI; use jojoe77777\FormAPI\FormAPI; -use jojoe77777\FormAPI\SimpleForm; use onebone\economyapi\EconomyAPI; use PiggyCustomEnchants\CustomEnchants\CustomEnchants; use pocketmine\command\Command; @@ -14,71 +13,135 @@ use pocketmine\Player; use pocketmine\plugin\PluginBase; use pocketmine\Server; +use pocketmine\utils\TextFormat; class Main extends PluginBase implements Listener { - /** @var SimpleForm $form */ - private $form; + /** @var array $dataStore */ + private static $dataStore = []; - public function onEnable() { - $dataStore = []; - - /** @var FormAPI $formsAPI */ - $formsAPI = $this->getServer()->getPluginManager()->getPlugin("FormAPI"); - $form = $formsAPI->createSimpleForm(function(Player $player, $data) use (&$dataStore) { + /** + * @param CommandSender $sender + * @param Command $command + * @param string $label + * @param array $args + * + * @return bool + * @throws \ReflectionException + */ + public function onCommand(CommandSender $sender, Command $command, string $label, array $args) : bool { + if($sender instanceof Player) { + self::createPlayerDataStore($sender); - $dataStore[$player->getName()][] = $data[0]; + /** @noinspection PhpUnhandledExceptionInspection */ + $class = new \ReflectionClass(CustomEnchants::class); + /** @var Enchantment[] $enchantments */ + $enchantments = $class->getStaticProperties()['enchantments']; + $enchantments = array_unique(array_filter($enchantments), SORT_REGULAR); /** @var FormAPI $formsAPI */ - $formsAPI = Server::getInstance()->getPluginManager()->getPlugin("FormAPI"); - $form = $formsAPI->createCustomForm(function(Player $player, $data) use (&$dataStore) { - - var_dump($data); //TODO remove - $dataStore[$player->getName()][] = (int) $data[""]; + $formsAPI = $this->getServer()->getPluginManager()->getPlugin("FormAPI"); + $form = $formsAPI->createSimpleForm(function(Player $player, $data) use ($enchantments) { + $i = 0; + foreach($enchantments as $enchantment) { + if($i === $data) { + $dataStore = Main::getFromDataStore($player); + $dataStore[] = $enchantment->getId(); + Main::setToDataStore($player, $dataStore); + break; + } + $i++; + } /** @var FormAPI $formsAPI */ $formsAPI = Server::getInstance()->getPluginManager()->getPlugin("FormAPI"); + $form = $formsAPI->createCustomForm(function(Player $player, $data) { - $economy = EconomyAPI::getInstance(); - $money = $economy->myMoney($player); - if($money - $dataStore[$player->getName()][3] < 0) { - $form = $formsAPI->createSimpleForm(); - $form->setTitle("Enchantment Shop"); - $form->setContent("You don't have enough money to buy that!"); - }else { - $form = $formsAPI->createModalForm(function(Player $player, $data) use (&$dataStore) { + $dataStore = Main::getFromDataStore($player); + $dataStore[] = (int) $data[0]; + $dataStore[] = (int) (((int) $data[0]) * 5000000); + Main::setToDataStore($player, $dataStore); + /** @var FormAPI $formsAPI */ + $formsAPI = Server::getInstance()->getPluginManager()->getPlugin("FormAPI"); - var_dump($data); //TODO remove - if($data) { - $economy = EconomyAPI::getInstance(); - $economy->reduceMoney($player, $dataStore[$player->getName()][2], false, "EnchantmentShop"); - $player->getInventory()->getItemInHand()->addEnchantment(new EnchantmentInstance(CustomEnchants::getEnchantmentByName($dataStore[$player->getName()][0]), $dataStore[$player->getName()][1])); - } - }); - $form->setTitle("Enchantment Shop"); - $form->setContent("Do you accept your charge of " . $economy->getConfig()->get("monetary-unit", "$") . $dataStore[$player->getName()][2] . "?"); - } + $economy = EconomyAPI::getInstance(); + $money = $economy->myMoney($player); + if($money - $dataStore[2] < 0) { + $form = $formsAPI->createCustomForm(); + $form->setTitle("Enchantment Shop"); + $form->addLabel("You don't have enough money to buy that!"); + }else{ + $form = $formsAPI->createModalForm(function(Player $player, $data) { + if($data) { + $dataStore = Main::getFromDataStore($player); + $enchantment = CustomEnchants::getEnchantment($dataStore[0]); + if($enchantment !== null) { + $inventory = $player->getInventory(); + $item = $inventory->getItemInHand(); + $item->addEnchantment(new EnchantmentInstance($enchantment, $dataStore[1])); + $inventory->setItemInHand($item); + $inventory->sendHeldItem($inventory->getHolder()->getLevel()->getPlayers()); + $inventory->sendContents($inventory->getHolder()); + $economy = EconomyAPI::getInstance(); + $economy->reduceMoney($player, $dataStore[2], false, "EnchantmentShop"); + $player->sendMessage(TextFormat::GREEN."Enchantment Purchased!"); + }else{ + $player->sendMessage(TextFormat::RED."There was an error! That enchantment doesn't exist!"); + } + } + }); + $form->setTitle("Enchantment Shop"); + $form->setContent("Do you accept your charge of " . $economy->getConfig()->get("monetary-unit", "$") . $dataStore[2] . "?"); + $form->setButton1("Yes, I accept the charge"); + $form->setButton2("No, I don't want to pay for this"); + } + $form->sendToPlayer($player); + }); + $form->setTitle("Enchantment Shop"); + $form->addSlider("Enchantment Level", 1, (int) (((int) EconomyAPI::getInstance()->getConfig()->get("max-money", 9999999999)) / 5000000)); + $form->sendToPlayer($player); }); $form->setTitle("Enchantment Shop"); - $maxLevel = (int) (((int) EconomyAPI::getInstance()->getConfig()->get("max-money", 9999999999)) / 5000000); - $form->addSlider("Enchantment Level", 1, $maxLevel); - }); - $form->setTitle("Enchantment Shop"); - $form->setContent("Choose an enchantment to add to your item"); + $form->setContent("Choose an enchantment to add to your item"); - /** @noinspection PhpUnhandledExceptionInspection */ - $class = new \ReflectionClass(CustomEnchants::class); - /** @var Enchantment[] $enchantments */ - $enchantments = $class->getStaticPropertyValue("enchantments", []); - foreach($enchantments as $enchantment) { - $form->addButton($enchantment->getName()); + foreach($enchantments as $enchantment) { + $form->addButton($enchantment->getName()); + } + $form->sendToPlayer($sender); } - $this->form = $form; + return true; } - public function onCommand(CommandSender $sender, Command $command, string $label, array $args) : bool { - if($sender instanceof Player) { - $this->form->sendToPlayer($sender); - } - return true; + /** + * @param Player $player + * + * @return array + */ + public static function createPlayerDataStore(Player $player) : array { + static::$dataStore[$player->getName()] = []; + return static::$dataStore[$player->getName()]; + } + + /** + * @param Player $player + * + * @return array + */ + public static function getFromDataStore(Player $player) : array { + return static::$dataStore[$player->getName()]; + } + + /** + * @param Player $player + * @param array $data + */ + public static function setToDataStore(Player $player, array $data) : void { + static::$dataStore[$player->getName()] = $data; + } + + /** + * @param Player $player + */ + public static function clearFromDataStore(Player $player) : void { + unset(static::$dataStore[$player->getName()]); } } \ No newline at end of file From d81a83da3f50db2d97037bd7f954d827ca2c0193 Mon Sep 17 00:00:00 2001 From: jasonwynn10 Date: Wed, 7 Mar 2018 06:22:31 -0500 Subject: [PATCH 11/22] Fixed command alias --- EnchantmentUI/plugin.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/EnchantmentUI/plugin.yml b/EnchantmentUI/plugin.yml index f47dda0..aee15ef 100644 --- a/EnchantmentUI/plugin.yml +++ b/EnchantmentUI/plugin.yml @@ -12,8 +12,8 @@ commands: enchantmentshop: description: "Opens the Enchantment Shop" permission: "enchantmentshop.cmd" - usage: "/enchshop" - alias: ["enchshop"] + usage: "/enchantmentshop" + aliases: ["enchshop", "enchantshop"] permissions: enchantmentshop.cmd: default: true \ No newline at end of file From b947e8becb5fe2cfe292eda0f99738c999debf3a Mon Sep 17 00:00:00 2001 From: jasonwynn10 Date: Wed, 7 Mar 2018 06:40:11 -0500 Subject: [PATCH 12/22] Start Masks --- Masks/plugin.yml | 17 ++++ Masks/resources/config.yml | 6 ++ Masks/src/jasonwynn10/masks/Main.php | 118 +++++++++++++++++++++++++++ Masks/temp | 37 +++++++++ 4 files changed, 178 insertions(+) create mode 100644 Masks/plugin.yml create mode 100644 Masks/resources/config.yml create mode 100644 Masks/src/jasonwynn10/masks/Main.php create mode 100644 Masks/temp diff --git a/Masks/plugin.yml b/Masks/plugin.yml new file mode 100644 index 0000000..782a908 --- /dev/null +++ b/Masks/plugin.yml @@ -0,0 +1,17 @@ +name: Masks +main: jasonwynn10\masks\Main +version: 0.1.0 +api: 3.0.0-ALPHA11 +description: "A commissioned mask effects plugin" +author: "jasonwynn10" +depend: + - FormAPI +commands: + masksetup: + description: "Opens the mask settings GUI" + usage: "/masksetup" + permission: "maskSetup" +permissions: + maskSetup: + default: op + description: "" \ No newline at end of file diff --git a/Masks/resources/config.yml b/Masks/resources/config.yml new file mode 100644 index 0000000..b3b887f --- /dev/null +++ b/Masks/resources/config.yml @@ -0,0 +1,6 @@ +Zombie Mask: + Speed: + Slowness: + Haste: + Fatigue: + Strength: diff --git a/Masks/src/jasonwynn10/masks/Main.php b/Masks/src/jasonwynn10/masks/Main.php new file mode 100644 index 0000000..6fed1c8 --- /dev/null +++ b/Masks/src/jasonwynn10/masks/Main.php @@ -0,0 +1,118 @@ +getServer()->getPluginManager()->registerEvents($this, $this); + } + + /** + * @param EntityArmorChangeEvent $event + */ + public function onMask(EntityArmorChangeEvent $event) { + $entity = $event->getEntity(); + if($entity instanceof Player) { + $mask = $event->getNewItem(); + if($mask->getId() === Item::MOB_HEAD) { + switch($mask->getDamage()) { + case 0: //SKELETON + $entity->addEffect(Effect::getEffect(Effect::HASTE)->setAmplifier(5)->setDuration(INT32_MAX)); + $entity->addEffect(Effect::getEffect(Effect::STRENGTH)->setAmplifier(5)->setDuration(INT32_MAX)); + $entity->addEffect(Effect::getEffect(Effect::SPEED)->setAmplifier(4)->setDuration(INT32_MAX)); + $entity->setAllowFlight(true); + break; + case 2: //ZOMBIE + $entity->addEffect(Effect::getEffect(Effect::HASTE)->setAmplifier(5)->setDuration(INT32_MAX)); + $entity->addEffect(Effect::getEffect(Effect::STRENGTH)->setAmplifier(5)->setDuration(INT32_MAX)); + $entity->addEffect(Effect::getEffect(Effect::SPEED)->setAmplifier(3)->setDuration(INT32_MAX)); + //TODO: Give poison to the other player level 5 if possible + break; + case 4: //CREEPER + $entity->addEffect(Effect::getEffect(Effect::HASTE)->setAmplifier(5)->setDuration(INT32_MAX)); + $entity->addEffect(Effect::getEffect(Effect::STRENGTH)->setAmplifier(5)->setDuration(INT32_MAX)); + $entity->addEffect(Effect::getEffect(Effect::SPEED)->setAmplifier(3)->setDuration(INT32_MAX)); + $entity->addEffect(Effect::getEffect(Effect::REGENERATION)->setAmplifier(5)->setDuration(INT32_MAX)); + $entity->setAllowFlight(true); + //TODO: Give poison to the Other player level 5 of possible + break; + case 5: //DRAGON + $entity->addEffect(Effect::getEffect(Effect::HASTE)->setAmplifier(5)->setDuration(INT32_MAX)); + $entity->addEffect(Effect::getEffect(Effect::STRENGTH)->setAmplifier(5)->setDuration(INT32_MAX)); + $entity->addEffect(Effect::getEffect(Effect::SPEED)->setAmplifier(2)->setDuration(INT32_MAX)); + $entity->setAllowFlight(true); + break; + default: // OTHER HEADS + $entity->addEffect(Effect::getEffect(Effect::HASTE)->setAmplifier(5)->setDuration(INT32_MAX)); + $entity->addEffect(Effect::getEffect(Effect::STRENGTH)->setAmplifier(3)->setDuration(INT32_MAX)); + $entity->addEffect(Effect::getEffect(Effect::SPEED)->setAmplifier(1)->setDuration(INT32_MAX)); + } + }elseif($event->getOldItem()->getId() === Item::MOB_HEAD) { + $entity->removeAllEffects(); + $entity->setAllowFlight(false); + } + } + } + + /** + * @param EntityDamageEvent $event + */ + public function onDamage(EntityDamageEvent $event) { + if($event instanceof EntityDamageByEntityEvent) { + $damager = $event->getDamager(); + $damaged = $event->getEntity(); + if($damager instanceof Player and $damaged instanceof Living) { + $mask = $damager->getArmorInventory()->getHelmet(); + if($mask->getId() === Item::MOB_HEAD and ($mask->getDamage() === 2 or $mask->getDamage() === 4)) { + $damaged->addEffect(Effect::getEffect(Effect::POISON)->setAmplifier(5)->setDuration(20*5)); + } + } + } + } + + public function onTap(PlayerInteractEvent $event) { + if($event->getAction() === $event::LEFT_CLICK_BLOCK and $event->getItem()->getId() === Item::BOOK) { + $player = $event->getPlayer(); + $inventory = $player->getInventory(); + $rand = mt_rand(1, 100); + if($rand) { + // + }else{ + // + } + } + } + + public function onCommand(CommandSender $sender, Command $command, string $label, array $args) : bool { + if($sender instanceof Player) { + /** @var FormAPI $formsAPI */ + $formsAPI = $this->getServer()->getPluginManager()->getPlugin("FormAPI"); + $form = $formsAPI->createCustomForm(function(Player $player, $data) { + // + }); + $form->setTitle("Mask Settings"); + $form->addLabel("Zombie Mask Settings"); + + $this->getConfig()->getNested(""); + + $class = new \ReflectionClass(Effect::class); + foreach($class->getConstants() as $name => $id) { + $form->addToggle(ucwords($name)." Effect"); + } + } + } +} \ No newline at end of file diff --git a/Masks/temp b/Masks/temp new file mode 100644 index 0000000..741f772 --- /dev/null +++ b/Masks/temp @@ -0,0 +1,37 @@ +Zombie mask +- Haste 5 unlimited time +- Strength 5 unlimited time +- Speed 3 unlimited +- Give poison to the other player level 5 if possible +Dragon mask +- Haste 5 unlimited time +- Strength 5 unlimited time +- Speed 2 unlimited +- Ability to fly +Creeper Mask +- Haste 5 unlimited time +- strength 5 unlimited time +- Speed 3 unlimited time +- Regeneration 5 unlimited time +- Give poison to the Other player level 5 of possible +- Ability to fly +Regular head +- Haste 5 +- Speed 1 +- Strength 3 +Skeleton mask +- Haste 5 unlimited time +- Strength 5 unlimited time +- Speed 4 unlimited +- Ability to fly +??? +- Haste 5 unlimited time +- strength 5 unlimited time +- Speed 3 unlimited time +- Regeneration 5 unlimited time +- Give poison to the Other player level 5 of possible +- Ability to fly + + +GUI to edit mask effects +Book mask charms - tap on ground for random mask \ No newline at end of file From 5486201016dea83987261778ff43f32e54e6f3f2 Mon Sep 17 00:00:00 2001 From: jasonwynn10 Date: Wed, 7 Mar 2018 09:10:31 -0500 Subject: [PATCH 13/22] Added customizability feature through config --- Masks/resources/config.yml | 109 +++++++++++++- Masks/src/jasonwynn10/masks/Main.php | 205 ++++++++++++++++++++++----- 2 files changed, 274 insertions(+), 40 deletions(-) diff --git a/Masks/resources/config.yml b/Masks/resources/config.yml index b3b887f..6c89f8a 100644 --- a/Masks/resources/config.yml +++ b/Masks/resources/config.yml @@ -1,6 +1,105 @@ Zombie Mask: - Speed: - Slowness: - Haste: - Fatigue: - Strength: + Speed: 3 + Slowness: 0 + Haste: 5 + Fatigue: 0 + Strength: 5 + Jump: 0 + Nausea: 0 + Regeneration: 0 + Resistance: 0 + Fire Resistance: 0 + Water Breathing: 0 + Invisibility: 0 + Blindness: 0 + Night Vision: 0 + Weakness: 0 + Poison: 0 + Wither: 0 + Health Boost: 0 + Flight: 0 + Poison Attacks: 0 +Skeleton Mask: + Speed: 4 + Slowness: 0 + Haste: 5 + Fatigue: 0 + Strength: 5 + Jump: 0 + Nausea: 0 + Regeneration: 0 + Resistance: 0 + Fire Resistance: 0 + Water Breathing: 0 + Invisibility: 0 + Blindness: 0 + Night Vision: 0 + Weakness: 0 + Poison: 0 + Wither: 0 + Health Boost: 0 + Flight: 0 + Poison Attacks: 0 +Creeper Mask: + Speed: 3 + Slowness: 0 + Haste: 5 + Fatigue: 0 + Strength: 5 + Jump: 0 + Nausea: 0 + Regeneration: 5 + Resistance: 0 + Fire Resistance: 0 + Water Breathing: 0 + Invisibility: 0 + Blindness: 0 + Night Vision: 0 + Weakness: 0 + Poison: 0 + Wither: 0 + Health Boost: 0 + Flight: 0 + Poison Attacks: 0 +Dragon Mask: + Speed: 3 + Slowness: 0 + Haste: 5 + Fatigue: 0 + Strength: 5 + Jump: 0 + Nausea: 0 + Regeneration: 0 + Resistance: 0 + Fire Resistance: 0 + Water Breathing: 0 + Invisibility: 0 + Blindness: 0 + Night Vision: 0 + Weakness: 0 + Poison: 0 + Wither: 0 + Health Boost: 0 + Flight: 0 + Poison Attacks: 0 +No Mask: + Speed: 3 + Slowness: 0 + Haste: 5 + Fatigue: 0 + Strength: 5 + Jump: 0 + Nausea: 0 + Regeneration: 0 + Resistance: 0 + Fire Resistance: 0 + Water Breathing: 0 + Invisibility: 0 + Blindness: 0 + Night Vision: 0 + Weakness: 0 + Poison: 0 + Wither: 0 + Health Boost: 0 + Flight: 0 + Poison Attacks: 0 \ No newline at end of file diff --git a/Masks/src/jasonwynn10/masks/Main.php b/Masks/src/jasonwynn10/masks/Main.php index 6fed1c8..d52925a 100644 --- a/Masks/src/jasonwynn10/masks/Main.php +++ b/Masks/src/jasonwynn10/masks/Main.php @@ -23,43 +23,131 @@ public function onEnable() { /** * @param EntityArmorChangeEvent $event + * @throws \ReflectionException */ public function onMask(EntityArmorChangeEvent $event) { $entity = $event->getEntity(); if($entity instanceof Player) { $mask = $event->getNewItem(); + /** @noinspection PhpUnhandledExceptionInspection */ + $class = new \ReflectionClass(Effect::class); if($mask->getId() === Item::MOB_HEAD) { switch($mask->getDamage()) { case 0: //SKELETON - $entity->addEffect(Effect::getEffect(Effect::HASTE)->setAmplifier(5)->setDuration(INT32_MAX)); - $entity->addEffect(Effect::getEffect(Effect::STRENGTH)->setAmplifier(5)->setDuration(INT32_MAX)); - $entity->addEffect(Effect::getEffect(Effect::SPEED)->setAmplifier(4)->setDuration(INT32_MAX)); - $entity->setAllowFlight(true); + $settings = $this->getConfig()->getNested("Skeleton Mask", []); + foreach($settings as $setting => $amplifier) { + if($setting === "Flight") { + if($amplifier == true) { + $entity->setAllowFlight(true); + }else { + $entity->setAllowFlight(false); + } + continue; + } + foreach($class->getConstants() as $name => $value) { + if(strpos(strtolower($setting), str_replace("_", " ", strtolower($name)))) { + if($amplifier > 0) { + $entity->addEffect(Effect::getEffect($value)->setDuration(INT32_MAX)->setAmplifier($amplifier)); + }else { + $entity->removeEffect($value); + } + break; + } + } + } break; case 2: //ZOMBIE - $entity->addEffect(Effect::getEffect(Effect::HASTE)->setAmplifier(5)->setDuration(INT32_MAX)); - $entity->addEffect(Effect::getEffect(Effect::STRENGTH)->setAmplifier(5)->setDuration(INT32_MAX)); - $entity->addEffect(Effect::getEffect(Effect::SPEED)->setAmplifier(3)->setDuration(INT32_MAX)); - //TODO: Give poison to the other player level 5 if possible + $settings = $this->getConfig()->getNested("Zombie Mask", []); + foreach($settings as $setting => $amplifier) { + if($setting === "Flight") { + if($amplifier == true) { + $entity->setAllowFlight(true); + }else { + $entity->setAllowFlight(false); + } + continue; + } + foreach($class->getConstants() as $name => $value) { + if(strpos(strtolower($setting), str_replace("_", " ", strtolower($name)))) { + if($amplifier > 0) { + $entity->addEffect(Effect::getEffect($value)->setDuration(INT32_MAX)->setAmplifier($amplifier)); + }else { + $entity->removeEffect($value); + } + break; + } + } + } break; case 4: //CREEPER - $entity->addEffect(Effect::getEffect(Effect::HASTE)->setAmplifier(5)->setDuration(INT32_MAX)); - $entity->addEffect(Effect::getEffect(Effect::STRENGTH)->setAmplifier(5)->setDuration(INT32_MAX)); - $entity->addEffect(Effect::getEffect(Effect::SPEED)->setAmplifier(3)->setDuration(INT32_MAX)); - $entity->addEffect(Effect::getEffect(Effect::REGENERATION)->setAmplifier(5)->setDuration(INT32_MAX)); - $entity->setAllowFlight(true); - //TODO: Give poison to the Other player level 5 of possible + $settings = $this->getConfig()->getNested("Creeper Mask", []); + foreach($settings as $setting => $amplifier) { + if($setting === "Flight") { + if($amplifier == true) { + $entity->setAllowFlight(true); + }else { + $entity->setAllowFlight(false); + } + continue; + } + foreach($class->getConstants() as $name => $value) { + if(strpos(strtolower($setting), str_replace("_", " ", strtolower($name)))) { + if($amplifier > 0) { + $entity->addEffect(Effect::getEffect($value)->setDuration(INT32_MAX)->setAmplifier($amplifier)); + }else { + $entity->removeEffect($value); + } + break; + } + } + } break; case 5: //DRAGON - $entity->addEffect(Effect::getEffect(Effect::HASTE)->setAmplifier(5)->setDuration(INT32_MAX)); - $entity->addEffect(Effect::getEffect(Effect::STRENGTH)->setAmplifier(5)->setDuration(INT32_MAX)); - $entity->addEffect(Effect::getEffect(Effect::SPEED)->setAmplifier(2)->setDuration(INT32_MAX)); - $entity->setAllowFlight(true); + $settings = $this->getConfig()->getNested("Dragon Mask", []); + foreach($settings as $setting => $amplifier) { + if($setting === "Flight") { + if($amplifier == true) { + $entity->setAllowFlight(true); + }else { + $entity->setAllowFlight(false); + } + continue; + } + foreach($class->getConstants() as $name => $value) { + if(strpos(strtolower($setting), str_replace("_", " ", strtolower($name)))) { + if($amplifier > 0) { + $entity->addEffect(Effect::getEffect($value)->setDuration(INT32_MAX)->setAmplifier($amplifier)); + }else { + $entity->removeEffect($value); + } + break; + } + } + } break; - default: // OTHER HEADS - $entity->addEffect(Effect::getEffect(Effect::HASTE)->setAmplifier(5)->setDuration(INT32_MAX)); - $entity->addEffect(Effect::getEffect(Effect::STRENGTH)->setAmplifier(3)->setDuration(INT32_MAX)); - $entity->addEffect(Effect::getEffect(Effect::SPEED)->setAmplifier(1)->setDuration(INT32_MAX)); + default: + $settings = $this->getConfig()->getNested("No Mask", []); + foreach($settings as $setting => $amplifier) { + if($setting === "Flight") { + if($amplifier == true) { + $entity->setAllowFlight(true); + }else { + $entity->setAllowFlight(false); + } + continue; + } + foreach($class->getConstants() as $name => $value) { + if(strpos(strtolower($setting), str_replace("_", " ", strtolower($name)))) { + if($amplifier > 0) { + $entity->addEffect(Effect::getEffect($value)->setDuration(INT32_MAX)->setAmplifier($amplifier)); + }else { + $entity->removeEffect($value); + } + break; + } + } + } + break; } }elseif($event->getOldItem()->getId() === Item::MOB_HEAD) { $entity->removeAllEffects(); @@ -77,8 +165,44 @@ public function onDamage(EntityDamageEvent $event) { $damaged = $event->getEntity(); if($damager instanceof Player and $damaged instanceof Living) { $mask = $damager->getArmorInventory()->getHelmet(); - if($mask->getId() === Item::MOB_HEAD and ($mask->getDamage() === 2 or $mask->getDamage() === 4)) { - $damaged->addEffect(Effect::getEffect(Effect::POISON)->setAmplifier(5)->setDuration(20*5)); + if($mask->getId() === Item::MOB_HEAD) { + switch($mask->getDamage()) { + case 0: //SKELETON + $settings = $this->getConfig()->getNested("Skeleton Mask", []); + if($settings["Poison Attacks"] > 0) { + $damaged->addEffect(Effect::getEffect(Effect::POISON)->setDuration(INT32_MAX)->setAmplifier($settings["Poison Attacks"])); + } + break; + case 2: //ZOMBIE + $settings = $this->getConfig()->getNested("Zombie Mask", []); + if($settings["Poison Attacks"] > 0) { + $damaged->addEffect(Effect::getEffect(Effect::POISON)->setDuration(INT32_MAX)->setAmplifier($settings["Poison Attacks"])); + } + break; + case 4: //CREEPER + $settings = $this->getConfig()->getNested("Creeper Mask", []); + if($settings["Poison Attacks"] > 0) { + $damaged->addEffect(Effect::getEffect(Effect::POISON)->setDuration(INT32_MAX)->setAmplifier($settings["Poison Attacks"])); + } + break; + case 5: //DRAGON + $settings = $this->getConfig()->getNested("Dragon Mask", []); + if($settings["Poison Attacks"] > 0) { + $damaged->addEffect(Effect::getEffect(Effect::POISON)->setDuration(INT32_MAX)->setAmplifier($settings["Poison Attacks"])); + } + break; + default: + $settings = $this->getConfig()->getNested("No Mask", []); + if($settings["Poison Attacks"] > 0) { + $damaged->addEffect(Effect::getEffect(Effect::POISON)->setDuration(INT32_MAX)->setAmplifier($settings["Poison Attacks"])); + } + break; + } + }elseif($mask->getId() === Item::AIR) { + $settings = $this->getConfig()->getNested("No Mask", []); + if($settings["Poison Attacks"] > 0) { + $damaged->addEffect(Effect::getEffect(Effect::POISON)->setDuration(INT32_MAX)->setAmplifier($settings["Poison Attacks"])); + } } } } @@ -89,10 +213,17 @@ public function onTap(PlayerInteractEvent $event) { $player = $event->getPlayer(); $inventory = $player->getInventory(); $rand = mt_rand(1, 100); - if($rand) { - // - }else{ - // + $item = Item::get(Item::MOB_HEAD); + if($rand <= 20) { + $inventory->setItemInHand($item->setDamage(0)); + }elseif($rand > 20 and $rand <= 40) { + $inventory->setItemInHand($item->setDamage(2)); + }elseif($rand > 40 and $rand <= 60) { + $inventory->setItemInHand($item->setDamage(4)); + }elseif($rand > 60 and $rand <= 80) { + $inventory->setItemInHand($item->setDamage(5)); + }elseif($rand > 80 and $rand <= 100) { + $inventory->setItemInHand($item->setDamage(mt_rand(0, 6))); // TODO: make better } } } @@ -102,17 +233,21 @@ public function onCommand(CommandSender $sender, Command $command, string $label /** @var FormAPI $formsAPI */ $formsAPI = $this->getServer()->getPluginManager()->getPlugin("FormAPI"); $form = $formsAPI->createCustomForm(function(Player $player, $data) { - // + var_dump($data); }); $form->setTitle("Mask Settings"); - $form->addLabel("Zombie Mask Settings"); - - $this->getConfig()->getNested(""); - $class = new \ReflectionClass(Effect::class); - foreach($class->getConstants() as $name => $id) { - $form->addToggle(ucwords($name)." Effect"); + foreach($this->getConfig()->getAll() as $mask => $settings) { + $form->addLabel($mask . " Settings"); + foreach($settings as $setting => $value) { + if($setting === "Flight") { + $form->addToggle($setting, $value); + }else { + $form->addSlider($setting, 0, 100, -1, $value); + } + } } } + return true; } } \ No newline at end of file From 1f65d3eda836bfac0694fff6e8ba2076d898a278 Mon Sep 17 00:00:00 2001 From: jasonwynn10 Date: Wed, 7 Mar 2018 10:07:13 -0500 Subject: [PATCH 14/22] Finish Masks commission --- Masks/resources/config.yml | 10 ++--- Masks/src/jasonwynn10/masks/Main.php | 67 +++++++++++++++++++++++++--- 2 files changed, 67 insertions(+), 10 deletions(-) diff --git a/Masks/resources/config.yml b/Masks/resources/config.yml index 6c89f8a..06238dd 100644 --- a/Masks/resources/config.yml +++ b/Masks/resources/config.yml @@ -17,7 +17,7 @@ Zombie Mask: Poison: 0 Wither: 0 Health Boost: 0 - Flight: 0 + Flight: false Poison Attacks: 0 Skeleton Mask: Speed: 4 @@ -38,7 +38,7 @@ Skeleton Mask: Poison: 0 Wither: 0 Health Boost: 0 - Flight: 0 + Flight: true Poison Attacks: 0 Creeper Mask: Speed: 3 @@ -59,7 +59,7 @@ Creeper Mask: Poison: 0 Wither: 0 Health Boost: 0 - Flight: 0 + Flight: true Poison Attacks: 0 Dragon Mask: Speed: 3 @@ -80,7 +80,7 @@ Dragon Mask: Poison: 0 Wither: 0 Health Boost: 0 - Flight: 0 + Flight: true Poison Attacks: 0 No Mask: Speed: 3 @@ -101,5 +101,5 @@ No Mask: Poison: 0 Wither: 0 Health Boost: 0 - Flight: 0 + Flight: true Poison Attacks: 0 \ No newline at end of file diff --git a/Masks/src/jasonwynn10/masks/Main.php b/Masks/src/jasonwynn10/masks/Main.php index d52925a..bf4e8be 100644 --- a/Masks/src/jasonwynn10/masks/Main.php +++ b/Masks/src/jasonwynn10/masks/Main.php @@ -18,6 +18,7 @@ class Main extends PluginBase implements Listener { public function onEnable() { + $this->saveDefaultConfig(); $this->getServer()->getPluginManager()->registerEvents($this, $this); } @@ -209,7 +210,7 @@ public function onDamage(EntityDamageEvent $event) { } public function onTap(PlayerInteractEvent $event) { - if($event->getAction() === $event::LEFT_CLICK_BLOCK and $event->getItem()->getId() === Item::BOOK) { + if($event->getItem()->getId() === Item::BOOK) { $player = $event->getPlayer(); $inventory = $player->getInventory(); $rand = mt_rand(1, 100); @@ -225,28 +226,84 @@ public function onTap(PlayerInteractEvent $event) { }elseif($rand > 80 and $rand <= 100) { $inventory->setItemInHand($item->setDamage(mt_rand(0, 6))); // TODO: make better } + $inventory->sendHeldItem($inventory->getHolder()->getLevel()->getPlayers()); + $inventory->sendContents($inventory->getHolder()); } } + /** + * @param CommandSender $sender + * @param Command $command + * @param string $label + * @param array $args + * @return bool + */ public function onCommand(CommandSender $sender, Command $command, string $label, array $args) : bool { if($sender instanceof Player) { + $config = $this->getConfig(); /** @var FormAPI $formsAPI */ $formsAPI = $this->getServer()->getPluginManager()->getPlugin("FormAPI"); - $form = $formsAPI->createCustomForm(function(Player $player, $data) { - var_dump($data); + $form = $formsAPI->createCustomForm(function(Player $player, $data) use ($config) { + if(empty($data)) { + return; + } + $settingsArray = array_chunk($data, 21); + $endSettings = []; + foreach($settingsArray as $key => $settings) { + switch($key) { + case 0: + $mask = "Zombie Mask"; + break; + case 1: + $mask = "Skeleton Mask"; + break; + case 2: + $mask = "Creeper Mask"; + break; + case 3: + $mask = "Dragon Mask"; + break; + default: + $mask = "No mask"; + break; + } + $endSettings[$mask]["Speed"] = (int) $settings[1]; + $endSettings[$mask]["Slowness"] = (int) $settings[2]; + $endSettings[$mask]["Haste"] = (int) $settings[3]; + $endSettings[$mask]["Fatigue"] = (int) $settings[4]; + $endSettings[$mask]["Strength"] = (int) $settings[5]; + $endSettings[$mask]["Jump"] = (int) $settings[6]; + $endSettings[$mask]["Nausea"] = (int) $settings[7]; + $endSettings[$mask]["Regeneration"] = (int) $settings[8]; + $endSettings[$mask]["Resistance"] = (int) $settings[9]; + $endSettings[$mask]["Fire Resistance"] = (int) $settings[10]; + $endSettings[$mask]["Water Breathing"] = (int) $settings[11]; + $endSettings[$mask]["Invisibility"] = (int) $settings[12]; + $endSettings[$mask]["Blindness"] = (int) $settings[13]; + $endSettings[$mask]["Night Vision"] = (int) $settings[14]; + $endSettings[$mask]["Weakness"] = (int) $settings[15]; + $endSettings[$mask]["Poison"] = (int) $settings[16]; + $endSettings[$mask]["Wither"] = (int) $settings[17]; + $endSettings[$mask]["Health Boost"] = (int) $settings[18]; + $endSettings[$mask]["Flight"] = (bool) $settings[19]; + $endSettings[$mask]["Poison Attacks"] = (int) $settings[20]; + } + $config->setAll($endSettings); + $config->save(); }); $form->setTitle("Mask Settings"); - foreach($this->getConfig()->getAll() as $mask => $settings) { + foreach($config->getAll() as $mask => $settings) { $form->addLabel($mask . " Settings"); foreach($settings as $setting => $value) { if($setting === "Flight") { - $form->addToggle($setting, $value); + $form->addToggle($setting, (bool) $value); }else { $form->addSlider($setting, 0, 100, -1, $value); } } } + $form->sendToPlayer($sender); } return true; } From a68cb424d468f250e77e1987b59973c802494333 Mon Sep 17 00:00:00 2001 From: jasonwynn10 Date: Wed, 7 Mar 2018 10:23:09 -0500 Subject: [PATCH 15/22] Added live effect updates --- Masks/src/jasonwynn10/masks/Main.php | 151 +++++++++++++++++++++++++-- Masks/temp | 37 ------- 2 files changed, 142 insertions(+), 46 deletions(-) delete mode 100644 Masks/temp diff --git a/Masks/src/jasonwynn10/masks/Main.php b/Masks/src/jasonwynn10/masks/Main.php index bf4e8be..47c3af6 100644 --- a/Masks/src/jasonwynn10/masks/Main.php +++ b/Masks/src/jasonwynn10/masks/Main.php @@ -15,11 +15,16 @@ use pocketmine\item\Item; use pocketmine\Player; use pocketmine\plugin\PluginBase; +use pocketmine\Server; class Main extends PluginBase implements Listener { + /** @var Main $insance */ + private static $insance; + public function onEnable() { $this->saveDefaultConfig(); $this->getServer()->getPluginManager()->registerEvents($this, $this); + self::$insance = $this; } /** @@ -46,7 +51,7 @@ public function onMask(EntityArmorChangeEvent $event) { continue; } foreach($class->getConstants() as $name => $value) { - if(strpos(strtolower($setting), str_replace("_", " ", strtolower($name)))) { + if(strpos(strtolower($setting), str_replace("_", " ", strtolower($name))) !== false) { if($amplifier > 0) { $entity->addEffect(Effect::getEffect($value)->setDuration(INT32_MAX)->setAmplifier($amplifier)); }else { @@ -56,7 +61,7 @@ public function onMask(EntityArmorChangeEvent $event) { } } } - break; + break; case 2: //ZOMBIE $settings = $this->getConfig()->getNested("Zombie Mask", []); foreach($settings as $setting => $amplifier) { @@ -69,7 +74,7 @@ public function onMask(EntityArmorChangeEvent $event) { continue; } foreach($class->getConstants() as $name => $value) { - if(strpos(strtolower($setting), str_replace("_", " ", strtolower($name)))) { + if(strpos(strtolower($setting), str_replace("_", " ", strtolower($name))) !== false) { if($amplifier > 0) { $entity->addEffect(Effect::getEffect($value)->setDuration(INT32_MAX)->setAmplifier($amplifier)); }else { @@ -79,7 +84,7 @@ public function onMask(EntityArmorChangeEvent $event) { } } } - break; + break; case 4: //CREEPER $settings = $this->getConfig()->getNested("Creeper Mask", []); foreach($settings as $setting => $amplifier) { @@ -92,7 +97,7 @@ public function onMask(EntityArmorChangeEvent $event) { continue; } foreach($class->getConstants() as $name => $value) { - if(strpos(strtolower($setting), str_replace("_", " ", strtolower($name)))) { + if(strpos(strtolower($setting), str_replace("_", " ", strtolower($name))) !== false) { if($amplifier > 0) { $entity->addEffect(Effect::getEffect($value)->setDuration(INT32_MAX)->setAmplifier($amplifier)); }else { @@ -102,7 +107,7 @@ public function onMask(EntityArmorChangeEvent $event) { } } } - break; + break; case 5: //DRAGON $settings = $this->getConfig()->getNested("Dragon Mask", []); foreach($settings as $setting => $amplifier) { @@ -115,7 +120,7 @@ public function onMask(EntityArmorChangeEvent $event) { continue; } foreach($class->getConstants() as $name => $value) { - if(strpos(strtolower($setting), str_replace("_", " ", strtolower($name)))) { + if(strpos(strtolower($setting), str_replace("_", " ", strtolower($name))) !== false) { if($amplifier > 0) { $entity->addEffect(Effect::getEffect($value)->setDuration(INT32_MAX)->setAmplifier($amplifier)); }else { @@ -125,7 +130,7 @@ public function onMask(EntityArmorChangeEvent $event) { } } } - break; + break; default: $settings = $this->getConfig()->getNested("No Mask", []); foreach($settings as $setting => $amplifier) { @@ -138,7 +143,7 @@ public function onMask(EntityArmorChangeEvent $event) { continue; } foreach($class->getConstants() as $name => $value) { - if(strpos(strtolower($setting), str_replace("_", " ", strtolower($name)))) { + if(strpos(strtolower($setting), str_replace("_", " ", strtolower($name))) !== false) { if($amplifier > 0) { $entity->addEffect(Effect::getEffect($value)->setDuration(INT32_MAX)->setAmplifier($amplifier)); }else { @@ -307,4 +312,132 @@ public function onCommand(CommandSender $sender, Command $command, string $label } return true; } + + public static function liveUpdateEffects() { + foreach(Server::getInstance()->getOnlinePlayers() as $player) { + $player->removeAllEffects(); + $mask = $player->getArmorInventory()->getHelmet(); + /** @noinspection PhpUnhandledExceptionInspection */ + $class = new \ReflectionClass(Effect::class); + if($mask->getId() === Item::MOB_HEAD) { + switch($mask->getDamage()) { + case 0: //SKELETON + $settings = self::$insance->getConfig()->getNested("Skeleton Mask", []); + foreach($settings as $setting => $amplifier) { + if($setting === "Flight") { + if($amplifier == true) { + $player->setAllowFlight(true); + }else { + $player->setAllowFlight(false); + } + continue; + } + foreach($class->getConstants() as $name => $value) { + if(strpos(strtolower($setting), str_replace("_", " ", strtolower($name))) !== false) { + if($amplifier > 0) { + $player->addEffect(Effect::getEffect($value)->setDuration(INT32_MAX)->setAmplifier($amplifier)); + }else { + $player->removeEffect($value); + } + break; + } + } + } + break; + case 2: //ZOMBIE + $settings = self::$insance->getConfig()->getNested("Zombie Mask", []); + foreach($settings as $setting => $amplifier) { + if($setting === "Flight") { + if($amplifier == true) { + $player->setAllowFlight(true); + }else { + $player->setAllowFlight(false); + } + continue; + } + foreach($class->getConstants() as $name => $value) { + if(strpos(strtolower($setting), str_replace("_", " ", strtolower($name))) !== false) { + if($amplifier > 0) { + $player->addEffect(Effect::getEffect($value)->setDuration(INT32_MAX)->setAmplifier($amplifier)); + }else { + $player->removeEffect($value); + } + break; + } + } + } + break; + case 4: //CREEPER + $settings = self::$insance->getConfig()->getNested("Creeper Mask", []); + foreach($settings as $setting => $amplifier) { + if($setting === "Flight") { + if($amplifier == true) { + $player->setAllowFlight(true); + }else { + $player->setAllowFlight(false); + } + continue; + } + foreach($class->getConstants() as $name => $value) { + if(strpos(strtolower($setting), str_replace("_", " ", strtolower($name))) !== false) { + if($amplifier > 0) { + $player->addEffect(Effect::getEffect($value)->setDuration(INT32_MAX)->setAmplifier($amplifier)); + }else { + $player->removeEffect($value); + } + break; + } + } + } + break; + case 5: //DRAGON + $settings = self::$insance->getConfig()->getNested("Dragon Mask", []); + foreach($settings as $setting => $amplifier) { + if($setting === "Flight") { + if($amplifier == true) { + $player->setAllowFlight(true); + }else { + $player->setAllowFlight(false); + } + continue; + } + foreach($class->getConstants() as $name => $value) { + if(strpos(strtolower($setting), str_replace("_", " ", strtolower($name))) !== false) { + if($amplifier > 0) { + $player->addEffect(Effect::getEffect($value)->setDuration(INT32_MAX)->setAmplifier($amplifier)); + }else { + $player->removeEffect($value); + } + break; + } + } + } + break; + default: + $settings = self::$insance->getConfig()->getNested("No Mask", []); + foreach($settings as $setting => $amplifier) { + if($setting === "Flight") { + if($amplifier == true) { + $player->setAllowFlight(true); + }else { + $player->setAllowFlight(false); + } + continue; + } + foreach($class->getConstants() as $name => $value) { + if(strpos(strtolower($setting), str_replace("_", " ", strtolower($name))) !== false) { + if($amplifier > 0) { + $player->addEffect(Effect::getEffect($value)->setDuration(INT32_MAX)->setAmplifier($amplifier)); + }else { + $player->removeEffect($value); + } + break; + } + } + } + break; + } + } + } + } } \ No newline at end of file diff --git a/Masks/temp b/Masks/temp deleted file mode 100644 index 741f772..0000000 --- a/Masks/temp +++ /dev/null @@ -1,37 +0,0 @@ -Zombie mask -- Haste 5 unlimited time -- Strength 5 unlimited time -- Speed 3 unlimited -- Give poison to the other player level 5 if possible -Dragon mask -- Haste 5 unlimited time -- Strength 5 unlimited time -- Speed 2 unlimited -- Ability to fly -Creeper Mask -- Haste 5 unlimited time -- strength 5 unlimited time -- Speed 3 unlimited time -- Regeneration 5 unlimited time -- Give poison to the Other player level 5 of possible -- Ability to fly -Regular head -- Haste 5 -- Speed 1 -- Strength 3 -Skeleton mask -- Haste 5 unlimited time -- Strength 5 unlimited time -- Speed 4 unlimited -- Ability to fly -??? -- Haste 5 unlimited time -- strength 5 unlimited time -- Speed 3 unlimited time -- Regeneration 5 unlimited time -- Give poison to the Other player level 5 of possible -- Ability to fly - - -GUI to edit mask effects -Book mask charms - tap on ground for random mask \ No newline at end of file From a2b5d8eeb1f6acfc5b17b728da94bf85de86342d Mon Sep 17 00:00:00 2001 From: TheFixerDevelopment <30442910+TheFixerDevelopment@users.noreply.github.com> Date: Wed, 18 Apr 2018 14:12:05 +0100 Subject: [PATCH 16/22] Update plugin.yml --- CrossOnlineCount/plugin.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CrossOnlineCount/plugin.yml b/CrossOnlineCount/plugin.yml index 40bea8e..531e736 100644 --- a/CrossOnlineCount/plugin.yml +++ b/CrossOnlineCount/plugin.yml @@ -1,9 +1,9 @@ name: CombinedSlots main: jasonwynn10\CrossOnlineCount\Main version: 0.1.0 -api: [3.0.0-ALPHA7] +api: [3.0.0-ALPHA11] load: STARTUP author: "jasonwynn10" description: "A PocketMine plugin which checks other servers for online players and displays THE INFORMATIONvia slappers" depend: - - Slapper \ No newline at end of file + - Slapper From 5a59160a783a04c3ad72690062560d90ceefcb69 Mon Sep 17 00:00:00 2001 From: TheFixerDevelopment <30442910+TheFixerDevelopment@users.noreply.github.com> Date: Wed, 18 Apr 2018 16:47:18 +0100 Subject: [PATCH 17/22] Update plugin.yml --- CrossOnlineCount/plugin.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/CrossOnlineCount/plugin.yml b/CrossOnlineCount/plugin.yml index 531e736..d6de3b0 100644 --- a/CrossOnlineCount/plugin.yml +++ b/CrossOnlineCount/plugin.yml @@ -4,6 +4,4 @@ version: 0.1.0 api: [3.0.0-ALPHA11] load: STARTUP author: "jasonwynn10" -description: "A PocketMine plugin which checks other servers for online players and displays THE INFORMATIONvia slappers" -depend: - - Slapper +description: "A PocketMine plugin which checks other servers for online players and displays THE INFORMATIONvia slappers From fb6a9b10ec7d4623fd390b7c0de10748ccab8875 Mon Sep 17 00:00:00 2001 From: TheFixerDevelopment <30442910+TheFixerDevelopment@users.noreply.github.com> Date: Wed, 18 Apr 2018 16:47:47 +0100 Subject: [PATCH 18/22] Fixed. --- CrossOnlineCount/plugin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CrossOnlineCount/plugin.yml b/CrossOnlineCount/plugin.yml index d6de3b0..1ea4d2c 100644 --- a/CrossOnlineCount/plugin.yml +++ b/CrossOnlineCount/plugin.yml @@ -4,4 +4,4 @@ version: 0.1.0 api: [3.0.0-ALPHA11] load: STARTUP author: "jasonwynn10" -description: "A PocketMine plugin which checks other servers for online players and displays THE INFORMATIONvia slappers +description: "A PocketMine plugin which checks other servers for online players and displays THE INFORMATIONvia slappers" From 9a19a073eb82c4a5467cc28e17e9d7223f9449ad Mon Sep 17 00:00:00 2001 From: notacoderr <38270548+notacoderr@users.noreply.github.com> Date: Thu, 14 Nov 2019 00:51:04 +0400 Subject: [PATCH 19/22] Update Main.php --- CrossOnlineCount/src/jasonwynn10/CrossOnlineCount/Main.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CrossOnlineCount/src/jasonwynn10/CrossOnlineCount/Main.php b/CrossOnlineCount/src/jasonwynn10/CrossOnlineCount/Main.php index 8442a5e..3d49183 100644 --- a/CrossOnlineCount/src/jasonwynn10/CrossOnlineCount/Main.php +++ b/CrossOnlineCount/src/jasonwynn10/CrossOnlineCount/Main.php @@ -14,7 +14,7 @@ class Main extends PluginBase implements Listener { public function onEnable() { SpoonDetector::printSpoon($this, "spoon.txt"); - $this->getServer()->getScheduler()->scheduleRepeatingTask(new UpdateTask($this), 5); // server updates query data every 5 ticks + $this->getScheduler()->scheduleRepeatingTask(new UpdateTask($this), 5); // server updates query data every 5 ticks $this->getServer()->getPluginManager()->registerEvents($this, $this); } @@ -108,4 +108,4 @@ public function is_valid_domain_name(string $domain_name) { public function isValidIP(string $ip) { return (preg_match("/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}):(\d{1,5})/", $ip) !== false); } -} \ No newline at end of file +} From ccdd16fbc50e0daefa755c5f0848747ac5051af1 Mon Sep 17 00:00:00 2001 From: notacoderr <38270548+notacoderr@users.noreply.github.com> Date: Thu, 14 Nov 2019 00:52:22 +0400 Subject: [PATCH 20/22] Update plugin.yml --- CrossOnlineCount/plugin.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CrossOnlineCount/plugin.yml b/CrossOnlineCount/plugin.yml index 1ea4d2c..65e11b9 100644 --- a/CrossOnlineCount/plugin.yml +++ b/CrossOnlineCount/plugin.yml @@ -1,7 +1,7 @@ name: CombinedSlots main: jasonwynn10\CrossOnlineCount\Main -version: 0.1.0 -api: [3.0.0-ALPHA11] +version: 0.2.0 +api: [3.8.0, 4.0.0] load: STARTUP author: "jasonwynn10" description: "A PocketMine plugin which checks other servers for online players and displays THE INFORMATIONvia slappers" From eeff6e354ec2b71b7c6e8a7a4829da44ddc197e7 Mon Sep 17 00:00:00 2001 From: notacoderr <38270548+notacoderr@users.noreply.github.com> Date: Thu, 14 Nov 2019 00:56:07 +0400 Subject: [PATCH 21/22] Update UpdateTask.php --- .../src/jasonwynn10/CrossOnlineCount/UpdateTask.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CrossOnlineCount/src/jasonwynn10/CrossOnlineCount/UpdateTask.php b/CrossOnlineCount/src/jasonwynn10/CrossOnlineCount/UpdateTask.php index 4370355..e22993d 100644 --- a/CrossOnlineCount/src/jasonwynn10/CrossOnlineCount/UpdateTask.php +++ b/CrossOnlineCount/src/jasonwynn10/CrossOnlineCount/UpdateTask.php @@ -1,10 +1,10 @@ getOwner()->update(); } -} \ No newline at end of file +} From d3a6ca1da4fd4973be6834afdd09b74015ed7612 Mon Sep 17 00:00:00 2001 From: notacoderr <38270548+notacoderr@users.noreply.github.com> Date: Thu, 14 Nov 2019 01:15:57 +0400 Subject: [PATCH 22/22] Update plugin.yml --- CrossOnlineCount/plugin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CrossOnlineCount/plugin.yml b/CrossOnlineCount/plugin.yml index 65e11b9..3576048 100644 --- a/CrossOnlineCount/plugin.yml +++ b/CrossOnlineCount/plugin.yml @@ -1,7 +1,7 @@ name: CombinedSlots main: jasonwynn10\CrossOnlineCount\Main version: 0.2.0 -api: [3.8.0, 4.0.0] +api: [3.8.0] load: STARTUP author: "jasonwynn10" description: "A PocketMine plugin which checks other servers for online players and displays THE INFORMATIONvia slappers"