mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-01 02:46:41 +00:00
Upstream
This commit is contained in:
@ -23,7 +23,11 @@ import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.OptionalInt;
|
||||
|
||||
/**
|
||||
* A collection of cardinal, ordinal, and secondary-ordinal directions.
|
||||
@ -65,7 +69,7 @@ public enum Direction {
|
||||
private final BlockVector3 blockPoint;
|
||||
|
||||
private static HashMap<String, Direction> map = new HashMap<>();
|
||||
|
||||
|
||||
static {
|
||||
for (Direction dir : Direction.values()) {
|
||||
map.put(dir.name(), dir);
|
||||
@ -80,11 +84,11 @@ public enum Direction {
|
||||
this.left = left;
|
||||
this.right = right;
|
||||
}
|
||||
|
||||
|
||||
public static Direction get(CharSequence sequence) {
|
||||
return map.get(sequence.toString());
|
||||
}
|
||||
|
||||
|
||||
public Direction getLeft() {
|
||||
return left != -1 ? values()[left] : null;
|
||||
}
|
||||
|
@ -38,8 +38,7 @@ import javax.annotation.Nullable;
|
||||
*/
|
||||
public class TargetBlock {
|
||||
|
||||
private final World world;
|
||||
|
||||
private World world;
|
||||
private int maxDistance;
|
||||
private double checkDistance, curDistance;
|
||||
private BlockVector3 targetPos = BlockVector3.ZERO;
|
||||
@ -122,7 +121,7 @@ public class TargetBlock {
|
||||
this.checkDistance = checkDistance;
|
||||
this.curDistance = 0;
|
||||
xRotation = (xRotation + 90) % 360;
|
||||
yRotation *= -1;
|
||||
yRotation = yRotation * -1;
|
||||
|
||||
double h = (checkDistance * Math.cos(Math.toRadians(yRotation)));
|
||||
|
||||
@ -145,15 +144,15 @@ public class TargetBlock {
|
||||
boolean searchForLastBlock = true;
|
||||
Location lastBlock = null;
|
||||
while (getNextBlock() != null) {
|
||||
if (stopMask.test(targetPos)) {
|
||||
break;
|
||||
} else {
|
||||
if (!stopMask.test(targetPos)) {
|
||||
if (searchForLastBlock) {
|
||||
lastBlock = getCurrentBlock();
|
||||
if (lastBlock.getBlockY() <= 0 || lastBlock.getBlockY() >= world.getMaxY()) {
|
||||
searchForLastBlock = false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
Location currentBlock = getCurrentBlock();
|
||||
|
@ -95,6 +95,4 @@ public class SimpleCommandMapping implements CommandMapping {
|
||||
'}';
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -20,13 +20,15 @@
|
||||
package com.sk89q.worldedit.util.command;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.util.StringMan;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandException;
|
||||
import com.sk89q.minecraft.util.commands.CommandLocals;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissionsException;
|
||||
import com.sk89q.minecraft.util.commands.WrappedCommandException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
@ -117,7 +119,7 @@ public class SimpleDispatcher implements Dispatcher {
|
||||
throw new CommandPermissionsException();
|
||||
}
|
||||
|
||||
String[] split = arguments.split(" ", -1);
|
||||
String[] split = CommandContext.split(arguments);
|
||||
Set<String> aliases = getPrimaryAliases();
|
||||
|
||||
if (aliases.isEmpty()) {
|
||||
@ -147,7 +149,7 @@ public class SimpleDispatcher implements Dispatcher {
|
||||
|
||||
@Override
|
||||
public List<String> getSuggestions(String arguments, CommandLocals locals) throws CommandException {
|
||||
String[] split = arguments.split(" ", -1);
|
||||
String[] split = CommandContext.split(arguments);
|
||||
|
||||
if (split.length <= 1) {
|
||||
String prefix = split.length > 0 ? split[0] : "";
|
||||
@ -189,4 +191,5 @@ public class SimpleDispatcher implements Dispatcher {
|
||||
// Checking every perm in the class here was unnecessarily stupid
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -20,14 +20,15 @@
|
||||
package com.sk89q.worldedit.util.command.fluent;
|
||||
|
||||
import com.boydti.fawe.config.Commands;
|
||||
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.worldedit.util.command.CallableProcessor;
|
||||
import com.sk89q.worldedit.util.command.CommandCallable;
|
||||
import com.sk89q.worldedit.util.command.Dispatcher;
|
||||
import com.sk89q.worldedit.util.command.SimpleDispatcher;
|
||||
import com.sk89q.worldedit.util.command.parametric.ParametricBuilder;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.lang.annotation.Annotation;
|
||||
|
||||
/**
|
||||
* A collection of commands.
|
||||
@ -41,12 +42,12 @@ public class DispatcherNode {
|
||||
/**
|
||||
* Create a new instance.
|
||||
*
|
||||
* @param graph the root fluent graph object
|
||||
* @param parent the parent node, or null
|
||||
* @param graph the root fluent graph object
|
||||
* @param parent the parent node, or null
|
||||
* @param dispatcher the dispatcher for this node
|
||||
*/
|
||||
public DispatcherNode(CommandGraph graph, DispatcherNode parent,
|
||||
SimpleDispatcher dispatcher) {
|
||||
DispatcherNode(CommandGraph graph, DispatcherNode parent,
|
||||
SimpleDispatcher dispatcher) {
|
||||
this.graph = graph;
|
||||
this.parent = parent;
|
||||
this.dispatcher = dispatcher;
|
||||
@ -54,7 +55,7 @@ public class DispatcherNode {
|
||||
|
||||
/**
|
||||
* Set the description.
|
||||
* <p>
|
||||
*
|
||||
* <p>This can only be used on {@link DispatcherNode}s returned by
|
||||
* {@link #group(String...)}.</p>
|
||||
*
|
||||
@ -70,7 +71,7 @@ public class DispatcherNode {
|
||||
* Register a command with this dispatcher.
|
||||
*
|
||||
* @param callable the executor
|
||||
* @param alias the list of aliases, where the first alias is the primary one
|
||||
* @param alias the list of aliases, where the first alias is the primary one
|
||||
*/
|
||||
public DispatcherNode register(CommandCallable callable, String... alias) {
|
||||
dispatcher.registerCommand(callable, alias);
|
||||
@ -145,7 +146,7 @@ public class DispatcherNode {
|
||||
|
||||
/**
|
||||
* Create a new command that will contain sub-commands.
|
||||
* <p>
|
||||
*
|
||||
* <p>The object returned by this method can be used to add sub-commands. To
|
||||
* return to this "parent" context, use {@link DispatcherNode#graph()}.</p>
|
||||
*
|
||||
@ -155,8 +156,7 @@ public class DispatcherNode {
|
||||
public DispatcherNode group(String... alias) {
|
||||
SimpleDispatcher command = new SimpleDispatcher();
|
||||
getDispatcher().registerCommand(command, alias);
|
||||
DispatcherNode res = new DispatcherNode(graph, this, command);
|
||||
return res;
|
||||
return new DispatcherNode(graph, this, command);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -191,5 +191,4 @@ public class DispatcherNode {
|
||||
return dispatcher;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ public abstract class AParametricCallable implements CommandCallable {
|
||||
* @param existing the existing scoped context
|
||||
* @return the context to use
|
||||
*/
|
||||
public static ArgumentStack getScopedContext(Parameter parameter, ArgumentStack existing) {
|
||||
static ArgumentStack getScopedContext(Parameter parameter, ArgumentStack existing) {
|
||||
if (parameter.getFlag() != null) {
|
||||
CommandContext context = existing.getContext();
|
||||
|
||||
@ -213,7 +213,6 @@ public abstract class AParametricCallable implements CommandCallable {
|
||||
|
||||
CommandContext context = new CommandContext(split, getValueFlags(), !arguments.endsWith(" "), locals);
|
||||
ContextArgumentStack scoped = new ContextArgumentStack(context);
|
||||
SuggestionContext suggestable = context.getSuggestionContext();
|
||||
|
||||
List<String> suggestions = new ArrayList<>(2);
|
||||
ParameterData parameter = null;
|
||||
|
@ -91,8 +91,4 @@ public interface ArgumentStack {
|
||||
* @return the consumed arguments
|
||||
*/
|
||||
String reset();
|
||||
|
||||
static Class<ArgumentStack> inject0() {
|
||||
return ArgumentStack.class;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
package com.sk89q.worldedit.util.command.parametric;
|
||||
|
||||
import com.boydti.fawe.util.StringMan;
|
||||
|
||||
import com.sk89q.minecraft.util.commands.CommandException;
|
||||
import com.sk89q.worldedit.util.command.binding.Range;
|
||||
import com.sk89q.worldedit.util.command.binding.Validate;
|
||||
@ -29,53 +30,51 @@ import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A binding helper that uses the {@link BindingMatch} annotation to make
|
||||
* writing bindings extremely easy.
|
||||
*
|
||||
*
|
||||
* <p>Methods must have the following and only the following parameters:</p>
|
||||
*
|
||||
*
|
||||
* <ul>
|
||||
* <li>A {@link ArgumentStack}</li>
|
||||
* <li>A {@link Annotation} <strong>if there is a classifier set</strong></li>
|
||||
* <li>A {@link Annotation}[]
|
||||
* <li>A {@link Annotation}[]
|
||||
* <strong>if there {@link BindingMatch#provideModifiers()} is true</strong></li>
|
||||
* </ul>
|
||||
*
|
||||
*
|
||||
* <p>Methods may throw any exception. Exceptions may be converted using a
|
||||
* {@link ExceptionConverter} registered with the {@link ParametricBuilder}.</p>
|
||||
*/
|
||||
@Deprecated
|
||||
public class BindingHelper implements Binding {
|
||||
|
||||
|
||||
private final List<BindingMap.BoundMethod> bindings;
|
||||
private final Type[] types;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
*/
|
||||
public BindingHelper() {
|
||||
List<BindingMap.BoundMethod> bindings = new ArrayList<>();
|
||||
List<Type> types = new ArrayList<>();
|
||||
|
||||
|
||||
for (Method method : this.getClass().getMethods()) {
|
||||
BindingMatch info = method.getAnnotation(BindingMatch.class);
|
||||
if (info != null) {
|
||||
Class<? extends Annotation> classifier = null;
|
||||
|
||||
|
||||
// Set classifier
|
||||
if (!info.classifier().equals(Annotation.class)) {
|
||||
classifier = info.classifier();
|
||||
types.add(classifier);
|
||||
}
|
||||
|
||||
|
||||
for (Type t : info.type()) {
|
||||
Type type = null;
|
||||
|
||||
|
||||
// Set type
|
||||
if (!t.equals(Class.class)) {
|
||||
type = t;
|
||||
@ -83,32 +82,32 @@ public class BindingHelper implements Binding {
|
||||
types.add(type); // Only if there is no classifier set!
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Check to see if at least one is set
|
||||
if (type == null && classifier == null) {
|
||||
throw new RuntimeException(
|
||||
"A @BindingMatch needs either a type or classifier set");
|
||||
}
|
||||
|
||||
|
||||
BindingMap.BoundMethod handler = new BindingMap.BoundMethod(info, type, classifier, method, this);
|
||||
bindings.add(handler);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Collections.sort(bindings);
|
||||
|
||||
|
||||
this.bindings = bindings;
|
||||
|
||||
|
||||
Type[] typesArray = new Type[types.size()];
|
||||
types.toArray(typesArray);
|
||||
this.types = typesArray;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Match a {@link BindingMatch} according to the given parameter.
|
||||
*
|
||||
*
|
||||
* @param parameter the parameter
|
||||
* @return a binding
|
||||
*/
|
||||
@ -116,7 +115,7 @@ public class BindingHelper implements Binding {
|
||||
for (BindingMap.BoundMethod binding : bindings) {
|
||||
Annotation classifer = parameter.getClassifier();
|
||||
Type type = parameter.getType();
|
||||
|
||||
|
||||
if (binding.classifier != null) {
|
||||
if (classifer != null && classifer.annotationType().equals(binding.classifier)) {
|
||||
if (binding.type == null || binding.type.equals(type)) {
|
||||
@ -127,7 +126,7 @@ public class BindingHelper implements Binding {
|
||||
return binding;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
throw new RuntimeException("Unknown type");
|
||||
}
|
||||
|
||||
@ -152,27 +151,27 @@ public class BindingHelper implements Binding {
|
||||
BindingMap.BoundMethod binding = match(parameter);
|
||||
List<Object> args = new ArrayList<>();
|
||||
args.add(scoped);
|
||||
|
||||
|
||||
if (binding.classifier != null) {
|
||||
args.add(parameter.getClassifier());
|
||||
}
|
||||
|
||||
|
||||
if (binding.annotation.provideModifiers()) {
|
||||
args.add(parameter.getModifiers());
|
||||
}
|
||||
|
||||
|
||||
if (onlyConsume && binding.annotation.behavior() == BindingBehavior.PROVIDES) {
|
||||
return null; // Nothing to consume, nothing to do
|
||||
}
|
||||
|
||||
|
||||
Object[] argsArray = new Object[args.size()];
|
||||
args.toArray(argsArray);
|
||||
|
||||
|
||||
try {
|
||||
return binding.method.invoke(this, argsArray);
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new RuntimeException(
|
||||
"Processing of classifier " + parameter.getClassifier() +
|
||||
"Processing of classifier " + parameter.getClassifier() +
|
||||
" and type " + parameter.getType() + " failed for method\n" +
|
||||
binding.method + "\nbecause the parameters for that method are wrong", e);
|
||||
} catch (IllegalAccessException e) {
|
||||
|
@ -31,39 +31,39 @@ import java.lang.annotation.Target;
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface BindingMatch {
|
||||
|
||||
|
||||
/**
|
||||
* The classifier.
|
||||
*
|
||||
*
|
||||
* @return the classifier, or {@link Annotation} if not set
|
||||
*/
|
||||
Class<? extends Annotation> classifier() default Annotation.class;
|
||||
|
||||
|
||||
/**
|
||||
* The type.
|
||||
*
|
||||
*
|
||||
* @return the type, or {@link Class} if not set
|
||||
*/
|
||||
Class<?>[] type() default Class.class;
|
||||
|
||||
/**
|
||||
* The binding behavior.
|
||||
*
|
||||
*
|
||||
* @return the behavior
|
||||
*/
|
||||
BindingBehavior behavior();
|
||||
|
||||
|
||||
/**
|
||||
* Get the number of arguments that this binding consumes.
|
||||
*
|
||||
*
|
||||
* @return -1 if unknown or irrelevant
|
||||
*/
|
||||
int consumedCount() default -1;
|
||||
|
||||
|
||||
/**
|
||||
* Set whether an array of modifier annotations is provided in the list of
|
||||
* arguments.
|
||||
*
|
||||
*
|
||||
* @return true to provide modifiers
|
||||
*/
|
||||
boolean provideModifiers() default false;
|
||||
|
@ -124,7 +124,6 @@ public class ContextArgumentStack implements ArgumentStack {
|
||||
*
|
||||
* <p>The marked position initially starts at 0.</p>
|
||||
*/
|
||||
@Override
|
||||
public void mark() {
|
||||
markedIndex = index;
|
||||
}
|
||||
@ -137,7 +136,6 @@ public class ContextArgumentStack implements ArgumentStack {
|
||||
*
|
||||
* @return the consumed arguments
|
||||
*/
|
||||
@Override
|
||||
public String reset() {
|
||||
String value = (index - 1 > markedIndex) ? context.getString(markedIndex, index - 1) : "";
|
||||
index = markedIndex;
|
||||
@ -177,6 +175,4 @@ public class ContextArgumentStack implements ArgumentStack {
|
||||
return context;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -32,11 +32,9 @@ package com.sk89q.worldedit.util.command.parametric;
|
||||
|
||||
import com.thoughtworks.paranamer.CachingParanamer;
|
||||
|
||||
import java.lang.reflect.AccessibleObject;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.lang.reflect.AccessibleObject;
|
||||
import java.lang.reflect.Parameter;
|
||||
|
||||
/**
|
||||
|
@ -1,15 +1,31 @@
|
||||
package com.sk89q.worldedit.util.command.parametric;
|
||||
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.util.StringMan;
|
||||
|
||||
import com.google.common.primitives.Chars;
|
||||
import com.sk89q.minecraft.util.commands.*;
|
||||
import com.sk89q.worldedit.util.command.*;
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandException;
|
||||
import com.sk89q.minecraft.util.commands.CommandLocals;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissionsException;
|
||||
import com.sk89q.minecraft.util.commands.WrappedCommandException;
|
||||
import com.sk89q.worldedit.util.command.CommandCallable;
|
||||
import com.sk89q.worldedit.util.command.InvalidUsageException;
|
||||
import com.sk89q.worldedit.util.command.MissingParameterException;
|
||||
import com.sk89q.worldedit.util.command.Parameter;
|
||||
import com.sk89q.worldedit.util.command.SimpleDescription;
|
||||
import com.sk89q.worldedit.util.command.UnconsumedParameterException;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class FunctionParametricCallable extends AParametricCallable {
|
||||
@ -33,48 +49,46 @@ public class FunctionParametricCallable extends AParametricCallable {
|
||||
this.group = group;
|
||||
|
||||
List<Object[]> paramParsables = new ArrayList<>();
|
||||
Map<String, Type> unqualified = new HashMap<>();
|
||||
for (Type type : builder.getBindings().getTypes()) {
|
||||
String typeStr = type.getTypeName();
|
||||
unqualified.put(typeStr, type);
|
||||
unqualified.put(typeStr.substring(typeStr.lastIndexOf('.') + 1), type);
|
||||
}
|
||||
{
|
||||
Map<String, Type> unqualified = new HashMap<>();
|
||||
for (Type type : builder.getBindings().getTypes()) {
|
||||
String typeStr = type.getTypeName();
|
||||
unqualified.put(typeStr, type);
|
||||
unqualified.put(typeStr.substring(typeStr.lastIndexOf('.') + 1), type);
|
||||
}
|
||||
{
|
||||
Object[] param = null; // name | type | optional value
|
||||
boolean checkEq = false;
|
||||
int checkEqI = 0;
|
||||
for (String arg : arguments) {
|
||||
if (arg.equals("=")) {
|
||||
checkEqI++;
|
||||
checkEq = true;
|
||||
} else if (param == null || !checkEq) {
|
||||
if (param != null) paramParsables.add(param);
|
||||
param = new Object[3];
|
||||
param[0] = arg;
|
||||
if (arg.length() == 1 && command.flags().contains(arg)) {
|
||||
param[1] = Boolean.class;
|
||||
} else {
|
||||
param[1] = String.class;
|
||||
}
|
||||
param[2] = null;
|
||||
Object[] param = null; // name | type | optional value
|
||||
boolean checkEq = false;
|
||||
int checkEqI = 0;
|
||||
for (String arg : arguments) {
|
||||
if (arg.equals("=")) {
|
||||
checkEqI++;
|
||||
checkEq = true;
|
||||
} else if (param == null || !checkEq) {
|
||||
if (param != null) paramParsables.add(param);
|
||||
param = new Object[3];
|
||||
param[0] = arg;
|
||||
if (arg.length() == 1 && command.flags().contains(arg)) {
|
||||
param[1] = Boolean.class;
|
||||
} else {
|
||||
param[1] = String.class;
|
||||
}
|
||||
param[2] = null;
|
||||
checkEqI = 0;
|
||||
checkEq = false;
|
||||
} else {
|
||||
if (checkEqI == 1) {
|
||||
param[1] = unqualified.getOrDefault(arg, String.class);
|
||||
checkEq = false;
|
||||
} else if (checkEqI == 2) {
|
||||
char c = arg.charAt(0);
|
||||
if (c == '\'' || c == '"') arg = arg.substring(1, arg.length() - 1);
|
||||
param[2] = arg;
|
||||
checkEqI = 0;
|
||||
checkEq = false;
|
||||
} else {
|
||||
if (checkEqI == 1) {
|
||||
param[1] = unqualified.getOrDefault(arg, String.class);
|
||||
checkEq = false;
|
||||
} else if (checkEqI == 2) {
|
||||
char c = arg.charAt(0);
|
||||
if (c == '\'' || c == '"') arg = arg.substring(1, arg.length() - 1);
|
||||
param[2] = arg;
|
||||
checkEqI = 0;
|
||||
checkEq = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (param != null) paramParsables.add(param);
|
||||
}
|
||||
if (param != null) paramParsables.add(param);
|
||||
}
|
||||
|
||||
parameters = new ParameterData[paramParsables.size()];
|
||||
|
@ -24,12 +24,9 @@ import com.sk89q.worldedit.util.command.binding.PrimitiveBindings;
|
||||
import com.sk89q.worldedit.util.command.binding.Range;
|
||||
import com.sk89q.worldedit.util.command.binding.Text;
|
||||
|
||||
import javax.xml.ws.Provider;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
@ -62,7 +59,7 @@ public class ParameterData extends SimpleParameter {
|
||||
|
||||
/**
|
||||
* Set the main type of this parameter.
|
||||
* <p>
|
||||
*
|
||||
* <p>The type is normally that is used to determine which binding is used
|
||||
* for a particular method's parameter.</p>
|
||||
*
|
||||
@ -84,7 +81,7 @@ public class ParameterData extends SimpleParameter {
|
||||
|
||||
/**
|
||||
* Get the classifier annotation.
|
||||
* <p>
|
||||
*
|
||||
* <p>Normally, the type determines what binding is called, but classifiers
|
||||
* take precedence if one is found (and registered with
|
||||
* {@link ParametricBuilder#addBinding(Binding, Type...)}).
|
||||
@ -107,7 +104,7 @@ public class ParameterData extends SimpleParameter {
|
||||
|
||||
/**
|
||||
* Get a list of modifier annotations.
|
||||
* <p>
|
||||
*
|
||||
* <p>Modifier annotations are not considered in the process of choosing a binding
|
||||
* for a method parameter, but they can be used to modify the behavior of a binding.
|
||||
* An example of a modifier annotation is {@link Range}, which can restrict
|
||||
@ -120,7 +117,7 @@ public class ParameterData extends SimpleParameter {
|
||||
return modifiers;
|
||||
}
|
||||
|
||||
public <T extends Annotation> T getModifier(Class<T> annotatedType) {
|
||||
<T extends Annotation> T getModifier(Class<T> annotatedType) {
|
||||
for (Annotation annotation : getModifiers()) {
|
||||
if (annotation.getClass() == annotatedType) return (T) annotation;
|
||||
}
|
||||
@ -141,7 +138,7 @@ public class ParameterData extends SimpleParameter {
|
||||
*
|
||||
* @return -1 if unknown or unavailable
|
||||
*/
|
||||
public int getConsumedCount() {
|
||||
int getConsumedCount() {
|
||||
return getBinding().getConsumedCount(this);
|
||||
}
|
||||
|
||||
@ -150,7 +147,7 @@ public class ParameterData extends SimpleParameter {
|
||||
*
|
||||
* @return true if this parameter is entered by the user.
|
||||
*/
|
||||
public boolean isUserInput() {
|
||||
boolean isUserInput() {
|
||||
return getBinding().getBehavior(this) != BindingBehavior.PROVIDES;
|
||||
}
|
||||
|
||||
@ -159,7 +156,7 @@ public class ParameterData extends SimpleParameter {
|
||||
*
|
||||
* @return true if this parameter consumes non-flag arguments
|
||||
*/
|
||||
public boolean isNonFlagConsumer() {
|
||||
boolean isNonFlagConsumer() {
|
||||
return getBinding().getBehavior(this) != BindingBehavior.PROVIDES && !isValueFlag();
|
||||
}
|
||||
|
||||
@ -167,7 +164,7 @@ public class ParameterData extends SimpleParameter {
|
||||
* Validate this parameter and its binding.
|
||||
*/
|
||||
public void validate(Method method, int parameterIndex) throws ParametricException {
|
||||
validate(() -> method.toGenericString(), parameterIndex);
|
||||
validate(method::toGenericString, parameterIndex);
|
||||
}
|
||||
|
||||
public void validate(Supplier<String> method, int parameterIndex) throws ParametricException {
|
||||
@ -206,5 +203,4 @@ public class ParameterData extends SimpleParameter {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -20,20 +20,16 @@
|
||||
package com.sk89q.worldedit.util.command.parametric;
|
||||
|
||||
import com.boydti.fawe.command.FawePrimitiveBinding;
|
||||
import com.boydti.fawe.command.MaskBinding;
|
||||
import com.boydti.fawe.command.PatternBinding;
|
||||
import com.boydti.fawe.config.Commands;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.google.common.collect.ImmutableBiMap.Builder;
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandException;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.command.MethodCommands;
|
||||
import com.sk89q.worldedit.internal.command.ActorAuthorizer;
|
||||
import com.sk89q.worldedit.internal.command.CommandLoggingHandler;
|
||||
import com.sk89q.worldedit.internal.command.UserCommandCompleter;
|
||||
import com.sk89q.worldedit.internal.command.WorldEditBinding;
|
||||
import com.sk89q.worldedit.util.auth.Authorizer;
|
||||
import com.sk89q.worldedit.util.auth.NullAuthorizer;
|
||||
import com.sk89q.worldedit.util.command.CallableProcessor;
|
||||
@ -46,15 +42,11 @@ import com.sk89q.worldedit.util.command.binding.PrimitiveBindings;
|
||||
import com.sk89q.worldedit.util.command.binding.StandardBindings;
|
||||
import com.sk89q.worldedit.util.command.binding.Switch;
|
||||
import com.thoughtworks.paranamer.Paranamer;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Creates commands using annotations placed on methods and individual parameters of
|
||||
@ -68,13 +60,12 @@ public class ParametricBuilder {
|
||||
private final BindingMap bindings;
|
||||
private final Paranamer paranamer = new FaweParanamer();
|
||||
private final List<InvokeListener> invokeListeners = new ArrayList<>();
|
||||
private final List<ExceptionConverter> exceptionConverters = new ArrayList<>();
|
||||
private Authorizer authorizer = new NullAuthorizer();
|
||||
private CommandCompleter defaultCompleter = new NullCompleter();
|
||||
|
||||
/**
|
||||
* Create a new builder.
|
||||
* <p>
|
||||
*
|
||||
* <p>This method will install {@link PrimitiveBindings} and
|
||||
* {@link StandardBindings} and default bindings.</p>
|
||||
*/
|
||||
@ -86,12 +77,12 @@ public class ParametricBuilder {
|
||||
|
||||
/**
|
||||
* Add a binding for a given type or classifier (annotation).
|
||||
* <p>
|
||||
*
|
||||
* <p>Whenever a method parameter is encountered, a binding must be found for it
|
||||
* so that it can be called later to consume the stack of arguments provided by
|
||||
* the user and return an object that is later passed to
|
||||
* {@link Method#invoke(Object, Object...)}.</p>
|
||||
* <p>
|
||||
*
|
||||
* <p>Normally, a {@link Type} is used to discern between different bindings, but
|
||||
* if this is not specific enough, an annotation can be defined and used. This
|
||||
* makes it a "classifier" and it will take precedence over the base type. For
|
||||
@ -102,9 +93,8 @@ public class ParametricBuilder {
|
||||
* the {@link String} type.</p>
|
||||
*
|
||||
* @param binding the binding
|
||||
* @param type a list of types (if specified) to override the binding's types
|
||||
* @param type a list of types (if specified) to override the binding's types
|
||||
*/
|
||||
@Deprecated
|
||||
public void addBinding(Binding binding, Type... type) {
|
||||
this.bindings.add(binding);
|
||||
}
|
||||
@ -119,50 +109,37 @@ public class ParametricBuilder {
|
||||
|
||||
/**
|
||||
* Attach an invocation listener.
|
||||
* <p>
|
||||
*
|
||||
* <p>Invocation handlers are called in order that their listeners are
|
||||
* registered with a {@link ParametricBuilder}. It is not guaranteed that
|
||||
* a listener may be called, in the case of a {@link CommandException} being
|
||||
* thrown at any time before the appropriate listener or handler is called.
|
||||
* It is possible for a
|
||||
* {@link com.sk89q.worldedit.util.command.parametric.InvokeHandler#preInvoke(Object, Method, com.sk89q.worldedit.util.command.parametric.ParameterData[], Object[], CommandContext)} to
|
||||
* {@link InvokeHandler#preInvoke(Object, Method, ParameterData[], Object[], CommandContext)} to
|
||||
* be called for a invocation handler, but not the associated
|
||||
* {@link com.sk89q.worldedit.util.command.parametric.InvokeHandler#postInvoke(Object, Method, com.sk89q.worldedit.util.command.parametric.ParameterData[], Object[], CommandContext)}.</p>
|
||||
* <p>
|
||||
* {@link InvokeHandler#postInvoke(Object, Method, ParameterData[], Object[], CommandContext)}.</p>
|
||||
*
|
||||
* <p>An example of an invocation listener is one to handle
|
||||
* {@link CommandPermissions}, by first checking to see if permission is available
|
||||
* in a {@link com.sk89q.worldedit.util.command.parametric.InvokeHandler#preInvoke(Object, Method, com.sk89q.worldedit.util.command.parametric.ParameterData[], Object[], CommandContext)}
|
||||
* in a {@link InvokeHandler#preInvoke(Object, Method, ParameterData[], Object[], CommandContext)}
|
||||
* call. If permission is not found, then an appropriate {@link CommandException}
|
||||
* can be thrown to cease invocation.</p>
|
||||
*
|
||||
* @param listener the listener
|
||||
* @see com.sk89q.worldedit.util.command.parametric.InvokeHandler the handler
|
||||
* @see InvokeHandler the handler
|
||||
*/
|
||||
public void addInvokeListener(InvokeListener listener) {
|
||||
invokeListeners.add(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attach an exception converter to this builder in order to wrap unknown
|
||||
* {@link Throwable}s into known {@link CommandException}s.
|
||||
* <p>
|
||||
* <p>Exception converters are called in order that they are registered.</p>
|
||||
*
|
||||
* @param converter the converter
|
||||
* @see ExceptionConverter for an explanation
|
||||
*/
|
||||
public void addExceptionConverter(ExceptionConverter converter) {
|
||||
exceptionConverters.add(converter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a list of commands from methods specially annotated with {@link Command}
|
||||
* (and other relevant annotations) and register them all with the given
|
||||
* {@link Dispatcher}.
|
||||
*
|
||||
* @param dispatcher the dispatcher to register commands with
|
||||
* @param object the object contain the methods
|
||||
* @throws com.sk89q.worldedit.util.command.parametric.ParametricException thrown if the commands cannot be registered
|
||||
* @param object the object contain the methods
|
||||
* @throws ParametricException thrown if the commands cannot be registered
|
||||
*/
|
||||
public void registerMethodsAsCommands(Dispatcher dispatcher, Object object) throws ParametricException {
|
||||
registerMethodsAsCommands(dispatcher, object, null);
|
||||
@ -204,8 +181,8 @@ public class ParametricBuilder {
|
||||
/**
|
||||
* Build a {@link CommandCallable} for the given method.
|
||||
*
|
||||
* @param object the object to be invoked on
|
||||
* @param method the method to invoke
|
||||
* @param object the object to be invoked on
|
||||
* @param method the method to invoke
|
||||
* @param definition the command definition annotation
|
||||
* @return the command executor
|
||||
* @throws ParametricException thrown on an error
|
||||
@ -229,7 +206,7 @@ public class ParametricBuilder {
|
||||
*
|
||||
* @return the paranamer
|
||||
*/
|
||||
public Paranamer getParanamer() {
|
||||
Paranamer getParanamer() {
|
||||
return paranamer;
|
||||
}
|
||||
|
||||
@ -247,19 +224,10 @@ public class ParametricBuilder {
|
||||
*
|
||||
* @return a list of invocation listeners
|
||||
*/
|
||||
public List<InvokeListener> getInvokeListeners() {
|
||||
List<InvokeListener> getInvokeListeners() {
|
||||
return invokeListeners;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of exception converters.
|
||||
*
|
||||
* @return a list of exception converters
|
||||
*/
|
||||
public List<ExceptionConverter> getExceptionConverters() {
|
||||
return exceptionConverters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the authorizer.
|
||||
*
|
||||
@ -300,6 +268,4 @@ public class ParametricBuilder {
|
||||
this.defaultCompleter = defaultCompleter;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -19,8 +19,6 @@
|
||||
|
||||
package com.sk89q.worldedit.util.command.parametric;
|
||||
|
||||
import com.boydti.fawe.command.SuggestInputParseException;
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.google.common.primitives.Chars;
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
@ -28,7 +26,6 @@ import com.sk89q.minecraft.util.commands.CommandException;
|
||||
import com.sk89q.minecraft.util.commands.CommandLocals;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissionsException;
|
||||
import com.sk89q.minecraft.util.commands.SuggestionContext;
|
||||
import com.sk89q.minecraft.util.commands.WrappedCommandException;
|
||||
import com.sk89q.worldedit.util.command.CommandCallable;
|
||||
import com.sk89q.worldedit.util.command.InvalidUsageException;
|
||||
@ -37,6 +34,7 @@ import com.sk89q.worldedit.util.command.Parameter;
|
||||
import com.sk89q.worldedit.util.command.SimpleDescription;
|
||||
import com.sk89q.worldedit.util.command.UnconsumedParameterException;
|
||||
import com.sk89q.worldedit.util.command.binding.Switch;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
@ -66,13 +64,13 @@ public class ParametricCallable extends AParametricCallable {
|
||||
/**
|
||||
* Create a new instance.
|
||||
*
|
||||
* @param builder the parametric builder
|
||||
* @param object the object to invoke on
|
||||
* @param method the method to invoke
|
||||
* @param builder the parametric builder
|
||||
* @param object the object to invoke on
|
||||
* @param method the method to invoke
|
||||
* @param definition the command definition annotation
|
||||
* @throws ParametricException thrown on an error
|
||||
*/
|
||||
public ParametricCallable(ParametricBuilder builder, Object object, Method method, Command definition) throws ParametricException {
|
||||
ParametricCallable(ParametricBuilder builder, Object object, Method method, Command definition) throws ParametricException {
|
||||
this.builder = builder;
|
||||
this.object = object;
|
||||
this.method = method;
|
||||
@ -80,7 +78,6 @@ public class ParametricCallable extends AParametricCallable {
|
||||
Annotation[][] annotations = method.getParameterAnnotations();
|
||||
String[] names = builder.getParanamer().lookupParameterNames(method, false);
|
||||
Type[] types = method.getGenericParameterTypes();
|
||||
|
||||
parameters = new ParameterData[types.length];
|
||||
List<Parameter> userParameters = new ArrayList<>();
|
||||
|
||||
@ -112,7 +109,7 @@ public class ParametricCallable extends AParametricCallable {
|
||||
if (value.length > 0) {
|
||||
parameter.setDefaultValue(value);
|
||||
}
|
||||
// Special annotation bindings
|
||||
// Special annotation bindings
|
||||
} else if (parameter.getBinding() == null) {
|
||||
parameter.setBinding(builder.getBindings());
|
||||
parameter.setClassifier(annotation);
|
||||
@ -147,10 +144,10 @@ public class ParametricCallable extends AParametricCallable {
|
||||
if (parameter.getConsumedCount() < 0) {
|
||||
throw new ParametricException(
|
||||
"Found an parameter using the binding " +
|
||||
parameter.getBinding().getClass().getCanonicalName() +
|
||||
"\nthat does not know how many arguments it consumes, but " +
|
||||
"it follows an optional parameter\nMethod: " +
|
||||
method.toGenericString());
|
||||
parameter.getBinding().getClass().getCanonicalName() +
|
||||
"\nthat does not know how many arguments it consumes, but " +
|
||||
"it follows an optional parameter\nMethod: " +
|
||||
method.toGenericString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -208,7 +205,7 @@ public class ParametricCallable extends AParametricCallable {
|
||||
locals.putIfAbsent(CommandCallable.class, this);
|
||||
|
||||
String calledCommand = parentCommands.length > 0 ? parentCommands[parentCommands.length - 1] : "_";
|
||||
String[] split = (calledCommand + " " + stringArguments).split(" ", -1);
|
||||
String[] split = CommandContext.split(calledCommand + " " + stringArguments);
|
||||
CommandContext context = new CommandContext(split, getValueFlags(), false, locals);
|
||||
|
||||
// Provide help if -? is specified
|
||||
@ -271,14 +268,14 @@ public class ParametricCallable extends AParametricCallable {
|
||||
}
|
||||
return result;
|
||||
} catch (MissingParameterException e) {
|
||||
throw new InvalidUsageException("Too few parameters!", this, true);
|
||||
throw new InvalidUsageException("Too few parameters!", this);
|
||||
} catch (UnconsumedParameterException e) {
|
||||
throw new InvalidUsageException("Too many parameters! Unused parameters: " + e.getUnconsumed(), this, true);
|
||||
throw new InvalidUsageException("Too many parameters! Unused parameters: " + e.getUnconsumed(), this);
|
||||
} catch (ParameterException e) {
|
||||
assert parameter != null;
|
||||
String name = parameter.getName();
|
||||
|
||||
throw new InvalidUsageException("For parameter '" + name + "': " + e.getMessage(), this, true);
|
||||
throw new InvalidUsageException("For parameter '" + name + "': " + e.getMessage(), this);
|
||||
} catch (InvocationTargetException e) {
|
||||
if (e.getCause() instanceof CommandException) {
|
||||
throw (CommandException) e.getCause();
|
||||
@ -344,12 +341,12 @@ public class ParametricCallable extends AParametricCallable {
|
||||
/**
|
||||
* Generate a name for a parameter.
|
||||
*
|
||||
* @param type the type
|
||||
* @param type the type
|
||||
* @param classifier the classifier
|
||||
* @param index the index
|
||||
* @param index the index
|
||||
* @return a generated name
|
||||
*/
|
||||
public static String generateName(Type type, Annotation classifier, int index) {
|
||||
private static String generateName(Type type, Annotation classifier, int index) {
|
||||
if (classifier != null) {
|
||||
return classifier.annotationType().getSimpleName().toLowerCase();
|
||||
} else {
|
||||
@ -361,5 +358,4 @@ public class ParametricCallable extends AParametricCallable {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -20,8 +20,8 @@
|
||||
package com.sk89q.worldedit.util.command.parametric;
|
||||
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.worldedit.util.command.MissingParameterException;
|
||||
import com.sk89q.util.StringUtil;
|
||||
import com.sk89q.worldedit.util.command.MissingParameterException;
|
||||
|
||||
/**
|
||||
* A virtual scope that does not actually read from the underlying
|
||||
|
@ -25,12 +25,12 @@ package com.sk89q.worldedit.util.formatting;
|
||||
public class Fragment {
|
||||
|
||||
private final StringBuilder builder = new StringBuilder();
|
||||
|
||||
public Fragment() {
|
||||
|
||||
Fragment() {
|
||||
}
|
||||
|
||||
public Fragment append(String str) {
|
||||
builder.append(str);
|
||||
builder.append(Style.stripColor(str));
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -88,5 +88,5 @@ public class Fragment {
|
||||
public String toString() {
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ public class CommandListBox extends MessageBox {
|
||||
return appendCommand(alias, description, true);
|
||||
}
|
||||
|
||||
public CommandListBox appendCommand(String alias, String description, boolean allowed) {
|
||||
CommandListBox appendCommand(String alias, String description, boolean allowed) {
|
||||
if (!first) {
|
||||
getContents().newLine();
|
||||
}
|
||||
@ -47,5 +47,4 @@ public class CommandListBox extends MessageBox {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -20,6 +20,8 @@
|
||||
package com.sk89q.worldedit.util.formatting.component;
|
||||
|
||||
import com.boydti.fawe.config.BBC;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import com.sk89q.minecraft.util.commands.CommandLocals;
|
||||
import com.sk89q.worldedit.extension.platform.CommandManager;
|
||||
import com.sk89q.worldedit.util.command.CommandCallable;
|
||||
@ -27,15 +29,11 @@ import com.sk89q.worldedit.util.command.CommandMapping;
|
||||
import com.sk89q.worldedit.util.command.Description;
|
||||
import com.sk89q.worldedit.util.command.Dispatcher;
|
||||
import com.sk89q.worldedit.util.command.PrimaryAliasComparator;
|
||||
import com.sk89q.worldedit.util.formatting.Style;
|
||||
import com.sk89q.worldedit.util.formatting.StyledFragment;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A box to describe usage of a command.
|
||||
@ -45,7 +43,7 @@ public class CommandUsageBox extends StyledFragment {
|
||||
/**
|
||||
* Create a new usage box.
|
||||
*
|
||||
* @param command the command to describe
|
||||
* @param command the command to describe
|
||||
* @param commandString the command that was used, such as "/we" or "/brush sphere"
|
||||
*/
|
||||
public CommandUsageBox(CommandCallable command, String commandString) {
|
||||
@ -55,9 +53,9 @@ public class CommandUsageBox extends StyledFragment {
|
||||
/**
|
||||
* Create a new usage box.
|
||||
*
|
||||
* @param command the command to describe
|
||||
* @param command the command to describe
|
||||
* @param commandString the command that was used, such as "/we" or "/brush sphere"
|
||||
* @param locals list of locals to use
|
||||
* @param locals list of locals to use
|
||||
*/
|
||||
public CommandUsageBox(CommandCallable command, String commandString, @Nullable CommandLocals locals) {
|
||||
checkNotNull(command);
|
||||
@ -74,7 +72,7 @@ public class CommandUsageBox extends StyledFragment {
|
||||
String prefix = !commandString.isEmpty() ? commandString + " " : "";
|
||||
|
||||
List<CommandMapping> list = new ArrayList<>(dispatcher.getCommands());
|
||||
Collections.sort(list, new PrimaryAliasComparator(CommandManager.COMMAND_CLEAN_PATTERN));
|
||||
list.sort(new PrimaryAliasComparator(CommandManager.COMMAND_CLEAN_PATTERN));
|
||||
|
||||
for (CommandMapping mapping : list) {
|
||||
boolean perm = locals == null || mapping.getCallable().testPermission(locals);
|
||||
@ -91,13 +89,11 @@ public class CommandUsageBox extends StyledFragment {
|
||||
if (description.getUsage() != null) {
|
||||
contents.append(new Label().append(BBC.COMMAND_SYNTAX.f(description.getUsage())));
|
||||
} else {
|
||||
contents.createFragment(Style.GRAY);
|
||||
contents.append(new Subtle().append("Usage information is not available."));
|
||||
}
|
||||
|
||||
contents.newLine();
|
||||
|
||||
contents.createFragment(Style.GRAY);
|
||||
if (description.getHelp() != null) {
|
||||
contents.append(description.getHelp());
|
||||
} else if (description.getDescription() != null) {
|
||||
@ -109,6 +105,4 @@ public class CommandUsageBox extends StyledFragment {
|
||||
append(box);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -41,6 +41,14 @@ public class MessageBox extends StyledFragment {
|
||||
append(contents);
|
||||
}
|
||||
|
||||
private String createBorder(int count) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (int i = 0; i < count; i++) {
|
||||
builder.append("-");
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the internal contents.
|
||||
*
|
||||
@ -50,5 +58,4 @@ public class MessageBox extends StyledFragment {
|
||||
return contents;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user