diff --git a/plugin.yml b/plugin.yml index 10086e1..7a80a91 100644 --- a/plugin.yml +++ b/plugin.yml @@ -3,5 +3,10 @@ name: C4 author: TonyDroidd api: 1.12.0 description: A simple plugin that add C4 to your server -version: 1.0 -main: TDroidd\C4\Main \ No newline at end of file +version: 1.1 +main: TDroidd\C4\Main + +commands: + boom: + permission: c4.boom + default: op \ No newline at end of file diff --git a/src/TDroidd/C4/Main.php b/src/TDroidd/C4/Main.php index 9a862ec..930d0dc 100644 --- a/src/TDroidd/C4/Main.php +++ b/src/TDroidd/C4/Main.php @@ -1,6 +1,7 @@ getName() === "boom") { + if(count($args)) { + if(!isset($args[1])) { + $sender->sendMessage("Usage: /boom true|false"); + return false; + } + if(is_numeric($args[0])) { + $sender->sendMessage(TextFormat::YELLOW . "Boom!"); + $e = new Explosion($sender, $args[0]); + switch ($args[1]) { + case "true": + $e->explodeA(); + $e->explodeB(); + break; + case "false": + $e->explodeB(); + break; + } + } else { + $sender->sendMessage(TextFormat::RED . "Select radius in numeric value!"); + return; + } + } + } + } + + public function onMove(PlayerMoveEvent $event){ $cfg = $this->getConfig(); $player = $event->getPlayer(); - $c4 = $block = $player->getLevel()->getBlockIdAt($player->x, ($player->y -0.1), $player->z); + $c4 = $event->getPlayer()->getLevel()->getBlock($event->getPlayer()->floor()->subtract(0, 1)); $e = new Explosion($player, $cfg->get("Explosion-Radius")); - if($c4 === $cfg->get("C4-Block")){ + if($c4->getId() === $cfg->get("C4-Block")) { if($cfg->get("Remove-Terrain") == true){ $player->sendMessage(TextFormat::YELLOW . "[C-4]" . TextFormat::RED . " Booom!!"); $e->explodeA();