From 32a07654845779a0e9534a33f934437284be6a7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20S=C3=B6derberg?= Date: Wed, 22 Jul 2020 21:09:38 +0200 Subject: [PATCH] Force more compilation errors --- .../core/configuration/Captions.java | 126 ------------------ 1 file changed, 126 deletions(-) diff --git a/Core/src/main/java/com/plotsquared/core/configuration/Captions.java b/Core/src/main/java/com/plotsquared/core/configuration/Captions.java index 5541a2842..37445ea69 100644 --- a/Core/src/main/java/com/plotsquared/core/configuration/Captions.java +++ b/Core/src/main/java/com/plotsquared/core/configuration/Captions.java @@ -830,130 +830,4 @@ public enum Captions implements Caption { CUSTOM_STRING("-", "-"); //@formatter:on - public static final HashMap replacements = new HashMap<>(); - - private final String defaultString; - private final String category; - private final boolean prefix; - private String translatedString; - private String[] replacementKeys; - - Captions(String defaultString, boolean prefix, String category, String... replacementKeys) { - this.defaultString = defaultString; - this.translatedString = defaultString; - this.prefix = prefix; - this.category = category.toLowerCase(); - this.replacementKeys = replacementKeys; - } - - Captions(String defaultString, String category, String... replacementKeys) { - this(defaultString, true, category.toLowerCase(), replacementKeys); - } - - public static String color(String string) { - return StringMan.replaceFromMap(string, replacements); - } - - public static void load(File file) { - try { - if (!file.exists()) { - file.getParentFile().mkdirs(); - file.createNewFile(); - } - YamlConfiguration yml = YamlConfiguration.loadConfiguration(file); - Set keys = yml.getKeys(true); - EnumSet allEnums = EnumSet.allOf(Captions.class); - HashSet allNames = new HashSet<>(); - HashSet categories = new HashSet<>(); - for (Captions caption : allEnums) { - allNames.add(caption.name()); - categories.add(caption.category.toLowerCase()); - } - HashSet captions = new HashSet<>(); - boolean changed = false; - HashSet toRemove = new HashSet<>(); - for (String key : keys) { - if (!yml.isString(key)) { - if (!categories.contains(key)) { - toRemove.add(key); - } - continue; - } - String[] split = key.split("\\."); - String node = split[split.length - 1].toUpperCase(); - Captions caption; - if (allNames.contains(node)) { - caption = valueOf(node); - } else { - caption = null; - } - if (caption != null) { - if (caption.category.startsWith("static")) { - continue; - } - String value = yml.getString(key); - if (!split[0].equalsIgnoreCase(caption.category)) { - changed = true; - yml.set(key, null); - yml.set(caption.category + '.' + caption.name().toLowerCase(), value); - } - captions.add(caption); - caption.translatedString = value; - } else { - toRemove.add(key); - } - } - for (String remove : toRemove) { - changed = true; - yml.set(remove, null); - } - ConfigurationSection config = PlotSquared.get().style.getConfigurationSection("color"); - Set styles = config.getKeys(false); - // HashMap replacements = new HashMap<>(); - replacements.clear(); - for (String style : styles) { - replacements.put('$' + style, '\u00A7' + config.getString(style)); - } - for (char letter : "1234567890abcdefklmnor".toCharArray()) { - replacements.put("&" + letter, "\u00a7" + letter); - } - replacements.put("\\\\n", "\n"); - replacements.put("\\n", "\n"); - replacements.put("&-", "\n"); - for (Captions caption : allEnums) { - if (!captions.contains(caption)) { - if (caption.getCategory().startsWith("static")) { - continue; - } - changed = true; - yml.set(caption.category + '.' + caption.name().toLowerCase(), - caption.defaultString); - } - caption.translatedString = - StringMan.replaceFromMap(caption.translatedString, replacements); - } - if (changed) { - yml.save(file); - } - } catch (IOException | IllegalArgumentException e) { - e.printStackTrace(); - } - } - - @Override public String getTranslated() { - return this.translatedString; - } - - public boolean usePrefix() { - return this.prefix; - } - - public String getCategory() { - return this.category; - } - - @Override public String toString() { - return this.getTranslated(); - } - }