mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-01 02:46:41 +00:00
More work on commands
This commit is contained in:
@ -124,8 +124,6 @@ import org.enginehub.piston.annotation.param.Switch;
|
||||
import org.enginehub.piston.inject.InjectedValueAccess;
|
||||
import org.enginehub.piston.inject.Key;
|
||||
|
||||
import static com.sk89q.worldedit.command.MethodCommands.*;
|
||||
|
||||
/**
|
||||
* Commands to set brush shape.
|
||||
*/
|
||||
@ -254,7 +252,7 @@ public class BrushCommands {
|
||||
@Arg(desc = "The radius to sample for blending", def = "25")
|
||||
Expression radius, InjectedValueAccess context) throws WorldEditException {
|
||||
worldEdit.checkMaxBrushRadius(radius);
|
||||
player.print(BBC.BRUSH_SPLINE.f(radius));
|
||||
player.print(BBC.BRUSH_SPLINE.format(radius));
|
||||
return set(session, context,
|
||||
new SplineBrush(player, session))
|
||||
.setSize(radius)
|
||||
@ -310,7 +308,7 @@ public class BrushCommands {
|
||||
public BrushSettings surfaceSpline(Player player, LocalSession session, Pattern fill,
|
||||
@Arg(desc = "The radius to sample for blending", def = "0")
|
||||
Expression radius, @Arg(name = "tension", desc = "double", def = "0") double tension, @Arg(name = "bias", desc = "double", def = "0") double bias, @Arg(name = "continuity", desc = "double", def = "0") double continuity, @Arg(name = "quality", desc = "double", def = "10") double quality, InjectedValueAccess context) throws WorldEditException {
|
||||
player.print(BBC.BRUSH_SPLINE.f(radius));
|
||||
player.print(BBC.BRUSH_SPLINE.format(radius));
|
||||
worldEdit.checkMaxBrushRadius(radius);
|
||||
return set(session, context,
|
||||
new SurfaceSpline(tension, bias, continuity, quality))
|
||||
@ -795,7 +793,7 @@ public class BrushCommands {
|
||||
@CommandPermissions("worldedit.brush.copy")
|
||||
public BrushSettings copy(Player player, LocalSession session, @Arg(name = "radius", desc = "Expression", def = "5") Expression radius, @Switch(name = 'r', desc = "Apply random rotation on paste") boolean randomRotate, @Switch(name = 'a', desc = "Apply auto view based rotation on paste") boolean autoRotate, InjectedValueAccess context) throws WorldEditException {
|
||||
worldEdit.checkMaxBrushRadius(radius);
|
||||
player.print(BBC.BRUSH_COPY.f(radius));
|
||||
player.print(BBC.BRUSH_COPY.format(radius));
|
||||
|
||||
return set(session, context,
|
||||
new CopyPastaBrush(player, session, randomRotate, autoRotate))
|
||||
|
@ -43,6 +43,7 @@ import java.util.zip.GZIPInputStream;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
import org.enginehub.piston.annotation.param.Arg;
|
||||
import org.enginehub.piston.annotation.param.ArgFlag;
|
||||
import org.enginehub.piston.annotation.param.Switch;
|
||||
import org.enginehub.piston.inject.InjectedValueAccess;
|
||||
|
||||
@ -138,7 +139,7 @@ public class BrushOptionsCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.list")
|
||||
public void list(Actor actor, InjectedValueAccess args,
|
||||
@Switch(name = 'p', desc = "Prints the requested page")
|
||||
@ArgFlag(name = 'p', desc = "Prints the requested page", def = "0")
|
||||
int page) throws WorldEditException {
|
||||
String baseCmd = Commands.getAlias(BrushCommands.class, "brush") + " " + Commands.getAlias(BrushOptionsCommands.class, "loadbrush");
|
||||
File dir = MainUtil.getFile(Fawe.imp().getDirectory(), "brushes");
|
||||
@ -349,7 +350,7 @@ public class BrushOptionsCommands {
|
||||
throws WorldEditException {
|
||||
BrushTool tool = session.getBrushTool(player, false);
|
||||
if (tool == null) {
|
||||
player.print(BBC.BRUSH_NONE.f());
|
||||
player.print(BBC.BRUSH_NONE.s());
|
||||
return;
|
||||
}
|
||||
if (mask == null) {
|
||||
@ -381,7 +382,7 @@ public class BrushOptionsCommands {
|
||||
Arguments arguments) throws WorldEditException {
|
||||
BrushTool tool = session.getBrushTool(player, false);
|
||||
if (tool == null) {
|
||||
player.print(BBC.BRUSH_NONE.f());
|
||||
player.print(BBC.BRUSH_NONE.s());
|
||||
return;
|
||||
}
|
||||
if (mask == null) {
|
||||
@ -409,7 +410,7 @@ public class BrushOptionsCommands {
|
||||
Arguments arguments) throws WorldEditException {
|
||||
BrushTool tool = session.getBrushTool(player, false);
|
||||
if (tool == null) {
|
||||
player.print(BBC.BRUSH_NONE.f());
|
||||
player.print(BBC.BRUSH_NONE.s());
|
||||
return;
|
||||
}
|
||||
if (transform == null) {
|
||||
@ -438,7 +439,7 @@ public class BrushOptionsCommands {
|
||||
Arguments arguments) throws WorldEditException {
|
||||
BrushTool tool = session.getBrushTool(player, false);
|
||||
if (tool == null) {
|
||||
player.print(BBC.BRUSH_NONE.f());
|
||||
player.print(BBC.BRUSH_NONE.s());
|
||||
return;
|
||||
}
|
||||
if (pattern == null) {
|
||||
@ -465,7 +466,7 @@ public class BrushOptionsCommands {
|
||||
range = Math.max(0, Math.min(256, range));
|
||||
BrushTool tool = session.getBrushTool(player, false);
|
||||
if (tool == null) {
|
||||
player.print(BBC.BRUSH_NONE.f());
|
||||
player.print(BBC.BRUSH_NONE.s());
|
||||
return;
|
||||
}
|
||||
tool.setRange(range);
|
||||
@ -485,7 +486,7 @@ public class BrushOptionsCommands {
|
||||
worldEdit.checkMaxBrushRadius(radius);
|
||||
BrushTool tool = session.getBrushTool(player, false);
|
||||
if (tool == null) {
|
||||
player.print(BBC.BRUSH_NONE.f());
|
||||
player.print(BBC.BRUSH_NONE.s());
|
||||
return;
|
||||
}
|
||||
BrushSettings settings = offHand ? tool.getOffHand() : tool.getContext();
|
||||
|
@ -1,24 +1,19 @@
|
||||
package com.sk89q.worldedit.command;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.StringMan;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissions;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
import org.enginehub.piston.annotation.param.Arg;
|
||||
import org.enginehub.piston.exception.StopExecutionException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Locale;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.regex.PatternSyntaxException;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
import org.enginehub.piston.exception.StopExecutionException;
|
||||
|
||||
//TODO This class breaks compilation
|
||||
@CommandContainer
|
||||
public class ListFilters {
|
||||
public class Filter {
|
||||
@ -81,7 +76,7 @@ public class ListFilters {
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "",
|
||||
name = "*", //TODO originally this was left blank but doing so causes a major compilation error
|
||||
desc = "wildcard"
|
||||
)
|
||||
public Filter wildcard(Actor actor, File root, String arg) {
|
||||
|
@ -19,25 +19,16 @@
|
||||
|
||||
package com.sk89q.worldedit.command;
|
||||
|
||||
import static com.boydti.fawe.util.ReflectionUtils.as;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.config.Commands;
|
||||
import com.boydti.fawe.config.Settings;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.object.RunnableVal3;
|
||||
import com.boydti.fawe.object.clipboard.MultiClipboardHolder;
|
||||
import com.boydti.fawe.object.clipboard.URIClipboardHolder;
|
||||
import com.boydti.fawe.object.clipboard.remap.ClipboardRemapper;
|
||||
import com.boydti.fawe.object.schematic.MinecraftStructure;
|
||||
import com.boydti.fawe.object.schematic.StructureFormat;
|
||||
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.chat.Message;
|
||||
import com.sk89q.worldedit.command.util.AsyncCommandBuilder;
|
||||
import org.enginehub.piston.inject.InjectedValueAccess;
|
||||
import com.sk89q.minecraft.util.commands.CommandException;
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
@ -51,7 +42,6 @@ import com.sk89q.worldedit.event.extent.PlayerSaveClipboardEvent;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.BuiltInClipboardFormat;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader;
|
||||
@ -59,7 +49,6 @@ import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter;
|
||||
import com.sk89q.worldedit.function.operation.Operations;
|
||||
import com.sk89q.worldedit.math.transform.Transform;
|
||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||
import com.sk89q.worldedit.util.formatting.component.CodeFormat;
|
||||
import com.sk89q.worldedit.util.formatting.component.ErrorFormat;
|
||||
import com.sk89q.worldedit.util.formatting.component.PaginationBox;
|
||||
import com.sk89q.worldedit.util.formatting.component.SchematicPaginationBox;
|
||||
@ -87,7 +76,6 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
@ -95,6 +83,7 @@ import org.enginehub.piston.annotation.param.Arg;
|
||||
import org.enginehub.piston.annotation.param.ArgFlag;
|
||||
import org.enginehub.piston.annotation.param.Switch;
|
||||
import org.enginehub.piston.exception.StopExecutionException;
|
||||
import org.enginehub.piston.inject.InjectedValueAccess;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -218,7 +207,8 @@ public class SchematicCommands {
|
||||
@Arg(desc = "Format name.", def = "sponge")
|
||||
String formatName) throws FilenameException {
|
||||
LocalConfiguration config = worldEdit.getConfiguration();
|
||||
ClipboardFormat format = formatName == null ? null : ClipboardFormats.findByAlias(formatName);
|
||||
|
||||
ClipboardFormat format = ClipboardFormats.findByAlias(formatName);
|
||||
InputStream in = null;
|
||||
try {
|
||||
URI uri;
|
||||
@ -228,19 +218,15 @@ public class SchematicCommands {
|
||||
return;
|
||||
}
|
||||
UUID uuid = UUID.fromString(filename.substring(4));
|
||||
URL base = new URL(Settings.IMP.WEB.URL);
|
||||
URL url = new URL(base, "uploads/" + uuid + "." + format.getPrimaryFileExtension());
|
||||
ReadableByteChannel rbc = Channels.newChannel(url.openStream());
|
||||
in = Channels.newInputStream(rbc);
|
||||
URL webUrl = new URL(Settings.IMP.WEB.URL);
|
||||
URL url = new URL(webUrl, "uploads/" + uuid + "." + format.getPrimaryFileExtension());
|
||||
ReadableByteChannel byteChannel = Channels.newChannel(url.openStream());
|
||||
in = Channels.newInputStream(byteChannel);
|
||||
uri = url.toURI();
|
||||
} else {
|
||||
if (!player.hasPermission("worldedit.schematic.load") && !player.hasPermission("worldedit.clipboard.load")) {
|
||||
BBC.NO_PERM.send(player, "worldedit.clipboard.load");
|
||||
return;
|
||||
}
|
||||
File working = worldEdit.getWorkingDirectoryFile(config.saveDir);
|
||||
File dir = Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS ? new File(working, player.getUniqueId().toString()) : working;
|
||||
File f;
|
||||
File saveDir = worldEdit.getWorkingDirectoryFile(config.saveDir);
|
||||
File dir = Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS ? new File(saveDir, player.getUniqueId().toString()) : saveDir;
|
||||
File file;
|
||||
if (filename.startsWith("#")) {
|
||||
String[] extensions;
|
||||
if (format != null) {
|
||||
@ -248,9 +234,9 @@ public class SchematicCommands {
|
||||
} else {
|
||||
extensions = ClipboardFormats.getFileExtensionArray();
|
||||
}
|
||||
f = player.openFileOpenDialog(extensions);
|
||||
if (f == null || !f.exists()) {
|
||||
player.printError("Schematic " + filename + " does not exist! (" + f + ")");
|
||||
file = player.openFileOpenDialog(extensions);
|
||||
if (file == null || !file.exists()) {
|
||||
player.printError("Schematic " + filename + " does not exist! (" + file + ")");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
@ -262,27 +248,27 @@ public class SchematicCommands {
|
||||
String extension = filename.substring(filename.lastIndexOf('.') + 1);
|
||||
format = ClipboardFormats.findByExtension(extension);
|
||||
}
|
||||
f = MainUtil.resolve(dir, filename, format, false);
|
||||
file = MainUtil.resolve(dir, filename, format, false);
|
||||
}
|
||||
if (f == null || !f.exists()) {
|
||||
if (file == null || !file.exists()) {
|
||||
if (!filename.contains("../")) {
|
||||
dir = this.worldEdit.getWorkingDirectoryFile(config.saveDir);
|
||||
f = MainUtil.resolve(dir, filename, format, false);
|
||||
file = MainUtil.resolve(dir, filename, format, false);
|
||||
}
|
||||
}
|
||||
if (f == null || !f.exists() || !MainUtil.isInSubDirectory(working, f)) {
|
||||
player.printError("Schematic " + filename + " does not exist! (" + (f != null && f.exists()) + "|" + f + "|" + (f != null && !MainUtil.isInSubDirectory(working, f)) + ")");
|
||||
if (file == null || !file.exists() || !MainUtil.isInSubDirectory(saveDir, file)) {
|
||||
player.printError("Schematic " + filename + " does not exist! (" + (file != null && file.exists()) + "|" + file + "|" + (file != null && !MainUtil.isInSubDirectory(saveDir, file)) + ")");
|
||||
return;
|
||||
}
|
||||
if (format == null) {
|
||||
format = ClipboardFormats.findByFile(f);
|
||||
format = ClipboardFormats.findByFile(file);
|
||||
if (format == null) {
|
||||
BBC.CLIPBOARD_INVALID_FORMAT.send(player, f.getName());
|
||||
BBC.CLIPBOARD_INVALID_FORMAT.send(player, file.getName());
|
||||
return;
|
||||
}
|
||||
}
|
||||
in = new FileInputStream(f);
|
||||
uri = f.toURI();
|
||||
in = new FileInputStream(file);
|
||||
uri = file.toURI();
|
||||
}
|
||||
format.hold(player, uri, in);
|
||||
BBC.SCHEMATIC_LOADED.send(player, filename);
|
||||
@ -418,7 +404,8 @@ public class SchematicCommands {
|
||||
continue;
|
||||
}
|
||||
if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && (!MainUtil.isInSubDirectory(dir, destFile) || !MainUtil.isInSubDirectory(dir, source)) && !player.hasPermission("worldedit.schematic.delete.other")) {
|
||||
BBC.SCHEMATIC_MOVE_FAILED.send(player, destFile, BBC.NO_PERM.f("worldedit.schematic.move.other"));
|
||||
BBC.SCHEMATIC_MOVE_FAILED.send(player, destFile,
|
||||
BBC.NO_PERM.format("worldedit.schematic.move.other"));
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
@ -522,7 +509,7 @@ public class SchematicCommands {
|
||||
" -f <format> restricts by format\n"
|
||||
)
|
||||
@CommandPermissions("worldedit.schematic.show")
|
||||
public void show(Player player, InjectedValueAccess args, @Switch(name='f', desc = "TODO") String formatName) {
|
||||
public void show(Player player, InjectedValueAccess args, @Switch(name='f', desc = "") String formatName) {
|
||||
FawePlayer fp = FawePlayer.wrap(player);
|
||||
if (args.argsLength() == 0) {
|
||||
if (fp.getSession().getVirtualWorld() != null) fp.setVirtualWorld(null);
|
||||
@ -586,66 +573,65 @@ public class SchematicCommands {
|
||||
public void list(FawePlayer fp, Actor actor, InjectedValueAccess args,
|
||||
@ArgFlag(name = 'p', desc = "Page to view.", def = "1")
|
||||
int page,
|
||||
@Switch(name = 'f', desc = "Restricts by format.")
|
||||
String formatName) throws WorldEditException {
|
||||
LocalConfiguration config = worldEdit.getConfiguration();
|
||||
File dir = worldEdit.getWorkingDirectoryFile(config.saveDir);
|
||||
@Switch(name = 'd', desc = "Sort by date, oldest first")
|
||||
boolean oldFirst,
|
||||
@Switch(name = 'n', desc = "Sort by date, newest first")
|
||||
boolean newFirst,
|
||||
@Switch(name = 'f', desc = "Restricts by format.")
|
||||
String formatName,
|
||||
@Arg(name = "filter", desc = "Filter for schematics", def = "all")
|
||||
String filter) throws WorldEditException {
|
||||
if (oldFirst && newFirst) {
|
||||
throw new StopExecutionException(TextComponent.of("Cannot sort by oldest and newest."));
|
||||
}
|
||||
final String saveDir = worldEdit.getConfiguration().saveDir;
|
||||
final int sortType = oldFirst ? -1 : newFirst ? 1 : 0;
|
||||
|
||||
String schemCmd = "/" + Commands.getAlias(SchematicCommands.class, "schematic");
|
||||
String loadSingle = schemCmd + " " + Commands.getAlias(SchematicCommands.class, "load");
|
||||
String loadMulti = schemCmd + " " + Commands.getAlias(SchematicCommands.class, "loadall");
|
||||
String unload = schemCmd + " " + Commands.getAlias(SchematicCommands.class, "unload");
|
||||
String delete = schemCmd + " " + Commands.getAlias(SchematicCommands.class, "delete");
|
||||
String list = schemCmd + " " + Commands.getAlias(SchematicCommands.class, "list");
|
||||
String showCmd = schemCmd + " " + Commands.getAlias(SchematicCommands.class, "show");
|
||||
final String pageCommand = actor.isPlayer()
|
||||
? "//schem list -p %page%" + (sortType == -1 ? " -d" : sortType == 1 ? " -n" : "") : null;
|
||||
|
||||
URIClipboardHolder multi = as(URIClipboardHolder.class, fp.getSession().getExistingClipboard());
|
||||
WorldEditAsyncCommandBuilder.createAndSendMessage(actor,
|
||||
new SchematicListTask(saveDir, sortType, page, pageCommand, filter, formatName), "(Please wait... gathering schematic list.)");
|
||||
|
||||
final boolean hasShow = actor.hasPermission("worldedit.schematic.show");
|
||||
UtilityCommands.list(dir, actor, args, page, -1, formatName, Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS, new RunnableVal3<Message, URI, String>() {
|
||||
@Override
|
||||
public void run(Message msg, URI uri, String relFilePath) {
|
||||
boolean isDir = false;
|
||||
boolean loaded = multi != null && multi.contains(uri);
|
||||
|
||||
String name = relFilePath;
|
||||
String uriStr = uri.toString();
|
||||
if (uriStr.startsWith("file:/")) {
|
||||
File file = new File(uri.getPath());
|
||||
name = file.getName();
|
||||
try {
|
||||
if (!MainUtil.isInSubDirectory(dir, file)) {
|
||||
throw new RuntimeException(new CommandException("Invalid path"));
|
||||
}
|
||||
} catch (IOException ignore) {}
|
||||
if (file.isDirectory()) {
|
||||
isDir = true;
|
||||
} else if (name.indexOf('.') != -1) {
|
||||
name = name.substring(0, name.lastIndexOf('.'));
|
||||
}
|
||||
} // url
|
||||
|
||||
msg.text(" - ");
|
||||
|
||||
if (msg.supportsInteraction()) {
|
||||
if (loaded) {
|
||||
msg.text("[-]").command(unload + " " + relFilePath).tooltip("Unload");
|
||||
} else {
|
||||
msg.text("[+]").command(loadMulti + " " + relFilePath).tooltip("Add to clipboard");
|
||||
}
|
||||
if (!isDir) msg.text("[X]").suggest("/" + delete + " " + relFilePath).tooltip("Delete");
|
||||
else if (hasShow) msg.text("[O]").command(showCmd + " " + args.getJoinedStrings(0) + " " + relFilePath).tooltip("Show");
|
||||
msg.text(name);
|
||||
if (isDir) {
|
||||
msg.command(list + " " + relFilePath).tooltip("List");
|
||||
} else {
|
||||
msg.command(loadSingle + " " + relFilePath).tooltip("Load");
|
||||
}
|
||||
} else {
|
||||
msg.text(name);
|
||||
}
|
||||
}
|
||||
});
|
||||
// UtilityCommands.list(dir, actor, args, page, -1, formatName, Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS, new RunnableVal3<Message, URI, String>() {
|
||||
// @Override
|
||||
// public void run(Message msg, URI uri, String relFilePath) {
|
||||
// boolean isDir = false;
|
||||
// boolean loaded = multi != null && multi.contains(uri);
|
||||
//
|
||||
// String name = relFilePath;
|
||||
// String uriStr = uri.toString();
|
||||
// if (uriStr.startsWith("file:/")) {
|
||||
// File file1 = new File(uri.getPath());
|
||||
// name = file1.getName();
|
||||
// try {
|
||||
// if (!MainUtil.isInSubDirectory(dir, file1)) {
|
||||
// throw new RuntimeException(new CommandException("Invalid path"));
|
||||
// }
|
||||
// } catch (IOException ignore) {}
|
||||
// if (file1.isDirectory()) {
|
||||
// isDir = true;
|
||||
// } else if (name.indexOf('.') != -1) {
|
||||
// name = name.substring(0, name.lastIndexOf('.'));
|
||||
// }
|
||||
// } // url
|
||||
//
|
||||
// msg.text(" - ");
|
||||
//
|
||||
// if (loaded) {
|
||||
// msg.text("[-]").command(unload + " " + relFilePath).tooltip("Unload");
|
||||
// } else {
|
||||
// msg.text("[+]").command(loadMulti + " " + relFilePath).tooltip("Add to clipboard");
|
||||
// }
|
||||
// if (!isDir) msg.text("[X]").suggest("/" + delete + " " + relFilePath).tooltip("Delete");
|
||||
// msg.text(name);
|
||||
// if (isDir) {
|
||||
// msg.command(list + " " + relFilePath).tooltip("List");
|
||||
// } else {
|
||||
// msg.command(loadSingle + " " + relFilePath).tooltip("Load");
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
private static class SchematicLoadTask implements Callable<ClipboardHolder> {
|
||||
@ -734,18 +720,24 @@ public class SchematicCommands {
|
||||
private final int page;
|
||||
private final File rootDir;
|
||||
private final String pageCommand;
|
||||
private final String filter;
|
||||
private String formatName;
|
||||
|
||||
SchematicListTask(String prefix, int sortType, int page, String pageCommand) {
|
||||
SchematicListTask(String prefix, int sortType, int page, String pageCommand,
|
||||
String filter, String formatName) {
|
||||
this.prefix = prefix;
|
||||
this.sortType = sortType;
|
||||
this.page = page;
|
||||
this.rootDir = WorldEdit.getInstance().getWorkingDirectoryFile(prefix);
|
||||
this.pageCommand = pageCommand;
|
||||
this.filter = filter;
|
||||
this.formatName = formatName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component call() throws Exception {
|
||||
List<File> fileList = allFiles(rootDir);
|
||||
ClipboardFormat format = ClipboardFormats.findByAlias(formatName);
|
||||
List<File> fileList = getFiles(rootDir,filter,format);
|
||||
|
||||
if (fileList == null || fileList.isEmpty()) {
|
||||
return ErrorFormat.wrap("No schematics found.");
|
||||
@ -776,13 +768,18 @@ public class SchematicCommands {
|
||||
}
|
||||
}
|
||||
|
||||
private static List<File> allFiles(File root) {
|
||||
//TODO filtering for directories, global, and private scheamtics needs to be reimplemented here
|
||||
private static List<File> getFiles(File root, String filter, ClipboardFormat format) {
|
||||
File[] files = root.listFiles();
|
||||
if (files == null) return null;
|
||||
//Only get the files that match the format parameter
|
||||
if (format != null) {
|
||||
files = Arrays.stream(files).filter(format::isFormat).toArray(File[]::new);
|
||||
}
|
||||
List<File> fileList = new ArrayList<>();
|
||||
for (File f : files) {
|
||||
if (f.isDirectory()) {
|
||||
List<File> subFiles = allFiles(f);
|
||||
List<File> subFiles = getFiles(f, filter, format);
|
||||
if (subFiles == null) continue; // empty subdir
|
||||
fileList.addAll(subFiles);
|
||||
} else {
|
||||
|
@ -554,7 +554,7 @@ public class SelectionCommands {
|
||||
newSelector = new Polygonal2DRegionSelector(oldSelector);
|
||||
player.print(BBC.SEL_2D_POLYGON.s());
|
||||
Optional<Integer> limit = ActorSelectorLimits.forActor(player).getPolygonVertexLimit();
|
||||
limit.ifPresent(integer -> player.print(BBC.SEL_MAX.f(integer)));
|
||||
limit.ifPresent(integer -> player.print(BBC.SEL_MAX.format(integer)));
|
||||
break;
|
||||
}
|
||||
case ELLIPSOID:
|
||||
@ -575,14 +575,14 @@ public class SelectionCommands {
|
||||
newSelector = new ConvexPolyhedralRegionSelector(oldSelector);
|
||||
player.print(BBC.SEL_CONVEX_POLYHEDRAL.s());
|
||||
Optional<Integer> limit = ActorSelectorLimits.forActor(player).getPolyhedronVertexLimit();
|
||||
limit.ifPresent(integer -> player.print(BBC.SEL_MAX.f(integer)));
|
||||
limit.ifPresent(integer -> player.print(BBC.SEL_MAX.format(integer)));
|
||||
break;
|
||||
}
|
||||
case POLYHEDRAL:
|
||||
newSelector = new PolyhedralRegionSelector(player.getWorld());
|
||||
player.print(BBC.SEL_CONVEX_POLYHEDRAL.s());
|
||||
Optional<Integer> limit = ActorSelectorLimits.forActor(player).getPolyhedronVertexLimit();
|
||||
limit.ifPresent(integer -> player.print(BBC.SEL_MAX.f(integer)));
|
||||
limit.ifPresent(integer -> player.print(BBC.SEL_MAX.format(integer)));
|
||||
player.print(BBC.SEL_LIST.s());
|
||||
break;
|
||||
case FUZZY:
|
||||
@ -591,8 +591,8 @@ public class SelectionCommands {
|
||||
mask = new IdMask(world);
|
||||
}
|
||||
newSelector = new FuzzyRegionSelector(player, editSession, mask);
|
||||
player.print(BBC.SEL_FUZZY.f());
|
||||
player.print(BBC.SEL_LIST.f());
|
||||
player.print(BBC.SEL_FUZZY.s());
|
||||
player.print(BBC.SEL_LIST.s());
|
||||
break;
|
||||
case LIST:
|
||||
default:
|
||||
|
@ -188,14 +188,11 @@ public class UtilityCommands {
|
||||
@Arg(desc = "The blocks to fill with")
|
||||
Pattern pattern,
|
||||
@Arg(desc = "The radius to fill in")
|
||||
double radius,
|
||||
@Range(min = 1) double radius,
|
||||
@Arg(desc = "The depth to fill", def = "1")
|
||||
int depth,
|
||||
@Arg(desc = "Direction to fill", def = "down")
|
||||
BlockVector3 direction) throws WorldEditException {
|
||||
radius = Math.max(1, radius);
|
||||
@Range(min = 1) int depth,
|
||||
@Arg(desc = "Direction to fill", def = "down") BlockVector3 direction) throws WorldEditException {
|
||||
we.checkMaxRadius(radius);
|
||||
depth = Math.max(1, depth);
|
||||
|
||||
BlockVector3 pos = session.getPlacementPosition(player);
|
||||
int affected = editSession.fillDirection(pos, pattern, radius, depth, direction);
|
||||
@ -284,10 +281,9 @@ public class UtilityCommands {
|
||||
@Arg(desc = "The blocks to fill with")
|
||||
Pattern pattern,
|
||||
@Arg(desc = "The radius to fill in")
|
||||
double radius,
|
||||
@Range(min = 1) double radius,
|
||||
@Arg(desc = "The depth to fill", def = "")
|
||||
Integer depth) throws WorldEditException {
|
||||
radius = Math.max(1, radius);
|
||||
@Range(min = 1) Integer depth) throws WorldEditException {
|
||||
we.checkMaxRadius(radius);
|
||||
depth = depth == null ? Integer.MAX_VALUE : Math.max(1, depth);
|
||||
we.checkMaxRadius(radius);
|
||||
@ -306,10 +302,9 @@ public class UtilityCommands {
|
||||
@Logging(PLACEMENT)
|
||||
public int drain(Player player, LocalSession session, EditSession editSession,
|
||||
@Arg(desc = "The radius to drain")
|
||||
double radius,
|
||||
@Range(min = 0) double radius,
|
||||
@Switch(name = 'w', desc = "Also un-waterlog blocks")
|
||||
boolean waterlogged) throws WorldEditException {
|
||||
radius = Math.max(0, radius);
|
||||
we.checkMaxRadius(radius);
|
||||
int affected = editSession.drainArea(
|
||||
session.getPlacementPosition(player), radius, waterlogged);
|
||||
@ -326,8 +321,7 @@ public class UtilityCommands {
|
||||
@Logging(PLACEMENT)
|
||||
public int fixLava(Player player, LocalSession session, EditSession editSession,
|
||||
@Arg(desc = "The radius to fix in")
|
||||
double radius) throws WorldEditException {
|
||||
radius = Math.max(0, radius);
|
||||
@Range(min = 0) double radius) throws WorldEditException {
|
||||
we.checkMaxRadius(radius);
|
||||
int affected = editSession.fixLiquid(session.getPlacementPosition(player), radius, BlockTypes.LAVA);
|
||||
player.print(affected + " block(s) have been changed.");
|
||||
@ -360,14 +354,10 @@ public class UtilityCommands {
|
||||
@Logging(PLACEMENT)
|
||||
public int removeAbove(Player player, LocalSession session, EditSession editSession,
|
||||
@Arg(desc = "The apothem of the square to remove from", def = "1")
|
||||
int size,
|
||||
@Range(min = 1) int size,
|
||||
@Arg(desc = "The maximum height above you to remove from", def = "")
|
||||
Integer height) throws WorldEditException {
|
||||
size = Math.max(1, size);
|
||||
we.checkMaxRadius(size);
|
||||
World world = player.getWorld();
|
||||
height = height != null ? Math.min((world.getMaxY() + 1), height + 1) : (world.getMaxY() + 1);
|
||||
|
||||
int affected = editSession.removeAbove(session.getPlacementPosition(player), size, height);
|
||||
BBC.VISITOR_BLOCK.send(player, affected);
|
||||
return affected;
|
||||
@ -382,10 +372,9 @@ public class UtilityCommands {
|
||||
@Logging(PLACEMENT)
|
||||
public int removeBelow(Player player, LocalSession session, EditSession editSession,
|
||||
@Arg(desc = "The apothem of the square to remove from", def = "1")
|
||||
int size,
|
||||
@Range(min =1) int size,
|
||||
@Arg(desc = "The maximum height below you to remove from", def = "")
|
||||
Integer height) throws WorldEditException {
|
||||
size = Math.max(1, size);
|
||||
we.checkMaxRadius(size);
|
||||
World world = player.getWorld();
|
||||
height = height != null ? Math.min((world.getMaxY() + 1), height + 1) : (world.getMaxY() + 1);
|
||||
@ -406,8 +395,7 @@ public class UtilityCommands {
|
||||
@Arg(desc = "The mask of blocks to remove")
|
||||
Mask mask,
|
||||
@Arg(desc = "The radius of the square to remove from", def = "50")
|
||||
int radius) throws WorldEditException {
|
||||
radius = Math.max(1, radius);
|
||||
@Range(min=1) int radius) throws WorldEditException {
|
||||
we.checkMaxRadius(radius);
|
||||
|
||||
int affected = editSession.removeNear(session.getPlacementPosition(player), mask, radius);
|
||||
@ -424,12 +412,11 @@ public class UtilityCommands {
|
||||
@Logging(PLACEMENT)
|
||||
public int replaceNear(Player player, LocalSession session, EditSession editSession,
|
||||
@Arg(desc = "The radius of the square to remove in")
|
||||
int radius,
|
||||
@Range(min=1) 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 {
|
||||
radius = Math.max(1, radius);
|
||||
we.checkMaxRadius(radius);
|
||||
|
||||
BlockVector3 base = session.getPlacementPosition(player);
|
||||
@ -455,8 +442,7 @@ public class UtilityCommands {
|
||||
@Logging(PLACEMENT)
|
||||
public int snow(Player player, LocalSession session, EditSession editSession,
|
||||
@Arg(desc = "The radius of the circle to snow in", def = "10")
|
||||
double size) throws WorldEditException {
|
||||
size = Math.max(1, size);
|
||||
@Range(min=1) double size) throws WorldEditException {
|
||||
we.checkMaxRadius(size);
|
||||
|
||||
int affected = editSession.simulateSnow(session.getPlacementPosition(player), size);
|
||||
@ -473,12 +459,11 @@ public class UtilityCommands {
|
||||
@Logging(PLACEMENT)
|
||||
public int thaw(Player player, LocalSession session, EditSession editSession,
|
||||
@Arg(desc = "The radius of the circle to thaw in", def = "10")
|
||||
double size) throws WorldEditException {
|
||||
size = Math.max(1, size);
|
||||
@Range(min=1) double size) throws WorldEditException {
|
||||
we.checkMaxRadius(size);
|
||||
|
||||
int affected = editSession.thaw(session.getPlacementPosition(player), size);
|
||||
player.print(affected + " surface(s) thawed.");
|
||||
player.print(affected + " surfaces thawed.");
|
||||
return affected;
|
||||
}
|
||||
|
||||
@ -491,10 +476,9 @@ public class UtilityCommands {
|
||||
@Logging(PLACEMENT)
|
||||
public int green(Player player, LocalSession session, EditSession editSession,
|
||||
@Arg(desc = "The radius of the circle to convert in", def = "10")
|
||||
double size,
|
||||
@Range(min=1) double size,
|
||||
@Switch(name = 'f', desc = "Also convert coarse dirt")
|
||||
boolean convertCoarse) throws WorldEditException {
|
||||
size = Math.max(1, size);
|
||||
we.checkMaxRadius(size);
|
||||
final boolean onlyNormalDirt = !convertCoarse;
|
||||
|
||||
@ -512,12 +496,12 @@ public class UtilityCommands {
|
||||
@Logging(PLACEMENT)
|
||||
public void extinguish(Player player, LocalSession session, EditSession editSession,
|
||||
@Arg(desc = "The radius of the square to remove in", def = "")
|
||||
Integer radius) throws WorldEditException {
|
||||
@Range(min=1) Integer radius) throws WorldEditException {
|
||||
|
||||
LocalConfiguration config = we.getConfiguration();
|
||||
|
||||
int defaultRadius = config.maxRadius != -1 ? Math.min(40, config.maxRadius) : 40;
|
||||
int size = radius != null ? Math.max(1, radius) : defaultRadius;
|
||||
int size = radius != null ? radius : defaultRadius;
|
||||
we.checkMaxRadius(size);
|
||||
|
||||
Mask mask = new BlockTypeMask(editSession, BlockTypes.FIRE);
|
||||
@ -673,8 +657,7 @@ public class UtilityCommands {
|
||||
return;
|
||||
}
|
||||
WorldEditAsyncCommandBuilder.createAndSendMessage(actor, () -> {
|
||||
double result = expression.evaluate(
|
||||
new double[]{}, WorldEdit.getInstance().getSessionManager().get(actor).getTimeout());
|
||||
double result = expression.evaluateTimeout(WorldEdit.getInstance().getSessionManager().get(actor).getTimeout());
|
||||
String formatted = Double.isNaN(result) ? "NaN" : formatter.format(result);
|
||||
return SubtleFormat.wrap(input + " = ").append(TextComponent.of(formatted, TextColor.LIGHT_PURPLE));
|
||||
}, null);
|
||||
@ -804,7 +787,7 @@ public class UtilityCommands {
|
||||
page = args.getInteger(--len);
|
||||
}
|
||||
for (int i = 0; i < len; i++) {
|
||||
String arg = args.getString(i);
|
||||
String arg = "";
|
||||
switch (arg.toLowerCase()) {
|
||||
case "me":
|
||||
case "mine":
|
||||
|
Reference in New Issue
Block a user