From 1ca2d36f5fa725bcba82e731469bba7e26ca7f86 Mon Sep 17 00:00:00 2001 From: EpicKnarvik97 Date: Tue, 9 Nov 2021 02:01:11 +0100 Subject: [PATCH] Adds an unfinished implementation of the config command, which is only able to display config options for now --- .../stargate/command/CommandConfig.java | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 src/main/java/net/knarcraft/stargate/command/CommandConfig.java diff --git a/src/main/java/net/knarcraft/stargate/command/CommandConfig.java b/src/main/java/net/knarcraft/stargate/command/CommandConfig.java new file mode 100644 index 0000000..cf4f1d8 --- /dev/null +++ b/src/main/java/net/knarcraft/stargate/command/CommandConfig.java @@ -0,0 +1,50 @@ +package net.knarcraft.stargate.command; + +import net.knarcraft.stargate.Stargate; +import net.knarcraft.stargate.config.ConfigOption; +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; + +/** + * This command represents the config command for changing config values + */ +public class CommandConfig implements CommandExecutor { + + @Override + public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s, + @NotNull String[] args) { + if (commandSender instanceof Player player) { + if (!player.hasPermission("stargate.admin")) { + Stargate.getMessageSender().sendErrorMessage(commandSender, "Permission Denied"); + return true; + } + } + + if (args.length > 1) { + //TODO: Do stuff + } else { + //TODO: Display list of config values + displayConfigValues(commandSender); + } + return true; + } + + /** + * Displays the name and a small description of every config value + * + * @param sender

The command sender to display the config list to

+ */ + private void displayConfigValues(CommandSender sender) { + sender.sendMessage(ChatColor.GREEN + Stargate.getBackupString("prefix") + ChatColor.GOLD + + "Config values:"); + for (ConfigOption option : ConfigOption.values()) { + sender.sendMessage(ChatColor.GOLD + option.getName() + ChatColor.WHITE + " - " + ChatColor.GREEN + + option.getDescription() + " (" + option.getDefaultValue() + ")"); + } + } + +}