diff --git a/src/main/java/pw/kaboom/extras/Main.java b/src/main/java/pw/kaboom/extras/Main.java index 155a366..f466d0f 100644 --- a/src/main/java/pw/kaboom/extras/Main.java +++ b/src/main/java/pw/kaboom/extras/Main.java @@ -5,20 +5,7 @@ import java.util.Collections; import org.bukkit.block.BlockFace; import org.bukkit.plugin.java.JavaPlugin; -import pw.kaboom.extras.commands.CommandClearChat; -import pw.kaboom.extras.commands.CommandConsole; -import pw.kaboom.extras.commands.CommandDestroyEntities; -import pw.kaboom.extras.commands.CommandEnchantAll; -import pw.kaboom.extras.commands.CommandJumpscare; -import pw.kaboom.extras.commands.CommandPrefix; -import pw.kaboom.extras.commands.CommandPumpkin; -import pw.kaboom.extras.commands.CommandServerInfo; -import pw.kaboom.extras.commands.CommandSkin; -import pw.kaboom.extras.commands.CommandSpawn; -import pw.kaboom.extras.commands.CommandSpidey; -import pw.kaboom.extras.commands.CommandTellraw; -import pw.kaboom.extras.commands.CommandUnloadChunks; -import pw.kaboom.extras.commands.CommandUsername; +import pw.kaboom.extras.commands.*; import pw.kaboom.extras.modules.block.BlockCheck; import pw.kaboom.extras.modules.block.BlockPhysics; import pw.kaboom.extras.modules.entity.EntityExplosion; @@ -426,6 +413,7 @@ public final class Main extends JavaPlugin { this.getCommand("destroyentities").setExecutor(new CommandDestroyEntities()); this.getCommand("enchantall").setExecutor(new CommandEnchantAll()); this.getCommand("jumpscare").setExecutor(new CommandJumpscare()); + this.getCommand("kaboom").setExecutor(new CommandKaboom()); this.getCommand("prefix").setExecutor(new CommandPrefix()); this.getCommand("pumpkin").setExecutor(new CommandPumpkin()); this.getCommand("serverinfo").setExecutor(new CommandServerInfo()); diff --git a/src/main/java/pw/kaboom/extras/commands/CommandKaboom.java b/src/main/java/pw/kaboom/extras/commands/CommandKaboom.java new file mode 100644 index 0000000..cc4c996 --- /dev/null +++ b/src/main/java/pw/kaboom/extras/commands/CommandKaboom.java @@ -0,0 +1,52 @@ +package pw.kaboom.extras.commands; + +import org.bukkit.Location; + +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; + +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import java.util.Random; + +public final class CommandKaboom implements CommandExecutor { + private double getRandom(final int min, final int max) { + return new Random().nextInt(max - min + 1) + min; + } + + public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) { + final Player player = (Player) sender; + int random = new Random().nextBoolean() ? 0 : 1; + + if (random == 0) { + final Location location = player.getLocation(); + final World world = player.getWorld(); + final int explosionCount = 20; + final int power = 8; + + world.createExplosion(location, power, true, true); + + for (int i = 0; i < explosionCount; i++) { + final double posX = location.getX() + getRandom(-15, 15); + final double posY = location.getY() + getRandom(-6, 6); + final double posZ = location.getZ() + getRandom(-15, 15); + + final Location explodeLocation = new Location(world, posX, posY, posZ); + final int power2 = 4; + + world.createExplosion(explodeLocation, power2, true, true); + explodeLocation.getBlock().setType(Material.LAVA); + } + + player.sendMessage("Forgive me :c"); + } else { + player.getInventory().setItemInMainHand(new ItemStack(Material.CAKE)); + player.sendMessage("Have a nice day :)"); + } + return true; + } +} \ No newline at end of file diff --git a/src/main/java/pw/kaboom/extras/commands/CommandPumpkin.java b/src/main/java/pw/kaboom/extras/commands/CommandPumpkin.java index 00db337..8ac28d7 100644 --- a/src/main/java/pw/kaboom/extras/commands/CommandPumpkin.java +++ b/src/main/java/pw/kaboom/extras/commands/CommandPumpkin.java @@ -32,7 +32,7 @@ public final class CommandPumpkin implements CommandExecutor { placePumpkin(target); sender.sendMessage("Player \"" + target.getName() + "\" is now a pumpkin"); } else { - sender.sendMessage("Player \"" + target.getName() + "\" not found"); + sender.sendMessage("Player \"" + args[0] + "\" not found"); } } } diff --git a/src/main/java/pw/kaboom/extras/commands/CommandSkin.java b/src/main/java/pw/kaboom/extras/commands/CommandSkin.java index 1e36af7..d800f27 100644 --- a/src/main/java/pw/kaboom/extras/commands/CommandSkin.java +++ b/src/main/java/pw/kaboom/extras/commands/CommandSkin.java @@ -7,7 +7,6 @@ import org.bukkit.command.CommandSender; import org.bukkit.command.ConsoleCommandSender; import org.bukkit.entity.Player; -import pw.kaboom.extras.Main; import pw.kaboom.extras.helpers.SkinDownloader; public final class CommandSkin implements CommandExecutor { @@ -20,7 +19,7 @@ public final class CommandSkin implements CommandExecutor { if (args.length == 0) { player.sendMessage(ChatColor.RED + "Usage: /" + label + " "); - } else if (!Main.skinInProgress.contains(player.getUniqueId())) { + } else if (!SkinDownloader.skinInProgress.contains(player.getUniqueId())) { final String name = args[0]; final boolean shouldChangeUsername = false; final boolean shouldSendMessage = true; diff --git a/src/main/java/pw/kaboom/extras/commands/CommandUsername.java b/src/main/java/pw/kaboom/extras/commands/CommandUsername.java index e690d4d..7478a5f 100644 --- a/src/main/java/pw/kaboom/extras/commands/CommandUsername.java +++ b/src/main/java/pw/kaboom/extras/commands/CommandUsername.java @@ -20,7 +20,7 @@ public final class CommandUsername implements CommandExecutor { if (args.length == 0) { player.sendMessage(ChatColor.RED + "Usage: /" + label + " "); - } else if (!Main.skinInProgress.contains(player.getUniqueId())) { + } else if (!SkinDownloader.skinInProgress.contains(player.getUniqueId())) { final String nameColor = ChatColor.translateAlternateColorCodes('&', String.join(" ", args)); final String name = nameColor.substring(0, Math.min(16, nameColor.length())); final boolean shouldChangeUsername = true; diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index a3e7ab4..e151fbd 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -27,6 +27,9 @@ commands: aliases: scare description: Scares a player permission: extras.jumpscare + kaboom: + description: I wonder... + permission: extras.kaboom prefix: aliases: [rank, tag] description: Changes your tag