From 197764622c254913393a7076c55188060b7788d6 Mon Sep 17 00:00:00 2001 From: benwoo1110 <30431861+benwoo1110@users.noreply.github.com> Date: Thu, 7 Jan 2021 11:12:35 +0800 Subject: [PATCH] Testing getContextValue for CommandCompletions. --- .../commandTools/MVCommandCompletions.java | 11 +++++++++++ .../MultiverseCore/commands/CreateCommand.java | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/onarandombox/MultiverseCore/commandTools/MVCommandCompletions.java b/src/main/java/com/onarandombox/MultiverseCore/commandTools/MVCommandCompletions.java index a11be118..d65b9ad9 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commandTools/MVCommandCompletions.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commandTools/MVCommandCompletions.java @@ -13,6 +13,7 @@ import co.aikar.commands.CommandIssuer; import co.aikar.commands.PaperCommandCompletions; import co.aikar.commands.RegisteredCommand; import co.aikar.commands.RootCommand; +import com.dumptruckman.minecraft.util.Logging; import com.onarandombox.MultiverseCore.MultiverseCore; import com.onarandombox.MultiverseCore.api.MVWorldManager; import com.onarandombox.MultiverseCore.api.MultiverseWorld; @@ -25,6 +26,7 @@ import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; +import java.io.Console; import java.io.File; import java.text.DecimalFormat; import java.util.Arrays; @@ -56,6 +58,7 @@ public class MVCommandCompletions extends PaperCommandCompletions { this.plugin = plugin; this.worldManager = plugin.getMVWorldManager(); + registerAsyncCompletion("worldSettings", this::suggestWorldSettings); registerAsyncCompletion("scripts", this::suggestScripts); registerAsyncCompletion("subCommands", this::suggestSubCommands); registerAsyncCompletion("MVWorlds", this::suggestMVWorlds); @@ -74,6 +77,14 @@ public class MVCommandCompletions extends PaperCommandCompletions { registerStaticCompletion("toggles", this::suggestToggles); } + @NotNull + private Collection suggestWorldSettings(@NotNull BukkitCommandCompletionContext context) { + context.getConfig() + final String[] contextValue = context.getContextValue(String[].class); + Logging.info(Arrays.toString(contextValue)); + return Collections.emptyList(); + } + @NotNull private Collection suggestScripts(@NotNull BukkitCommandCompletionContext context) { Buscript scriptAPI = this.plugin.getScriptAPI(); diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/CreateCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/CreateCommand.java index 0fe65383..16a1fada 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commands/CreateCommand.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commands/CreateCommand.java @@ -36,7 +36,7 @@ public class CreateCommand extends MultiverseCommand { @Subcommand("create") @CommandPermission("multiverse.core.create") @Syntax(" -s [seed] -g [generator[:id]] -t [worldtype] [-n] -a [true|false]") - @CommandCompletion("@empty @environments -s|-g|-t|-n|-a") + @CommandCompletion("@empty @environments @worldSettings") @Description("Creates a new world and loads it.") public void onCreateCommand(@NotNull CommandSender sender,