mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-04 03:56:41 +00:00
Remove FAWE-Piston
Disables a lot of previous functionality in FAWE until replacements can be made. This commit was untested and may cause major issues.
This commit is contained in:
@ -15,7 +15,6 @@ import com.boydti.fawe.util.TextureUtil;
|
||||
import com.boydti.fawe.util.WEManager;
|
||||
import com.github.luben.zstd.util.Native;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.extension.factory.DefaultTransformParser;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.session.request.Request;
|
||||
import java.io.BufferedReader;
|
||||
@ -92,7 +91,8 @@ public class Fawe {
|
||||
private FaweVersion version;
|
||||
private VisualQueue visualQueue;
|
||||
private TextureUtil textures;
|
||||
private DefaultTransformParser transformParser;
|
||||
// TODO: Ping @MattBDev to reimplement 2020-02-04
|
||||
// private DefaultTransformParser transformParser;
|
||||
|
||||
private QueueHandler queueHandler;
|
||||
|
||||
@ -184,7 +184,8 @@ public class Fawe {
|
||||
// Delayed worldedit setup
|
||||
TaskManager.IMP.later(() -> {
|
||||
try {
|
||||
transformParser = new DefaultTransformParser(getWorldEdit());
|
||||
// TODO: Ping @MattBDev to reimplement 2020-02-04
|
||||
// transformParser = new DefaultTransformParser(getWorldEdit());
|
||||
visualQueue = new VisualQueue(3);
|
||||
WEManager.IMP.managers.addAll(Fawe.this.IMP.getMaskManagers());
|
||||
WEManager.IMP.managers.add(new PlotSquaredFeature());
|
||||
@ -208,10 +209,11 @@ public class Fawe {
|
||||
}
|
||||
return queueHandler;
|
||||
}
|
||||
|
||||
public DefaultTransformParser getTransformParser() {
|
||||
return transformParser;
|
||||
}
|
||||
|
||||
// TODO: Ping @MattBDev to reimplement 2020-02-04
|
||||
// public DefaultTransformParser getTransformParser() {
|
||||
// return transformParser;
|
||||
// }
|
||||
|
||||
public TextureUtil getCachedTextureUtil(boolean randomize, int min, int max) {
|
||||
// TODO NOT IMPLEMENTED - optimize this by caching the default true/0/100 texture util
|
||||
|
@ -1,88 +1,89 @@
|
||||
package com.boydti.fawe.command;
|
||||
|
||||
import static com.sk89q.worldedit.util.formatting.text.TextComponent.newline;
|
||||
|
||||
import com.boydti.fawe.command.CFICommands.CFISettings;
|
||||
import com.boydti.fawe.object.brush.visualization.cfi.HeightMapMCAGenerator;
|
||||
import com.boydti.fawe.object.changeset.CFIChangeSet;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.enginehub.piston.CommandManager;
|
||||
import org.enginehub.piston.exception.StopExecutionException;
|
||||
import org.enginehub.piston.inject.InjectedValueAccess;
|
||||
import org.enginehub.piston.inject.Key;
|
||||
|
||||
public class CFICommand extends CommandProcessor<Object, Object> {
|
||||
|
||||
public CFICommand(CommandManager manager) {
|
||||
super(manager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> preprocess(InjectedValueAccess context, List<String> args) {
|
||||
Player player = context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player"));
|
||||
CFICommands.CFISettings settings = CFICommands.getSettings(player);
|
||||
settings.popMessages(player);
|
||||
args = dispatch(player, settings, args, context);
|
||||
HeightMapMCAGenerator gen = settings.getGenerator();
|
||||
if (gen != null && gen.isModified()) {
|
||||
try {
|
||||
gen.update();
|
||||
CFIChangeSet set = new CFIChangeSet(gen, player.getUniqueId());
|
||||
LocalSession session = player.getSession();
|
||||
session.remember(player, gen, set, player.getLimit());
|
||||
} catch (IOException e) {
|
||||
throw new StopExecutionException(TextComponent.of(e.getMessage()));
|
||||
}
|
||||
}
|
||||
return args;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object process(InjectedValueAccess context, List<String> args, Object result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
private List<String> dispatch(Player player, CFISettings settings, List<String> args, InjectedValueAccess context) {
|
||||
if (!settings.hasGenerator()) {
|
||||
if (args.size() == 0) {
|
||||
String hmCmd = "/cfi ";
|
||||
if (settings.image == null) {
|
||||
hmCmd += "image";
|
||||
} else {
|
||||
hmCmd = "heightmap" + " " + settings.imageArg;
|
||||
}
|
||||
TextComponent build = TextComponent.builder("What do you want to use as the base?")
|
||||
.append(newline())
|
||||
.append("[HeightMap]")/* TODO .cmdTip(hmCmd).*/.append(" - A heightmap like ")
|
||||
.append("[this]")//TODO .linkTip("http://i.imgur.com/qCd30MR.jpg")
|
||||
.append(newline())
|
||||
.append("[Empty]")//TODO .cmdTip(CFICommands.alias() + " empty")
|
||||
.append("- An empty map of a specific size").build();
|
||||
player.print(build);
|
||||
} else {
|
||||
args = new ArrayList<>(args);
|
||||
switch (args.size()) {
|
||||
case 1:
|
||||
args.add(0, "heightmap");
|
||||
break;
|
||||
case 2:
|
||||
args.add(0, "empty");
|
||||
break;
|
||||
}
|
||||
return args;
|
||||
}
|
||||
} else {
|
||||
if (args.isEmpty()) {
|
||||
settings.setCategory(null);
|
||||
CFICommands.mainMenu(player);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return args;
|
||||
}
|
||||
}
|
||||
// TODO: Ping @MattBDev to reimplement 2020-02-04
|
||||
//package com.boydti.fawe.command;
|
||||
//
|
||||
//import static com.sk89q.worldedit.util.formatting.text.TextComponent.newline;
|
||||
//
|
||||
//import com.boydti.fawe.command.CFICommands.CFISettings;
|
||||
//import com.boydti.fawe.object.brush.visualization.cfi.HeightMapMCAGenerator;
|
||||
//import com.boydti.fawe.object.changeset.CFIChangeSet;
|
||||
//import com.sk89q.worldedit.LocalSession;
|
||||
//import com.sk89q.worldedit.entity.Player;
|
||||
//import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
//import java.io.IOException;
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.List;
|
||||
//import org.enginehub.piston.CommandManager;
|
||||
//import org.enginehub.piston.exception.StopExecutionException;
|
||||
//import org.enginehub.piston.inject.InjectedValueAccess;
|
||||
//import org.enginehub.piston.inject.Key;
|
||||
//
|
||||
//public class CFICommand extends CommandProcessor<Object, Object> {
|
||||
//
|
||||
// public CFICommand(CommandManager manager) {
|
||||
// super(manager);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public List<String> preprocess(InjectedValueAccess context, List<String> args) {
|
||||
// Player player = context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player"));
|
||||
// CFICommands.CFISettings settings = CFICommands.getSettings(player);
|
||||
// settings.popMessages(player);
|
||||
// args = dispatch(player, settings, args, context);
|
||||
// HeightMapMCAGenerator gen = settings.getGenerator();
|
||||
// if (gen != null && gen.isModified()) {
|
||||
// try {
|
||||
// gen.update();
|
||||
// CFIChangeSet set = new CFIChangeSet(gen, player.getUniqueId());
|
||||
// LocalSession session = player.getSession();
|
||||
// session.remember(player, gen, set, player.getLimit());
|
||||
// } catch (IOException e) {
|
||||
// throw new StopExecutionException(TextComponent.of(e.getMessage()));
|
||||
// }
|
||||
// }
|
||||
// return args;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Object process(InjectedValueAccess context, List<String> args, Object result) {
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// private List<String> dispatch(Player player, CFISettings settings, List<String> args, InjectedValueAccess context) {
|
||||
// if (!settings.hasGenerator()) {
|
||||
// if (args.size() == 0) {
|
||||
// String hmCmd = "/cfi ";
|
||||
// if (settings.image == null) {
|
||||
// hmCmd += "image";
|
||||
// } else {
|
||||
// hmCmd = "heightmap" + " " + settings.imageArg;
|
||||
// }
|
||||
// TextComponent build = TextComponent.builder("What do you want to use as the base?")
|
||||
// .append(newline())
|
||||
// .append("[HeightMap]")/* TODO .cmdTip(hmCmd).*/.append(" - A heightmap like ")
|
||||
// .append("[this]")//TODO .linkTip("http://i.imgur.com/qCd30MR.jpg")
|
||||
// .append(newline())
|
||||
// .append("[Empty]")//TODO .cmdTip(CFICommands.alias() + " empty")
|
||||
// .append("- An empty map of a specific size").build();
|
||||
// player.print(build);
|
||||
// } else {
|
||||
// args = new ArrayList<>(args);
|
||||
// switch (args.size()) {
|
||||
// case 1:
|
||||
// args.add(0, "heightmap");
|
||||
// break;
|
||||
// case 2:
|
||||
// args.add(0, "empty");
|
||||
// break;
|
||||
// }
|
||||
// return args;
|
||||
// }
|
||||
// } else {
|
||||
// if (args.isEmpty()) {
|
||||
// settings.setCategory(null);
|
||||
// CFICommands.mainMenu(player);
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
// return args;
|
||||
// }
|
||||
//}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,93 +0,0 @@
|
||||
package com.boydti.fawe.command;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.enginehub.piston.Command;
|
||||
import org.enginehub.piston.CommandManager;
|
||||
import org.enginehub.piston.CommandParseResult;
|
||||
import org.enginehub.piston.converter.ArgumentConverter;
|
||||
import org.enginehub.piston.inject.InjectedValueAccess;
|
||||
import org.enginehub.piston.inject.Key;
|
||||
import org.enginehub.piston.suggestion.Suggestion;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public abstract class CommandProcessor<I, O> implements CommandManager {
|
||||
private final CommandManager parent;
|
||||
|
||||
public CommandProcessor(CommandManager parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Command.Builder newCommand(String s) {
|
||||
return parent.newCommand(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void register(Command command) {
|
||||
parent.register(command);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void register(String name, Consumer<Command.Builder> registrationProcess) {
|
||||
parent.register(name, registrationProcess);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void registerManager(CommandManager manager) {
|
||||
parent.registerManager(manager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Stream<Command> getAllCommands() {
|
||||
return parent.getAllCommands();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean containsCommand(String name) {
|
||||
return parent.containsCommand(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Optional<Command> getCommand(String s) {
|
||||
return parent.getCommand(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final ImmutableSet<Suggestion> getSuggestions(InjectedValueAccess injectedValueAccess, List<String> list) {
|
||||
return parent.getSuggestions(injectedValueAccess, list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final CommandParseResult parse(InjectedValueAccess injectedValueAccess, List<String> list) {
|
||||
return parent.parse(injectedValueAccess, list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Object execute(InjectedValueAccess context, List<String> args) {
|
||||
args = preprocess(context, args);
|
||||
if (args != null) {
|
||||
Object result = parent.execute(context, args);
|
||||
return process(context, args, result); // TODO NOT IMPLEMENTED (recompile piston)
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final <T> void registerConverter(Key<T> key, ArgumentConverter<T> argumentConverter) {
|
||||
parent.registerConverter(key, argumentConverter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final <T> Optional<ArgumentConverter<T>> getConverter(Key<T> key) {
|
||||
return parent.getConverter(key);
|
||||
}
|
||||
|
||||
public abstract List<String> preprocess(InjectedValueAccess context, List<String> args);
|
||||
|
||||
public abstract Object process(InjectedValueAccess context, List<String> args, Object result);
|
||||
}
|
@ -1,113 +1,114 @@
|
||||
package com.boydti.fawe.command;
|
||||
|
||||
import com.boydti.fawe.util.StringMan;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.extension.platform.PlatformCommandManager;
|
||||
import com.sk89q.worldedit.internal.registry.InputParser;
|
||||
import org.enginehub.piston.inject.InjectedValueAccess;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public abstract class FaweParser<T> extends InputParser<T> {
|
||||
|
||||
private final String prefix;
|
||||
|
||||
protected FaweParser(WorldEdit worldEdit, String prefix) {
|
||||
super(worldEdit);
|
||||
this.prefix = prefix;
|
||||
}
|
||||
|
||||
public PlatformCommandManager getPlatform() {
|
||||
return PlatformCommandManager.getInstance();
|
||||
}
|
||||
|
||||
public T parse(String input, ParserContext context) {
|
||||
input = prefix + " " + input;
|
||||
InjectedValueAccess injected = context.getInjected();
|
||||
if (injected != null) {
|
||||
return getPlatform().parseCommand(input, injected);
|
||||
} else {
|
||||
return getPlatform().parseCommand(input, context.getActor());
|
||||
}
|
||||
}
|
||||
|
||||
public T catchSuggestion(String currentInput, String nextInput, ParserContext context) throws InputParseException {
|
||||
try {
|
||||
return parseFromInput(nextInput, context);
|
||||
} catch (SuggestInputParseException e) {
|
||||
e.prepend(currentInput.substring(0, currentInput.length() - nextInput.length()));
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
protected static class ParseEntry {
|
||||
public boolean and;
|
||||
public String input;
|
||||
public String full;
|
||||
|
||||
public ParseEntry(String full, String input, boolean type) {
|
||||
this.full = full;
|
||||
this.input = input;
|
||||
this.and = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return input + " | " + and;
|
||||
}
|
||||
}
|
||||
|
||||
public static List<Map.Entry<ParseEntry, List<String>>> parse(String toParse) throws InputParseException {
|
||||
List<Map.Entry<ParseEntry, List<String>>> keys = new ArrayList<>();
|
||||
List<String> inputs = new ArrayList<>();
|
||||
List<Boolean> and = new ArrayList<>();
|
||||
int last = 0;
|
||||
outer:
|
||||
for (int i = 0; i < toParse.length(); i++) {
|
||||
char c = toParse.charAt(i);
|
||||
switch (c) {
|
||||
case ',':
|
||||
case '&':
|
||||
String result = toParse.substring(last, i);
|
||||
if (!result.isEmpty()) {
|
||||
inputs.add(result);
|
||||
and.add(c == '&');
|
||||
} else {
|
||||
throw new InputParseException("Invalid dangling character " + c);
|
||||
}
|
||||
last = i + 1;
|
||||
continue outer;
|
||||
default:
|
||||
if (c == '[' && StringMan.getMatchingBracket(c) != c) {
|
||||
int next = StringMan.findMatchingBracket(toParse, i);
|
||||
if (next != -1) {
|
||||
i = next;
|
||||
} else {
|
||||
toParse += "]";
|
||||
i = toParse.length();
|
||||
}
|
||||
continue outer;
|
||||
}
|
||||
}
|
||||
}
|
||||
inputs.add(toParse.substring(last));
|
||||
for (int i = 0; i < inputs.size(); i++) {
|
||||
String full = inputs.get(i);
|
||||
String command = full;
|
||||
List<String> args = new ArrayList<>();
|
||||
while (!command.isEmpty() && command.charAt(command.length() - 1) == ']') {
|
||||
int startPos = StringMan.findMatchingBracket(command, command.length() - 1);
|
||||
if (startPos == -1) break;
|
||||
String arg = command.substring(startPos + 1, command.length() - 1);
|
||||
args.add(arg);
|
||||
command = full.substring(0, startPos);
|
||||
}
|
||||
Collections.reverse(args);
|
||||
ParseEntry entry = new ParseEntry(full, command, i > 0 ? and.get(i - 1) : false);
|
||||
keys.add(new AbstractMap.SimpleEntry<>(entry, args));
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
}
|
||||
// TODO: Ping @MattBDev to reimplement 2020-02-04
|
||||
//package com.boydti.fawe.command;
|
||||
//
|
||||
//import com.boydti.fawe.util.StringMan;
|
||||
//import com.sk89q.worldedit.WorldEdit;
|
||||
//import com.sk89q.worldedit.extension.input.InputParseException;
|
||||
//import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
//import com.sk89q.worldedit.extension.platform.PlatformCommandManager;
|
||||
//import com.sk89q.worldedit.internal.registry.InputParser;
|
||||
//import org.enginehub.piston.inject.InjectedValueAccess;
|
||||
//
|
||||
//import java.util.*;
|
||||
//
|
||||
//public abstract class FaweParser<T> extends InputParser<T> {
|
||||
//
|
||||
// private final String prefix;
|
||||
//
|
||||
// protected FaweParser(WorldEdit worldEdit, String prefix) {
|
||||
// super(worldEdit);
|
||||
// this.prefix = prefix;
|
||||
// }
|
||||
//
|
||||
// public PlatformCommandManager getPlatform() {
|
||||
// return PlatformCommandManager.getInstance();
|
||||
// }
|
||||
//
|
||||
// public T parse(String input, ParserContext context) {
|
||||
// input = prefix + " " + input;
|
||||
// InjectedValueAccess injected = context.getInjected();
|
||||
// if (injected != null) {
|
||||
// return getPlatform().parseCommand(input, injected);
|
||||
// } else {
|
||||
// return getPlatform().parseCommand(input, context.getActor());
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public T catchSuggestion(String currentInput, String nextInput, ParserContext context) throws InputParseException {
|
||||
// try {
|
||||
// return parseFromInput(nextInput, context);
|
||||
// } catch (SuggestInputParseException e) {
|
||||
// e.prepend(currentInput.substring(0, currentInput.length() - nextInput.length()));
|
||||
// throw e;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// protected static class ParseEntry {
|
||||
// public boolean and;
|
||||
// public String input;
|
||||
// public String full;
|
||||
//
|
||||
// public ParseEntry(String full, String input, boolean type) {
|
||||
// this.full = full;
|
||||
// this.input = input;
|
||||
// this.and = type;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String toString() {
|
||||
// return input + " | " + and;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public static List<Map.Entry<ParseEntry, List<String>>> parse(String toParse) throws InputParseException {
|
||||
// List<Map.Entry<ParseEntry, List<String>>> keys = new ArrayList<>();
|
||||
// List<String> inputs = new ArrayList<>();
|
||||
// List<Boolean> and = new ArrayList<>();
|
||||
// int last = 0;
|
||||
// outer:
|
||||
// for (int i = 0; i < toParse.length(); i++) {
|
||||
// char c = toParse.charAt(i);
|
||||
// switch (c) {
|
||||
// case ',':
|
||||
// case '&':
|
||||
// String result = toParse.substring(last, i);
|
||||
// if (!result.isEmpty()) {
|
||||
// inputs.add(result);
|
||||
// and.add(c == '&');
|
||||
// } else {
|
||||
// throw new InputParseException("Invalid dangling character " + c);
|
||||
// }
|
||||
// last = i + 1;
|
||||
// continue outer;
|
||||
// default:
|
||||
// if (c == '[' && StringMan.getMatchingBracket(c) != c) {
|
||||
// int next = StringMan.findMatchingBracket(toParse, i);
|
||||
// if (next != -1) {
|
||||
// i = next;
|
||||
// } else {
|
||||
// toParse += "]";
|
||||
// i = toParse.length();
|
||||
// }
|
||||
// continue outer;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// inputs.add(toParse.substring(last));
|
||||
// for (int i = 0; i < inputs.size(); i++) {
|
||||
// String full = inputs.get(i);
|
||||
// String command = full;
|
||||
// List<String> args = new ArrayList<>();
|
||||
// while (!command.isEmpty() && command.charAt(command.length() - 1) == ']') {
|
||||
// int startPos = StringMan.findMatchingBracket(command, command.length() - 1);
|
||||
// if (startPos == -1) break;
|
||||
// String arg = command.substring(startPos + 1, command.length() - 1);
|
||||
// args.add(arg);
|
||||
// command = full.substring(0, startPos);
|
||||
// }
|
||||
// Collections.reverse(args);
|
||||
// ParseEntry entry = new ParseEntry(full, command, i > 0 ? and.get(i - 1) : false);
|
||||
// keys.add(new AbstractMap.SimpleEntry<>(entry, args));
|
||||
// }
|
||||
// return keys;
|
||||
// }
|
||||
//}
|
||||
|
@ -1,82 +1,83 @@
|
||||
package com.boydti.fawe.command;
|
||||
|
||||
import com.boydti.fawe.command.CFICommands.CFISettings;
|
||||
import com.boydti.fawe.object.RunnableVal;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.commands.Auto;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.worlds.PlotAreaManager;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotArea;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotAreaManager;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class PlotLoader {
|
||||
|
||||
@Deprecated
|
||||
public static void autoClaimFromDatabase(PlotPlayer player, PlotArea area, PlotId start,
|
||||
com.github.intellectualsites.plotsquared.plot.object.RunnableVal<Plot> whenDone) {
|
||||
final Plot plot = area.getNextFreePlot(player, start);
|
||||
if (plot == null) {
|
||||
whenDone.run(null);
|
||||
return;
|
||||
}
|
||||
whenDone.value = plot;
|
||||
plot.owner = player.getUUID();
|
||||
DBFunc.createPlotSafe(plot, whenDone,
|
||||
() -> autoClaimFromDatabase(player, area, plot.getId(), whenDone));
|
||||
}
|
||||
|
||||
public void load(Actor actor, CFISettings settings, Function<File, Boolean> createTask) throws IOException {
|
||||
PlotAreaManager manager = PlotSquared.get().getPlotAreaManager();
|
||||
if (manager instanceof SinglePlotAreaManager) {
|
||||
SinglePlotAreaManager sManager = (SinglePlotAreaManager) manager;
|
||||
SinglePlotArea area = sManager.getArea();
|
||||
PlotPlayer player = PlotPlayer.get(actor.getName());
|
||||
|
||||
actor.print("Claiming world");
|
||||
Plot plot = TaskManager.IMP.sync(new RunnableVal<Plot>() {
|
||||
@Override
|
||||
public void run(Plot o) {
|
||||
int currentPlots = Settings.Limit.GLOBAL ? player.getPlotCount()
|
||||
: player.getPlotCount(area.worldname);
|
||||
int diff = player.getAllowedPlots() - currentPlots;
|
||||
if (diff < 1) {
|
||||
Captions.CANT_CLAIM_MORE_PLOTS_NUM.send(player, -diff);
|
||||
return;
|
||||
}
|
||||
|
||||
if (area.getMeta("lastPlot") == null) {
|
||||
area.setMeta("lastPlot", new PlotId(0, 0));
|
||||
}
|
||||
PlotId lastId = (PlotId) area.getMeta("lastPlot");
|
||||
do {
|
||||
lastId = Auto.getNextPlotId(lastId, 1);
|
||||
} while (!area.canClaim(player, lastId, lastId));
|
||||
area.setMeta("lastPlot", lastId);
|
||||
this.value = area.getPlot(lastId);
|
||||
this.value.setOwner(player.getUUID());
|
||||
}
|
||||
});
|
||||
if (plot != null) {
|
||||
|
||||
File folder = CFICommands.getFolder(plot.getWorldName());
|
||||
Boolean result = createTask.apply(folder);
|
||||
if (result == Boolean.TRUE) {
|
||||
TaskManager.IMP.sync(() -> plot.teleportPlayer(player));
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
createTask.apply(null);
|
||||
}
|
||||
}
|
||||
// TODO: Ping @MattBDev to reimplement 2020-02-04
|
||||
//package com.boydti.fawe.command;
|
||||
//
|
||||
//import com.boydti.fawe.command.CFICommands.CFISettings;
|
||||
//import com.boydti.fawe.object.RunnableVal;
|
||||
//import com.boydti.fawe.util.TaskManager;
|
||||
//import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
//import com.github.intellectualsites.plotsquared.plot.commands.Auto;
|
||||
//import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
//import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||
//import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
||||
//import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
//import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||
//import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
||||
//import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
//import com.github.intellectualsites.plotsquared.plot.object.worlds.PlotAreaManager;
|
||||
//import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotArea;
|
||||
//import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotAreaManager;
|
||||
//import com.sk89q.worldedit.extension.platform.Actor;
|
||||
//import java.io.File;
|
||||
//import java.io.IOException;
|
||||
//import java.util.function.Function;
|
||||
//
|
||||
//public class PlotLoader {
|
||||
//
|
||||
// @Deprecated
|
||||
// public static void autoClaimFromDatabase(PlotPlayer player, PlotArea area, PlotId start,
|
||||
// com.github.intellectualsites.plotsquared.plot.object.RunnableVal<Plot> whenDone) {
|
||||
// final Plot plot = area.getNextFreePlot(player, start);
|
||||
// if (plot == null) {
|
||||
// whenDone.run(null);
|
||||
// return;
|
||||
// }
|
||||
// whenDone.value = plot;
|
||||
// plot.owner = player.getUUID();
|
||||
// DBFunc.createPlotSafe(plot, whenDone,
|
||||
// () -> autoClaimFromDatabase(player, area, plot.getId(), whenDone));
|
||||
// }
|
||||
//
|
||||
// public void load(Actor actor, CFISettings settings, Function<File, Boolean> createTask) throws IOException {
|
||||
// PlotAreaManager manager = PlotSquared.get().getPlotAreaManager();
|
||||
// if (manager instanceof SinglePlotAreaManager) {
|
||||
// SinglePlotAreaManager sManager = (SinglePlotAreaManager) manager;
|
||||
// SinglePlotArea area = sManager.getArea();
|
||||
// PlotPlayer player = PlotPlayer.get(actor.getName());
|
||||
//
|
||||
// actor.print("Claiming world");
|
||||
// Plot plot = TaskManager.IMP.sync(new RunnableVal<Plot>() {
|
||||
// @Override
|
||||
// public void run(Plot o) {
|
||||
// int currentPlots = Settings.Limit.GLOBAL ? player.getPlotCount()
|
||||
// : player.getPlotCount(area.worldname);
|
||||
// int diff = player.getAllowedPlots() - currentPlots;
|
||||
// if (diff < 1) {
|
||||
// Captions.CANT_CLAIM_MORE_PLOTS_NUM.send(player, -diff);
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// if (area.getMeta("lastPlot") == null) {
|
||||
// area.setMeta("lastPlot", new PlotId(0, 0));
|
||||
// }
|
||||
// PlotId lastId = (PlotId) area.getMeta("lastPlot");
|
||||
// do {
|
||||
// lastId = Auto.getNextPlotId(lastId, 1);
|
||||
// } while (!area.canClaim(player, lastId, lastId));
|
||||
// area.setMeta("lastPlot", lastId);
|
||||
// this.value = area.getPlot(lastId);
|
||||
// this.value.setOwner(player.getUUID());
|
||||
// }
|
||||
// });
|
||||
// if (plot != null) {
|
||||
//
|
||||
// File folder = CFICommands.getFolder(plot.getWorldName());
|
||||
// Boolean result = createTask.apply(folder);
|
||||
// if (result == Boolean.TRUE) {
|
||||
// TaskManager.IMP.sync(() -> plot.teleportPlayer(player));
|
||||
// }
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// createTask.apply(null);
|
||||
// }
|
||||
//}
|
||||
|
@ -58,65 +58,66 @@ public class BrushSettings {
|
||||
this.constructor.put(SettingType.PERMISSIONS, permissions);
|
||||
}
|
||||
|
||||
public static BrushSettings get(BrushTool tool, Player player, LocalSession session, Map<String, Object> settings) throws InputParseException {
|
||||
PlatformCommandManager manager = PlatformCommandManager.getInstance();
|
||||
String constructor = (String) settings.get(SettingType.BRUSH.name());
|
||||
if (constructor == null) {
|
||||
return new BrushSettings();
|
||||
}
|
||||
BrushSettings bs = manager.parseCommand(constructor, player);
|
||||
bs.constructor.put(SettingType.BRUSH, constructor);
|
||||
if (settings.containsKey(SettingType.PERMISSIONS.name())) {
|
||||
bs.permissions.addAll((Collection<? extends String>) settings.get(SettingType.PERMISSIONS.name()));
|
||||
}
|
||||
if (settings.containsKey(SettingType.SIZE.name())) {
|
||||
try {
|
||||
bs.size = Expression.compile((String) settings.getOrDefault(SettingType.SIZE.name(), -1));
|
||||
bs.size.optimize();
|
||||
} catch (ExpressionException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
ParserContext parserContext = new ParserContext();
|
||||
parserContext.setActor(player);
|
||||
parserContext.setWorld(player.getWorld());
|
||||
parserContext.setSession(session);
|
||||
|
||||
if (settings.containsKey(SettingType.MASK.name())) {
|
||||
String maskArgs = (String) settings.get(SettingType.MASK.name());
|
||||
Mask mask = WorldEdit.getInstance().getMaskFactory().parseFromInput(maskArgs, parserContext);
|
||||
bs.setMask(mask);
|
||||
bs.constructor.put(SettingType.MASK, maskArgs);
|
||||
}
|
||||
if (settings.containsKey(SettingType.SOURCE_MASK.name())) {
|
||||
String maskArgs = (String) settings.get(SettingType.SOURCE_MASK.name());
|
||||
Mask mask = WorldEdit.getInstance().getMaskFactory().parseFromInput(maskArgs, parserContext);
|
||||
bs.setSourceMask(mask);
|
||||
bs.constructor.put(SettingType.SOURCE_MASK, maskArgs);
|
||||
}
|
||||
if (settings.containsKey(SettingType.TRANSFORM.name())) {
|
||||
String transformArgs = (String) settings.get(SettingType.TRANSFORM.name());
|
||||
ResettableExtent extent = Fawe.get().getTransformParser().parseFromInput(transformArgs, parserContext);
|
||||
bs.setTransform(extent);
|
||||
bs.constructor.put(SettingType.TRANSFORM, transformArgs);
|
||||
}
|
||||
if (settings.containsKey(SettingType.FILL.name())) {
|
||||
String fillArgs = (String) settings.get(SettingType.FILL.name());
|
||||
Pattern pattern = WorldEdit.getInstance().getPatternFactory().parseFromInput(fillArgs, parserContext);
|
||||
bs.setFill(pattern);
|
||||
bs.constructor.put(SettingType.FILL, fillArgs);
|
||||
}
|
||||
if (settings.containsKey(SettingType.SCROLL_ACTION.name())) {
|
||||
String actionArgs = (String) settings.get(SettingType.SCROLL_ACTION.name());
|
||||
Scroll action = Scroll.fromArguments(tool, player, session, actionArgs, false);
|
||||
if (action != null) {
|
||||
bs.setScrollAction(action);
|
||||
bs.constructor.put(SettingType.SCROLL_ACTION, actionArgs);
|
||||
}
|
||||
}
|
||||
return bs;
|
||||
}
|
||||
// TODO: Ping @MattBDev to reimplement 2020-02-04
|
||||
// public static BrushSettings get(BrushTool tool, Player player, LocalSession session, Map<String, Object> settings) throws InputParseException {
|
||||
// PlatformCommandManager manager = PlatformCommandManager.getInstance();
|
||||
// String constructor = (String) settings.get(SettingType.BRUSH.name());
|
||||
// if (constructor == null) {
|
||||
// return new BrushSettings();
|
||||
// }
|
||||
// BrushSettings bs = manager.parseCommand(constructor, player);
|
||||
// bs.constructor.put(SettingType.BRUSH, constructor);
|
||||
// if (settings.containsKey(SettingType.PERMISSIONS.name())) {
|
||||
// bs.permissions.addAll((Collection<? extends String>) settings.get(SettingType.PERMISSIONS.name()));
|
||||
// }
|
||||
// if (settings.containsKey(SettingType.SIZE.name())) {
|
||||
// try {
|
||||
// bs.size = Expression.compile((String) settings.getOrDefault(SettingType.SIZE.name(), -1));
|
||||
// bs.size.optimize();
|
||||
// } catch (ExpressionException e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// ParserContext parserContext = new ParserContext();
|
||||
// parserContext.setActor(player);
|
||||
// parserContext.setWorld(player.getWorld());
|
||||
// parserContext.setSession(session);
|
||||
//
|
||||
// if (settings.containsKey(SettingType.MASK.name())) {
|
||||
// String maskArgs = (String) settings.get(SettingType.MASK.name());
|
||||
// Mask mask = WorldEdit.getInstance().getMaskFactory().parseFromInput(maskArgs, parserContext);
|
||||
// bs.setMask(mask);
|
||||
// bs.constructor.put(SettingType.MASK, maskArgs);
|
||||
// }
|
||||
// if (settings.containsKey(SettingType.SOURCE_MASK.name())) {
|
||||
// String maskArgs = (String) settings.get(SettingType.SOURCE_MASK.name());
|
||||
// Mask mask = WorldEdit.getInstance().getMaskFactory().parseFromInput(maskArgs, parserContext);
|
||||
// bs.setSourceMask(mask);
|
||||
// bs.constructor.put(SettingType.SOURCE_MASK, maskArgs);
|
||||
// }
|
||||
// if (settings.containsKey(SettingType.TRANSFORM.name())) {
|
||||
// String transformArgs = (String) settings.get(SettingType.TRANSFORM.name());
|
||||
// ResettableExtent extent = Fawe.get().getTransformParser().parseFromInput(transformArgs, parserContext);
|
||||
// bs.setTransform(extent);
|
||||
// bs.constructor.put(SettingType.TRANSFORM, transformArgs);
|
||||
// }
|
||||
// if (settings.containsKey(SettingType.FILL.name())) {
|
||||
// String fillArgs = (String) settings.get(SettingType.FILL.name());
|
||||
// Pattern pattern = WorldEdit.getInstance().getPatternFactory().parseFromInput(fillArgs, parserContext);
|
||||
// bs.setFill(pattern);
|
||||
// bs.constructor.put(SettingType.FILL, fillArgs);
|
||||
// }
|
||||
// if (settings.containsKey(SettingType.SCROLL_ACTION.name())) {
|
||||
// String actionArgs = (String) settings.get(SettingType.SCROLL_ACTION.name());
|
||||
// Scroll action = Scroll.fromArguments(tool, player, session, actionArgs, false);
|
||||
// if (action != null) {
|
||||
// bs.setScrollAction(action);
|
||||
// bs.constructor.put(SettingType.SCROLL_ACTION, actionArgs);
|
||||
// }
|
||||
// }
|
||||
// return bs;
|
||||
// }
|
||||
|
||||
public BrushSettings setBrush(Brush brush) {
|
||||
Brush tmp = this.brush;
|
||||
|
@ -41,23 +41,24 @@ public final class BrushCache {
|
||||
CompoundTag nbt = item.getNbtData();
|
||||
if (nbt == null) return null;
|
||||
StringTag json = (StringTag) nbt.getValue().get("weBrushJson");
|
||||
if (json != null) {
|
||||
try {
|
||||
if (RECURSION.get() != null) return null;
|
||||
RECURSION.set(true);
|
||||
|
||||
BrushTool tool = BrushTool.fromString(player, session, json.getValue());
|
||||
tool.setHolder(item);
|
||||
brushCache.put(key, tool);
|
||||
return tool;
|
||||
} catch (Exception throwable) {
|
||||
getLogger(BrushCache.class).debug("Invalid brush for " + player + " holding " + item.getType() + ": " + json.getValue(), throwable);
|
||||
item.setNbtData(null);
|
||||
brushCache.remove(key);
|
||||
} finally {
|
||||
RECURSION.remove();
|
||||
}
|
||||
}
|
||||
// TODO: Ping @MattBDev to reimplement 2020-02-04
|
||||
// if (json != null) {
|
||||
// try {
|
||||
// if (RECURSION.get() != null) return null;
|
||||
// RECURSION.set(true);
|
||||
//
|
||||
// BrushTool tool = BrushTool.fromString(player, session, json.getValue());
|
||||
// tool.setHolder(item);
|
||||
// brushCache.put(key, tool);
|
||||
// return tool;
|
||||
// } catch (Exception throwable) {
|
||||
// getLogger(BrushCache.class).debug("Invalid brush for " + player + " holding " + item.getType() + ": " + json.getValue(), throwable);
|
||||
// item.setNbtData(null);
|
||||
// brushCache.remove(key);
|
||||
// } finally {
|
||||
// RECURSION.remove();
|
||||
// }
|
||||
// }
|
||||
return null;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user