diff --git a/plugin/src/main/java/me/filoghost/chestcommands/command/CommandHandler.java b/plugin/src/main/java/me/filoghost/chestcommands/command/CommandHandler.java index b4e44c0..6b89ff1 100644 --- a/plugin/src/main/java/me/filoghost/chestcommands/command/CommandHandler.java +++ b/plugin/src/main/java/me/filoghost/chestcommands/command/CommandHandler.java @@ -7,7 +7,6 @@ package me.filoghost.chestcommands.command; import me.filoghost.chestcommands.ChestCommands; import me.filoghost.chestcommands.Permissions; -import me.filoghost.chestcommands.config.Lang; import me.filoghost.chestcommands.menu.InternalIconMenu; import me.filoghost.chestcommands.menu.MenuManager; import me.filoghost.chestcommands.util.Utils; @@ -120,13 +119,9 @@ public class CommandHandler extends CommandFramework { } if (sender.getName().equalsIgnoreCase(target.getName())) { - if (!Lang.open_menu.isEmpty()) { - sender.sendMessage(Lang.open_menu.replace("{menu}", menuName)); - } + sender.sendMessage(ChatColor.GREEN + "Opening the menu " + menuName + "."); } else { - if (!Lang.open_menu_others.isEmpty()) { - sender.sendMessage(Lang.open_menu_others.replace("{menu}", menuName).replace("{player}", target.getName())); - } + sender.sendMessage(ChatColor.GREEN + "Opening the menu " + menuName + " to " + target.getName() + "."); } menu.open(target); diff --git a/plugin/src/main/java/me/filoghost/chestcommands/config/Lang.java b/plugin/src/main/java/me/filoghost/chestcommands/config/Lang.java index 0f30b8b..44a635f 100644 --- a/plugin/src/main/java/me/filoghost/chestcommands/config/Lang.java +++ b/plugin/src/main/java/me/filoghost/chestcommands/config/Lang.java @@ -20,8 +20,6 @@ public class Lang extends MappedConfig { public static String no_money = "&cYou need {money}$ for this."; public static String no_exp = "&cYou need {levels} XP levels for this."; public static String menu_not_found = "&cMenu not found! " + Errors.User.notifyStaffRequest; - public static String open_menu = "&aOpening the menu \"{menu}\"."; - public static String open_menu_others = "&aOpening the menu \"{menu}\" to {player}."; public static String any = "any"; // Used in no_required_item when durability is not restrictive } diff --git a/plugin/src/main/java/me/filoghost/chestcommands/legacy/Backup.java b/plugin/src/main/java/me/filoghost/chestcommands/legacy/Backup.java index fcb7960..12644b4 100644 --- a/plugin/src/main/java/me/filoghost/chestcommands/legacy/Backup.java +++ b/plugin/src/main/java/me/filoghost/chestcommands/legacy/Backup.java @@ -37,9 +37,13 @@ public class Backup { Preconditions.checkArgument(fileToBackup.startsWith(dataFolder), "file is not inside data folder"); Path destination = backupFolder.resolve(dataFolder.relativize(fileToBackup)); Files.createDirectories(destination.getParent()); + + // Add backup file if no already present if (!Files.isRegularFile(destination)) { Files.copy(fileToBackup, destination); } + + // Add README file if not already present if (!Files.isRegularFile(infoFile)) { Files.write(infoFile, Arrays.asList( "Files in this folders are copies of original configuration files that have been automatically upgraded.", diff --git a/plugin/src/main/java/me/filoghost/chestcommands/legacy/upgrade/YamlUpgradeTask.java b/plugin/src/main/java/me/filoghost/chestcommands/legacy/upgrade/YamlUpgradeTask.java index c89a334..b357e36 100644 --- a/plugin/src/main/java/me/filoghost/chestcommands/legacy/upgrade/YamlUpgradeTask.java +++ b/plugin/src/main/java/me/filoghost/chestcommands/legacy/upgrade/YamlUpgradeTask.java @@ -55,4 +55,12 @@ public abstract class YamlUpgradeTask extends UpgradeTask { } } + protected void replaceStringValue(Config settingsConfig, String node, String target, String replacement) { + String value = settingsConfig.getString(node); + if (value.contains(target)) { + settingsConfig.setString(node, value.replace(target, replacement)); + setSaveRequired(); + } + } + } diff --git a/plugin/src/main/java/me/filoghost/chestcommands/legacy/v4_0/v4_0_LangUpgradeTask.java b/plugin/src/main/java/me/filoghost/chestcommands/legacy/v4_0/v4_0_LangUpgradeTask.java index d7ca502..2cc0c33 100644 --- a/plugin/src/main/java/me/filoghost/chestcommands/legacy/v4_0/v4_0_LangUpgradeTask.java +++ b/plugin/src/main/java/me/filoghost/chestcommands/legacy/v4_0/v4_0_LangUpgradeTask.java @@ -6,17 +6,20 @@ package me.filoghost.chestcommands.legacy.v4_0; import me.filoghost.chestcommands.config.ConfigManager; -import me.filoghost.chestcommands.legacy.upgrade.RegexUpgradeTask; +import me.filoghost.chestcommands.legacy.upgrade.YamlUpgradeTask; +import me.filoghost.commons.config.Config; -public class v4_0_LangUpgradeTask extends RegexUpgradeTask { +public class v4_0_LangUpgradeTask extends YamlUpgradeTask { public v4_0_LangUpgradeTask(ConfigManager configManager) { - super(configManager.getRootDataFolder().resolve("lang.yml")); + super(configManager.getConfigLoader("lang.yml")); } @Override - protected void computeRegexChanges() { - replaceString("{datavalue}", "{durability}"); + public void computeYamlChanges(Config settingsConfig) { + removeNode(settingsConfig, "open-menu"); + removeNode(settingsConfig, "open-menu-others"); + replaceStringValue(settingsConfig, "no-required-item", "{datavalue}", "{durability}"); } }