mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-01 02:46:41 +00:00
visual chunk
This commit is contained in:
@ -0,0 +1,136 @@
|
||||
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 org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
import org.enginehub.piston.annotation.param.Arg;
|
||||
|
||||
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;
|
||||
|
||||
@CommandContainer
|
||||
public class SchemListFilters {
|
||||
public class Filter {
|
||||
public boolean listPrivate() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean listPublic() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public File getPath(File root) {
|
||||
return root;
|
||||
}
|
||||
|
||||
public boolean applies(File file) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "all",
|
||||
desc = "List both public and private schematics"
|
||||
)
|
||||
public Filter all() {
|
||||
return new Filter() {
|
||||
@Override
|
||||
public boolean listPublic() {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "private",
|
||||
aliases = {"me", "mine", "local"},
|
||||
desc = "List your personal schematics"
|
||||
)
|
||||
public Filter local() {
|
||||
return new Filter();
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "public",
|
||||
aliases = {"global"},
|
||||
desc = "List public schematics"
|
||||
)
|
||||
public Filter global() {
|
||||
return new Filter() {
|
||||
@Override
|
||||
public boolean listPrivate() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean listPublic() {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "",
|
||||
desc = "wildcard"
|
||||
)
|
||||
public Filter wildcard(Actor actor, String arg) {
|
||||
arg = arg.replace("/", File.separator);
|
||||
String argLower = arg.toLowerCase(Locale.ROOT);
|
||||
if (arg.endsWith("/") || arg.endsWith(File.separator)) {
|
||||
if (arg.length() > 3 && arg.length() <= 16) {
|
||||
// possible player name
|
||||
}
|
||||
} else {
|
||||
if (StringMan.containsAny(arg, "\\^$.|?+(){}<>~$!%^&*+-/")) {
|
||||
Pattern pattern;
|
||||
try {
|
||||
pattern = Pattern.compile(argLower);
|
||||
} catch (PatternSyntaxException ignore) {
|
||||
pattern = Pattern.compile(Pattern.quote(argLower));
|
||||
}
|
||||
Pattern finalPattern = pattern;
|
||||
return new Filter() {
|
||||
@Override
|
||||
public boolean applies(File file) {
|
||||
String path = file.getPath().toLowerCase(Locale.ROOT);
|
||||
return finalPattern.matcher(path).find();
|
||||
}
|
||||
};
|
||||
}
|
||||
return new Filter() {
|
||||
@Override
|
||||
public boolean applies(File file) {
|
||||
return StringMan.containsIgnoreCase(file.getPath(), argLower);
|
||||
}
|
||||
};
|
||||
}
|
||||
if (arg.endsWith("/") || arg.endsWith(File.separator)) {
|
||||
arg = arg.replace("/", File.separator);
|
||||
String newDirFilter = dirFilter + arg;
|
||||
boolean exists = new File(dir, newDirFilter).exists() || playerFolder && MainUtil.resolveRelative(new File(dir, actor.getUniqueId() + newDirFilter)).exists();
|
||||
if (!exists) {
|
||||
arg = arg.substring(0, arg.length() - File.separator.length());
|
||||
if (arg.length() > 3 && arg.length() <= 16) {
|
||||
UUID fromName = Fawe.imp().getUUID(arg);
|
||||
if (fromName != null) {
|
||||
newDirFilter = dirFilter + fromName + File.separator;
|
||||
listGlobal = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
dirFilter = newDirFilter;
|
||||
}
|
||||
else {
|
||||
filters.add(arg);
|
||||
}
|
||||
}
|
||||
}
|
@ -30,6 +30,7 @@ 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;
|
||||
|
@ -104,7 +104,7 @@ import org.enginehub.piston.annotation.param.Switch;
|
||||
* Utility commands.
|
||||
*/
|
||||
@CommandContainer(superTypes = {CommandPermissionsConditionGenerator.Registration.class, CommandQueuedConditionGenerator.Registration.class})
|
||||
@Command(aliases = {}, desc = "Various utility commands: [More Info](http://wiki.sk89q.com/wiki/WorldEdit/Utilities)")
|
||||
//@Command(aliases = {}, desc = "Various utility commands: [More Info](http://wiki.sk89q.com/wiki/WorldEdit/Utilities)")
|
||||
public class UtilityCommands {
|
||||
|
||||
private final WorldEdit we;
|
||||
@ -693,34 +693,6 @@ public class UtilityCommands {
|
||||
PrintCommandHelp.help(command, page, listSubCommands, we, actor);
|
||||
}
|
||||
|
||||
protected static CommandMapping detectCommand(Dispatcher dispatcher, String command, boolean isRootLevel) {
|
||||
CommandMapping mapping;
|
||||
|
||||
// First try the command as entered
|
||||
mapping = dispatcher.get(command);
|
||||
if (mapping != null) {
|
||||
return mapping;
|
||||
}
|
||||
|
||||
// Then if we're looking at root commands and the user didn't use
|
||||
// any slashes, let's try double slashes and then single slashes.
|
||||
// However, be aware that there exists different single slash
|
||||
// and double slash commands in WorldEdit
|
||||
if (isRootLevel && !command.contains("/")) {
|
||||
mapping = dispatcher.get("//" + command);
|
||||
if (mapping != null) {
|
||||
return mapping;
|
||||
}
|
||||
|
||||
mapping = dispatcher.get("/" + command);
|
||||
if (mapping != null) {
|
||||
return mapping;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void list(File dir, Actor actor, InjectedValueAccess args, @Range(min = 0) int page, String formatName, boolean playerFolder, String onClickCmd) {
|
||||
list(dir, actor, args, page, -1, formatName, playerFolder, new RunnableVal3<Message, URI, String>() {
|
||||
@Override
|
||||
@ -800,6 +772,7 @@ public class UtilityCommands {
|
||||
|
||||
public static int getFiles(File dir, Actor actor, InjectedValueAccess args, @Range(min = 0) int page, int perPage, String formatName, boolean playerFolder, Consumer<File> forEachFile) {
|
||||
Consumer<File> rootFunction = forEachFile;
|
||||
//schem list all <path>
|
||||
|
||||
int len = args.argsLength();
|
||||
List<String> filters = new ArrayList<>();
|
||||
|
Reference in New Issue
Block a user