From ffa4423b7cd898a218bef9840ee781313ce5365d Mon Sep 17 00:00:00 2001 From: JaTiTV Date: Mon, 8 Jul 2024 05:10:38 +0200 Subject: [PATCH] smal fix --- .../Spigot/config/ConfigFileConverter.java | 25 +++++++------------ .../alias/Spigot/config/alias/AliasFile.java | 18 ++++++------- .../net/t2code/alias/Spigot/system/Load.java | 3 +-- 3 files changed, 18 insertions(+), 28 deletions(-) diff --git a/src/main/java/net/t2code/alias/Spigot/config/ConfigFileConverter.java b/src/main/java/net/t2code/alias/Spigot/config/ConfigFileConverter.java index f70d5cb..2e83b2f 100644 --- a/src/main/java/net/t2code/alias/Spigot/config/ConfigFileConverter.java +++ b/src/main/java/net/t2code/alias/Spigot/config/ConfigFileConverter.java @@ -35,7 +35,7 @@ public class ConfigFileConverter { if (!f.exists()) return; File[] fileArray = f.listFiles(); - assert fileArray != null; + if (fileArray == null) return; for (File file : fileArray) { String sub = file.getName().substring(file.getName().length() - 4); if (sub.equals(".yml")) { @@ -75,16 +75,12 @@ public class ConfigFileConverter { setConfig("Alias.Console.Message.Messages", AliasFile.VALUES.consoleMessages); T2C_ConfigWriter.createConfig(Util.getPrefix(), new File(Main.getPath(), "alias/" + file.getName()), AliasFile.VALUES.values(), false, Util.getConfigLogo()); + file.delete(); } } - File fo = new File(Main.getPath() + "/OldConfig/"); - if(!fo.exists())fo.mkdir(); - - if (f.renameTo(new File(Main.getPath() + "/OldConfig/Alias/"))) { - T2C_Send.sendStartTextCenter(Util.getPrefix(), "§4The Alias files in the plugins/T2C-Alias/Alias folder", false); - T2C_Send.sendStartTextCenter(Util.getPrefix(), "§4have been converted to the new folder plugins/T2C-Alias/alias!", false); - T2C_Send.sendStartTextCenter(Util.getPrefix(), "§4The old files have been moved to plugins/T2C-Alias/OldConfig/Alias.", false); - } + File[] fileArray2 = f.listFiles(); + if (fileArray2 != null) return; + f.delete(); } private static void convertSubAlias() { @@ -133,15 +129,12 @@ public class ConfigFileConverter { setConfig("SubAlias.Console.Message.Messages", SubAliasFile.VALUES.consoleMessages); T2C_ConfigWriter.createConfig(Util.getPrefix(), new File(Main.getPath(), "subAlias/" + file.getName()), SubAliasFile.VALUES.values(), false, Util.getConfigLogo()); + file.delete(); } } - File fo = new File(Main.getPath() + "/OldConfig/"); - if(!fo.exists())fo.mkdir(); - if (f.renameTo(new File(Main.getPath() + "/OldConfig/SubAlias/"))) { - T2C_Send.sendStartTextCenter(Util.getPrefix(), "§4The SubAlias files in the plugins/T2C-Alias/SubAlias folder", false); - T2C_Send.sendStartTextCenter(Util.getPrefix(), "§4have been converted to the new folder plugins/T2C-Alias/subAlias!", false); - T2C_Send.sendStartTextCenter(Util.getPrefix(), "§4The old files have been moved to plugins/T2C-Alias/OldConfig/SubAlias.", false); - } + File[] fileArray2 = f.listFiles(); + if (fileArray2 != null) return; + f.delete(); } private static void setConfig(String path, T2C_ConfigItem item) { diff --git a/src/main/java/net/t2code/alias/Spigot/config/alias/AliasFile.java b/src/main/java/net/t2code/alias/Spigot/config/alias/AliasFile.java index 9f507b9..94f1ca3 100644 --- a/src/main/java/net/t2code/alias/Spigot/config/alias/AliasFile.java +++ b/src/main/java/net/t2code/alias/Spigot/config/alias/AliasFile.java @@ -238,7 +238,7 @@ public class AliasFile { @Override public String getLanguagePath() { - return Config.VALUES.language.getPath(); + return Config.VALUES.language.getValue().toString(); } @Override @@ -247,20 +247,18 @@ public class AliasFile { } } + public static void set(boolean isReload) { - T2C_ConfigWriter.createConfig(Util.getPrefix(), new File(Main.getPath(), "alias/aliasexample.yml"), VALUES.values(), isReload, Util.getConfigLogo()); - } - - - public static void select(boolean isReload) { ConfigFileConverter.convert(); File f = new File(Main.getPath() + "/alias/"); File[] fileArray = f.listFiles(); - assert fileArray != null; - for (File config_gui : fileArray) { - String sub = config_gui.getName().substring(config_gui.getName().length() - 4); + if (fileArray == null){ + T2C_ConfigWriter.createConfig(Util.getPrefix(), new File(Main.getPath(), "alias/aliasexample.yml"), VALUES.values(), isReload, Util.getConfigLogo()); + } + for (File file : fileArray) { + String sub = file.getName().substring(file.getName().length() - 4); if (sub.equals(".yml")) { - T2C_ConfigWriter.createConfig(Util.getPrefix(), new File(Main.getPath(), "alias/" + config_gui.getName()), VALUES.values(), isReload, Util.getConfigLogo()); + T2C_ConfigWriter.createConfig(Util.getPrefix(), new File(Main.getPath(), "alias/" + file.getName()), VALUES.values(), isReload, Util.getConfigLogo()); for (String s : (List) VALUES.aliasList.value) { if (s != null) { Main.allAliases.add(s); diff --git a/src/main/java/net/t2code/alias/Spigot/system/Load.java b/src/main/java/net/t2code/alias/Spigot/system/Load.java index e222194..45926b9 100644 --- a/src/main/java/net/t2code/alias/Spigot/system/Load.java +++ b/src/main/java/net/t2code/alias/Spigot/system/Load.java @@ -53,10 +53,9 @@ public class Load { Language.set(false); T2C_Template.onLoadSeparateStroke(Util.getPrefix()); if (newInstall) { - AliasFile.set(false); SubAliasFile.set(false); } - AliasFile.select(false); + AliasFile.set(false); SubAliasFile.select(false);