I hate the fact that we started using Checkstyle.

Whose decision was that anyway..?
This commit is contained in:
Alexander Söderberg 2021-07-10 11:38:42 +01:00 committed by Jason
parent 5934c2fd3b
commit 6871341291
4 changed files with 21 additions and 10 deletions

View file

@ -485,7 +485,8 @@ public final class AnnotationParser<C> {
builder = builder.senderType(senderType); builder = builder.senderType(senderType);
} }
try { try {
final MethodCommandExecutionHandler.CommandMethodContext<C> context = new MethodCommandExecutionHandler.CommandMethodContext<>( final MethodCommandExecutionHandler.CommandMethodContext<C> context =
new MethodCommandExecutionHandler.CommandMethodContext<>(
instance, instance,
commandArguments, commandArguments,
method, method,
@ -494,8 +495,9 @@ public final class AnnotationParser<C> {
/* Create the command execution handler */ /* Create the command execution handler */
CommandExecutionHandler<C> commandExecutionHandler = new MethodCommandExecutionHandler<>(context); CommandExecutionHandler<C> commandExecutionHandler = new MethodCommandExecutionHandler<>(context);
for (final Map.Entry<Predicate<Method>, Function<MethodCommandExecutionHandler.CommandMethodContext<C>, MethodCommandExecutionHandler<C>>> entry : for (final Map.Entry<Predicate<Method>, Function<MethodCommandExecutionHandler.CommandMethodContext<C>,
commandMethodFactories.entrySet()) { MethodCommandExecutionHandler<C>>> entry
: this.commandMethodFactories.entrySet()) {
if (entry.getKey().test(method)) { if (entry.getKey().test(method)) {
commandExecutionHandler = entry.getValue().apply(context); commandExecutionHandler = entry.getValue().apply(context);

View file

@ -74,10 +74,12 @@ public class MethodCommandExecutionHandler<C> implements CommandExecutionHandler
public void execute(final @NonNull CommandContext<C> commandContext) { public void execute(final @NonNull CommandContext<C> commandContext) {
/* Invoke the command method */ /* Invoke the command method */
try { try {
this.methodHandle.invokeWithArguments(createParameterValues( this.methodHandle.invokeWithArguments(
commandContext, this.createParameterValues(
commandContext.flags(), commandContext,
true) commandContext.flags(),
true
)
); );
} catch (final Error e) { } catch (final Error e) {
throw e; throw e;
@ -86,7 +88,15 @@ public class MethodCommandExecutionHandler<C> implements CommandExecutionHandler
} }
} }
protected List<Object> createParameterValues( /**
* Creates a list containing the values for all method parameters
*
* @param commandContext The context
* @param flagContext The flag context
* @param throwOnMissing Whether exceptions should be thrown on missing parameters
* @return A list containing all parameters, in order
*/
protected final List<Object> createParameterValues(
final CommandContext<C> commandContext, final CommandContext<C> commandContext,
final FlagContext flagContext, final FlagContext flagContext,
final boolean throwOnMissing final boolean throwOnMissing

View file

@ -57,7 +57,7 @@ public interface CommandExecutionHandler<C> {
default CompletableFuture<@Nullable Object> executeFuture(@NonNull CommandContext<C> commandContext) { default CompletableFuture<@Nullable Object> executeFuture(@NonNull CommandContext<C> commandContext) {
final CompletableFuture<Object> future = new CompletableFuture<>(); final CompletableFuture<Object> future = new CompletableFuture<>();
try { try {
execute(commandContext); this.execute(commandContext);
/* The command executed successfully */ /* The command executed successfully */
future.complete(null); future.complete(null);
} catch (final Throwable throwable) { } catch (final Throwable throwable) {

View file

@ -24,7 +24,6 @@
package cloud.commandframework.extra.confirmation; package cloud.commandframework.extra.confirmation;
import cloud.commandframework.CommandManager; import cloud.commandframework.CommandManager;
import cloud.commandframework.context.CommandContext;
import cloud.commandframework.execution.CommandExecutionHandler; import cloud.commandframework.execution.CommandExecutionHandler;
import cloud.commandframework.execution.postprocessor.CommandPostprocessingContext; import cloud.commandframework.execution.postprocessor.CommandPostprocessingContext;
import cloud.commandframework.execution.postprocessor.CommandPostprocessor; import cloud.commandframework.execution.postprocessor.CommandPostprocessor;