use of com.sk89q.worldedit.command.util.CommandPermissions in project FastAsyncWorldEdit by IntellectualSites.
the class ToolUtilCommands method smask.
@Command(name = "smask", aliases = { "/smask", "/sourcemask", "sourcemask" }, desc = "Set the brush source mask", descFooter = "Set the brush source mask")
@CommandPermissions({ "worldedit.brush.options.mask", "worldedit.mask.brush" })
public void smask(Player player, LocalSession session, EditSession editSession, @Arg(desc = "The destination mask", def = "") Mask maskArg, @Switch(name = 'h', desc = "Whether the offhand should be considered or not") boolean offHand, Arguments arguments) throws WorldEditException {
BrushTool tool = session.getBrushTool(player, false);
if (tool == null) {
player.print(Caption.of("fawe.worldedit.brush.brush.none"));
return;
}
if (maskArg == null) {
player.print(Caption.of("fawe.worldedit.brush.brush.source.mask.disabled"));
tool.setSourceMask(null);
return;
}
BrushSettings settings = offHand ? tool.getOffHand() : tool.getContext();
String lastArg = Iterables.getLast(CommandArgParser.spaceSplit(arguments.get())).getSubstring();
settings.addSetting(BrushSettings.SettingType.SOURCE_MASK, lastArg);
settings.setSourceMask(maskArg);
tool.update();
player.print(Caption.of("fawe.worldedit.brush.brush.source.mask"));
}
use of com.sk89q.worldedit.command.util.CommandPermissions in project FastAsyncWorldEdit by IntellectualSites.
the class ToolUtilCommands method secondary.
@Command(name = "secondary", aliases = { "/secondary" }, desc = "Set the left click brush", descFooter = "Set the left click brush")
@CommandPermissions("worldedit.brush.secondary")
public void secondary(Player player, LocalSession session, @Arg(desc = "The brush command", variable = true) List<String> commandStr) throws WorldEditException {
BaseItem item = player.getItemInHand(HandSide.MAIN_HAND);
BrushTool tool = session.getBrushTool(player, false);
session.setTool(item, null, player);
String cmd = "brush " + StringMan.join(commandStr, " ");
CommandEvent event = new CommandEvent(player, cmd);
PlatformCommandManager.getInstance().handleCommandOnCurrentThread(event);
BrushTool newTool = session.getBrushTool(item, player, false);
if (newTool != null && tool != null) {
newTool.setPrimary(tool.getPrimary());
}
}
use of com.sk89q.worldedit.command.util.CommandPermissions in project FastAsyncWorldEdit by IntellectualSites.
the class UtilityCommands method fillr.
/*
@Command(
name = "masks",
desc = "View help about masks",
descFooter = "Masks determine if a block can be placed\n" +
" - Use [brackets] for arguments\n" +
" - Use , to OR multiple\n" +
" - Use & to AND multiple\n" +
"e.g., >[stone,dirt],#light[0][5],$jungle\n" +
"More Info: https://git.io/v9r4K"
)
@CommandQueued(false)
@CommandPermissions("worldedit.masks")
public void masks(Player player, LocalSession session, InjectedValueAccess args) throws WorldEditException {
displayModifierHelp(player, DefaultMaskParser.class, args);
}
@Command(
name = "transforms",
desc = "View help about transforms",
descFooter = "Transforms modify how a block is placed\n" +
" - Use [brackets] for arguments\n" +
" - Use , to OR multiple\n" +
" - Use & to AND multiple\n" +
"More Info: https://git.io/v9KHO",
)
@CommandQueued(false)
@CommandPermissions("worldedit.transforms")
public void transforms(Player player, LocalSession session, InjectedValueAccess args) throws WorldEditException {
displayModifierHelp(player, DefaultTransformParser.class, args);
}
private void displayModifierHelp(Player player, Class<? extends FaweParser> clazz, InjectedValueAccess args) {
FaweParser parser = FaweAPI.getParser(clazz);
if (args.argsLength() == 0) {
String base = getCommand().aliases()[0];
UsageMessage msg = new UsageMessage(getCallable(), "/" + base, args.getLocals());
msg.newline().paginate(base, 0, 1).send(player);
return;
}
if (parser != null) {
CommandMapping mapping = parser.getDispatcher().get(args.getString(0));
if (mapping != null) {
new UsageMessage(mapping.getCallable(), args.getString(0), args.getLocals()) {
@Override
public String separateArg(String arg) {
return "&7[" + arg + "&7]";
}
}.send(player);
} else {
UtilityCommands.help(args, player, getCommand().aliases()[0] + " ", parser.getDispatcher());
}
}
}
*/
@Command(name = "/fillr", desc = "Fill a hole recursively")
@CommandPermissions("worldedit.fill.recursive")
@Logging(PLACEMENT)
public int fillr(Actor actor, LocalSession session, EditSession editSession, @Arg(desc = "The blocks to fill with") Pattern pattern, // FAWE start - we take an expression over a double
@Arg(desc = "The radius to fill in") Expression radiusExp, // FAWE end
@Arg(desc = "The depth to fill", def = "") Integer depth) throws WorldEditException {
// FAWE start
double radius = radiusExp.evaluate();
// FAWE end
radius = Math.max(1, radius);
we.checkMaxRadius(radius);
depth = depth == null ? Integer.MAX_VALUE : Math.max(1, depth);
we.checkMaxRadius(radius);
BlockVector3 pos = session.getPlacementPosition(actor);
int affected = editSession.fillXZ(pos, pattern, radius, depth, true);
actor.print(Caption.of("worldedit.fillr.created", TextComponent.of(affected)));
return affected;
}
use of com.sk89q.worldedit.command.util.CommandPermissions in project FastAsyncWorldEdit by IntellectualSites.
the class UtilityCommands method replaceNear.
@Command(name = "replacenear", aliases = { "/replacenear" }, desc = "Replace nearby blocks")
@CommandPermissions("worldedit.replacenear")
@Logging(PLACEMENT)
public int replaceNear(Actor actor, World world, LocalSession session, EditSession editSession, @Arg(desc = "The radius of the square to remove in") int radius, @Arg(desc = "The mask matching blocks to remove", def = "") Mask from, @Arg(desc = "The pattern of blocks to replace with") Pattern to) throws WorldEditException {
// FAWE start > the mask will have been initialised with a WorldWrapper extent (very bad/slow)
new MaskTraverser(from).setNewExtent(editSession);
// FAWE end
radius = Math.max(1, radius);
we.checkMaxRadius(radius);
BlockVector3 base = session.getPlacementPosition(actor);
BlockVector3 min = base.subtract(radius, radius, radius);
BlockVector3 max = base.add(radius, radius, radius);
Region region = new CuboidRegion(world, min, max);
if (from == null) {
from = new ExistingBlockMask(editSession);
}
int affected = editSession.replaceBlocks(region, from, to);
actor.print(Caption.of("worldedit.replacenear.replaced", TextComponent.of(affected)));
return affected;
}
use of com.sk89q.worldedit.command.util.CommandPermissions in project FastAsyncWorldEdit by IntellectualSites.
the class WorldEditCommands method reload.
@Command(name = "reload", desc = "Reload configuration and translations")
@CommandPermissions("worldedit.reload")
public void reload(Actor actor) {
we.getPlatformManager().queryCapability(Capability.CONFIGURATION).reload();
we.getEventBus().post(new ConfigurationLoadEvent(we.getPlatformManager().queryCapability(Capability.CONFIGURATION).getConfiguration()));
// FAWE start
Fawe.instance().setupConfigs();
// FAWE end
actor.print(Caption.of("worldedit.reload.config"));
}
Aggregations