From 050442fac3bc54004ab3e96f453ed3fa6f353b91 Mon Sep 17 00:00:00 2001 From: TomyLobo Date: Wed, 21 Dec 2011 18:10:34 +0100 Subject: [PATCH] Added a -l flag to /butcher, which spawns fake lightning on all killed entities. --- src/main/java/com/sk89q/worldedit/LocalWorld.java | 1 + src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java | 4 ++++ .../java/com/sk89q/worldedit/commands/UtilityCommands.java | 6 ++++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/sk89q/worldedit/LocalWorld.java b/src/main/java/com/sk89q/worldedit/LocalWorld.java index f63d980ad..1dbd90927 100644 --- a/src/main/java/com/sk89q/worldedit/LocalWorld.java +++ b/src/main/java/com/sk89q/worldedit/LocalWorld.java @@ -39,6 +39,7 @@ public abstract class LocalWorld { public static final int PETS = 1 << 0; public static final int NPCS = 1 << 1; public static final int ANIMALS = 1 << 2; + public static final int WITH_LIGHTNING = 1 << 20; } /** diff --git a/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java b/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java index f16d220fa..361aae7db 100644 --- a/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java +++ b/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java @@ -475,6 +475,7 @@ public class BukkitWorld extends LocalWorld { boolean killPets = (flags & KillFlags.PETS) != 0; boolean killNPCs = (flags & KillFlags.NPCS) != 0; boolean killAnimals = (flags & KillFlags.ANIMALS) != 0; + boolean withLightning = (flags & KillFlags.WITH_LIGHTNING) != 0; int num = 0; double radiusSq = radius * radius; @@ -502,6 +503,9 @@ public class BukkitWorld extends LocalWorld { } catch (ClassNotFoundException e) {} if (radius < 0 || bukkitOrigin.distanceSquared(ent.getLocation()) <= radiusSq) { + if (withLightning) { + world.strikeLightningEffect(ent.getLocation()); + } ent.remove(); ++num; } diff --git a/src/main/java/com/sk89q/worldedit/commands/UtilityCommands.java b/src/main/java/com/sk89q/worldedit/commands/UtilityCommands.java index df659e263..2316ac10c 100644 --- a/src/main/java/com/sk89q/worldedit/commands/UtilityCommands.java +++ b/src/main/java/com/sk89q/worldedit/commands/UtilityCommands.java @@ -346,14 +346,15 @@ public class UtilityCommands { @Command( aliases = { "butcher" }, usage = "[radius]", - flags = "pna", + flags = "plan", desc = "Kill all or nearby mobs", help = "Kills nearby mobs, or all mobs if you don't specify a radius.\n" + "Flags:" + " -p also kills pets.\n" + " -n also kills NPCs.\n" + - " -a also kills animals.", + " -a also kills animals.\n" + + " -l strikes lightning on each killed mob.", min = 0, max = 1 ) @@ -369,6 +370,7 @@ public class UtilityCommands { if (args.hasFlag('p')) flags |= KillFlags.PETS; if (args.hasFlag('n')) flags |= KillFlags.NPCS; if (args.hasFlag('a')) flags |= KillFlags.ANIMALS; + if (args.hasFlag('l') && player.hasPermission("worldedit.butcher.lightning")) flags |= KillFlags.WITH_LIGHTNING; int killed; if (player.isPlayer()) {