From a9d13d43d6689aec0e5c6121d9a4392ebb1079f7 Mon Sep 17 00:00:00 2001 From: efekos <56752400+efekos@users.noreply.github.com> Date: Wed, 29 May 2024 07:11:05 +0300 Subject: [PATCH] format code --- src/main/java/dev/efekos/arn/Arn.java | 1 + .../efekos/arn/argument/CustomArgumentType.java | 8 ++++++-- .../dev/efekos/arn/exception/ArnException.java | 10 +++++----- .../arn/resolver/impl/command/CmdCustomArg.java | 7 +++++-- .../arn/resolver/impl/handler/HndCustomArg.java | 15 +++++++++++---- 5 files changed, 28 insertions(+), 13 deletions(-) diff --git a/src/main/java/dev/efekos/arn/Arn.java b/src/main/java/dev/efekos/arn/Arn.java index f09421c..11be2a5 100644 --- a/src/main/java/dev/efekos/arn/Arn.java +++ b/src/main/java/dev/efekos/arn/Arn.java @@ -178,6 +178,7 @@ public static void run(Class mainClass) { /** * Scans {@link Container}s annotated with {@link CustomArgumentType} and creates a resolver for them. + * * @param reflections Main reflections. */ private void scanCustomArguments(Reflections reflections) { diff --git a/src/main/java/dev/efekos/arn/argument/CustomArgumentType.java b/src/main/java/dev/efekos/arn/argument/CustomArgumentType.java index 6147fd3..be592db 100644 --- a/src/main/java/dev/efekos/arn/argument/CustomArgumentType.java +++ b/src/main/java/dev/efekos/arn/argument/CustomArgumentType.java @@ -32,20 +32,23 @@ /** * An interface used to create custom argument types. When scanned by {@link dev.efekos.arn.Arn}, {@link T} becomes a * usable argument type that is handled by the implementation of this interface. + * * @param Type of the custom argument. - * @since 0.3.1 * @author efekos + * @since 0.3.1 */ public interface CustomArgumentType { /** * Returns class instance of the custom argument. + * * @return A {@link Class} instance. */ Class getType(); /** * Suggests a list of strings to the given command sender. + * * @param sender Any command sender. * @return A list of suggestions. */ @@ -53,8 +56,9 @@ public interface CustomArgumentType { /** * Parses the given argument. + * * @param sender Sender who sent this argument. - * @param arg The argument value. + * @param arg The argument value. * @return Parsed object. * @throws CommandSyntaxException If {@code arg} is invalid. */ diff --git a/src/main/java/dev/efekos/arn/exception/ArnException.java b/src/main/java/dev/efekos/arn/exception/ArnException.java index d1fa88f..f7e96f1 100644 --- a/src/main/java/dev/efekos/arn/exception/ArnException.java +++ b/src/main/java/dev/efekos/arn/exception/ArnException.java @@ -42,7 +42,7 @@ public class ArnException extends Exception { */ public ArnException() { List list = new ArrayList<>(Arrays.asList(this.getStackTrace())); - for (int i = 0; i < 3; i++) list.remove(list.size()-1); + for (int i = 0; i < 3; i++) list.remove(list.size() - 1); setStackTrace(list.toArray(new StackTraceElement[list.size()])); } @@ -54,7 +54,7 @@ public ArnException() { public ArnException(String message) { super(message); List list = new ArrayList<>(Arrays.asList(this.getStackTrace())); - for (int i = 0; i < 3; i++) list.remove(list.size()-1); + for (int i = 0; i < 3; i++) list.remove(list.size() - 1); setStackTrace(list.toArray(new StackTraceElement[list.size()])); } @@ -67,7 +67,7 @@ public ArnException(String message) { public ArnException(String message, Throwable cause) { super(message, cause); List list = new ArrayList<>(Arrays.asList(this.getStackTrace())); - for (int i = 0; i < 3; i++) list.remove(list.size()-1); + for (int i = 0; i < 3; i++) list.remove(list.size() - 1); setStackTrace(list.toArray(new StackTraceElement[list.size()])); } @@ -79,7 +79,7 @@ public ArnException(String message, Throwable cause) { public ArnException(Throwable cause) { super(cause); List list = new ArrayList<>(Arrays.asList(this.getStackTrace())); - for (int i = 0; i < 3; i++) list.remove(list.size()-1); + for (int i = 0; i < 3; i++) list.remove(list.size() - 1); setStackTrace(list.toArray(new StackTraceElement[list.size()])); } @@ -94,7 +94,7 @@ public ArnException(Throwable cause) { public ArnException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { super(message, cause, enableSuppression, writableStackTrace); List list = new ArrayList<>(Arrays.asList(this.getStackTrace())); - for (int i = 0; i < 3; i++) list.remove(list.size()-1); + for (int i = 0; i < 3; i++) list.remove(list.size() - 1); setStackTrace(list.toArray(new StackTraceElement[list.size()])); } diff --git a/src/main/java/dev/efekos/arn/resolver/impl/command/CmdCustomArg.java b/src/main/java/dev/efekos/arn/resolver/impl/command/CmdCustomArg.java index be33ecf..c10a0d4 100644 --- a/src/main/java/dev/efekos/arn/resolver/impl/command/CmdCustomArg.java +++ b/src/main/java/dev/efekos/arn/resolver/impl/command/CmdCustomArg.java @@ -48,6 +48,7 @@ public final class CmdCustomArg implements CommandArgumentResolver { /** * Creates a new resolver. + * * @param customArgumentType An instance of the {@link CustomArgumentType} this resolver resolves. */ public CmdCustomArg(CustomArgumentType customArgumentType) { @@ -62,11 +63,13 @@ public boolean isApplicable(Parameter parameter) { return parameter.isAnnotationPresent(CommandArgument.class) && parameter.getType().equals(customArgumentType.getType()); } - /**{@inheritDoc}*/ + /** + * {@inheritDoc} + */ @Override public ArgumentBuilder apply(Parameter parameter) { String s = parameter.getAnnotation(CommandArgument.class).value(); - return CommandDispatcher.a(s.isEmpty()?parameter.getName():s,StringArgumentType.string()).suggests((commandContext, suggestionsBuilder) -> { + return CommandDispatcher.a(s.isEmpty() ? parameter.getName() : s, StringArgumentType.string()).suggests((commandContext, suggestionsBuilder) -> { for (String ss : customArgumentType.suggest(commandContext.getSource().getBukkitSender())) { suggestionsBuilder.suggest(ss); } diff --git a/src/main/java/dev/efekos/arn/resolver/impl/handler/HndCustomArg.java b/src/main/java/dev/efekos/arn/resolver/impl/handler/HndCustomArg.java index 57ecde2..29f4754 100644 --- a/src/main/java/dev/efekos/arn/resolver/impl/handler/HndCustomArg.java +++ b/src/main/java/dev/efekos/arn/resolver/impl/handler/HndCustomArg.java @@ -51,29 +51,36 @@ public final class HndCustomArg implements CommandHandlerMethodArgumentResolver /** * Creates a new resolver. + * * @param customArgumentType An instance of the {@link CustomArgumentType} this resolver resolves. */ public HndCustomArg(CustomArgumentType customArgumentType) { this.customArgumentType = customArgumentType; } - /**{@inheritDoc}*/ + /** + * {@inheritDoc} + */ @Override public boolean isApplicable(Parameter parameter) { return parameter.isAnnotationPresent(CommandArgument.class) && parameter.getType().equals(customArgumentType.getType()); } - /**{@inheritDoc}*/ + /** + * {@inheritDoc} + */ @Override public boolean requireCommandArgument() { return true; } - /**{@inheritDoc}*/ + /** + * {@inheritDoc} + */ @Override public Object resolve(Parameter parameter, CommandHandlerMethod method, CommandContext context) throws CommandSyntaxException { String s = parameter.getAnnotation(CommandArgument.class).value(); String string = StringArgumentType.getString(context, s.isEmpty() ? parameter.getName() : s); - return customArgumentType.parse(context.getSource().getBukkitSender(),string); + return customArgumentType.parse(context.getSource().getBukkitSender(), string); } }