3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-12-24 18:10:08 +01:00

Add /br raise and /br lower as shortcuts for /br deform.

Dieser Commit ist enthalten in:
Albert Pham 2015-10-28 13:50:07 -07:00
Ursprung 98b61d0fbd
Commit cba32732a3
4 geänderte Dateien mit 95 neuen und 8 gelöschten Zeilen

Datei anzeigen

@ -48,13 +48,15 @@ import com.sk89q.worldedit.command.ToolUtilCommands;
import com.sk89q.worldedit.command.UtilityCommands;
import com.sk89q.worldedit.command.WorldEditCommands;
import com.sk89q.worldedit.command.argument.DeformArg;
import com.sk89q.worldedit.command.composition.ReplaceBrushCommand;
import com.sk89q.worldedit.command.argument.RegionReplaceArg;
import com.sk89q.worldedit.command.composition.ApplyCommand;
import com.sk89q.worldedit.command.composition.ReplaceBrushCommand;
import com.sk89q.worldedit.command.composition.ScatterCommand;
import com.sk89q.worldedit.command.composition.ShapedBrushCommand;
import com.sk89q.worldedit.command.composition.ApplyCommand;
import com.sk89q.worldedit.event.platform.CommandEvent;
import com.sk89q.worldedit.event.platform.CommandSuggestionEvent;
import com.sk89q.worldedit.function.factory.Deform;
import com.sk89q.worldedit.function.factory.Deform.Mode;
import com.sk89q.worldedit.function.factory.OperationFactory;
import com.sk89q.worldedit.internal.command.ActorAuthorizer;
import com.sk89q.worldedit.internal.command.CommandLoggingHandler;
@ -64,7 +66,7 @@ import com.sk89q.worldedit.internal.command.WorldEditExceptionConverter;
import com.sk89q.worldedit.session.request.Request;
import com.sk89q.worldedit.util.command.Dispatcher;
import com.sk89q.worldedit.util.command.InvalidUsageException;
import com.sk89q.worldedit.util.command.composition.LegacyCommandAdapter;
import com.sk89q.worldedit.util.command.composition.ProvidedValue;
import com.sk89q.worldedit.util.command.fluent.CommandGraph;
import com.sk89q.worldedit.util.command.parametric.ExceptionConverter;
import com.sk89q.worldedit.util.command.parametric.LegacyCommandsHandler;
@ -83,6 +85,7 @@ import java.util.logging.Logger;
import java.util.regex.Pattern;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.sk89q.worldedit.util.command.composition.LegacyCommandAdapter.adapt;
/**
* Handles the registration and invocation of commands.
@ -162,10 +165,12 @@ public final class CommandManager {
.group("brush", "br")
.describeAs("Brushing commands")
.registerMethods(new BrushCommands(worldEdit))
.register(new LegacyCommandAdapter(new ShapedBrushCommand(new DeformArg(), "worldedit.brush.deform")), "deform")
.register(new LegacyCommandAdapter(new ShapedBrushCommand(new ReplaceBrushCommand<OperationFactory>(new RegionReplaceArg()), "worldedit.brush.set")), "set")
.register(new LegacyCommandAdapter(new ShapedBrushCommand(new ScatterCommand(), "worldedit.brush.scatter")), "scatter")
.register(new LegacyCommandAdapter(new ShapedBrushCommand(new ApplyCommand(), "worldedit.brush.apply")), "apply")
.register(adapt(new ShapedBrushCommand(new DeformArg(), "worldedit.brush.deform")), "deform")
.register(adapt(new ShapedBrushCommand(ProvidedValue.create(new Deform("y-=1", Mode.RAW_COORD), "Raise one block"), "worldedit.brush.raise")), "raise")
.register(adapt(new ShapedBrushCommand(ProvidedValue.create(new Deform("y+=1", Mode.RAW_COORD), "Lower one block"), "worldedit.brush.lower")), "lower")
.register(adapt(new ShapedBrushCommand(new ReplaceBrushCommand<OperationFactory>(new RegionReplaceArg()), "worldedit.brush.set")), "set")
.register(adapt(new ShapedBrushCommand(new ScatterCommand(), "worldedit.brush.scatter")), "scatter")
.register(adapt(new ShapedBrushCommand(new ApplyCommand(), "worldedit.brush.apply")), "apply")
.parent()
.group("superpickaxe", "pickaxe", "sp")
.describeAs("Super-pickaxe commands")

Datei anzeigen

@ -19,6 +19,7 @@
package com.sk89q.worldedit.function.factory;
import com.google.common.base.Preconditions;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEditException;
@ -42,6 +43,13 @@ public class Deform implements OperationFactory {
this.expression = expression;
}
public Deform(String expression, Mode mode) {
checkNotNull(expression, "expression");
checkNotNull(mode, "mode");
this.expression = expression;
this.mode = mode;
}
public String getExpression() {
return expression;
}

Datei anzeigen

@ -35,7 +35,7 @@ public class LegacyCommandAdapter implements CommandCallable {
private final CommandExecutor<?> executor;
public LegacyCommandAdapter(CommandExecutor<?> executor) {
private LegacyCommandAdapter(CommandExecutor<?> executor) {
this.executor = executor;
}
@ -79,4 +79,9 @@ public class LegacyCommandAdapter implements CommandCallable {
return Lists.newArrayList();
}
}
public static LegacyCommandAdapter adapt(CommandExecutor<?> executor) {
return new LegacyCommandAdapter(executor);
}
}

Datei anzeigen

@ -0,0 +1,69 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.util.command.composition;
import com.sk89q.minecraft.util.commands.CommandException;
import com.sk89q.minecraft.util.commands.CommandLocals;
import com.sk89q.worldedit.util.command.argument.CommandArgs;
import com.sk89q.worldedit.util.command.argument.MissingArgumentException;
import java.util.Collections;
import java.util.List;
public class ProvidedValue<T> implements CommandExecutor<T> {
private final T value;
private final String description;
private ProvidedValue(T value, String description) {
this.value = value;
this.description = description;
}
@Override
public T call(CommandArgs args, CommandLocals locals) throws CommandException {
return value;
}
@Override
public List<String> getSuggestions(CommandArgs args, CommandLocals locals) throws MissingArgumentException {
return Collections.emptyList();
}
@Override
public String getUsage() {
return "";
}
@Override
public String getDescription() {
return description;
}
@Override
public boolean testPermission(CommandLocals locals) {
return true;
}
public static <T> ProvidedValue<T> create(T value, String description) {
return new ProvidedValue<T>(value, description);
}
}