mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 17:57:38 +00:00
Added a -a flag to /butcher to kill animals. Its now disabled by default.
This commit is contained in:
parent
bc3a4377ec
commit
c21c380bba
@ -38,6 +38,7 @@ public abstract class LocalWorld {
|
||||
public class KillFlags {
|
||||
public static final int PETS = 1 << 0;
|
||||
public static final int NPCS = 1 << 1;
|
||||
public static final int ANIMALS = 1 << 2;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -33,6 +33,7 @@ import org.bukkit.block.Furnace;
|
||||
import org.bukkit.block.CreatureSpawner;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Animals;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Boat;
|
||||
import org.bukkit.entity.Entity;
|
||||
@ -500,6 +501,7 @@ public class BukkitWorld extends LocalWorld {
|
||||
public int killMobs(Vector origin, double radius, int flags) {
|
||||
boolean killPets = (flags & KillFlags.PETS) != 0;
|
||||
boolean killNPCs = (flags & KillFlags.NPCS) != 0;
|
||||
boolean killAnimals = (flags & KillFlags.ANIMALS) != 0;
|
||||
|
||||
int num = 0;
|
||||
double radiusSq = radius * radius;
|
||||
@ -511,6 +513,10 @@ public class BukkitWorld extends LocalWorld {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!killAnimals && ent instanceof Animals) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!killPets && ent instanceof Tameable && ((Tameable) ent).isTamed()) {
|
||||
continue; // tamed wolf
|
||||
}
|
||||
|
@ -345,13 +345,14 @@ public class UtilityCommands {
|
||||
@Command(
|
||||
aliases = { "butcher" },
|
||||
usage = "[radius]",
|
||||
flags = "pn",
|
||||
flags = "pna",
|
||||
desc = "Kill all or nearby mobs",
|
||||
help =
|
||||
"Kills nearby mobs, or all mobs if you don't specify a radius.\n" +
|
||||
"Flags:" +
|
||||
" -p also kill pets.\n" +
|
||||
" -n also kill NPCs.",
|
||||
" -p also kills pets.\n" +
|
||||
" -n also kills NPCs.\n" +
|
||||
" -a also kills animals.",
|
||||
min = 0,
|
||||
max = 1
|
||||
)
|
||||
@ -368,6 +369,7 @@ public class UtilityCommands {
|
||||
int flags = 0;
|
||||
if (args.hasFlag('p')) flags |= KillFlags.PETS;
|
||||
if (args.hasFlag('n')) flags |= KillFlags.NPCS;
|
||||
if (args.hasFlag('a')) flags |= KillFlags.ANIMALS;
|
||||
|
||||
int killed = player.getWorld().killMobs(origin, radius, flags);
|
||||
player.print("Killed " + killed + " mobs.");
|
||||
|
Loading…
Reference in New Issue
Block a user