geforkt von Mirrors/FastAsyncWorldEdit
BrushCommands
Dieser Commit ist enthalten in:
Ursprung
ee5e15eda3
Commit
f5c202af6d
@ -2,27 +2,20 @@ package com.boydti.fawe.beta.implementation;
|
|||||||
|
|
||||||
import com.boydti.fawe.Fawe;
|
import com.boydti.fawe.Fawe;
|
||||||
import com.boydti.fawe.FaweCache;
|
import com.boydti.fawe.FaweCache;
|
||||||
import com.boydti.fawe.beta.ChunkFilterBlock;
|
|
||||||
import com.boydti.fawe.beta.Filter;
|
|
||||||
import com.boydti.fawe.beta.IChunk;
|
import com.boydti.fawe.beta.IChunk;
|
||||||
import com.boydti.fawe.beta.IQueueExtent;
|
import com.boydti.fawe.beta.IQueueExtent;
|
||||||
import com.boydti.fawe.beta.Trimable;
|
import com.boydti.fawe.beta.Trimable;
|
||||||
import com.boydti.fawe.config.Settings;
|
import com.boydti.fawe.config.Settings;
|
||||||
import com.boydti.fawe.object.collection.IterableThreadLocal;
|
import com.boydti.fawe.object.collection.IterableThreadLocal;
|
||||||
import com.boydti.fawe.util.MemUtil;
|
import com.boydti.fawe.util.MemUtil;
|
||||||
import com.boydti.fawe.util.SetQueue;
|
|
||||||
import com.boydti.fawe.util.TaskManager;
|
import com.boydti.fawe.util.TaskManager;
|
||||||
import com.boydti.fawe.wrappers.WorldWrapper;
|
import com.boydti.fawe.wrappers.WorldWrapper;
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
|
||||||
import com.sk89q.worldedit.math.MutableBlockVector3;
|
|
||||||
import com.sk89q.worldedit.regions.Region;
|
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
|
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
|
@ -18,6 +18,7 @@ import com.sk89q.worldedit.function.visitor.BreadthFirstSearch;
|
|||||||
import com.sk89q.worldedit.function.visitor.RecursiveVisitor;
|
import com.sk89q.worldedit.function.visitor.RecursiveVisitor;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.math.MutableBlockVector3;
|
import com.sk89q.worldedit.math.MutableBlockVector3;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
|
||||||
@ -25,11 +26,11 @@ import java.util.Arrays;
|
|||||||
|
|
||||||
public class LayerBrush implements Brush {
|
public class LayerBrush implements Brush {
|
||||||
|
|
||||||
private final BlockStateHolder[] layers;
|
private final BlockState[] layers;
|
||||||
private RecursiveVisitor visitor;
|
private RecursiveVisitor visitor;
|
||||||
private MutableBlockVector3 mutable = new MutableBlockVector3();
|
private MutableBlockVector3 mutable = new MutableBlockVector3();
|
||||||
|
|
||||||
public LayerBrush(BlockStateHolder[] layers) {
|
public LayerBrush(BlockState[] layers) {
|
||||||
this.layers = layers;
|
this.layers = layers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1373,23 +1373,24 @@ public class LocalSession implements TextureHolder {
|
|||||||
this.fastMode = fastMode;
|
this.fastMode = fastMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
/**
|
||||||
// * Gets the reorder mode of the session.
|
* Gets the reorder mode of the session.
|
||||||
// *
|
*
|
||||||
// * @return The reorder mode
|
* @return The reorder mode
|
||||||
// */
|
*/
|
||||||
// public EditSession.ReorderMode getReorderMode() {
|
public EditSession.ReorderMode getReorderMode() {
|
||||||
// return reorderMode;
|
// return reorderMode;
|
||||||
// }
|
return EditSession.ReorderMode.FAST;
|
||||||
//
|
}
|
||||||
// /**
|
|
||||||
// * Sets the reorder mode of the session.
|
/**
|
||||||
// *
|
* Sets the reorder mode of the session.
|
||||||
// * @param reorderMode The reorder mode
|
*
|
||||||
// */
|
* @param reorderMode The reorder mode
|
||||||
// public void setReorderMode(EditSession.ReorderMode reorderMode) {
|
*/
|
||||||
|
public void setReorderMode(EditSession.ReorderMode reorderMode) {
|
||||||
// this.reorderMode = reorderMode;
|
// this.reorderMode = reorderMode;
|
||||||
// }
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the mask.
|
* Get the mask.
|
||||||
|
Datei-Diff unterdrückt, da er zu groß ist
Diff laden
@ -43,7 +43,6 @@ import com.sk89q.worldedit.extension.input.ParserContext;
|
|||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
import com.sk89q.worldedit.function.mask.Mask;
|
import com.sk89q.worldedit.function.mask.Mask;
|
||||||
import com.sk89q.worldedit.util.command.parametric.ParameterException;
|
|
||||||
import com.sk89q.worldedit.util.formatting.component.PaginationBox;
|
import com.sk89q.worldedit.util.formatting.component.PaginationBox;
|
||||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
@ -69,7 +68,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||||||
* General WorldEdit commands.
|
* General WorldEdit commands.
|
||||||
*/
|
*/
|
||||||
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
||||||
@Command(aliases = {}, desc = "Player toggles, settings and item info")
|
//@Command(aliases = {}, desc = "Player toggles, settings and item info")
|
||||||
public class GeneralCommands {
|
public class GeneralCommands {
|
||||||
|
|
||||||
private final WorldEdit worldEdit;
|
private final WorldEdit worldEdit;
|
||||||
@ -373,18 +372,11 @@ public class GeneralCommands {
|
|||||||
desc = "Set the global transform"
|
desc = "Set the global transform"
|
||||||
)
|
)
|
||||||
@CommandPermissions({"worldedit.global-transform", "worldedit.transform.global"})
|
@CommandPermissions({"worldedit.global-transform", "worldedit.transform.global"})
|
||||||
public void gtransform(Player player, EditSession editSession, LocalSession session, @Arg(name = "context", desc = "InjectedValueAccess", def = "") InjectedValueAccess context) throws WorldEditException {
|
public void gtransform(Player player, EditSession editSession, LocalSession session, ResettableExtent transform) throws WorldEditException {
|
||||||
if (context == null || context.argsLength() == 0) {
|
session.setTransform(transform);
|
||||||
session.setTransform(null);
|
if (transform == null) {
|
||||||
BBC.TRANSFORM_DISABLED.send(player);
|
BBC.TRANSFORM_DISABLED.send(player);
|
||||||
} else {
|
} else {
|
||||||
ParserContext parserContext = new ParserContext();
|
|
||||||
parserContext.setActor(player);
|
|
||||||
parserContext.setWorld(player.getWorld());
|
|
||||||
parserContext.setSession(session);
|
|
||||||
parserContext.setExtent(editSession);
|
|
||||||
ResettableExtent transform = Fawe.get().getTransformParser().parseFromInput(context.getJoinedStrings(0), parserContext);
|
|
||||||
session.setTransform(transform);
|
|
||||||
BBC.TRANSFORM.send(player);
|
BBC.TRANSFORM.send(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,6 @@ import com.sk89q.worldedit.regions.Region;
|
|||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
import com.sk89q.worldedit.internal.annotation.Range;
|
import com.sk89q.worldedit.internal.annotation.Range;
|
||||||
import org.enginehub.piston.annotation.param.Switch;
|
import org.enginehub.piston.annotation.param.Switch;
|
||||||
import com.sk89q.worldedit.util.command.parametric.Optional;
|
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -55,20 +54,25 @@ import org.enginehub.piston.annotation.Command;
|
|||||||
import org.enginehub.piston.annotation.CommandContainer;
|
import org.enginehub.piston.annotation.CommandContainer;
|
||||||
import org.enginehub.piston.annotation.param.Arg;
|
import org.enginehub.piston.annotation.param.Arg;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Commands to undo, redo, and clear history.
|
* Commands to undo, redo, and clear history.
|
||||||
*/
|
*/
|
||||||
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
||||||
@Command(aliases = {}, desc = "Commands to undo, redo, and clear history: [More Info](http://wiki.sk89q.com/wiki/WorldEdit/Features#History)")
|
//@Command(aliases = {}, desc = "Commands to undo, redo, and clear history: [More Info](http://wiki.sk89q.com/wiki/WorldEdit/Features#History)")
|
||||||
public class HistoryCommands extends MethodCommands {
|
public class HistoryCommands extends MethodCommands {
|
||||||
|
|
||||||
|
private final WorldEdit worldEdit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new instance.
|
* Create a new instance.
|
||||||
*
|
*
|
||||||
* @param worldEdit reference to WorldEdit
|
* @param worldEdit reference to WorldEdit
|
||||||
*/
|
*/
|
||||||
public HistoryCommands(WorldEdit worldEdit) {
|
public HistoryCommands(WorldEdit worldEdit) {
|
||||||
super(worldEdit);
|
checkNotNull(worldEdit);
|
||||||
|
this.worldEdit = worldEdit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -79,7 +83,7 @@ public class HistoryCommands extends MethodCommands {
|
|||||||
" - Import from disk: /frb #import"
|
" - Import from disk: /frb #import"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.history.rollback")
|
@CommandPermissions("worldedit.history.rollback")
|
||||||
public void faweRollback(final Player player, LocalSession session, final String user, @Optional("0") @Range(min = 0) int radius, @Arg(name = "time", desc = "String", def = "0") String time, @Switch(name='r', desc = "TODO") boolean restore) throws WorldEditException {
|
public void faweRollback(final Player player, LocalSession session, final String user, @Arg(def = "0", desc = "radius") @Range(min = 0) int radius, @Arg(name = "time", desc = "String", def = "0") String time, @Switch(name='r', desc = "TODO") boolean restore) throws WorldEditException {
|
||||||
if (!Settings.IMP.HISTORY.USE_DATABASE) {
|
if (!Settings.IMP.HISTORY.USE_DATABASE) {
|
||||||
BBC.SETTING_DISABLE.send(player, "history.use-database (Import with /frb #import )");
|
BBC.SETTING_DISABLE.send(player, "history.use-database (Import with /frb #import )");
|
||||||
return;
|
return;
|
||||||
@ -205,7 +209,7 @@ public class HistoryCommands extends MethodCommands {
|
|||||||
" - Import from disk: /frb #import"
|
" - Import from disk: /frb #import"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.history.rollback")
|
@CommandPermissions("worldedit.history.rollback")
|
||||||
public void restore(final Player player, LocalSession session, final String user, @Optional("0") @Range(min = 0) int radius, @Arg(name = "time", desc = "String", def = "0") String time) throws WorldEditException {
|
public void restore(final Player player, LocalSession session, final String user, @Arg(def = "0", desc = "radius") @Range(min = 0) int radius, @Arg(name = "time", desc = "String", def = "0") String time) throws WorldEditException {
|
||||||
faweRollback(player, session, user, radius, time, true);
|
faweRollback(player, session, user, radius, time, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,7 +230,7 @@ public class HistoryCommands extends MethodCommands {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
LocalSession undoSession;
|
LocalSession undoSession;
|
||||||
if (context.argsLength() == 2) {
|
if (playerName != null && !playerName.isEmpty()) {
|
||||||
player.checkPermission("worldedit.history.undo.other");
|
player.checkPermission("worldedit.history.undo.other");
|
||||||
undoSession = worldEdit.getSessionManager().findByName(playerName);
|
undoSession = worldEdit.getSessionManager().findByName(playerName);
|
||||||
if (undoSession == null) {
|
if (undoSession == null) {
|
||||||
|
@ -6,9 +6,11 @@ import com.boydti.fawe.util.StringMan;
|
|||||||
import com.sk89q.worldedit.command.util.CommandPermissions;
|
import com.sk89q.worldedit.command.util.CommandPermissions;
|
||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
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.Command;
|
||||||
import org.enginehub.piston.annotation.CommandContainer;
|
import org.enginehub.piston.annotation.CommandContainer;
|
||||||
import org.enginehub.piston.annotation.param.Arg;
|
import org.enginehub.piston.annotation.param.Arg;
|
||||||
|
import org.enginehub.piston.exception.StopExecutionException;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -18,7 +20,7 @@ import java.util.regex.Pattern;
|
|||||||
import java.util.regex.PatternSyntaxException;
|
import java.util.regex.PatternSyntaxException;
|
||||||
|
|
||||||
@CommandContainer
|
@CommandContainer
|
||||||
public class SchemListFilters {
|
public class ListFilters {
|
||||||
public class Filter {
|
public class Filter {
|
||||||
public boolean listPrivate() {
|
public boolean listPrivate() {
|
||||||
return true;
|
return true;
|
||||||
@ -29,7 +31,7 @@ public class SchemListFilters {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public File getPath(File root) {
|
public File getPath(File root) {
|
||||||
return root;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean applies(File file) {
|
public boolean applies(File file) {
|
||||||
@ -82,13 +84,27 @@ public class SchemListFilters {
|
|||||||
name = "",
|
name = "",
|
||||||
desc = "wildcard"
|
desc = "wildcard"
|
||||||
)
|
)
|
||||||
public Filter wildcard(Actor actor, String arg) {
|
public Filter wildcard(Actor actor, File root, String arg) {
|
||||||
arg = arg.replace("/", File.separator);
|
arg = arg.replace("/", File.separator);
|
||||||
String argLower = arg.toLowerCase(Locale.ROOT);
|
String argLower = arg.toLowerCase(Locale.ROOT);
|
||||||
if (arg.endsWith("/") || arg.endsWith(File.separator)) {
|
if (arg.endsWith(File.separator)) {
|
||||||
if (arg.length() > 3 && arg.length() <= 16) {
|
String finalArg = arg;
|
||||||
// possible player name
|
return new Filter() {
|
||||||
}
|
@Override
|
||||||
|
public File getPath(File root) {
|
||||||
|
File newRoot = new File(root, finalArg);
|
||||||
|
if (newRoot.exists()) return newRoot;
|
||||||
|
String firstArg = finalArg.substring(0, finalArg.length() - File.separator.length());
|
||||||
|
if (firstArg.length() > 3 && firstArg.length() <= 16) {
|
||||||
|
UUID fromName = Fawe.imp().getUUID(finalArg);
|
||||||
|
if (fromName != null) {
|
||||||
|
newRoot = new File(root, finalArg);
|
||||||
|
if (newRoot.exists()) return newRoot;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new StopExecutionException(TextComponent.of("Cannot find path: " + finalArg));
|
||||||
|
}
|
||||||
|
};
|
||||||
} else {
|
} else {
|
||||||
if (StringMan.containsAny(arg, "\\^$.|?+(){}<>~$!%^&*+-/")) {
|
if (StringMan.containsAny(arg, "\\^$.|?+(){}<>~$!%^&*+-/")) {
|
||||||
Pattern pattern;
|
Pattern pattern;
|
||||||
@ -113,24 +129,5 @@ public class SchemListFilters {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,58 +1,20 @@
|
|||||||
package com.sk89q.worldedit.command;
|
package com.sk89q.worldedit.command;
|
||||||
|
|
||||||
import com.boydti.fawe.config.Commands;
|
import com.boydti.fawe.config.Commands;
|
||||||
|
import com.sk89q.worldedit.command.argument.Arguments;
|
||||||
import org.enginehub.piston.annotation.Command;
|
import org.enginehub.piston.annotation.Command;
|
||||||
import org.enginehub.piston.inject.InjectedValueAccess;
|
import org.enginehub.piston.inject.InjectedValueAccess;
|
||||||
import com.sk89q.minecraft.util.commands.CommandLocals;
|
|
||||||
import com.sk89q.worldedit.command.util.CommandPermissions;
|
import com.sk89q.worldedit.command.util.CommandPermissions;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.util.command.CommandCallable;
|
import org.enginehub.piston.inject.Key;
|
||||||
import com.sk89q.worldedit.util.command.Dispatcher;
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
public class MethodCommands {
|
public class MethodCommands {
|
||||||
public final WorldEdit worldEdit;
|
|
||||||
private ConcurrentHashMap<Method, CommandCallable> callables;
|
|
||||||
private Dispatcher dispatcher;
|
|
||||||
|
|
||||||
public MethodCommands(WorldEdit worldEdit) {
|
|
||||||
checkNotNull(worldEdit);
|
|
||||||
this.worldEdit = worldEdit;
|
|
||||||
callables = new ConcurrentHashMap<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public MethodCommands() {
|
|
||||||
this(WorldEdit.getInstance());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void register(Method method, CommandCallable callable, Dispatcher dispatcher) {
|
|
||||||
this.dispatcher = dispatcher;
|
|
||||||
this.callables.put(method, callable);
|
|
||||||
}
|
|
||||||
|
|
||||||
public CommandCallable getCallable() {
|
|
||||||
try {
|
|
||||||
StackTraceElement[] stack = new Exception().getStackTrace();
|
|
||||||
for (StackTraceElement elem : stack) {
|
|
||||||
Class<?> clazz = Class.forName(elem.getClassName());
|
|
||||||
for (Method method : clazz.getMethods()) {
|
|
||||||
if (method.getName().equals(elem.getMethodName())) {
|
|
||||||
Command command = method.getAnnotation(Command.class);
|
|
||||||
if (command != null) return callables.get(method);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Throwable e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return dispatcher;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Command getCommand() {
|
public Command getCommand() {
|
||||||
try {
|
try {
|
||||||
StackTraceElement[] stack = new Exception().getStackTrace();
|
StackTraceElement[] stack = new Exception().getStackTrace();
|
||||||
@ -73,14 +35,18 @@ public class MethodCommands {
|
|||||||
|
|
||||||
public String getArguments(InjectedValueAccess context) {
|
public String getArguments(InjectedValueAccess context) {
|
||||||
if (context == null) return null;
|
if (context == null) return null;
|
||||||
CommandLocals locals = context.getLocals();
|
Optional<Arguments> arguments = context.injectedValue(Key.of(Arguments.class));
|
||||||
if (locals != null) {
|
if (arguments.isPresent()) {
|
||||||
return (String) locals.get("arguments");
|
return arguments.get().get();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getPermissions() {
|
public String[] getPermissions(InjectedValueAccess context) {
|
||||||
|
CommandPermissions cmdPerms = context.injectedValue(Key.of(CommandPermissions.class)).orElse(null);
|
||||||
|
if (cmdPerms != null) {
|
||||||
|
return cmdPerms.value();
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
StackTraceElement[] stack = new Exception().getStackTrace();
|
StackTraceElement[] stack = new Exception().getStackTrace();
|
||||||
for (StackTraceElement elem : stack) {
|
for (StackTraceElement elem : stack) {
|
||||||
|
@ -20,8 +20,7 @@
|
|||||||
package com.sk89q.worldedit.command;
|
package com.sk89q.worldedit.command;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.ALL;
|
import static com.sk89q.worldedit.command.util.Logging.LogMode.ALL;
|
||||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.REGION;
|
|
||||||
import static com.sk89q.worldedit.command.util.Logging.LogMode.ORIENTATION_REGION;
|
import static com.sk89q.worldedit.command.util.Logging.LogMode.ORIENTATION_REGION;
|
||||||
import static com.sk89q.worldedit.command.util.Logging.LogMode.REGION;
|
import static com.sk89q.worldedit.command.util.Logging.LogMode.REGION;
|
||||||
import static com.sk89q.worldedit.internal.command.CommandUtil.checkCommandArgument;
|
import static com.sk89q.worldedit.internal.command.CommandUtil.checkCommandArgument;
|
||||||
@ -30,12 +29,12 @@ import static com.sk89q.worldedit.regions.Regions.maximumBlockY;
|
|||||||
import static com.sk89q.worldedit.regions.Regions.minimumBlockY;
|
import static com.sk89q.worldedit.regions.Regions.minimumBlockY;
|
||||||
|
|
||||||
|
|
||||||
|
import com.boydti.fawe.Fawe;
|
||||||
import com.boydti.fawe.FaweAPI;
|
import com.boydti.fawe.FaweAPI;
|
||||||
import com.boydti.fawe.beta.filters.SetFilter;
|
import com.boydti.fawe.beta.filters.SetFilter;
|
||||||
import com.boydti.fawe.beta.implementation.QueueHandler;
|
import com.boydti.fawe.beta.implementation.QueueHandler;
|
||||||
import com.boydti.fawe.beta.filters.DistrFilter;
|
import com.boydti.fawe.beta.filters.DistrFilter;
|
||||||
import com.boydti.fawe.config.BBC;
|
import com.boydti.fawe.config.BBC;
|
||||||
import com.boydti.fawe.example.NMSMappedIQueueExtent;
|
|
||||||
import com.boydti.fawe.object.FaweLimit;
|
import com.boydti.fawe.object.FaweLimit;
|
||||||
import com.boydti.fawe.object.FawePlayer;
|
import com.boydti.fawe.object.FawePlayer;
|
||||||
import com.boydti.fawe.beta.IQueueExtent;
|
import com.boydti.fawe.beta.IQueueExtent;
|
||||||
@ -99,9 +98,9 @@ import org.enginehub.piston.annotation.param.Switch;
|
|||||||
/**
|
/**
|
||||||
* Commands that operate on regions.
|
* Commands that operate on regions.
|
||||||
*/
|
*/
|
||||||
@Command(aliases = {}, desc = "Commands that operate on regions: [More Info](http://wiki.sk89q.com/wiki/WorldEdit/Region_operations)")
|
//@Command(aliases = {}, desc = "Commands that operate on regions: [More Info](http://wiki.sk89q.com/wiki/WorldEdit/Region_operations)")
|
||||||
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
|
||||||
public class RegionCommands {
|
public class RegionCommands extends MethodCommands {
|
||||||
|
|
||||||
private final WorldEdit worldEdit;
|
private final WorldEdit worldEdit;
|
||||||
|
|
||||||
@ -115,43 +114,6 @@ public class RegionCommands {
|
|||||||
this.worldEdit = worldEdit;
|
this.worldEdit = worldEdit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = {"debugtest"},
|
|
||||||
usage = "",
|
|
||||||
desc = "debugtest",
|
|
||||||
help = "debugtest"
|
|
||||||
)
|
|
||||||
@CommandPermissions("fawe.admin.debug")
|
|
||||||
public void debugtest(Player player, @Selection Region region) throws WorldEditException {
|
|
||||||
QueueHandler queueHandler = Fawe.get().getQueueHandler();
|
|
||||||
World world = player.getWorld();
|
|
||||||
DistrFilter filter = new DistrFilter();
|
|
||||||
long start = System.currentTimeMillis();
|
|
||||||
queueHandler.apply(world, region, filter);
|
|
||||||
long diff = System.currentTimeMillis() - start;
|
|
||||||
System.out.println(diff);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = {"db2"},
|
|
||||||
usage = "",
|
|
||||||
desc = "db2",
|
|
||||||
help = "db2"
|
|
||||||
)
|
|
||||||
@CommandPermissions("fawe.admin.debug")
|
|
||||||
public void db2(Player player, @Selection Region region, String blockStr) throws WorldEditException {
|
|
||||||
QueueHandler queueHandler = Fawe.get().getQueueHandler();
|
|
||||||
World world = player.getWorld();
|
|
||||||
BlockState block = BlockState.get(blockStr);
|
|
||||||
SetFilter filter = new SetFilter(block);
|
|
||||||
long start = System.currentTimeMillis();
|
|
||||||
queueHandler.apply(world, region, filter);
|
|
||||||
long diff = System.currentTimeMillis() - start;
|
|
||||||
System.out.println(diff);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
name = "/fixlighting",
|
name = "/fixlighting",
|
||||||
desc = "Get the light at a position"
|
desc = "Get the light at a position"
|
||||||
@ -166,7 +128,7 @@ public class RegionCommands {
|
|||||||
final int cz = loc.getBlockZ() >> 4;
|
final int cz = loc.getBlockZ() >> 4;
|
||||||
selection = new CuboidRegion(BlockVector3.at(cx - 8, 0, cz - 8).multiply(16), BlockVector3.at(cx + 8, 0, cz + 8).multiply(16));
|
selection = new CuboidRegion(BlockVector3.at(cx - 8, 0, cz - 8).multiply(16), BlockVector3.at(cx + 8, 0, cz + 8).multiply(16));
|
||||||
}
|
}
|
||||||
int count = FaweAPI.fixLighting(player.getWorld(), selection,null, IQueueExtent.RelightMode.ALL);
|
int count = FaweAPI.fixLighting(player.getWorld(), selection,null);
|
||||||
BBC.LIGHTING_PROPOGATE_SELECTION.send(fp, count);
|
BBC.LIGHTING_PROPOGATE_SELECTION.send(fp, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,11 +137,12 @@ public class RegionCommands {
|
|||||||
desc = "Get the light at a position"
|
desc = "Get the light at a position"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.light.fix")
|
@CommandPermissions("worldedit.light.fix")
|
||||||
public void getlighting(Player player) throws WorldEditException {
|
public void getlighting(Player player, EditSession editSession) throws WorldEditException {
|
||||||
FawePlayer fp = FawePlayer.wrap(player);
|
FawePlayer fp = FawePlayer.wrap(player);
|
||||||
final Location loc = player.getLocation();
|
final Location loc = player.getLocation();
|
||||||
IQueueExtent queue = fp.getIQueueExtent(false);
|
int block = editSession.getBlockLight(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||||
fp.sendMessage("Light: " + queue.getEmmittedLight(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()) + " | " + queue.getSkyLight(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
|
int sky = editSession.getSkyLight(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||||
|
fp.sendMessage("Light: " + block + " | " + sky);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -195,7 +158,7 @@ public class RegionCommands {
|
|||||||
final int cz = player.getLocation().getBlockZ() >> 4;
|
final int cz = player.getLocation().getBlockZ() >> 4;
|
||||||
selection = new CuboidRegion(BlockVector3.at(cx - 8, 0, cz - 8).multiply(16), BlockVector3.at(cx + 8, 0, cz + 8).multiply(16));
|
selection = new CuboidRegion(BlockVector3.at(cx - 8, 0, cz - 8).multiply(16), BlockVector3.at(cx + 8, 0, cz + 8).multiply(16));
|
||||||
}
|
}
|
||||||
int count = FaweAPI.fixLighting(player.getWorld(), selection, null, IQueueExtent.RelightMode.NONE);
|
int count = FaweAPI.fixLighting(player.getWorld(), selection, null);
|
||||||
BBC.UPDATED_LIGHTING_SELECTION.send(fp, count);
|
BBC.UPDATED_LIGHTING_SELECTION.send(fp, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,18 +186,8 @@ public class RegionCommands {
|
|||||||
desc = "Set block lighting in a selection"
|
desc = "Set block lighting in a selection"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.light.set")
|
@CommandPermissions("worldedit.light.set")
|
||||||
public void setlighting(Player player, @Selection Region region, @Range(min = 0, max = 15) int value) {
|
public void setlighting(Player player, EditSession editSession, @Selection Region region, @Range(min = 0, max = 15) int value) {
|
||||||
FawePlayer fp = FawePlayer.wrap(player);
|
// TODO NOT IMPLEMENTED
|
||||||
final NMSMappedIQueueExtent queue = (NMSMappedIQueueExtent) fp.getIQueueExtent(false);
|
|
||||||
for (BlockVector3 pt : region) {
|
|
||||||
queue.setBlockLight(pt.getX(), pt.getY(), pt.getZ(), value);
|
|
||||||
}
|
|
||||||
int count = 0;
|
|
||||||
for (BlockVector2 chunk : region.getChunks()) {
|
|
||||||
queue.sendChunk(queue.getFaweChunk(chunk.getBlockX(), chunk.getBlockZ()));
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
BBC.UPDATED_LIGHTING_SELECTION.send(fp, count);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -243,17 +196,7 @@ public class RegionCommands {
|
|||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.light.set")
|
@CommandPermissions("worldedit.light.set")
|
||||||
public void setskylighting(Player player, @Selection Region region, @Range(min = 0, max = 15) int value) {
|
public void setskylighting(Player player, @Selection Region region, @Range(min = 0, max = 15) int value) {
|
||||||
FawePlayer fp = FawePlayer.wrap(player);
|
// TODO NOT IMPLEMENTED
|
||||||
final NMSMappedIQueueExtent queue = (NMSMappedIQueueExtent) fp.getIQueueExtent(false);
|
|
||||||
for (BlockVector3 pt : region) {
|
|
||||||
queue.setSkyLight(pt.getX(), pt.getY(), pt.getZ(), value);
|
|
||||||
}
|
|
||||||
int count = 0;
|
|
||||||
for (BlockVector2 chunk : region.getChunks()) {
|
|
||||||
queue.sendChunk(queue.getFaweChunk(chunk.getBlockX(), chunk.getBlockZ()));
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
BBC.UPDATED_LIGHTING_SELECTION.send(fp, count);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -338,7 +281,8 @@ public class RegionCommands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "/set", "/s" },
|
name = "/set",
|
||||||
|
aliases = { "/s" },
|
||||||
desc = "Set all blocks within selection"
|
desc = "Set all blocks within selection"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.region.set")
|
@CommandPermissions("worldedit.region.set")
|
||||||
@ -628,7 +572,7 @@ public class RegionCommands {
|
|||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.region.deform")
|
@CommandPermissions("worldedit.region.deform")
|
||||||
@Logging(ALL)
|
@Logging(ALL)
|
||||||
public void deform(FawePlayer fp, Player player, LocalSession session, EditSession editSession,
|
public void deform(FawePlayer fp, Player player, LocalSession session, EditSession editSession, InjectedValueAccess context,
|
||||||
@Selection Region region,
|
@Selection Region region,
|
||||||
@Arg(desc = "The expression to use", variable = true)
|
@Arg(desc = "The expression to use", variable = true)
|
||||||
List<String> expression,
|
List<String> expression,
|
||||||
@ -660,7 +604,7 @@ public class RegionCommands {
|
|||||||
final Vector3 unit1 = unit;
|
final Vector3 unit1 = unit;
|
||||||
fp.checkConfirmationRegion(() -> {
|
fp.checkConfirmationRegion(() -> {
|
||||||
try {
|
try {
|
||||||
final int affected = editSession.deformRegion(region, zero, unit1, expression);
|
final int affected = editSession.deformRegion(region, zero, unit1, String.join(" ", expression), session.getTimeout());
|
||||||
player.findFreePosition();
|
player.findFreePosition();
|
||||||
BBC.VISITOR_BLOCK.send(fp, affected);
|
BBC.VISITOR_BLOCK.send(fp, affected);
|
||||||
} catch (ExpressionException e) {
|
} catch (ExpressionException e) {
|
||||||
@ -679,18 +623,14 @@ public class RegionCommands {
|
|||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.regen")
|
@CommandPermissions("worldedit.regen")
|
||||||
@Logging(REGION)
|
@Logging(REGION)
|
||||||
public void regenerateChunk(FawePlayer player, LocalSession session, EditSession editSession, @Selection Region region, InjectedValueAccess context) throws WorldEditException {
|
public void regenerateChunk(FawePlayer player, LocalSession session, EditSession editSession, @Selection Region region,
|
||||||
|
@Arg(def = "", desc = "Regenerate with biome") BiomeType biome,
|
||||||
|
@Arg(def = "", desc = "Regenerate with seed") Long seed,
|
||||||
|
InjectedValueAccess context) throws WorldEditException {
|
||||||
player.checkConfirmationRegion(() -> {
|
player.checkConfirmationRegion(() -> {
|
||||||
Mask mask = session.getMask();
|
Mask mask = session.getMask();
|
||||||
session.setMask((Mask) null);
|
session.setMask((Mask) null);
|
||||||
session.setSourceMask((Mask) null);
|
session.setSourceMask((Mask) null);
|
||||||
BiomeType biome = null;
|
|
||||||
if (context.argsLength() >= 1) {
|
|
||||||
BiomeRegistry biomeRegistry = worldEdit.getPlatformManager().queryCapability(Capability.GAME_HOOKS).getRegistries().getBiomeRegistry();
|
|
||||||
Collection<BiomeType> knownBiomes = BiomeTypes.values();
|
|
||||||
biome = Biomes.findBiomeByName(knownBiomes, context.getString(0), biomeRegistry);
|
|
||||||
}
|
|
||||||
Long seed = context.argsLength() != 2 || !MathMan.isInteger(context.getString(1)) ? null : Long.parseLong(context.getString(1));
|
|
||||||
editSession.regenerate(region, biome, seed);
|
editSession.regenerate(region, biome, seed);
|
||||||
session.setMask(mask);
|
session.setMask(mask);
|
||||||
session.setSourceMask(mask);
|
session.setSourceMask(mask);
|
||||||
@ -726,7 +666,7 @@ public class RegionCommands {
|
|||||||
int thickness,
|
int thickness,
|
||||||
@Arg(desc = "The pattern of blocks to replace the hollowed area with", def = "air")
|
@Arg(desc = "The pattern of blocks to replace the hollowed area with", def = "air")
|
||||||
Pattern pattern,
|
Pattern pattern,
|
||||||
|
@Switch(name='m', desc = "Mask to hollow with") Mask mask,
|
||||||
InjectedValueAccess context) throws WorldEditException {
|
InjectedValueAccess context) throws WorldEditException {
|
||||||
Mask finalMask = mask == null ? new SolidBlockMask(editSession) : mask;
|
Mask finalMask = mask == null ? new SolidBlockMask(editSession) : mask;
|
||||||
player.checkConfirmationRegion(() -> {
|
player.checkConfirmationRegion(() -> {
|
||||||
|
@ -704,7 +704,6 @@ public class UtilityCommands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void list(File dir, Actor actor, InjectedValueAccess args, @Range(min = 0) int page, int perPage, String formatName, boolean playerFolder, RunnableVal3<Message, URI, String> eachMsg) {
|
public static void list(File dir, Actor actor, InjectedValueAccess args, @Range(min = 0) int page, int perPage, String formatName, boolean playerFolder, RunnableVal3<Message, URI, String> eachMsg) {
|
||||||
AtomicInteger pageInt = new AtomicInteger(page);
|
|
||||||
List<File> fileList = new ArrayList<>();
|
List<File> fileList = new ArrayList<>();
|
||||||
if (perPage == -1) perPage = actor instanceof Player ? 12 : 20; // More pages for console
|
if (perPage == -1) perPage = actor instanceof Player ? 12 : 20; // More pages for console
|
||||||
page = getFiles(dir, actor, args, page, perPage, formatName, playerFolder, fileList::add);
|
page = getFiles(dir, actor, args, page, perPage, formatName, playerFolder, fileList::add);
|
||||||
@ -770,6 +769,11 @@ public class UtilityCommands {
|
|||||||
m.send(actor);
|
m.send(actor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int getFiles(File root, Actor actor, InjectedValueAccess args, int page, int perPage, String formatName, boolean playerFolder, Consumer<File> forEachFile, ListFilters... filters) {
|
||||||
|
// TODO NOT IMPLEMENTED replace getFiles
|
||||||
|
return page;
|
||||||
|
}
|
||||||
|
|
||||||
public static int getFiles(File dir, Actor actor, InjectedValueAccess args, @Range(min = 0) int page, int perPage, String formatName, boolean playerFolder, Consumer<File> forEachFile) {
|
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;
|
Consumer<File> rootFunction = forEachFile;
|
||||||
//schem list all <path>
|
//schem list all <path>
|
||||||
@ -890,7 +894,6 @@ public class UtilityCommands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static List<File> filter(List<File> fileList, List<String> filters) {
|
private static List<File> filter(List<File> fileList, List<String> filters) {
|
||||||
|
|
||||||
String[] normalizedNames = new String[fileList.size()];
|
String[] normalizedNames = new String[fileList.size()];
|
||||||
for (int i = 0; i < fileList.size(); i++) {
|
for (int i = 0; i < fileList.size(); i++) {
|
||||||
String normalized = fileList.get(i).getName().toLowerCase();
|
String normalized = fileList.get(i).getName().toLowerCase();
|
||||||
|
@ -85,6 +85,7 @@ import com.sk89q.worldedit.command.argument.RegistryConverter;
|
|||||||
import com.sk89q.worldedit.command.argument.VectorConverter;
|
import com.sk89q.worldedit.command.argument.VectorConverter;
|
||||||
import com.sk89q.worldedit.command.argument.ZonedDateTimeConverter;
|
import com.sk89q.worldedit.command.argument.ZonedDateTimeConverter;
|
||||||
import com.sk89q.worldedit.command.tool.brush.Brush;
|
import com.sk89q.worldedit.command.tool.brush.Brush;
|
||||||
|
import com.sk89q.worldedit.command.util.CommandPermissions;
|
||||||
import com.sk89q.worldedit.command.util.CommandQueued;
|
import com.sk89q.worldedit.command.util.CommandQueued;
|
||||||
import com.sk89q.worldedit.command.util.CommandQueuedCondition;
|
import com.sk89q.worldedit.command.util.CommandQueuedCondition;
|
||||||
import com.sk89q.worldedit.command.util.PermissionCondition;
|
import com.sk89q.worldedit.command.util.PermissionCondition;
|
||||||
@ -114,6 +115,7 @@ import com.sk89q.worldedit.util.logging.LogFormat;
|
|||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.lang.annotation.Annotation;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -545,13 +547,48 @@ public final class PlatformCommandManager {
|
|||||||
return def;
|
return def;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Actor wrapActor(Actor actor, InjectedValueStore context) {
|
||||||
|
if (actor instanceof Player) {
|
||||||
|
final Set<String> failedPermissions = new LinkedHashSet<>();
|
||||||
|
Player player = (Player) actor;
|
||||||
|
Player unwrapped = LocationMaskedPlayerWrapper.unwrap(player);
|
||||||
|
actor = new LocationMaskedPlayerWrapper(unwrapped, player.getLocation(), true) {
|
||||||
|
@Override
|
||||||
|
public boolean hasPermission(String permission) {
|
||||||
|
if (!super.hasPermission(permission)) {
|
||||||
|
failedPermissions.add(permission);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void checkPermission(String permission) throws AuthorizationException {
|
||||||
|
try {
|
||||||
|
super.checkPermission(permission);
|
||||||
|
} catch (AuthorizationException e) {
|
||||||
|
failedPermissions.add(permission);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
context.injectValue(Key.of(CommandPermissions.class), i -> Optional.of(new CommandPermissions() {
|
||||||
|
@Override
|
||||||
|
public Class<? extends Annotation> annotationType() {
|
||||||
|
return CommandPermissions.class;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String[] value() {
|
||||||
|
return failedPermissions.toArray(new String[0]);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
return actor;
|
||||||
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void handleCommand(CommandEvent event) {
|
public void handleCommand(CommandEvent event) {
|
||||||
Request.reset();
|
Request.reset();
|
||||||
Actor actor = event.getActor();
|
Actor actor = event.getActor();
|
||||||
if (actor instanceof Player) {
|
|
||||||
actor = LocationMaskedPlayerWrapper.wrap((Player) actor);
|
|
||||||
}
|
|
||||||
String args = event.getArguments();
|
String args = event.getArguments();
|
||||||
CommandEvent finalEvent = new CommandEvent(actor, args);
|
CommandEvent finalEvent = new CommandEvent(actor, args);
|
||||||
final FawePlayer<Object> fp = FawePlayer.wrap(actor);
|
final FawePlayer<Object> fp = FawePlayer.wrap(actor);
|
||||||
@ -595,22 +632,14 @@ public final class PlatformCommandManager {
|
|||||||
}
|
}
|
||||||
MemoizingValueAccess context = initializeInjectedValues(event::getArguments, actor);
|
MemoizingValueAccess context = initializeInjectedValues(event::getArguments, actor);
|
||||||
|
|
||||||
final FawePlayer fp = FawePlayer.wrap(actor);
|
|
||||||
if (fp == null) {
|
|
||||||
throw new IllegalArgumentException("FAWE doesn't support: " + actor);
|
|
||||||
}
|
|
||||||
|
|
||||||
ThrowableSupplier<Throwable> task =
|
ThrowableSupplier<Throwable> task =
|
||||||
() -> commandManager.execute(context,Lists.newArrayList(split));
|
() -> commandManager.execute(context,Lists.newArrayList(split));
|
||||||
|
|
||||||
handleCommandTask(task, context, actor, session, event);
|
handleCommandTask(task, context, session, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object handleCommandTask(ThrowableSupplier<Throwable> task, InjectedValueAccess context, @NotNull Actor actor, @Nullable LocalSession session, CommandEvent event) {
|
public Object handleCommandTask(ThrowableSupplier<Throwable> task, InjectedValueAccess context, @Nullable LocalSession session, CommandEvent event) {
|
||||||
String[] split = parseArgs(event.getArguments())
|
Actor actor = context.injectedValue(Key.of(Actor.class)).orElseThrow(() -> new IllegalStateException("No player"));
|
||||||
.map(Substring::getSubstring)
|
|
||||||
.toArray(String[]::new);
|
|
||||||
|
|
||||||
Request.reset();
|
Request.reset();
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
|
|
||||||
@ -689,9 +718,10 @@ public final class PlatformCommandManager {
|
|||||||
|
|
||||||
private MemoizingValueAccess initializeInjectedValues(Arguments arguments, Actor actor) {
|
private MemoizingValueAccess initializeInjectedValues(Arguments arguments, Actor actor) {
|
||||||
InjectedValueStore store = MapBackedValueStore.create();
|
InjectedValueStore store = MapBackedValueStore.create();
|
||||||
store.injectValue(Key.of(Actor.class), ValueProvider.constant(actor));
|
Actor finalActor = wrapActor(actor, store);
|
||||||
if (actor instanceof Player) {
|
store.injectValue(Key.of(Actor.class), ValueProvider.constant(finalActor));
|
||||||
store.injectValue(Key.of(Player.class), ValueProvider.constant((Player) actor));
|
if (finalActor instanceof Player) {
|
||||||
|
store.injectValue(Key.of(Player.class), ValueProvider.constant((Player) finalActor));
|
||||||
} else {
|
} else {
|
||||||
store.injectValue(Key.of(Player.class), context -> {
|
store.injectValue(Key.of(Player.class), context -> {
|
||||||
throw new CommandException(TextComponent.of("This command must be used with a player."), ImmutableList.of());
|
throw new CommandException(TextComponent.of("This command must be used with a player."), ImmutableList.of());
|
||||||
@ -700,8 +730,8 @@ public final class PlatformCommandManager {
|
|||||||
store.injectValue(Key.of(Arguments.class), ValueProvider.constant(arguments));
|
store.injectValue(Key.of(Arguments.class), ValueProvider.constant(arguments));
|
||||||
store.injectValue(Key.of(LocalSession.class),
|
store.injectValue(Key.of(LocalSession.class),
|
||||||
context -> {
|
context -> {
|
||||||
LocalSession localSession = worldEdit.getSessionManager().get(actor);
|
LocalSession localSession = worldEdit.getSessionManager().get(finalActor);
|
||||||
localSession.tellVersion(actor);
|
localSession.tellVersion(finalActor);
|
||||||
return Optional.of(localSession);
|
return Optional.of(localSession);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren