diff --git a/src/main/java/dev/twme/debugstickpro/DebugStickPro.java b/src/main/java/dev/twme/debugstickpro/DebugStickPro.java index 7f8dbeb..899704a 100644 --- a/src/main/java/dev/twme/debugstickpro/DebugStickPro.java +++ b/src/main/java/dev/twme/debugstickpro/DebugStickPro.java @@ -1,14 +1,15 @@ package dev.twme.debugstickpro; import dev.twme.debugstickpro.blockdatautil.BlockDataSeparater; +import dev.twme.debugstickpro.commands.MainCommandTabComplete; +import dev.twme.debugstickpro.commands.MainCommands; import dev.twme.debugstickpro.configs.ConfigFile; import dev.twme.debugstickpro.configs.ConfigLoader; import dev.twme.debugstickpro.configs.LangLoader; import dev.twme.debugstickpro.display.ActionBarDisplayTask; import dev.twme.debugstickpro.hook.CoreProtectUtil; -import dev.twme.debugstickpro.mode.freeze.FreezeBlockManager; -import dev.twme.debugstickpro.commands.MainCommands; import dev.twme.debugstickpro.listeners.*; +import dev.twme.debugstickpro.mode.freeze.FreezeBlockManager; import dev.twme.debugstickpro.util.Log; import org.bukkit.Bukkit; import org.bukkit.event.Listener; @@ -23,7 +24,7 @@ public final class DebugStickPro extends JavaPlugin { public static final int ConfigVersion = 3; // TODO: 如果更改此值,請確保在 lang.yml 中也更改了相應的值 - public static final int LangVersion = 2; + public static final int LangVersion = 3; @Override public void onEnable() { @@ -59,6 +60,7 @@ public void onDisable() { private void registerCommands() { this.getCommand("debugstickpro").setExecutor(new MainCommands()); + this.getCommand("debugstickpro").setTabCompleter(new MainCommandTabComplete()); } private void registerListeners() { diff --git a/src/main/java/dev/twme/debugstickpro/commands/MainCommandTabComplete.java b/src/main/java/dev/twme/debugstickpro/commands/MainCommandTabComplete.java new file mode 100644 index 0000000..4511b27 --- /dev/null +++ b/src/main/java/dev/twme/debugstickpro/commands/MainCommandTabComplete.java @@ -0,0 +1,57 @@ +package dev.twme.debugstickpro.commands; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.command.TabCompleter; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.ArrayList; +import java.util.List; + +public class MainCommandTabComplete implements TabCompleter { + @Override + public @Nullable List onTabComplete(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s, @NotNull String[] strings) { + if (!(commandSender instanceof Player)) { + return null; + } + ArrayList list = new ArrayList<>(); + Player player = (Player) commandSender; + if (strings.length == 1) { + if (player.hasPermission("debugstickpro.help")) { + list.add("help"); + } + if (player.hasPermission("debugstickpro.reload")) { + list.add("reload"); + } + if (player.hasPermission("debugstickpro.give")) { + list.add("give"); + } + if (player.hasPermission("debugstickpro.mode")) { + list.add("mode"); + } + return list; + } + + if (strings.length == 2) { + if (strings[0].equalsIgnoreCase("give")) { + return null; + } + + if (strings[0].equalsIgnoreCase("mode")) { + if (player.hasPermission("debugstickpro.mode")) { + list.add("classic"); + } + if (player.hasPermission("debugstickpro.mode.copy")) { + list.add("copy"); + } + if (player.hasPermission("debugstickpro.mode.freeze")) { + list.add("freeze"); + } + return list; + } + } + return list; + } +} diff --git a/src/main/java/dev/twme/debugstickpro/commands/MainCommands.java b/src/main/java/dev/twme/debugstickpro/commands/MainCommands.java index d9aa486..a507012 100644 --- a/src/main/java/dev/twme/debugstickpro/commands/MainCommands.java +++ b/src/main/java/dev/twme/debugstickpro/commands/MainCommands.java @@ -1,34 +1,24 @@ package dev.twme.debugstickpro.commands; -import dev.twme.debugstickpro.DebugStickPro; +import dev.twme.debugstickpro.commands.subcommand.GiveCommand; +import dev.twme.debugstickpro.commands.subcommand.HelpCommand; +import dev.twme.debugstickpro.commands.subcommand.ModeCommand; +import dev.twme.debugstickpro.commands.subcommand.ReloadCommand; import dev.twme.debugstickpro.configs.LangFile; -import dev.twme.debugstickpro.events.PlayerChangeDebugStickModeEvent; -import dev.twme.debugstickpro.playerdata.DebugStickMode; -import dev.twme.debugstickpro.playerdata.PlayerData; -import dev.twme.debugstickpro.playerdata.PlayerDataManager; -import dev.twme.debugstickpro.util.DebugStickItem; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.minimessage.MiniMessage; -import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; -import org.bukkit.command.TabCompleter; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; - -public class MainCommands implements CommandExecutor , TabCompleter { +public class MainCommands implements CommandExecutor { @Override public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s, @NotNull String[] strings) { - MiniMessage mm = MiniMessage.miniMessage(); - - if (!(commandSender instanceof Player)){ + if (!(commandSender instanceof Player)) { + MiniMessage mm = MiniMessage.miniMessage(); Component parsed = mm.deserialize(LangFile.CommandsMessages.YouAreNotPlayer); commandSender.sendMessage(parsed); return true; @@ -36,162 +26,19 @@ public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command Player player = (Player) commandSender; - if (strings.length == 0 || strings[0].equalsIgnoreCase("help")){ - Component parsed = mm.deserialize(LangFile.CommandsMessages.Help.Title); - player.sendMessage(parsed); - Component component = mm.deserialize(LangFile.CommandsMessages.Help.Usage); - player.sendMessage(component); - Component component1 = mm.deserialize(LangFile.CommandsMessages.Help.Description); - player.sendMessage(component1); - return true; + if (strings.length == 0 || strings[0].equalsIgnoreCase("help")) { + return HelpCommand.onHelpCommand(player, strings); } - if (strings[0].equalsIgnoreCase("reload")){ - DebugStickPro.getInstance().onReload(); - Component parsed = mm.deserialize(LangFile.CommandsMessages.Reload.Success); - player.sendMessage(parsed); - return true; + if (strings[0].equalsIgnoreCase("reload")) { + return ReloadCommand.onReloadCommand(player, strings); } - if (strings[0].equalsIgnoreCase("give")){ - if (strings.length == 1) { - player.getInventory().addItem(DebugStickItem.getDebugStickItem()); - - Component parsed = mm.deserialize(LangFile.CommandsMessages.Give.Success.replace("%player%", player.getName())); - player.sendMessage(parsed); - if (DebugStickItem.checkPlayer(player)) { - PlayerDataManager.addPlayerToDisplayList(player.getUniqueId()); - } - return true; - } else { - Player onlinePlayer = Bukkit.getPlayerExact(strings[1]); - if (onlinePlayer == null){ - Component parsed = mm.deserialize(LangFile.CommandsMessages.Give.NoPlayer); - player.sendMessage(parsed); - return true; - } else { - onlinePlayer.getInventory().addItem(DebugStickItem.getDebugStickItem()); - Component parsed = mm.deserialize(LangFile.CommandsMessages.Give.Success.replace("%player%", player.getName())); - player.sendMessage(parsed); - if (DebugStickItem.checkPlayer(onlinePlayer)) { - PlayerDataManager.addPlayerToDisplayList(onlinePlayer.getUniqueId()); - } - return true; - } - } + if (strings[0].equalsIgnoreCase("give")) { + return GiveCommand.onGiveCommand(player, strings); } if (strings[0].equalsIgnoreCase("mode")) { - if (!player.hasPermission("debugstickpro.mode")) { - Component parsed = mm.deserialize(LangFile.CommandsMessages.NoPermission); - player.sendMessage(parsed); - return true; - } - if (strings.length == 1) { - Component parsed = mm.deserialize(LangFile.CommandsMessages.Mode.Usage); - player.sendMessage(parsed); - return true; - } else { - if (strings[1].equalsIgnoreCase("classic")) { - PlayerData playerData = PlayerDataManager.getPlayerData(player.getUniqueId()); - - if (modeChangeEventCancelled(player.getUniqueId(), playerData.getDebugStickMode(), DebugStickMode.CLASSIC)) { - return true; - } - - PlayerDataManager.setPlayerData(player.getUniqueId(),playerData.setDebugStickMode(DebugStickMode.CLASSIC)); - Component parsed = mm.deserialize(LangFile.CommandsMessages.Mode.SuccessSetToClassic); - player.sendMessage(parsed); - return true; - } - if (strings[1].equalsIgnoreCase("copy")) { - if (player.hasPermission("debugstickpro.mode.copy")) { - PlayerData playerData = PlayerDataManager.getPlayerData(player.getUniqueId()); - - if (modeChangeEventCancelled(player.getUniqueId(), playerData.getDebugStickMode(), DebugStickMode.COPY)) { - return true; - } - - PlayerDataManager.setPlayerData(player.getUniqueId(),playerData.setDebugStickMode(DebugStickMode.COPY)); - Component parsed = mm.deserialize(LangFile.CommandsMessages.Mode.SuccessSetToCopy); - player.sendMessage(parsed); - return true; - } else { - Component parsed = mm.deserialize(LangFile.CommandsMessages.NoPermission); - player.sendMessage(parsed); - return true; - } - } - if (strings[1].equalsIgnoreCase("freeze")) { - if (player.hasPermission("debugstickpro.mode.freeze")) { - PlayerData playerData = PlayerDataManager.getPlayerData(player.getUniqueId()); - - if (modeChangeEventCancelled(player.getUniqueId(), playerData.getDebugStickMode(), DebugStickMode.FREEZE)) { - return true; - } - - PlayerDataManager.setPlayerData(player.getUniqueId(),PlayerDataManager.getPlayerData(player.getUniqueId()).setDebugStickMode(DebugStickMode.FREEZE)); - Component parsed = mm.deserialize(LangFile.CommandsMessages.Mode.SuccessSetToFreeze); - player.sendMessage(parsed); - return true; - } else { - Component parsed = mm.deserialize(LangFile.CommandsMessages.NoPermission); - player.sendMessage(parsed); - return true; - } - } - } + return ModeCommand.onModeCommand(player, strings); } return false; } - - @Override - public @Nullable List onTabComplete(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s, @NotNull String[] strings) { - if (!(commandSender instanceof Player)){ - return null; - } - ArrayList list = new ArrayList<>(); - Player player = (Player) commandSender; - if (strings.length == 1){ - if (player.hasPermission("debugstickpro.help")){ - list.add("help"); - } - if (player.hasPermission("debugstickpro.reload")){ - list.add("reload"); - } - if (player.hasPermission("debugstickpro.give")){ - list.add("give"); - } - if (player.hasPermission("debugstickpro.mode")){ - list.add("mode"); - } - return list; - } - - if (strings.length == 2){ - if (strings[0].equalsIgnoreCase("give")){ - return null; - } - - if (strings[0].equalsIgnoreCase("mode")){ - if (player.hasPermission("debugstickpro.mode")){ - list.add("classic"); - } - if (player.hasPermission("debugstickpro.mode.copy")){ - list.add("copy"); - } - if (player.hasPermission("debugstickpro.mode.freeze")){ - list.add("freeze"); - } - return list; - } - } - return list; - } - - public static boolean modeChangeEventCancelled(UUID playerUUID, DebugStickMode previousMode, DebugStickMode newMode) { - PlayerChangeDebugStickModeEvent event = new PlayerChangeDebugStickModeEvent(playerUUID, previousMode, newMode); - - Bukkit.getPluginManager().callEvent(event); - - return event.isCancelled(); - } } diff --git a/src/main/java/dev/twme/debugstickpro/commands/subcommand/GiveCommand.java b/src/main/java/dev/twme/debugstickpro/commands/subcommand/GiveCommand.java new file mode 100644 index 0000000..0a819de --- /dev/null +++ b/src/main/java/dev/twme/debugstickpro/commands/subcommand/GiveCommand.java @@ -0,0 +1,47 @@ +package dev.twme.debugstickpro.commands.subcommand; + +import dev.twme.debugstickpro.configs.LangFile; +import dev.twme.debugstickpro.playerdata.PlayerDataManager; +import dev.twme.debugstickpro.util.DebugStickItem; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.minimessage.MiniMessage; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; + +public class GiveCommand { + public static boolean onGiveCommand(Player player, String[] args) { + MiniMessage mm = MiniMessage.miniMessage(); + + if (!player.hasPermission("debugstickpro.give")) { + Component parsed = mm.deserialize(LangFile.CommandsMessages.NoPermission); + player.sendMessage(parsed); + return true; + } + + if (args.length == 1) { + player.getInventory().addItem(DebugStickItem.getDebugStickItem()); + + Component parsed = mm.deserialize(LangFile.CommandsMessages.Give.Success.replace("%player%", player.getName())); + player.sendMessage(parsed); + if (DebugStickItem.checkPlayer(player)) { + PlayerDataManager.addPlayerToDisplayList(player.getUniqueId()); + } + return true; + } else { + Player onlinePlayer = Bukkit.getPlayerExact(args[1]); + if (onlinePlayer == null) { + Component parsed = mm.deserialize(LangFile.CommandsMessages.Give.NoPlayer); + player.sendMessage(parsed); + return true; + } else { + onlinePlayer.getInventory().addItem(DebugStickItem.getDebugStickItem()); + Component parsed = mm.deserialize(LangFile.CommandsMessages.Give.Success.replace("%player%", player.getName())); + player.sendMessage(parsed); + if (DebugStickItem.checkPlayer(onlinePlayer)) { + PlayerDataManager.addPlayerToDisplayList(onlinePlayer.getUniqueId()); + } + return true; + } + } + } +} diff --git a/src/main/java/dev/twme/debugstickpro/commands/subcommand/HelpCommand.java b/src/main/java/dev/twme/debugstickpro/commands/subcommand/HelpCommand.java new file mode 100644 index 0000000..fe53e7c --- /dev/null +++ b/src/main/java/dev/twme/debugstickpro/commands/subcommand/HelpCommand.java @@ -0,0 +1,24 @@ +package dev.twme.debugstickpro.commands.subcommand; + +import dev.twme.debugstickpro.configs.LangFile; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.minimessage.MiniMessage; +import org.bukkit.entity.Player; + +public class HelpCommand { + public static boolean onHelpCommand(Player player, String[] args) { + MiniMessage mm = MiniMessage.miniMessage(); + if (args.length > 1) { + return false; + } + if (!player.hasPermission("debugstickpro.help")) { + Component parsed = mm.deserialize(LangFile.CommandsMessages.NoPermission); + player.sendMessage(parsed); + return true; + } + for (Component component : LangFile.CommandsMessages.Help.HelpMessage) { + player.sendMessage(component); + } + return true; + } +} diff --git a/src/main/java/dev/twme/debugstickpro/commands/subcommand/ModeCommand.java b/src/main/java/dev/twme/debugstickpro/commands/subcommand/ModeCommand.java new file mode 100644 index 0000000..0d5dfb5 --- /dev/null +++ b/src/main/java/dev/twme/debugstickpro/commands/subcommand/ModeCommand.java @@ -0,0 +1,90 @@ +package dev.twme.debugstickpro.commands.subcommand; + +import dev.twme.debugstickpro.configs.LangFile; +import dev.twme.debugstickpro.events.PlayerChangeDebugStickModeEvent; +import dev.twme.debugstickpro.playerdata.DebugStickMode; +import dev.twme.debugstickpro.playerdata.PlayerData; +import dev.twme.debugstickpro.playerdata.PlayerDataManager; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.minimessage.MiniMessage; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; + +import java.util.UUID; + +public class ModeCommand { + + public static boolean modeChangeEventCancelled(UUID playerUUID, DebugStickMode previousMode, DebugStickMode newMode) { + PlayerChangeDebugStickModeEvent event = new PlayerChangeDebugStickModeEvent(playerUUID, previousMode, newMode); + + Bukkit.getPluginManager().callEvent(event); + + return event.isCancelled(); + } + + public static boolean onModeCommand(Player player, String[] args) { + MiniMessage mm = MiniMessage.miniMessage(); + + if (!player.hasPermission("debugstickpro.mode")) { + Component parsed = mm.deserialize(LangFile.CommandsMessages.NoPermission); + player.sendMessage(parsed); + return true; + } + if (args.length == 1) { + Component parsed = mm.deserialize(LangFile.CommandsMessages.Mode.Usage); + player.sendMessage(parsed); + return true; + } else { + if (args[1].equalsIgnoreCase("classic")) { + PlayerData playerData = PlayerDataManager.getPlayerData(player.getUniqueId()); + + if (modeChangeEventCancelled(player.getUniqueId(), playerData.getDebugStickMode(), DebugStickMode.CLASSIC)) { + return true; + } + + PlayerDataManager.setPlayerData(player.getUniqueId(), playerData.setDebugStickMode(DebugStickMode.CLASSIC)); + Component parsed = mm.deserialize(LangFile.CommandsMessages.Mode.SuccessSetToClassic); + player.sendMessage(parsed); + return true; + } else if (args[1].equalsIgnoreCase("copy")) { + if (player.hasPermission("debugstickpro.mode.copy")) { + PlayerData playerData = PlayerDataManager.getPlayerData(player.getUniqueId()); + + if (modeChangeEventCancelled(player.getUniqueId(), playerData.getDebugStickMode(), DebugStickMode.COPY)) { + return true; + } + + PlayerDataManager.setPlayerData(player.getUniqueId(), playerData.setDebugStickMode(DebugStickMode.COPY)); + Component parsed = mm.deserialize(LangFile.CommandsMessages.Mode.SuccessSetToCopy); + player.sendMessage(parsed); + return true; + } else { + Component parsed = mm.deserialize(LangFile.CommandsMessages.NoPermission); + player.sendMessage(parsed); + return true; + } + } else if (args[1].equalsIgnoreCase("freeze")) { + if (player.hasPermission("debugstickpro.mode.freeze")) { + PlayerData playerData = PlayerDataManager.getPlayerData(player.getUniqueId()); + + if (modeChangeEventCancelled(player.getUniqueId(), playerData.getDebugStickMode(), DebugStickMode.FREEZE)) { + return true; + } + + PlayerDataManager.setPlayerData(player.getUniqueId(), PlayerDataManager.getPlayerData(player.getUniqueId()).setDebugStickMode(DebugStickMode.FREEZE)); + Component parsed = mm.deserialize(LangFile.CommandsMessages.Mode.SuccessSetToFreeze); + player.sendMessage(parsed); + return true; + } else { + Component parsed = mm.deserialize(LangFile.CommandsMessages.NoPermission); + player.sendMessage(parsed); + return true; + } + } else { + Component parsed = mm.deserialize(LangFile.CommandsMessages.Mode.Usage); + player.sendMessage(parsed); + return true; + } + } + } +} diff --git a/src/main/java/dev/twme/debugstickpro/commands/subcommand/ReloadCommand.java b/src/main/java/dev/twme/debugstickpro/commands/subcommand/ReloadCommand.java new file mode 100644 index 0000000..6c0875e --- /dev/null +++ b/src/main/java/dev/twme/debugstickpro/commands/subcommand/ReloadCommand.java @@ -0,0 +1,25 @@ +package dev.twme.debugstickpro.commands.subcommand; + +import dev.twme.debugstickpro.DebugStickPro; +import dev.twme.debugstickpro.configs.LangFile; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.minimessage.MiniMessage; +import org.bukkit.entity.Player; + +public class ReloadCommand { + public static boolean onReloadCommand(Player player, String[] args) { + MiniMessage mm = MiniMessage.miniMessage(); + if (args.length > 1) { + return false; + } + if (!player.hasPermission("debugstickpro.reload")) { + Component parsed = mm.deserialize(LangFile.CommandsMessages.NoPermission); + player.sendMessage(parsed); + return true; + } + DebugStickPro.getInstance().onReload(); + Component parsed = mm.deserialize(LangFile.CommandsMessages.Reload.Success); + player.sendMessage(parsed); + return true; + } +} diff --git a/src/main/java/dev/twme/debugstickpro/configs/LangFile.java b/src/main/java/dev/twme/debugstickpro/configs/LangFile.java index 1b1a80a..bd603bc 100644 --- a/src/main/java/dev/twme/debugstickpro/configs/LangFile.java +++ b/src/main/java/dev/twme/debugstickpro/configs/LangFile.java @@ -1,14 +1,16 @@ package dev.twme.debugstickpro.configs; +import net.kyori.adventure.text.Component; + +import java.util.ArrayList; + public class LangFile { public static int LangFileVersion; public static class CommandsMessages { public static class Help { - public static String Title; - public static String Description; - public static String Usage; + public static ArrayList HelpMessage; } public static class Reload { @@ -26,29 +28,33 @@ public static class Mode { public static String SuccessSetToCopy; public static String SuccessSetToFreeze; } + public static String NoPermission; public static String YouAreNotPlayer; } public static class ActionBar { public static String SelectedDataFormat; - public static String formatSelectedData(String key, String value){ + + public static String formatSelectedData(String key, String value) { return SelectedDataFormat.replace("%key%", key).replace("%value%", value); } public static String NotSelectedDataFormat; - public static String formatNotSelectedData(String key, String value){ + + public static String formatNotSelectedData(String key, String value) { return NotSelectedDataFormat.replace("%key%", key).replace("%value%", value); } public static String CopiedBlockDataFormat; - public static String formatCopiedBlockData(String key, String value){ + + public static String formatCopiedBlockData(String key, String value) { return CopiedBlockDataFormat.replace("%key%", key).replace("%value%", value); } public static String FreezeBlockCount; - public static String formatFreezeBlockCount(int count){ + public static String formatFreezeBlockCount(int count) { return FreezeBlockCount.replace("%count%", String.valueOf(count)); } } diff --git a/src/main/java/dev/twme/debugstickpro/configs/LangLoader.java b/src/main/java/dev/twme/debugstickpro/configs/LangLoader.java index d286622..68e7df5 100644 --- a/src/main/java/dev/twme/debugstickpro/configs/LangLoader.java +++ b/src/main/java/dev/twme/debugstickpro/configs/LangLoader.java @@ -2,20 +2,24 @@ import dev.twme.debugstickpro.DebugStickPro; import dev.twme.debugstickpro.util.Log; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.minimessage.MiniMessage; import org.bukkit.configuration.file.YamlConfiguration; import java.io.File; import java.text.SimpleDateFormat; +import java.util.ArrayList; import java.util.Date; public class LangLoader { private final static LangLoader instance = new LangLoader(); private File file; private YamlConfiguration langFile; + private LangLoader() { } - public void load(){ + public void load() { file = new File(DebugStickPro.getInstance().getDataFolder(), "lang.yml"); if (!file.exists()) { @@ -33,20 +37,20 @@ public void load(){ LangFile.LangFileVersion = langFile.getInt("LangFileVersion"); - if(!checkLangFileVersion()){ + if (!checkLangFileVersion()) { load(); return; } loadValues(); } - public boolean checkLangFileVersion(){ - if(LangFile.LangFileVersion != DebugStickPro.LangVersion){ + public boolean checkLangFileVersion() { + if (LangFile.LangFileVersion != DebugStickPro.LangVersion) { Log.warning("Lang file version is not compatible with this version of the plugin."); Date date = new Date(); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss"); String strDate = formatter.format(date); - String backupFileName = file.getAbsolutePath().replace("lang","lang-" + strDate); + String backupFileName = file.getAbsolutePath().replace("lang", "lang-" + strDate); File newFile = new File(backupFileName); if (file.renameTo(newFile)) { @@ -79,9 +83,12 @@ public static LangLoader getInstance() { private void loadValues() { - LangFile.CommandsMessages.Help.Title = langFile.getString("CommandsMessages.Help.Title"); - LangFile.CommandsMessages.Help.Description = langFile.getString("CommandsMessages.Help.Description"); - LangFile.CommandsMessages.Help.Usage = langFile.getString("CommandsMessages.Help.Usage"); + MiniMessage mm = MiniMessage.miniMessage(); + ArrayList messages = new ArrayList<>(); + for (String loreString : langFile.getStringList("CommandsMessages.Help.HelpMessage")) { + messages.add(mm.deserialize(loreString)); + } + LangFile.CommandsMessages.Help.HelpMessage = messages; LangFile.CommandsMessages.Reload.Success = langFile.getString("CommandsMessages.Reload.Success"); diff --git a/src/main/resources/lang.yml b/src/main/resources/lang.yml index 1cfdd0b..b189f7e 100644 --- a/src/main/resources/lang.yml +++ b/src/main/resources/lang.yml @@ -1,11 +1,15 @@ # Don't change this value -LangFileVersion: 2 +LangFileVersion: 3 CommandsMessages: Help: - Title: "DebugStickPro Help" - Description: "Use /dsp help to show this help message." - Usage: "Usage: /dsp [help|onReload|give] (player)" + HelpMessage: + - "Debug Stick - Plugin to modify block data." + - "Commands:" + - " /dsp reload - Reloads the plugin." + - " /dsp give - Gives Debug Stick to the player." + - " /dsp mode - Changes the mode of the Debug Stick." + - " /dsp - Shows the help message." Reload: Success: "Reloaded successfully." Give: