make SuggestionProvider use CompletableFuture
This commit is contained in:
parent
35709b702d
commit
c2aec2842a
5 changed files with 11 additions and 6 deletions
|
|
@ -7,7 +7,7 @@ plugins {
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "de.kentoj.scrow"
|
group = "de.kentoj.scrow"
|
||||||
version = "0.2"
|
version = "0.4"
|
||||||
|
|
||||||
fun RepositoryHandler.scrowRepo() = maven {
|
fun RepositoryHandler.scrowRepo() = maven {
|
||||||
name = "scrow"
|
name = "scrow"
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import de.kentoj.kencommandapi.BukkitCommandContext;
|
||||||
import de.kentoj.kencommandapi.api.processing.CommandException;
|
import de.kentoj.kencommandapi.api.processing.CommandException;
|
||||||
import de.kentoj.kencommandapi.api.structure.argument.ArgumentType;
|
import de.kentoj.kencommandapi.api.structure.argument.ArgumentType;
|
||||||
import de.kentoj.kencommandapi.api.structure.argument.SuggestionProvider;
|
import de.kentoj.kencommandapi.api.structure.argument.SuggestionProvider;
|
||||||
|
import de.kentoj.kencommandapi.api.structure.argument.suggestion.NoSuggestionProvider;
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
@ -37,6 +38,6 @@ public class OfflinePlayerArgumentType implements ArgumentType<CommandSender, Bu
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SuggestionProvider<CommandSender, BukkitCommandContext> defaultSuggestionProvider() {
|
public SuggestionProvider<CommandSender, BukkitCommandContext> defaultSuggestionProvider() {
|
||||||
return context -> Set.of();
|
return new NoSuggestionProvider<>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import de.kentoj.kencommandapi.BukkitCommandContext;
|
||||||
import de.kentoj.kencommandapi.api.processing.CommandException;
|
import de.kentoj.kencommandapi.api.processing.CommandException;
|
||||||
import de.kentoj.kencommandapi.api.structure.argument.ArgumentType;
|
import de.kentoj.kencommandapi.api.structure.argument.ArgumentType;
|
||||||
import de.kentoj.kencommandapi.api.structure.argument.SuggestionProvider;
|
import de.kentoj.kencommandapi.api.structure.argument.SuggestionProvider;
|
||||||
|
import de.kentoj.kencommandapi.api.structure.argument.suggestion.NoSuggestionProvider;
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
@ -28,6 +29,6 @@ public class PlayerArgumentType implements ArgumentType<CommandSender, BukkitCom
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SuggestionProvider<CommandSender, BukkitCommandContext> defaultSuggestionProvider() {
|
public SuggestionProvider<CommandSender, BukkitCommandContext> defaultSuggestionProvider() {
|
||||||
return context -> Set.of();
|
return new NoSuggestionProvider<>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,9 @@ package de.kentoj.kencommandapi.api.structure.argument;
|
||||||
import de.kentoj.kencommandapi.api.processing.CommandContext;
|
import de.kentoj.kencommandapi.api.processing.CommandContext;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
public interface SuggestionProvider<T, S extends CommandContext<T, ?>> {
|
public interface SuggestionProvider<T, S extends CommandContext<T, ?>> {
|
||||||
|
|
||||||
Set<String> suggest(S context);
|
CompletableFuture<Set<String>> suggest(S context);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,14 @@ package de.kentoj.kencommandapi.api.structure.argument.suggestion;
|
||||||
import de.kentoj.kencommandapi.api.processing.CommandContext;
|
import de.kentoj.kencommandapi.api.processing.CommandContext;
|
||||||
import de.kentoj.kencommandapi.api.structure.argument.SuggestionProvider;
|
import de.kentoj.kencommandapi.api.structure.argument.SuggestionProvider;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
public class NoSuggestionProvider<T, S extends CommandContext<T, ?>> implements SuggestionProvider<T, S> {
|
public class NoSuggestionProvider<T, S extends CommandContext<T, ?>> implements SuggestionProvider<T, S> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<String> suggest(S context) {
|
public CompletableFuture<Set<String>> suggest(S ctx) {
|
||||||
return Set.of();
|
return CompletableFuture.completedFuture(Collections.emptySet());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue