From 7044bf8ec7aaaf197365ee02be249118259ca154 Mon Sep 17 00:00:00 2001 From: Slqmy <90862990+Slqmy@users.noreply.github.com> Date: Fri, 2 Aug 2024 19:09:46 +0100 Subject: [PATCH] Add set language command with language arguments --- .../TemplatePaperPlugin.java | 4 ++- .../commands/SetLanguageCommand.java | 29 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 src/main/java/net/slqmy/template_paper_plugin/commands/SetLanguageCommand.java diff --git a/src/main/java/net/slqmy/template_paper_plugin/TemplatePaperPlugin.java b/src/main/java/net/slqmy/template_paper_plugin/TemplatePaperPlugin.java index 024e79a4..45838aaf 100644 --- a/src/main/java/net/slqmy/template_paper_plugin/TemplatePaperPlugin.java +++ b/src/main/java/net/slqmy/template_paper_plugin/TemplatePaperPlugin.java @@ -6,7 +6,7 @@ import dev.jorel.commandapi.CommandAPI; import dev.jorel.commandapi.CommandAPIBukkitConfig; - +import net.slqmy.template_paper_plugin.commands.SetLanguageCommand; import net.slqmy.template_paper_plugin.data.player.PlayerDataManager; import net.slqmy.template_paper_plugin.language.LanguageManager; @@ -35,6 +35,8 @@ public void onEnable() { playerDataManager = new PlayerDataManager(this); languageManager = new LanguageManager(this); + + new SetLanguageCommand(this); } @Override diff --git a/src/main/java/net/slqmy/template_paper_plugin/commands/SetLanguageCommand.java b/src/main/java/net/slqmy/template_paper_plugin/commands/SetLanguageCommand.java new file mode 100644 index 00000000..e48db033 --- /dev/null +++ b/src/main/java/net/slqmy/template_paper_plugin/commands/SetLanguageCommand.java @@ -0,0 +1,29 @@ +package net.slqmy.template_paper_plugin.commands; + +import dev.jorel.commandapi.CommandAPICommand; +import dev.jorel.commandapi.arguments.MultiLiteralArgument; + +import java.util.stream.Stream; + +import net.slqmy.template_paper_plugin.TemplatePaperPlugin; +import net.slqmy.template_paper_plugin.language.Language; +import net.slqmy.template_paper_plugin.language.LanguageData; + +public class SetLanguageCommand extends CommandAPICommand { + + public SetLanguageCommand(TemplatePaperPlugin plugin) { + super("set-language"); + + withArguments(new MultiLiteralArgument("language", Stream.of(Language.values()).map((language) -> { + LanguageData data = plugin.getLanguageManager().getLanguageData(language); + + return data.getName(); + }).toArray(String[]::new))); + + executes((sender, arguments) -> { + + }); + + register(plugin); + } +}