2014-04-03 02:08:50 +00:00
|
|
|
/*
|
2014-04-04 22:03:18 +00:00
|
|
|
* WorldEdit, a Minecraft world manipulation toolkit
|
|
|
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
|
|
|
* Copyright (C) WorldEdit team and contributors
|
2014-04-03 02:08:50 +00:00
|
|
|
*
|
2014-04-04 22:03:18 +00:00
|
|
|
* This program is free software: you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU Lesser General Public License as published by the
|
|
|
|
* Free Software Foundation, either version 3 of the License, or
|
2014-04-03 02:08:50 +00:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
2014-04-04 22:03:18 +00:00
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
|
|
|
* for more details.
|
2014-04-03 02:08:50 +00:00
|
|
|
*
|
2014-04-04 22:03:18 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
2014-04-03 02:08:50 +00:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2014-04-04 22:03:18 +00:00
|
|
|
*/
|
2014-04-03 02:08:50 +00:00
|
|
|
|
|
|
|
package com.sk89q.worldedit.command;
|
|
|
|
|
|
|
|
import com.sk89q.minecraft.util.commands.*;
|
|
|
|
import com.sk89q.worldedit.*;
|
|
|
|
import com.sk89q.worldedit.LocalWorld.KillFlags;
|
|
|
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
2014-06-28 00:55:39 +00:00
|
|
|
import com.sk89q.worldedit.entity.Player;
|
|
|
|
import com.sk89q.worldedit.extension.platform.Actor;
|
2014-04-03 02:08:50 +00:00
|
|
|
import com.sk89q.worldedit.patterns.Pattern;
|
|
|
|
import com.sk89q.worldedit.patterns.SingleBlockPattern;
|
|
|
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
|
|
|
import com.sk89q.worldedit.regions.Region;
|
2014-06-27 23:03:29 +00:00
|
|
|
import com.sk89q.worldedit.util.command.CommandMapping;
|
|
|
|
import com.sk89q.worldedit.util.command.Description;
|
|
|
|
import com.sk89q.worldedit.util.command.Dispatcher;
|
2014-06-28 00:55:39 +00:00
|
|
|
import com.sk89q.worldedit.util.command.parametric.Optional;
|
2014-04-05 09:59:38 +00:00
|
|
|
import com.sk89q.worldedit.world.World;
|
2014-04-03 02:08:50 +00:00
|
|
|
|
|
|
|
import java.util.Comparator;
|
|
|
|
import java.util.Set;
|
|
|
|
import java.util.SortedSet;
|
|
|
|
import java.util.TreeSet;
|
|
|
|
|
|
|
|
import static com.sk89q.minecraft.util.commands.Logging.LogMode.PLACEMENT;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Utility commands.
|
|
|
|
*
|
|
|
|
* @author sk89q
|
|
|
|
*/
|
|
|
|
public class UtilityCommands {
|
|
|
|
private final WorldEdit we;
|
|
|
|
|
|
|
|
public UtilityCommands(WorldEdit we) {
|
|
|
|
this.we = we;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
|
|
|
aliases = { "/fill" },
|
|
|
|
usage = "<block> <radius> [depth]",
|
|
|
|
desc = "Fill a hole",
|
|
|
|
min = 2,
|
|
|
|
max = 3
|
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.fill")
|
|
|
|
@Logging(PLACEMENT)
|
2014-06-28 08:01:49 +00:00
|
|
|
public void fill(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
2014-04-03 02:08:50 +00:00
|
|
|
|
|
|
|
Pattern pattern = we.getBlockPattern(player, args.getString(0));
|
|
|
|
double radius = Math.max(1, args.getDouble(1));
|
|
|
|
we.checkMaxRadius(radius);
|
|
|
|
int depth = args.argsLength() > 2 ? Math.max(1, args.getInteger(2)) : 1;
|
|
|
|
|
|
|
|
Vector pos = session.getPlacementPosition(player);
|
|
|
|
int affected = 0;
|
|
|
|
if (pattern instanceof SingleBlockPattern) {
|
|
|
|
affected = editSession.fillXZ(pos,
|
|
|
|
((SingleBlockPattern) pattern).getBlock(),
|
|
|
|
radius, depth, false);
|
|
|
|
} else {
|
|
|
|
affected = editSession.fillXZ(pos, pattern, radius, depth, false);
|
|
|
|
}
|
|
|
|
player.print(affected + " block(s) have been created.");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
|
|
|
aliases = { "/fillr" },
|
|
|
|
usage = "<block> <radius> [depth]",
|
|
|
|
desc = "Fill a hole recursively",
|
|
|
|
min = 2,
|
|
|
|
max = 3
|
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.fill.recursive")
|
|
|
|
@Logging(PLACEMENT)
|
2014-06-28 08:01:49 +00:00
|
|
|
public void fillr(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
2014-04-03 02:08:50 +00:00
|
|
|
|
|
|
|
Pattern pattern = we.getBlockPattern(player, args.getString(0));
|
|
|
|
double radius = Math.max(1, args.getDouble(1));
|
|
|
|
we.checkMaxRadius(radius);
|
|
|
|
int depth = args.argsLength() > 2 ? Math.max(1, args.getInteger(2)) : Integer.MAX_VALUE;
|
|
|
|
|
|
|
|
Vector pos = session.getPlacementPosition(player);
|
|
|
|
int affected = 0;
|
|
|
|
if (pattern instanceof SingleBlockPattern) {
|
|
|
|
affected = editSession.fillXZ(pos,
|
|
|
|
((SingleBlockPattern) pattern).getBlock(),
|
|
|
|
radius, depth, true);
|
|
|
|
} else {
|
|
|
|
affected = editSession.fillXZ(pos, pattern, radius, depth, true);
|
|
|
|
}
|
|
|
|
player.print(affected + " block(s) have been created.");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
|
|
|
aliases = { "/drain" },
|
|
|
|
usage = "<radius>",
|
|
|
|
desc = "Drain a pool",
|
|
|
|
min = 1,
|
|
|
|
max = 1
|
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.drain")
|
|
|
|
@Logging(PLACEMENT)
|
2014-06-28 08:01:49 +00:00
|
|
|
public void drain(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
2014-04-03 02:08:50 +00:00
|
|
|
|
|
|
|
double radius = Math.max(0, args.getDouble(0));
|
|
|
|
we.checkMaxRadius(radius);
|
|
|
|
int affected = editSession.drainArea(
|
|
|
|
session.getPlacementPosition(player), radius);
|
|
|
|
player.print(affected + " block(s) have been changed.");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
|
|
|
aliases = { "/fixlava", "fixlava" },
|
|
|
|
usage = "<radius>",
|
|
|
|
desc = "Fix lava to be stationary",
|
|
|
|
min = 1,
|
|
|
|
max = 1
|
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.fixlava")
|
|
|
|
@Logging(PLACEMENT)
|
2014-06-28 08:01:49 +00:00
|
|
|
public void fixLava(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
2014-04-03 02:08:50 +00:00
|
|
|
|
|
|
|
double radius = Math.max(0, args.getDouble(0));
|
|
|
|
we.checkMaxRadius(radius);
|
|
|
|
int affected = editSession.fixLiquid(
|
|
|
|
session.getPlacementPosition(player), radius, 10, 11);
|
|
|
|
player.print(affected + " block(s) have been changed.");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
|
|
|
aliases = { "/fixwater", "fixwater" },
|
|
|
|
usage = "<radius>",
|
|
|
|
desc = "Fix water to be stationary",
|
|
|
|
min = 1,
|
|
|
|
max = 1
|
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.fixwater")
|
|
|
|
@Logging(PLACEMENT)
|
2014-06-28 08:01:49 +00:00
|
|
|
public void fixWater(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
2014-04-03 02:08:50 +00:00
|
|
|
|
|
|
|
double radius = Math.max(0, args.getDouble(0));
|
|
|
|
we.checkMaxRadius(radius);
|
|
|
|
int affected = editSession.fixLiquid(
|
|
|
|
session.getPlacementPosition(player), radius, 8, 9);
|
|
|
|
player.print(affected + " block(s) have been changed.");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
|
|
|
aliases = { "/removeabove", "removeabove" },
|
|
|
|
usage = "[size] [height]",
|
|
|
|
desc = "Remove blocks above your head.",
|
|
|
|
min = 0,
|
|
|
|
max = 2
|
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.removeabove")
|
|
|
|
@Logging(PLACEMENT)
|
2014-06-28 08:01:49 +00:00
|
|
|
public void removeAbove(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
2014-04-03 02:08:50 +00:00
|
|
|
|
|
|
|
int size = args.argsLength() > 0 ? Math.max(1, args.getInteger(0)) : 1;
|
|
|
|
we.checkMaxRadius(size);
|
2014-04-05 09:59:38 +00:00
|
|
|
World world = player.getWorld();
|
2014-04-03 02:08:50 +00:00
|
|
|
int height = args.argsLength() > 1 ? Math.min((world.getMaxY() + 1), args.getInteger(1) + 2) : (world.getMaxY() + 1);
|
|
|
|
|
|
|
|
int affected = editSession.removeAbove(
|
|
|
|
session.getPlacementPosition(player), size, height);
|
|
|
|
player.print(affected + " block(s) have been removed.");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
|
|
|
aliases = { "/removebelow", "removebelow" },
|
|
|
|
usage = "[size] [height]",
|
|
|
|
desc = "Remove blocks below you.",
|
|
|
|
min = 0,
|
|
|
|
max = 2
|
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.removebelow")
|
|
|
|
@Logging(PLACEMENT)
|
2014-06-28 08:01:49 +00:00
|
|
|
public void removeBelow(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
2014-04-03 02:08:50 +00:00
|
|
|
|
|
|
|
int size = args.argsLength() > 0 ? Math.max(1, args.getInteger(0)) : 1;
|
|
|
|
we.checkMaxRadius(size);
|
2014-04-05 09:59:38 +00:00
|
|
|
World world = player.getWorld();
|
2014-04-03 02:08:50 +00:00
|
|
|
int height = args.argsLength() > 1 ? Math.min((world.getMaxY() + 1), args.getInteger(1) + 2) : (world.getMaxY() + 1);
|
|
|
|
|
|
|
|
int affected = editSession.removeBelow(session.getPlacementPosition(player), size, height);
|
|
|
|
player.print(affected + " block(s) have been removed.");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
|
|
|
aliases = { "/removenear", "removenear" },
|
|
|
|
usage = "<block> [size]",
|
|
|
|
desc = "Remove blocks near you.",
|
|
|
|
min = 1,
|
|
|
|
max = 2
|
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.removenear")
|
|
|
|
@Logging(PLACEMENT)
|
2014-06-28 08:01:49 +00:00
|
|
|
public void removeNear(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
2014-04-03 02:08:50 +00:00
|
|
|
|
|
|
|
BaseBlock block = we.getBlock(player, args.getString(0), true);
|
|
|
|
int size = Math.max(1, args.getInteger(1, 50));
|
|
|
|
we.checkMaxRadius(size);
|
|
|
|
|
|
|
|
int affected = editSession.removeNear(session.getPlacementPosition(player), block.getType(), size);
|
|
|
|
player.print(affected + " block(s) have been removed.");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
|
|
|
aliases = { "/replacenear", "replacenear" },
|
|
|
|
usage = "<size> <from-id> <to-id>",
|
|
|
|
desc = "Replace nearby blocks",
|
|
|
|
flags = "f",
|
|
|
|
min = 3,
|
|
|
|
max = 3
|
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.replacenear")
|
|
|
|
@Logging(PLACEMENT)
|
2014-06-28 08:01:49 +00:00
|
|
|
public void replaceNear(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
2014-04-03 02:08:50 +00:00
|
|
|
|
|
|
|
int size = Math.max(1, args.getInteger(0));
|
|
|
|
int affected;
|
|
|
|
Set<BaseBlock> from;
|
|
|
|
Pattern to;
|
|
|
|
if (args.argsLength() == 2) {
|
|
|
|
from = null;
|
|
|
|
to = we.getBlockPattern(player, args.getString(1));
|
|
|
|
} else {
|
|
|
|
from = we.getBlocks(player, args.getString(1), true, !args.hasFlag('f'));
|
|
|
|
to = we.getBlockPattern(player, args.getString(2));
|
|
|
|
}
|
|
|
|
|
|
|
|
Vector base = session.getPlacementPosition(player);
|
|
|
|
Vector min = base.subtract(size, size, size);
|
|
|
|
Vector max = base.add(size, size, size);
|
|
|
|
Region region = new CuboidRegion(player.getWorld(), min, max);
|
|
|
|
|
|
|
|
if (to instanceof SingleBlockPattern) {
|
|
|
|
affected = editSession.replaceBlocks(region, from, ((SingleBlockPattern) to).getBlock());
|
|
|
|
} else {
|
|
|
|
affected = editSession.replaceBlocks(region, from, to);
|
|
|
|
}
|
|
|
|
player.print(affected + " block(s) have been replaced.");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
|
|
|
aliases = { "/snow", "snow" },
|
|
|
|
usage = "[radius]",
|
|
|
|
desc = "Simulates snow",
|
|
|
|
min = 0,
|
|
|
|
max = 1
|
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.snow")
|
|
|
|
@Logging(PLACEMENT)
|
2014-06-28 08:01:49 +00:00
|
|
|
public void snow(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
2014-04-03 02:08:50 +00:00
|
|
|
|
|
|
|
double size = args.argsLength() > 0 ? Math.max(1, args.getDouble(0)) : 10;
|
|
|
|
|
|
|
|
int affected = editSession.simulateSnow(session.getPlacementPosition(player), size);
|
|
|
|
player.print(affected + " surfaces covered. Let it snow~");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
|
|
|
aliases = {"/thaw", "thaw"},
|
|
|
|
usage = "[radius]",
|
|
|
|
desc = "Thaws the area",
|
|
|
|
min = 0,
|
|
|
|
max = 1
|
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.thaw")
|
|
|
|
@Logging(PLACEMENT)
|
2014-06-28 08:01:49 +00:00
|
|
|
public void thaw(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
2014-04-03 02:08:50 +00:00
|
|
|
|
|
|
|
double size = args.argsLength() > 0 ? Math.max(1, args.getDouble(0)) : 10;
|
|
|
|
|
|
|
|
int affected = editSession.thaw(session.getPlacementPosition(player), size);
|
|
|
|
player.print(affected + " surfaces thawed.");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
|
|
|
aliases = { "/green", "green" },
|
|
|
|
usage = "[radius]",
|
|
|
|
desc = "Greens the area",
|
|
|
|
flags = "f",
|
|
|
|
min = 0,
|
|
|
|
max = 1
|
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.green")
|
|
|
|
@Logging(PLACEMENT)
|
2014-06-28 08:01:49 +00:00
|
|
|
public void green(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
2014-04-03 02:08:50 +00:00
|
|
|
|
|
|
|
final double size = args.argsLength() > 0 ? Math.max(1, args.getDouble(0)) : 10;
|
|
|
|
final boolean onlyNormalDirt = !args.hasFlag('f');
|
|
|
|
|
|
|
|
final int affected = editSession.green(session.getPlacementPosition(player), size, onlyNormalDirt);
|
|
|
|
player.print(affected + " surfaces greened.");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
|
|
|
aliases = { "/ex", "/ext", "/extinguish", "ex", "ext", "extinguish" },
|
|
|
|
usage = "[radius]",
|
|
|
|
desc = "Extinguish nearby fire",
|
|
|
|
min = 0,
|
|
|
|
max = 1
|
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.extinguish")
|
|
|
|
@Logging(PLACEMENT)
|
2014-06-28 08:01:49 +00:00
|
|
|
public void extinguish(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
2014-04-03 02:08:50 +00:00
|
|
|
|
|
|
|
LocalConfiguration config = we.getConfiguration();
|
|
|
|
|
|
|
|
int defaultRadius = config.maxRadius != -1 ? Math.min(40, config.maxRadius) : 40;
|
|
|
|
int size = args.argsLength() > 0 ? Math.max(1, args.getInteger(0))
|
|
|
|
: defaultRadius;
|
|
|
|
we.checkMaxRadius(size);
|
|
|
|
|
|
|
|
int affected = editSession.removeNear(session.getPlacementPosition(player), 51, size);
|
|
|
|
player.print(affected + " block(s) have been removed.");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
|
|
|
aliases = { "butcher" },
|
|
|
|
usage = "[radius]",
|
2014-05-02 00:36:11 +00:00
|
|
|
flags = "plangbtf",
|
2014-04-03 02:08:50 +00:00
|
|
|
desc = "Kill all or nearby mobs",
|
|
|
|
help =
|
|
|
|
"Kills nearby mobs, based on radius, if none is given uses default in configuration.\n" +
|
|
|
|
"Flags:" +
|
|
|
|
" -p also kills pets.\n" +
|
|
|
|
" -n also kills NPCs.\n" +
|
|
|
|
" -g also kills Golems.\n" +
|
|
|
|
" -a also kills animals.\n" +
|
|
|
|
" -b also kills ambient mobs.\n" +
|
2014-05-02 00:36:11 +00:00
|
|
|
" -t also kills mobs with name tags.\n" +
|
2014-04-03 02:08:50 +00:00
|
|
|
" -f compounds all previous flags.\n" +
|
|
|
|
" -l strikes lightning on each killed mob.",
|
|
|
|
min = 0,
|
|
|
|
max = 1
|
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.butcher")
|
|
|
|
@Logging(PLACEMENT)
|
2014-06-28 00:55:39 +00:00
|
|
|
public void butcher(Actor actor, @Optional Player player, @Optional LocalSession session, CommandContext args) throws WorldEditException {
|
2014-04-03 02:08:50 +00:00
|
|
|
|
|
|
|
LocalConfiguration config = we.getConfiguration();
|
|
|
|
|
|
|
|
// technically the default can be larger than the max, but that's not my problem
|
|
|
|
int radius = config.butcherDefaultRadius;
|
|
|
|
|
|
|
|
// there might be a better way to do this but my brain is fried right now
|
|
|
|
if (args.argsLength() > 0) { // user inputted radius, override the default
|
|
|
|
radius = args.getInteger(0);
|
|
|
|
if (config.butcherMaxRadius != -1) { // clamp if there is a max
|
|
|
|
if (radius == -1) {
|
|
|
|
radius = config.butcherMaxRadius;
|
|
|
|
} else { // Math.min does not work if radius is -1 (actually highest possible value)
|
|
|
|
radius = Math.min(radius, config.butcherMaxRadius);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-28 00:55:39 +00:00
|
|
|
FlagContainer flags = new FlagContainer(actor);
|
2014-04-03 02:08:50 +00:00
|
|
|
flags.or(KillFlags.FRIENDLY , args.hasFlag('f')); // No permission check here. Flags will instead be filtered by the subsequent calls.
|
|
|
|
flags.or(KillFlags.PETS , args.hasFlag('p'), "worldedit.butcher.pets");
|
|
|
|
flags.or(KillFlags.NPCS , args.hasFlag('n'), "worldedit.butcher.npcs");
|
|
|
|
flags.or(KillFlags.GOLEMS , args.hasFlag('g'), "worldedit.butcher.golems");
|
|
|
|
flags.or(KillFlags.ANIMALS , args.hasFlag('a'), "worldedit.butcher.animals");
|
|
|
|
flags.or(KillFlags.AMBIENT , args.hasFlag('b'), "worldedit.butcher.ambient");
|
2014-05-02 00:36:11 +00:00
|
|
|
flags.or(KillFlags.TAGGED , args.hasFlag('t'), "worldedit.butcher.tagged");
|
2014-04-03 02:08:50 +00:00
|
|
|
flags.or(KillFlags.WITH_LIGHTNING, args.hasFlag('l'), "worldedit.butcher.lightning");
|
|
|
|
// If you add flags here, please add them to com.sk89q.worldedit.commands.BrushCommands.butcherBrush() as well
|
|
|
|
|
|
|
|
int killed;
|
2014-06-28 00:55:39 +00:00
|
|
|
if (player != null) {
|
2014-04-03 02:08:50 +00:00
|
|
|
killed = player.getWorld().killMobs(session.getPlacementPosition(player), radius, flags.flags);
|
|
|
|
} else {
|
|
|
|
killed = 0;
|
2014-04-05 09:59:38 +00:00
|
|
|
for (World world : we.getServer().getWorlds()) {
|
2014-04-03 02:08:50 +00:00
|
|
|
killed += world.killMobs(new Vector(), radius, flags.flags);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (radius < 0) {
|
2014-06-28 00:55:39 +00:00
|
|
|
actor.print("Killed " + killed + " mobs.");
|
2014-04-03 02:08:50 +00:00
|
|
|
} else {
|
2014-06-28 00:55:39 +00:00
|
|
|
actor.print("Killed " + killed + " mobs in a radius of " + radius + ".");
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static class FlagContainer {
|
2014-06-28 00:55:39 +00:00
|
|
|
private final Actor player;
|
2014-04-03 02:08:50 +00:00
|
|
|
public int flags = 0;
|
2014-06-28 00:55:39 +00:00
|
|
|
public FlagContainer(Actor player) {
|
2014-04-03 02:08:50 +00:00
|
|
|
this.player = player;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void or(int flag, boolean on) {
|
|
|
|
if (on) flags |= flag;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void or(int flag, boolean on, String permission) {
|
|
|
|
or(flag, on);
|
|
|
|
|
|
|
|
if ((flags & flag) != 0 && !player.hasPermission(permission)) {
|
|
|
|
flags &= ~flag;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
|
|
|
aliases = { "remove", "rem", "rement" },
|
|
|
|
usage = "<type> <radius>",
|
|
|
|
desc = "Remove all entities of a type",
|
|
|
|
min = 2,
|
|
|
|
max = 2
|
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.remove")
|
|
|
|
@Logging(PLACEMENT)
|
2014-06-28 00:55:39 +00:00
|
|
|
public void remove(Actor actor, @Optional Player player, @Optional LocalSession session, CommandContext args) throws WorldEditException {
|
2014-04-03 02:08:50 +00:00
|
|
|
|
|
|
|
String typeStr = args.getString(0);
|
|
|
|
int radius = args.getInteger(1);
|
|
|
|
|
|
|
|
if (radius < -1) {
|
2014-06-28 00:55:39 +00:00
|
|
|
actor.printError("Use -1 to remove all entities in loaded chunks");
|
2014-04-03 02:08:50 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
EntityType type = null;
|
|
|
|
|
|
|
|
if (typeStr.matches("all")) {
|
|
|
|
type = EntityType.ALL;
|
|
|
|
} else if (typeStr.matches("projectiles?|arrows?")) {
|
|
|
|
type = EntityType.PROJECTILES;
|
|
|
|
} else if (typeStr.matches("items?")
|
|
|
|
|| typeStr.matches("drops?")) {
|
|
|
|
type = EntityType.ITEMS;
|
|
|
|
} else if (typeStr.matches("falling(blocks?|sand|gravel)")) {
|
|
|
|
type = EntityType.FALLING_BLOCKS;
|
|
|
|
} else if (typeStr.matches("paintings?")
|
|
|
|
|| typeStr.matches("art")) {
|
|
|
|
type = EntityType.PAINTINGS;
|
|
|
|
} else if (typeStr.matches("(item)frames?")) {
|
|
|
|
type = EntityType.ITEM_FRAMES;
|
|
|
|
} else if (typeStr.matches("boats?")) {
|
|
|
|
type = EntityType.BOATS;
|
|
|
|
} else if (typeStr.matches("minecarts?")
|
|
|
|
|| typeStr.matches("carts?")) {
|
|
|
|
type = EntityType.MINECARTS;
|
|
|
|
} else if (typeStr.matches("tnt")) {
|
|
|
|
type = EntityType.TNT;
|
|
|
|
} else if (typeStr.matches("xp")) {
|
|
|
|
type = EntityType.XP_ORBS;
|
|
|
|
} else {
|
2014-06-28 00:55:39 +00:00
|
|
|
actor.printError("Acceptable types: projectiles, items, paintings, itemframes, boats, minecarts, tnt, xp, or all");
|
2014-04-03 02:08:50 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int removed = 0;
|
2014-06-28 00:55:39 +00:00
|
|
|
if (player != null) {
|
2014-04-03 02:08:50 +00:00
|
|
|
Vector origin = session.getPlacementPosition(player);
|
|
|
|
removed = player.getWorld().removeEntities(type, origin, radius);
|
|
|
|
} else {
|
2014-04-05 09:59:38 +00:00
|
|
|
for (World world : we.getServer().getWorlds()) {
|
2014-04-03 02:08:50 +00:00
|
|
|
removed += world.removeEntities(type, new Vector(), radius);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
player.print("Marked " + removed + " entit(ies) for removal.");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command(
|
|
|
|
aliases = { "/help" },
|
|
|
|
usage = "[<command>]",
|
|
|
|
desc = "Displays help for the given command or lists all commands.",
|
|
|
|
min = 0,
|
|
|
|
max = -1
|
|
|
|
)
|
|
|
|
@CommandPermissions("worldedit.help")
|
2014-06-28 00:55:39 +00:00
|
|
|
public void help(Actor actor, CommandContext args) throws WorldEditException {
|
|
|
|
help(args, we, actor);
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
|
2014-06-28 00:55:39 +00:00
|
|
|
public static void help(CommandContext args, WorldEdit we, Actor actor) {
|
2014-06-27 23:03:29 +00:00
|
|
|
final Dispatcher dispatcher = we.getPlatformManager().getCommandManager().getDispatcher();
|
2014-04-03 02:08:50 +00:00
|
|
|
|
|
|
|
if (args.argsLength() == 0) {
|
|
|
|
SortedSet<String> commands = new TreeSet<String>(new Comparator<String>() {
|
|
|
|
@Override
|
|
|
|
public int compare(String o1, String o2) {
|
|
|
|
final int ret = o1.replaceAll("/", "").compareToIgnoreCase(o2.replaceAll("/", ""));
|
|
|
|
if (ret == 0) {
|
|
|
|
return o1.compareToIgnoreCase(o2);
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
});
|
2014-06-27 23:03:29 +00:00
|
|
|
commands.addAll(dispatcher.getPrimaryAliases());
|
2014-04-03 02:08:50 +00:00
|
|
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
boolean first = true;
|
|
|
|
for (String command : commands) {
|
|
|
|
if (!first) {
|
|
|
|
sb.append(", ");
|
|
|
|
}
|
|
|
|
|
|
|
|
sb.append('/');
|
|
|
|
sb.append(command);
|
|
|
|
first = false;
|
|
|
|
}
|
|
|
|
|
2014-06-28 00:55:39 +00:00
|
|
|
actor.print(sb.toString());
|
2014-04-03 02:08:50 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-06-27 23:03:29 +00:00
|
|
|
String command = args.getJoinedStrings(0).toLowerCase().replaceAll("^/", "");
|
|
|
|
CommandMapping mapping = dispatcher.get(command);
|
2014-04-03 02:08:50 +00:00
|
|
|
|
2014-06-27 23:03:29 +00:00
|
|
|
if (mapping == null) {
|
2014-06-28 00:55:39 +00:00
|
|
|
actor.printError("Unknown command '" + command + "'.");
|
2014-04-03 02:08:50 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-06-27 23:03:29 +00:00
|
|
|
Description description = mapping.getDescription();
|
|
|
|
|
|
|
|
if (description.getUsage() != null) {
|
2014-06-28 00:55:39 +00:00
|
|
|
actor.printDebug("Usage: " + description.getUsage());
|
2014-06-27 23:03:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (description.getHelp() != null) {
|
2014-06-28 00:55:39 +00:00
|
|
|
actor.print(description.getHelp());
|
2014-06-27 23:03:29 +00:00
|
|
|
} else if (description.getDescription() != null) {
|
2014-06-28 00:55:39 +00:00
|
|
|
actor.print(description.getDescription());
|
2014-06-27 23:03:29 +00:00
|
|
|
} else {
|
2014-06-28 00:55:39 +00:00
|
|
|
actor.print("No further help is available.");
|
2014-06-27 23:03:29 +00:00
|
|
|
}
|
2014-04-03 02:08:50 +00:00
|
|
|
}
|
|
|
|
}
|