use of com.sk89q.worldedit.command.util.CommandPermissions in project FastAsyncWorldEdit by IntellectualSites.
the class ToolUtilCommands method mask.
// FAWE start - destination mask > mask
@Command(name = "mask", aliases = "/mask", desc = "Set the brush destination mask")
@CommandPermissions({ "worldedit.brush.options.mask", "worldedit.mask.brush" })
public void mask(Player player, LocalSession session, @Switch(name = 'h', desc = "Whether the offhand should be considered or not") boolean offHand, @Arg(desc = "The destination mask", def = "") Mask maskOpt, Arguments arguments) throws WorldEditException {
BrushTool tool = session.getBrushTool(player, false);
if (tool == null) {
player.print(Caption.of("fawe.worldedit.brush.brush.none"));
return;
}
if (maskOpt == null) {
player.print(Caption.of("worldedit.tool.mask.disabled"));
tool.setMask(null);
} else {
BrushSettings settings = offHand ? tool.getOffHand() : tool.getContext();
String lastArg = Iterables.getLast(CommandArgParser.spaceSplit(arguments.get())).getSubstring();
settings.addSetting(BrushSettings.SettingType.MASK, lastArg);
settings.setMask(maskOpt);
tool.update();
player.print(Caption.of("worldedit.tool.mask.set"));
}
}
use of com.sk89q.worldedit.command.util.CommandPermissions in project FastAsyncWorldEdit by IntellectualSites.
the class ToolUtilCommands method primary.
// FAWE start
@Command(name = "primary", aliases = { "/primary" }, desc = "Set the right click brush", descFooter = "Set the right click brush")
@CommandPermissions("worldedit.brush.primary")
public void primary(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.setSecondary(tool.getSecondary());
}
}
use of com.sk89q.worldedit.command.util.CommandPermissions in project FastAsyncWorldEdit by IntellectualSites.
the class UtilityCommands method fill.
@Command(name = "/fill", desc = "Fill a hole")
@CommandPermissions("worldedit.fill")
@Logging(PLACEMENT)
public int fill(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 = "1") int depth, @Arg(desc = "The direction to move", def = "down") @Direction BlockVector3 direction) throws WorldEditException, EvaluationException {
// FAWE start
double radius = radiusExp.evaluate();
// FAWE end
radius = Math.max(1, radius);
we.checkMaxRadius(radius);
depth = Math.max(1, depth);
BlockVector3 pos = session.getPlacementPosition(actor);
int affected = editSession.fillDirection(pos, pattern, radius, depth, direction);
actor.print(Caption.of("worldedit.fill.created", TextComponent.of(affected)));
return affected;
}
use of com.sk89q.worldedit.command.util.CommandPermissions in project FastAsyncWorldEdit by IntellectualSites.
the class UtilityCommands method heightmapInterface.
@Command(name = "/heightmapinterface", aliases = { "/hmi", "hmi" }, desc = "Generate the heightmap interface: https://github.com/IntellectualSites/HeightMap")
@CommandPermissions("fawe.admin")
public void heightmapInterface(Actor actor, @Arg(name = "min", desc = "int", def = "100") int min, @Arg(name = "max", desc = "int", def = "200") int max) throws IOException {
actor.print(TextComponent.of("Please wait while we generate the minified heightmaps."));
File srcFolder = MainUtil.getFile(Fawe.platform().getDirectory(), Settings.settings().PATHS.HEIGHTMAP);
File webSrc = new File(Fawe.platform().getDirectory(), "web" + File.separator + "heightmap");
File minImages = new File(webSrc, "images" + File.separator + "min");
File maxImages = new File(webSrc, "images" + File.separator + "max");
final int sub = srcFolder.getAbsolutePath().length();
List<String> images = new ArrayList<>();
MainUtil.iterateFiles(srcFolder, file -> {
switch(file.getName().substring(file.getName().lastIndexOf('.')).toLowerCase(Locale.ROOT)) {
case ".png":
case ".jpeg":
break;
default:
return;
}
try {
String name = file.getAbsolutePath().substring(sub);
if (name.startsWith(File.separator)) {
name = name.replaceFirst(java.util.regex.Pattern.quote(File.separator), "");
}
BufferedImage img = MainUtil.readImage(file);
BufferedImage minImg = ImageUtil.getScaledInstance(img, min, min, RenderingHints.VALUE_INTERPOLATION_BILINEAR, true);
BufferedImage maxImg = max == -1 ? img : ImageUtil.getScaledInstance(img, max, max, RenderingHints.VALUE_INTERPOLATION_BILINEAR, true);
actor.print(TextComponent.of(String.format("Writing %s", name)));
File minFile = new File(minImages, name);
File maxFile = new File(maxImages, name);
minFile.getParentFile().mkdirs();
maxFile.getParentFile().mkdirs();
ImageIO.write(minImg, "png", minFile);
ImageIO.write(maxImg, "png", maxFile);
images.add(name);
} catch (IOException e) {
throw new RuntimeException(e);
}
});
StringBuilder config = new StringBuilder();
config.append("var images = [\n");
for (String image : images) {
config.append('"' + image.replace(File.separator, "/") + "\",\n");
}
config.append("];\n");
config.append("// The low res images (they should all be the same size)\n");
config.append("var src_min = \"images/min/\";\n");
config.append("// The max resolution images (Use the same if there are no higher resolution ones available)\n");
config.append("var src_max = \"images/max/\";\n");
config.append("// The local source for the image (used in commands)\n");
config.append("var src_local = \"file://\";\n");
File configFile = new File(webSrc, "config.js");
actor.print(TextComponent.of(String.format("Writing %s", configFile)));
Files.write(configFile.toPath(), config.toString().getBytes());
actor.print(TextComponent.of("Done! See: `FastAsyncWorldEdit/web/heightmap`"));
}
use of com.sk89q.worldedit.command.util.CommandPermissions in project FastAsyncWorldEdit by IntellectualSites.
the class UtilityCommands method snow.
@Command(name = "snow", aliases = { "/snow" }, desc = "Simulates snow")
@CommandPermissions("worldedit.snow")
@Logging(PLACEMENT)
public int snow(Actor actor, LocalSession session, EditSession editSession, @Arg(desc = "The radius of the cylinder to snow in", def = "10") double size, @Arg(desc = "The height of the cylinder to snow in", def = HeightConverter.DEFAULT_VALUE) @VertHeight int height, @Switch(name = 's', desc = "Stack snow layers") boolean stack) throws WorldEditException {
size = Math.max(1, size);
height = Math.max(1, height);
we.checkMaxRadius(size);
BlockVector3 position = session.getPlacementPosition(actor);
CylinderRegion region = new CylinderRegion(position, Vector2.at(size, size), position.getBlockY() - height, position.getBlockY() + height);
int affected = editSession.simulateSnow(region, stack);
actor.print(Caption.of("worldedit.snow.created", TextComponent.of(affected)));
return affected;
}
Aggregations