Make CommandExecutionHandler#executeFuture return CompletableFuture<Void> instead of CompletableFuture<Object>
The value of the completed future is never used, void makes this more obvious
This commit is contained in:
parent
9e39b0ca8e
commit
a92ff9d39a
2 changed files with 6 additions and 5 deletions
|
|
@ -54,8 +54,8 @@ public interface CommandExecutionHandler<C> {
|
||||||
* @return future that completes when the command has finished execution
|
* @return future that completes when the command has finished execution
|
||||||
* @since 1.6.0
|
* @since 1.6.0
|
||||||
*/
|
*/
|
||||||
default CompletableFuture<@Nullable Object> executeFuture(@NonNull CommandContext<C> commandContext) {
|
default CompletableFuture<@Nullable Void> executeFuture(@NonNull CommandContext<C> commandContext) {
|
||||||
final CompletableFuture<Object> future = new CompletableFuture<>();
|
final CompletableFuture<Void> future = new CompletableFuture<>();
|
||||||
try {
|
try {
|
||||||
this.execute(commandContext);
|
this.execute(commandContext);
|
||||||
/* The command executed successfully */
|
/* The command executed successfully */
|
||||||
|
|
@ -97,7 +97,7 @@ public interface CommandExecutionHandler<C> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
CompletableFuture<@Nullable Object> executeFuture(
|
CompletableFuture<@Nullable Void> executeFuture(
|
||||||
@NonNull CommandContext<C> commandContext
|
@NonNull CommandContext<C> commandContext
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -68,13 +68,14 @@ private class KotlinMethodCommandExecutionHandler<C>(
|
||||||
context: CommandMethodContext<C>
|
context: CommandMethodContext<C>
|
||||||
) : MethodCommandExecutionHandler<C>(context) {
|
) : MethodCommandExecutionHandler<C>(context) {
|
||||||
|
|
||||||
override fun executeFuture(commandContext: CommandContext<C>): CompletableFuture<Any?> {
|
override fun executeFuture(commandContext: CommandContext<C>): CompletableFuture<Void?> {
|
||||||
val instance = context().instance()
|
val instance = context().instance()
|
||||||
val params = createParameterValues(commandContext, commandContext.flags(), false)
|
val params = createParameterValues(commandContext, commandContext.flags(), false)
|
||||||
// We need to propagate exceptions to the caller.
|
// We need to propagate exceptions to the caller.
|
||||||
return coroutineScope
|
return coroutineScope
|
||||||
.async(this@KotlinMethodCommandExecutionHandler.coroutineContext) {
|
.async<Void?>(this@KotlinMethodCommandExecutionHandler.coroutineContext) {
|
||||||
context().method().kotlinFunction?.callSuspend(instance, *params.toTypedArray())
|
context().method().kotlinFunction?.callSuspend(instance, *params.toTypedArray())
|
||||||
|
null
|
||||||
}
|
}
|
||||||
.asCompletableFuture()
|
.asCompletableFuture()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue