Format code

This commit is contained in:
2026-05-16 23:08:09 +02:00
parent 81dd8045f2
commit d110df924e
562 changed files with 11025 additions and 10059 deletions
@@ -182,8 +182,9 @@ public abstract class AbstractSWCommand<T> {
if (!checkType(method.getAnnotations(), method.getReturnType(), false, annotation -> {
CommandMetaData.Method methodMetaData = annotation.annotationType().getAnnotation(CommandMetaData.Method.class);
if (methodMetaData == null) return (aClass, varArg) -> true;
if (method.getParameterCount() > methodMetaData.maxParameterCount() || method.getParameterCount() < methodMetaData.minParameterCount())
if (method.getParameterCount() > methodMetaData.maxParameterCount() || method.getParameterCount() < methodMetaData.minParameterCount()) {
return (aClass, varArg) -> false;
}
return (aClass, varArg) -> {
Class<?>[] types = methodMetaData.value();
if (types == null) return true;
@@ -31,8 +31,8 @@ public interface AbstractValidator<K, T> {
/**
* Validates the given value.
*
* @param sender The sender of the command.
* @param value The value to validate or null if mapping returned null.
* @param sender The sender of the command.
* @param value The value to validate or null if mapping returned null.
* @param messageSender The message sender to send messages to the player. Never send messages directly to the player.
* @return The result of the validation.
*/
@@ -33,7 +33,9 @@ public @interface CommandMetaData {
@Target(ElementType.ANNOTATION_TYPE)
@interface Method {
Class<?>[] value();
int minParameterCount() default 0;
int maxParameterCount() default Integer.MAX_VALUE;
}
@@ -44,6 +46,7 @@ public @interface CommandMetaData {
@Target(ElementType.ANNOTATION_TYPE)
@interface Parameter {
Class<?>[] value() default {};
Class<?> handler() default void.class;
}
@@ -148,7 +148,8 @@ class CommandPart<T> {
List<Object> currentArgs = new ArrayList<>(mappedArgs);
List<Object> varArgs = new ArrayList<>();
for (int i = startIndex; i < args.length - 1; i++) {
CheckArgumentResult validArgument = checkArgument((ignore) -> {}, sender, args, mappedArgs, i);
CheckArgumentResult validArgument = checkArgument((ignore) -> {
}, sender, args, mappedArgs, i);
if (!validArgument.success) return;
varArgs.add(validArgument.value);
}
@@ -162,7 +163,8 @@ class CommandPart<T> {
}
if (args.length - 1 > startIndex) {
CheckArgumentResult checkArgumentResult = checkArgument((ignore) -> {}, sender, args, mappedArgs, startIndex);
CheckArgumentResult checkArgumentResult = checkArgument((ignore) -> {
}, sender, args, mappedArgs, startIndex);
if (checkArgumentResult.success && next != null) {
if (!ignoreAsArgument) {
mappedArgs.add(checkArgumentResult.value);
@@ -138,7 +138,8 @@ public class SubCommand<T> implements Comparable<SubCommand<T>> {
}
List<String> tabComplete(T sender, String[] args) {
if (validator != null && !validator.validate(sender, sender, (s, objects) -> {})) {
if (validator != null && !validator.validate(sender, sender, (s, objects) -> {
})) {
return null;
}
if (commandPart == null) {
@@ -32,7 +32,7 @@ public class NullMapperCommandTest {
public void testNull() {
NullMapperCommand command = new NullMapperCommand();
try {
command.execute("test", "", new String[] {"Hello World"});
command.execute("test", "", new String[]{"Hello World"});
assertThat(true, is(false));
} catch (Exception e) {
assertCMDFramework(e, ExecutionIdentifier.class, "null");
@@ -43,7 +43,7 @@ public class NullMapperCommandTest {
public void testNonNull() {
NullMapperCommand command = new NullMapperCommand();
try {
command.execute("test", "", new String[] {"Hello"});
command.execute("test", "", new String[]{"Hello"});
assertThat(true, is(false));
} catch (Exception e) {
assertCMDFramework(e, ExecutionIdentifier.class, "notnull");
@@ -35,7 +35,7 @@ public class NumberValidatorCommandTest {
@Test
public void testMaxValue() {
NumberValidatorCommand command = new NumberValidatorCommand();
command.execute("sender", "", new String[]{"11"});
command.execute("sender", "", new String[]{"11"});
}
@Test
@@ -43,7 +43,7 @@ public class SimpleCommandTest {
public void testVarArgs() {
SimpleCommand cmd = new SimpleCommand();
try {
cmd.execute("test", "", new String[] {"a", "b", "c"});
cmd.execute("test", "", new String[]{"a", "b", "c"});
} catch (Exception e) {
assertCMDFramework(e, ExecutionIdentifier.class, "RunSimple with Varargs");
}
@@ -39,7 +39,7 @@ public class StaticValueCommand extends TestSWCommand {
}
@Register
public void booleanStaticValueOtherFalseValue(String s, @StaticValue(value = {"-d", "-e", "-f"}, allowISE = true, falseValues = { 1 }) boolean staticValue) {
public void booleanStaticValueOtherFalseValue(String s, @StaticValue(value = {"-d", "-e", "-f"}, allowISE = true, falseValues = {1}) boolean staticValue) {
throw new ExecutionIdentifier("RunStaticValue with " + staticValue);
}
@@ -40,13 +40,13 @@ public class StaticValueCommandTest {
public void defaultTest() {
StaticValueCommand cmd = new StaticValueCommand();
try {
cmd.execute("", "", new String[] {"hello"});
cmd.execute("", "", new String[]{"hello"});
assert false;
} catch (Exception e) {
assertCMDFramework(e, ExecutionIdentifier.class, "RunStaticValue with hello");
}
try {
cmd.execute("", "", new String[] {"world"});
cmd.execute("", "", new String[]{"world"});
assert false;
} catch (Exception e) {
assertCMDFramework(e, ExecutionIdentifier.class, "RunStaticValue with world");
@@ -57,19 +57,19 @@ public class StaticValueCommandTest {
public void booleanTest() {
StaticValueCommand cmd = new StaticValueCommand();
try {
cmd.execute("", "", new String[] {"-a"});
cmd.execute("", "", new String[]{"-a"});
assert false;
} catch (Exception e) {
assertCMDFramework(e, ExecutionIdentifier.class, "RunStaticValue with false");
}
try {
cmd.execute("", "", new String[] {"-b"});
cmd.execute("", "", new String[]{"-b"});
assert false;
} catch (Exception e) {
assertCMDFramework(e, ExecutionIdentifier.class, "RunStaticValue with true");
}
try {
cmd.execute("", "", new String[] {"-c"});
cmd.execute("", "", new String[]{"-c"});
assert false;
} catch (Exception e) {
assertCMDFramework(e, ExecutionIdentifier.class, "RunStaticValue with true");
@@ -80,19 +80,19 @@ public class StaticValueCommandTest {
public void booleanOtherFalseTest() {
StaticValueCommand cmd = new StaticValueCommand();
try {
cmd.execute("", "", new String[] {"-d"});
cmd.execute("", "", new String[]{"-d"});
assert false;
} catch (Exception e) {
assertCMDFramework(e, ExecutionIdentifier.class, "RunStaticValue with true");
}
try {
cmd.execute("", "", new String[] {"-e"});
cmd.execute("", "", new String[]{"-e"});
assert false;
} catch (Exception e) {
assertCMDFramework(e, ExecutionIdentifier.class, "RunStaticValue with false");
}
try {
cmd.execute("", "", new String[] {"-f"});
cmd.execute("", "", new String[]{"-f"});
assert false;
} catch (Exception e) {
assertCMDFramework(e, ExecutionIdentifier.class, "RunStaticValue with true");
@@ -103,19 +103,19 @@ public class StaticValueCommandTest {
public void intTest() {
StaticValueCommand cmd = new StaticValueCommand();
try {
cmd.execute("", "", new String[] {"-g"});
cmd.execute("", "", new String[]{"-g"});
assert false;
} catch (Exception e) {
assertCMDFramework(e, ExecutionIdentifier.class, "RunStaticValue with int 0");
}
try {
cmd.execute("", "", new String[] {"-h"});
cmd.execute("", "", new String[]{"-h"});
assert false;
} catch (Exception e) {
assertCMDFramework(e, ExecutionIdentifier.class, "RunStaticValue with int 1");
}
try {
cmd.execute("", "", new String[] {"-i"});
cmd.execute("", "", new String[]{"-i"});
assert false;
} catch (Exception e) {
assertCMDFramework(e, ExecutionIdentifier.class, "RunStaticValue with int 2");
@@ -126,19 +126,19 @@ public class StaticValueCommandTest {
public void longTest() {
StaticValueCommand cmd = new StaticValueCommand();
try {
cmd.execute("", "", new String[] {"-j"});
cmd.execute("", "", new String[]{"-j"});
assert false;
} catch (Exception e) {
assertCMDFramework(e, ExecutionIdentifier.class, "RunStaticValue with long 0");
}
try {
cmd.execute("", "", new String[] {"-k"});
cmd.execute("", "", new String[]{"-k"});
assert false;
} catch (Exception e) {
assertCMDFramework(e, ExecutionIdentifier.class, "RunStaticValue with long 1");
}
try {
cmd.execute("", "", new String[] {"-l"});
cmd.execute("", "", new String[]{"-l"});
assert false;
} catch (Exception e) {
assertCMDFramework(e, ExecutionIdentifier.class, "RunStaticValue with long 2");