mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-21 18:15:26 +01:00
Implement auto-complete for anchor names
This commit is contained in:
parent
5337bc75cd
commit
e8af526be5
@ -29,7 +29,7 @@ class AnchorDeleteCommand extends MultiverseCommand {
|
||||
|
||||
@Subcommand("anchor delete")
|
||||
@CommandPermission("multiverse.core.anchor.delete")
|
||||
@CommandCompletion("")
|
||||
@CommandCompletion("@anchornames")
|
||||
@Syntax("<name>")
|
||||
@Description("")
|
||||
void onAnchorDeleteCommand(
|
||||
|
@ -26,6 +26,7 @@ import org.bukkit.World;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
import org.mvplugins.multiverse.core.anchor.AnchorManager;
|
||||
import org.mvplugins.multiverse.core.config.MVCoreConfig;
|
||||
import org.mvplugins.multiverse.core.destination.DestinationsProvider;
|
||||
import org.mvplugins.multiverse.core.destination.ParsedDestination;
|
||||
@ -38,19 +39,23 @@ class MVCommandCompletions extends PaperCommandCompletions {
|
||||
|
||||
private final MVCommandManager commandManager;
|
||||
private final WorldManager worldManager;
|
||||
private final AnchorManager anchorManager;
|
||||
private final DestinationsProvider destinationsProvider;
|
||||
|
||||
@Inject
|
||||
MVCommandCompletions(
|
||||
@NotNull MVCommandManager mvCommandManager,
|
||||
@NotNull WorldManager worldManager,
|
||||
@NotNull AnchorManager anchorManager,
|
||||
@NotNull DestinationsProvider destinationsProvider,
|
||||
@NotNull MVCoreConfig config) {
|
||||
super(mvCommandManager);
|
||||
this.commandManager = mvCommandManager;
|
||||
this.worldManager = worldManager;
|
||||
this.anchorManager = anchorManager;
|
||||
this.destinationsProvider = destinationsProvider;
|
||||
|
||||
registerAsyncCompletion("anchornames", this::suggestAnchorNames);
|
||||
registerAsyncCompletion("commands", this::suggestCommands);
|
||||
registerAsyncCompletion("destinations", this::suggestDestinations);
|
||||
registerStaticCompletion("difficulties", suggestEnums(Difficulty.class));
|
||||
@ -70,6 +75,10 @@ class MVCommandCompletions extends PaperCommandCompletions {
|
||||
setDefaultCompletion("mvworlds", LoadedMultiverseWorld.class);
|
||||
}
|
||||
|
||||
private Collection<String> suggestAnchorNames(BukkitCommandCompletionContext context) {
|
||||
return anchorManager.getAnchors(context.getPlayer());
|
||||
}
|
||||
|
||||
private Collection<String> suggestCommands(BukkitCommandCompletionContext context) {
|
||||
String rootCmdName = context.getConfig();
|
||||
if (rootCmdName == null) {
|
||||
|
Loading…
Reference in New Issue
Block a user