use of com.sk89q.worldedit.command.tool.BrushTool in project FastAsyncWorldEdit by IntellectualSites.
the class BrushCommands method saveBrush.
@Command(name = "savebrush", aliases = { "save" }, desc = "Save your current brush")
@CommandPermissions("worldedit.brush.save")
public void saveBrush(Player player, LocalSession session, @Arg(desc = "String name") String name, @Switch(name = 'g', desc = "Save the brush globally") boolean root) throws WorldEditException, IOException {
BrushTool tool = session.getBrushTool(player);
if (tool != null) {
root |= name.startsWith("../");
name = FileSystems.getDefault().getPath(name).getFileName().toString();
File folder = MainUtil.getFile(Fawe.platform().getDirectory(), "brushes");
name = name.endsWith(".jsgz") ? name : name + ".jsgz";
File file;
if (root && player.hasPermission("worldedit.brush.save.other")) {
file = new File(folder, name);
} else {
file = new File(folder, player.getUniqueId() + File.separator + name);
}
File parent = file.getParentFile();
if (!parent.exists()) {
parent.mkdirs();
}
file.createNewFile();
try (DataOutputStream out = new DataOutputStream(new ParallelGZIPOutputStream(new FileOutputStream(file)))) {
out.writeUTF(tool.toString());
} catch (Throwable e) {
e.printStackTrace();
}
player.print(Caption.of("fawe.worldedit.schematic.schematic.saved", name));
} else {
player.print(Caption.of("fawe.worldedit.brush.brush.none"));
}
}
use of com.sk89q.worldedit.command.tool.BrushTool in project FastAsyncWorldEdit by IntellectualSites.
the class BrushCommands method set.
public BrushSettings set(InjectedValueAccess context, Brush brush, String permission) throws InvalidToolBindException {
Player player = context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player"));
LocalSession session = player.getSession();
BrushSettings bs = new BrushSettings();
BrushTool tool = session.getBrushTool(player, false);
if (tool != null) {
BrushSettings currentContext = tool.getContext();
if (currentContext != null) {
Brush currentBrush = currentContext.getBrush();
if (currentBrush != null && currentBrush.getClass() == brush.getClass()) {
bs = currentContext;
}
}
}
Arguments arguments = context.injectedValue(Key.of(Arguments.class)).orElse(null);
if (arguments != null) {
String args = arguments.get();
bs.addSetting(BrushSettings.SettingType.BRUSH, args.substring(args.indexOf(' ') + 1));
}
bs.addPermission(permission);
bs.setBrush(brush);
return process(player, arguments, bs);
}
use of com.sk89q.worldedit.command.tool.BrushTool in project FastAsyncWorldEdit by IntellectualSites.
the class ToolUtilCommands method transform.
@Command(name = "transform", aliases = { "/transform" }, desc = "Set the brush transform")
@CommandPermissions({ "worldedit.brush.options.transform", "worldedit.transform.brush" })
public void transform(Player player, LocalSession session, EditSession editSession, @Arg(desc = "The transform", def = "") ResettableExtent transform, @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 (transform == null) {
player.print(Caption.of("fawe.worldedit.brush.brush.transform.disabled"));
tool.setTransform(null);
return;
}
BrushSettings settings = offHand ? tool.getOffHand() : tool.getContext();
String lastArg = Iterables.getLast(CommandArgParser.spaceSplit(arguments.get())).getSubstring();
settings.addSetting(BrushSettings.SettingType.TRANSFORM, lastArg);
settings.setTransform(transform);
tool.update();
player.print(Caption.of("fawe.worldedit.brush.brush.transform"));
}
use of com.sk89q.worldedit.command.tool.BrushTool 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.tool.BrushTool in project FastAsyncWorldEdit by IntellectualSites.
the class ToolUtilCommands method target.
@Command(name = "target", aliases = { "tar", "/target", "/tar" }, desc = "Toggle between different target modes")
@CommandPermissions("worldedit.brush.target")
public void target(Player player, LocalSession session, @Arg(name = "mode", desc = "int", def = "0") int mode) throws WorldEditException {
BrushTool tool = session.getBrushTool(player, false);
if (tool == null) {
player.print(Caption.of("fawe.worldedit.brush.brush.none"));
return;
}
TargetMode[] modes = TargetMode.values();
TargetMode newMode = modes[MathMan.wrap(mode, 0, modes.length - 1)];
tool.setTargetMode(newMode);
player.print(Caption.of("fawe.worldedit.brush.brush.target.mode.set", newMode));
}
Aggregations