use of com.sk89q.minecraft.util.commands.Command in project WorldGuard by EngineHub.
the class GeneralCommands method slay.
@Command(aliases = { "slay" }, usage = "[player]", desc = "Slay a player", flags = "s", max = 1)
public void slay(CommandContext args, Actor sender) throws CommandException, AuthorizationException {
Iterable<? extends LocalPlayer> targets = Lists.newArrayList();
boolean included = false;
// Detect arguments based on the number of arguments provided
if (args.argsLength() == 0) {
targets = worldGuard.getPlatform().getMatcher().matchPlayers(worldGuard.checkPlayer(sender));
// Check permissions!
sender.checkPermission("worldguard.slay");
} else if (args.argsLength() == 1) {
targets = worldGuard.getPlatform().getMatcher().matchPlayers(sender, args.getString(0));
// Check permissions!
sender.checkPermission("worldguard.slay.other");
}
for (LocalPlayer player : targets) {
player.setHealth(0);
// Tell the user
if (player.equals(sender)) {
player.print("Slain!");
// Keep track of this
included = true;
} else {
player.print("Slain by " + sender.getDisplayName() + ".");
}
}
// user a message so s/he know that something is indeed working
if (!included && args.hasFlag('s')) {
sender.print("Players slain.");
}
}
Aggregations