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")
|
@Subcommand("anchor delete")
|
||||||
@CommandPermission("multiverse.core.anchor.delete")
|
@CommandPermission("multiverse.core.anchor.delete")
|
||||||
@CommandCompletion("")
|
@CommandCompletion("@anchornames")
|
||||||
@Syntax("<name>")
|
@Syntax("<name>")
|
||||||
@Description("")
|
@Description("")
|
||||||
void onAnchorDeleteCommand(
|
void onAnchorDeleteCommand(
|
||||||
|
@ -26,6 +26,7 @@ import org.bukkit.World;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jvnet.hk2.annotations.Service;
|
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.config.MVCoreConfig;
|
||||||
import org.mvplugins.multiverse.core.destination.DestinationsProvider;
|
import org.mvplugins.multiverse.core.destination.DestinationsProvider;
|
||||||
import org.mvplugins.multiverse.core.destination.ParsedDestination;
|
import org.mvplugins.multiverse.core.destination.ParsedDestination;
|
||||||
@ -38,19 +39,23 @@ class MVCommandCompletions extends PaperCommandCompletions {
|
|||||||
|
|
||||||
private final MVCommandManager commandManager;
|
private final MVCommandManager commandManager;
|
||||||
private final WorldManager worldManager;
|
private final WorldManager worldManager;
|
||||||
|
private final AnchorManager anchorManager;
|
||||||
private final DestinationsProvider destinationsProvider;
|
private final DestinationsProvider destinationsProvider;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
MVCommandCompletions(
|
MVCommandCompletions(
|
||||||
@NotNull MVCommandManager mvCommandManager,
|
@NotNull MVCommandManager mvCommandManager,
|
||||||
@NotNull WorldManager worldManager,
|
@NotNull WorldManager worldManager,
|
||||||
|
@NotNull AnchorManager anchorManager,
|
||||||
@NotNull DestinationsProvider destinationsProvider,
|
@NotNull DestinationsProvider destinationsProvider,
|
||||||
@NotNull MVCoreConfig config) {
|
@NotNull MVCoreConfig config) {
|
||||||
super(mvCommandManager);
|
super(mvCommandManager);
|
||||||
this.commandManager = mvCommandManager;
|
this.commandManager = mvCommandManager;
|
||||||
this.worldManager = worldManager;
|
this.worldManager = worldManager;
|
||||||
|
this.anchorManager = anchorManager;
|
||||||
this.destinationsProvider = destinationsProvider;
|
this.destinationsProvider = destinationsProvider;
|
||||||
|
|
||||||
|
registerAsyncCompletion("anchornames", this::suggestAnchorNames);
|
||||||
registerAsyncCompletion("commands", this::suggestCommands);
|
registerAsyncCompletion("commands", this::suggestCommands);
|
||||||
registerAsyncCompletion("destinations", this::suggestDestinations);
|
registerAsyncCompletion("destinations", this::suggestDestinations);
|
||||||
registerStaticCompletion("difficulties", suggestEnums(Difficulty.class));
|
registerStaticCompletion("difficulties", suggestEnums(Difficulty.class));
|
||||||
@ -70,6 +75,10 @@ class MVCommandCompletions extends PaperCommandCompletions {
|
|||||||
setDefaultCompletion("mvworlds", LoadedMultiverseWorld.class);
|
setDefaultCompletion("mvworlds", LoadedMultiverseWorld.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Collection<String> suggestAnchorNames(BukkitCommandCompletionContext context) {
|
||||||
|
return anchorManager.getAnchors(context.getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
private Collection<String> suggestCommands(BukkitCommandCompletionContext context) {
|
private Collection<String> suggestCommands(BukkitCommandCompletionContext context) {
|
||||||
String rootCmdName = context.getConfig();
|
String rootCmdName = context.getConfig();
|
||||||
if (rootCmdName == null) {
|
if (rootCmdName == null) {
|
||||||
|
Loading…
Reference in New Issue
Block a user