Dieser Commit ist enthalten in:
Ursprung
0f636e5890
Commit
5372781618
@ -170,7 +170,7 @@ public abstract class AbstractSWCommand<T> {
|
|||||||
if (compare != 0) {
|
if (compare != 0) {
|
||||||
return compare;
|
return compare;
|
||||||
} else {
|
} else {
|
||||||
return Integer.compare(o1.comparableValue, o2.comparableValue);
|
return Double.compare(o1.comparableValue, o2.comparableValue);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
commandHelpList.sort((o1, o2) -> {
|
commandHelpList.sort((o1, o2) -> {
|
||||||
|
@ -23,6 +23,7 @@ import java.lang.reflect.InvocationTargetException;
|
|||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Parameter;
|
import java.lang.reflect.Parameter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
@ -30,6 +31,14 @@ import java.util.function.Predicate;
|
|||||||
|
|
||||||
public class SubCommand<T> {
|
public class SubCommand<T> {
|
||||||
|
|
||||||
|
private static Map<Class<?>, Double> increment = new HashMap<>();
|
||||||
|
static {
|
||||||
|
increment.put(double.class, 0.1);
|
||||||
|
increment.put(Double.class, 0.1);
|
||||||
|
increment.put(float.class, 0.1);
|
||||||
|
increment.put(Float.class, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
private AbstractSWCommand<T> abstractSWCommand;
|
private AbstractSWCommand<T> abstractSWCommand;
|
||||||
Method method;
|
Method method;
|
||||||
String[] description;
|
String[] description;
|
||||||
@ -38,12 +47,11 @@ public class SubCommand<T> {
|
|||||||
private Function<T, ?> senderFunction;
|
private Function<T, ?> senderFunction;
|
||||||
AbstractGuardChecker<T> guardChecker;
|
AbstractGuardChecker<T> guardChecker;
|
||||||
boolean noTabComplete;
|
boolean noTabComplete;
|
||||||
int comparableValue;
|
double comparableValue;
|
||||||
|
|
||||||
private CommandPart<T> commandPart;
|
private CommandPart<T> commandPart;
|
||||||
|
|
||||||
SubCommand(AbstractSWCommand<T> abstractSWCommand, Method method, String[] subCommand, Map<String, AbstractTypeMapper<T, ?>> localTypeMapper, Map<String, AbstractGuardChecker<T>> localGuardChecker, boolean help, String[] description, boolean noTabComplete) {
|
SubCommand(AbstractSWCommand<T> abstractSWCommand, Method method, String[] subCommand, Map<String, AbstractTypeMapper<T, ?>> localTypeMapper, Map<String, AbstractGuardChecker<T>> localGuardChecker, boolean help, String[] description, boolean noTabComplete) {
|
||||||
System.out.println(method);
|
|
||||||
this.abstractSWCommand = abstractSWCommand;
|
this.abstractSWCommand = abstractSWCommand;
|
||||||
this.method = method;
|
this.method = method;
|
||||||
this.subCommand = subCommand;
|
this.subCommand = subCommand;
|
||||||
@ -52,6 +60,9 @@ public class SubCommand<T> {
|
|||||||
|
|
||||||
Parameter[] parameters = method.getParameters();
|
Parameter[] parameters = method.getParameters();
|
||||||
comparableValue = parameters[parameters.length - 1].isVarArgs() ? Integer.MAX_VALUE : -parameters.length;
|
comparableValue = parameters[parameters.length - 1].isVarArgs() ? Integer.MAX_VALUE : -parameters.length;
|
||||||
|
for (Parameter parameter : parameters) {
|
||||||
|
comparableValue += increment.getOrDefault(parameter.getType(), 0.0);
|
||||||
|
}
|
||||||
|
|
||||||
guardChecker = SWCommandUtils.getGuardChecker(parameters[0], localGuardChecker);
|
guardChecker = SWCommandUtils.getGuardChecker(parameters[0], localGuardChecker);
|
||||||
|
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren