diff --git a/pom.xml b/pom.xml index f22c1bd..8669509 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ net.t2code T2CodeLib - 16.7_dev-4 + 16.7_dev-5 diff --git a/src/main/java/net/t2code/t2codelib/BUNGEE/api/yaml/T2CBconfigWriter.java b/src/main/java/net/t2code/t2codelib/BUNGEE/api/yaml/T2CBconfigWriter.java index 5d43294..aaa18e1 100644 --- a/src/main/java/net/t2code/t2codelib/BUNGEE/api/yaml/T2CBconfigWriter.java +++ b/src/main/java/net/t2code/t2codelib/BUNGEE/api/yaml/T2CBconfigWriter.java @@ -6,6 +6,7 @@ import net.md_5.bungee.config.ConfigurationProvider; import net.md_5.bungee.config.YamlConfiguration; import net.t2code.t2codelib.T2CconfigItem; import net.md_5.bungee.config.Configuration; +import net.t2code.t2codelib.T2CLanguageEnum; import java.io.File; import java.io.IOException; @@ -38,14 +39,18 @@ public class T2CBconfigWriter { } Map> comments = new LinkedHashMap<>(); + T2CLanguageEnum lang = T2CLanguageEnum.english; + for(T2CconfigItem item : values){ if (item.getForceSet() || !exist) { if(!config.contains(item.getPath())){ config.set(item.getPath(), item.getValue()); } - comments.put(item.getPath(), item.getComments()); + List commandList = item.getComments().get(lang); + if (commandList != null){ + comments.put(item.getPath(),commandList ); + } } - } saveConfigWithComments(configFile, comments, header); readConfig(config,values); diff --git a/src/main/java/net/t2code/t2codelib/BUNGEE/system/config/T2CBlibConfig.java b/src/main/java/net/t2code/t2codelib/BUNGEE/system/config/T2CBlibConfig.java index 02cf9d2..c385194 100644 --- a/src/main/java/net/t2code/t2codelib/BUNGEE/system/config/T2CBlibConfig.java +++ b/src/main/java/net/t2code/t2codelib/BUNGEE/system/config/T2CBlibConfig.java @@ -3,35 +3,50 @@ package net.t2code.t2codelib.BUNGEE.system.config; import net.t2code.t2codelib.BUNGEE.api.yaml.T2CBconfigWriter; import net.t2code.t2codelib.BUNGEE.system.T2CodeBMain; import net.t2code.t2codelib.T2CconfigItem; +import net.t2code.t2codelib.T2CLanguageEnum; import net.t2code.t2codelib.Util; import java.io.File; import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; +import java.util.HashMap; import java.util.List; public class T2CBlibConfig { - public enum VALUES implements T2CconfigItem{ - updateTimer("updateCheck.timerInMin", 60,true,"In this option you can set the time interval in minutes in which updates should be checked."), - seePreReleaseUpdates("updateCheck.seePreReleaseUpdates", true,true,"In this option you can set whether you want to receive and display beta and snapshot versions in the update check."), + public enum VALUES implements T2CconfigItem { + updateTimer("updateCheck.timerInMin", 60, true, + new HashMap<>() {{ + put(T2CLanguageEnum.english, List.of("In this option you can set the time interval in minutes in which updates should be checked.")); + }}), + seePreReleaseUpdates("updateCheck.seePreReleaseUpdates", true, true, + new HashMap<>() {{ + put(T2CLanguageEnum.english, List.of("In this option you can set whether you want to receive and display beta and snapshot versions in the update check.")); + }}), - apiCommandGUIEnable("api.commandGUI.enable", false, true,"With this option you activate the api interface for the T2C-CommandGUI plugin."), - apiAutoResponse("api.autoResponse.enable", false,true,"With this option you activate the api interface for the T2C-AutoResponse plugin."), - apiOpSecurity("api.opSecurity.enable", false,true,"With this option you activate the api interface for the T2C-OPSecurity plugin."), + apiCommandGUIEnable("api.commandGUI.enable", false, true, + new HashMap<>() {{ + put(T2CLanguageEnum.english, List.of("With this option you activate the api interface for the T2C-CommandGUI plugin.")); + }}), + apiAutoResponse("api.autoResponse.enable", false, true, + new HashMap<>() {{ + put(T2CLanguageEnum.english, List.of("With this option you activate the api interface for the T2C-AutoResponse plugin.")); + }}), + apiOpSecurity("api.opSecurity.enable", false, true, + new HashMap<>() {{ + put(T2CLanguageEnum.english, List.of("With this option you activate the api interface for the T2C-OPSecurity plugin.")); + }}), ; private final String path; private Object value; private final boolean forceSet; - private final List comments; + private final HashMap> comments; - VALUES(String path, Object value,boolean forceSet, String... comments) { + VALUES(String path, Object value, boolean forceSet, HashMap> comments) { this.path = path; this.value = value; - this.forceSet=forceSet; - this.comments = new ArrayList<>(Arrays.asList(comments)); + this.forceSet = forceSet; + this.comments = comments; } @Override @@ -50,17 +65,22 @@ public class T2CBlibConfig { } @Override - public List getComments() { + public HashMap> getComments() { return comments; } + @Override + public String getLanguagePath() { + return null; + } + @Override public void setValue(Object newValue) { value = newValue; } } - public static void set(){ + public static void set() { try { ConvertT2CBlibConfig.convert(); } catch (IOException e) { diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/api/eco/T2Ceco.java b/src/main/java/net/t2code/t2codelib/SPIGOT/api/eco/T2Ceco.java index 48dcd92..16cdc54 100644 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/api/eco/T2Ceco.java +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/api/eco/T2Ceco.java @@ -4,7 +4,7 @@ import com.bencodez.votingplugin.VotingPluginMain; import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend; import net.t2code.t2codelib.SPIGOT.api.plugins.T2CpluginCheck; import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain; -import net.t2code.t2codelib.SPIGOT.system.config.languages.SelectLibMsg; +import net.t2code.t2codelib.SPIGOT.system.config.languages.old.SelectLibMsg; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/api/messages/T2Ctemplate.java b/src/main/java/net/t2code/t2codelib/SPIGOT/api/messages/T2Ctemplate.java index abb9886..7bc0dd5 100644 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/api/messages/T2Ctemplate.java +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/api/messages/T2Ctemplate.java @@ -2,17 +2,13 @@ package net.t2code.t2codelib.SPIGOT.api.messages; import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI; import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain; -import net.t2code.t2codelib.T2CconfigItem; import net.t2code.t2codelib.T2CupdateWebData; import net.t2code.t2codelib.Util; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; -import org.bukkit.plugin.PluginLogger; -import org.jetbrains.annotations.NotNull; import java.util.List; -import java.util.logging.Level; public class T2Ctemplate { public static Long onLoadHeader(String prefix, List autor, String version, String spigot, String discord) { diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/api/yaml/T2Cconfig.java b/src/main/java/net/t2code/t2codelib/SPIGOT/api/yaml/T2Cconfig.java index ecdc229..b1ec439 100644 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/api/yaml/T2Cconfig.java +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/api/yaml/T2Cconfig.java @@ -3,7 +3,7 @@ package net.t2code.t2codelib.SPIGOT.api.yaml; import net.t2code.t2codelib.SPIGOT.api.messages.T2Creplace; import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend; import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion; -import net.t2code.t2codelib.SPIGOT.system.config.languages.SelectLibMsg; +import net.t2code.t2codelib.SPIGOT.system.config.languages.old.SelectLibMsg; import org.bukkit.Sound; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.inventory.ItemStack; diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/api/yaml/T2CconfigWriter.java b/src/main/java/net/t2code/t2codelib/SPIGOT/api/yaml/T2CconfigWriter.java index 654548c..f8d04f9 100644 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/api/yaml/T2CconfigWriter.java +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/api/yaml/T2CconfigWriter.java @@ -2,14 +2,13 @@ package net.t2code.t2codelib.SPIGOT.api.yaml; +import net.t2code.t2codelib.T2CLanguageEnum; import net.t2code.t2codelib.T2CconfigItem; -import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.YamlConfiguration; import java.io.File; import java.io.IOException; -import java.nio.file.Files; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -18,7 +17,6 @@ public class T2CconfigWriter { private static FileConfiguration config; - public static void createConfig(File configFile, T2CconfigItem[] values, String... header) { boolean exist = configFile.exists(); if (!exist) { @@ -34,17 +32,27 @@ public class T2CconfigWriter { config = YamlConfiguration.loadConfiguration(configFile); Map> comments = new LinkedHashMap<>(); + T2CLanguageEnum lang = T2CLanguageEnum.english; + try { + lang = T2CLanguageEnum.valueOf(config.getString(values[0].getLanguagePath().replace(".yml", ""))); + } catch (Exception ignore) { + } + for (T2CconfigItem item : values) { if (item.getForceSet() || !exist) { config.addDefault(item.getPath(), item.getValue()); - comments.put(item.getPath(), item.getComments()); + + List commandList = item.getComments().get(lang); + if (commandList != null) { + comments.put(item.getPath(), commandList); + } } } // Copy default values if they are missing config.options().copyDefaults(true); - saveConfigWithComments(configFile, comments, header); + T2CymlWriter.saveConfigWithComments(configFile, config, comments, header); readConfig(config, values); } @@ -53,61 +61,4 @@ public class T2CconfigWriter { value.setValue(config.get(value.getPath())); } } - - private static void saveConfigWithComments(File file, Map> comments, String... headers) { - try { - StringBuilder configContent = new StringBuilder(); - for (String h : headers) { - configContent.append(h).append("\n"); - } - configContent.append("\n"); - addSection(config, comments, configContent, "", 0); - - // Write the content to the file - Files.write(file.toPath(), configContent.toString().getBytes()); - } catch (IOException e) { - e.printStackTrace(); - } - } - - private static void addSection(ConfigurationSection section, Map> comments, StringBuilder builder, String prefix, int indentLevel) { - String indent = " ".repeat(indentLevel); - - - for (String key : section.getKeys(false)) { - String fullKey = prefix.isEmpty() ? key : prefix + "." + key; - Object value = section.get(key); - - // Add comment if it exists for this key - List commentList = comments.get(fullKey); - if (commentList != null) { - for (String c : commentList) { - builder.append(indent).append("# ").append(c).append("\n"); - } - } - - // Check if the value is a section (nested map) - if (value instanceof ConfigurationSection) { - // Correctly add the section - builder.append(indent).append(key).append(":\n"); - addSection((ConfigurationSection) value, comments, builder, fullKey, indentLevel + 1); - } else { - // Add value with proper indentation - // builder.append(indent).append(key).append(": ").append(value).append("\n"); - if (value instanceof List) { - builder.append(indent).append(key).append(": ").append("\n"); - List zw = (List) value; - for (Object s : zw) { - if (s instanceof String) { - builder.append(indent).append("- \"").append(s).append("\"\n"); - } else builder.append(indent).append("- ").append(s).append("\n"); - } - } else { - if (value instanceof String) { - builder.append(indent).append(key).append(": \"").append(value).append("\"\n"); - } else builder.append(indent).append(key).append(": ").append(value).append("\n"); - } - } - } - } } diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/api/yaml/T2CconfigWriterLanguage.java b/src/main/java/net/t2code/t2codelib/SPIGOT/api/yaml/T2CconfigWriterLanguage.java new file mode 100644 index 0000000..862c27c --- /dev/null +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/api/yaml/T2CconfigWriterLanguage.java @@ -0,0 +1,92 @@ +// This class was created by JaTiTV. + +package net.t2code.t2codelib.SPIGOT.api.yaml; + +import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate; +import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain; + +import net.t2code.t2codelib.T2CLanguageEnum; +import net.t2code.t2codelib.T2CconfigItemLanguages; +import net.t2code.t2codelib.Util; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.configuration.file.YamlConfiguration; + +import java.io.File; +import java.io.IOException; +import java.util.*; + +public class T2CconfigWriterLanguage { + + private static FileConfiguration config; + + public static void createConfig(File path, T2CconfigItemLanguages[] values, String loadConfig, String... header) { + + File f = new File(path + "/languages/"); + f.mkdirs(); + File[] fileArray = f.listFiles(); + if(fileArray.length == 0){ + List zw = new ArrayList<>(); + for(T2CLanguageEnum lan : T2CLanguageEnum.values()){ + if(values[0].getLanguage().containsKey(lan)){ + zw.add(new File(path + "/languages/" + lan.name() + ".yml")); + } + } + fileArray = zw.toArray(new File[0]); + } + for (File langFile : fileArray) { + if (langFile.getName().endsWith(".yml")) { + T2CLanguageEnum lang = T2CLanguageEnum.english; + try { + lang = T2CLanguageEnum.valueOf(langFile.getName().replace(".yml", "")); + } catch (Exception ignore) { + } + + if (!langFile.exists()) { + langFile.getParentFile().mkdirs(); + try { + langFile.createNewFile(); + } catch (IOException e) { + e.printStackTrace(); + return; + } + } + Map> comments = new LinkedHashMap<>(); + // Copy default values if they are missing + config = YamlConfiguration.loadConfiguration(langFile); + config.options().copyDefaults(true); + for (T2CconfigItemLanguages item : values) { + config.addDefault(item.getPath(), item.getLanguage().get(lang)); + + + List commandList = item.getComments().get(lang); + if (commandList != null) { + comments.put(item.getPath(), commandList); + } + } + T2CymlWriter.saveConfigWithComments(langFile, config, comments, header); + } + } + readConfig(values, loadConfig); + } + + private static void readConfig(T2CconfigItemLanguages[] values, String loadConfig) { + String selectMSG; + File msg; + msg = new File(T2CodeLibMain.getPath(), "languages/" + loadConfig + ".yml"); + if (!msg.isFile()) { + T2Ctemplate.onStartMsg(Util.getPrefix(), ""); + T2Ctemplate.onStartMsg(Util.getPrefix(), "§4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); + T2Ctemplate.onStartMsg(Util.getPrefix(), "§4The selected §c" + loadConfig + " §4language file was not found."); + T2Ctemplate.onStartMsg(Util.getPrefix(), "§6The default language §e" + T2CLanguageEnum.english.name() + " §6is used!"); + T2Ctemplate.onStartMsg(Util.getPrefix(), "§4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); + T2Ctemplate.onStartMsg(Util.getPrefix(), ""); + msg = new File(T2CodeLibMain.getPath(), "languages/" + T2CLanguageEnum.english.name() + ".yml"); + selectMSG = T2CLanguageEnum.english.name(); + } else selectMSG = loadConfig; + YamlConfiguration yml = YamlConfiguration.loadConfiguration(msg); + for (T2CconfigItemLanguages value : values) { + value.setValue(yml.get(value.getPath())); + } + T2Ctemplate.onStartMsg(Util.getPrefix(), "§2Language successfully selected to: §6" + selectMSG); + } +} diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/api/yaml/T2CymlWriter.java b/src/main/java/net/t2code/t2codelib/SPIGOT/api/yaml/T2CymlWriter.java new file mode 100644 index 0000000..afbb7c5 --- /dev/null +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/api/yaml/T2CymlWriter.java @@ -0,0 +1,70 @@ +// This class was created by JaTiTV. + +package net.t2code.t2codelib.SPIGOT.api.yaml; + +import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.configuration.file.FileConfiguration; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.util.List; +import java.util.Map; + +public class T2CymlWriter { + protected static void saveConfigWithComments(File file, FileConfiguration config, Map> comments, String... headers) { + try { + StringBuilder configContent = new StringBuilder(); + for (String h : headers) { + configContent.append(h).append("\n"); + } + configContent.append("\n"); + addSection(config, comments, configContent, "", 0); + + // Write the content to the file + Files.write(file.toPath(), configContent.toString().getBytes()); + } catch (IOException e) { + e.printStackTrace(); + } + } + + protected static void addSection(ConfigurationSection section, Map> comments, StringBuilder builder, String prefix, int indentLevel) { + String indent = " ".repeat(indentLevel); + + for (String key : section.getKeys(false)) { + String fullKey = prefix.isEmpty() ? key : prefix + "." + key; + Object value = section.get(key); + + // Add comment if it exists for this key + List commentList = comments.get(fullKey); + if (commentList != null) { + for (String c : commentList) { + builder.append(indent).append("# ").append(c).append("\n"); + } + } + + // Check if the value is a section (nested map) + if (value instanceof ConfigurationSection) { + // Correctly add the section + builder.append(indent).append(key).append(":\n"); + addSection((ConfigurationSection) value, comments, builder, fullKey, indentLevel + 1); + } else { + // Add value with proper indentation + // builder.append(indent).append(key).append(": ").append(value).append("\n"); + if (value instanceof List) { + builder.append(indent).append(key).append(": ").append("\n"); + List zw = (List) value; + for (Object s : zw) { + if (s instanceof String) { + builder.append(indent).append("- \"").append(s).append("\"\n"); + } else builder.append(indent).append("- ").append(s).append("\n"); + } + } else { + if (value instanceof String) { + builder.append(indent).append(key).append(": \"").append(value).append("\"\n"); + } else builder.append(indent).append(key).append(": ").append(value).append("\n"); + } + } + } + } +} diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/newLanguageFileBuilder/Languages.java b/src/main/java/net/t2code/t2codelib/SPIGOT/newLanguageFileBuilder/Languages.java deleted file mode 100644 index 07605e3..0000000 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/newLanguageFileBuilder/Languages.java +++ /dev/null @@ -1,82 +0,0 @@ -// This class was created by JaTiTV. - -package net.t2code.t2codelib.SPIGOT.newLanguageFileBuilder; - - -import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain; -import net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig; -import net.t2code.t2codelib.Util; - -import java.util.*; - -public class Languages { - - - public enum VALUES implements T2CconfigItemLanguages { - - - vaultNotSetUp("Plugin.VaultNotSetUp", - null, - List.of( - new T2ClanguageObject("english", "[prefix] &4Vault / Economy not set up!"), - new T2ClanguageObject("german", "[prefix] &4Vault / Economy nicht eingerichtet!")) - , "comment 1"), - - votingPluginNotSetUp("Plugin.VotingPluginNotSetUp", - null, - List.of(new T2ClanguageObject("english", "[prefix] &4VotingPlugin is not present on the server!"), - new T2ClanguageObject("german", "[prefix] &4VotingPlugin ist auf dem Server nicht vorhanden!")) - , "comment 2"), - soundNotFound("Plugin.SoundNotFound", - null, - List.of(new T2ClanguageObject("english", "[prefix] &4The sound &6[sound] &4was not found! Please check the settings."), - new T2ClanguageObject("german", "[prefix] &4Der Sound &6[sound] &4wurde nicht gefunden! Bitte [ue]berpr[ue]fe die Einstellungen.")) - , "comment 3"), - - ; - - private final String path; - private Object value; - private final List lang; - - private final List comments; - - VALUES(String path, Object value, List lang, String... comments) { - this.path = path; - this.value = value; - this.lang = lang; - - this.comments = new ArrayList<>(Arrays.asList(comments)); - } - - @Override - public String getPath() { - return path; - } - - @Override - public Object getValue() { - return value; - } - - @Override - public List getLanguage() { - return lang; - } - - @Override - public List getComments() { - return comments; - } - - @Override - public void setValue(Object newValue) { - value = newValue; - } - } - - public static void set() { - T2CconfigWriterLanguage.createConfig(T2CodeLibMain.getPath(), Arrays.asList("german", "english"), VALUES.values(), T2CLibConfig.VALUES.language.getValue().toString(), Util.getConfigLogo()); - - } -} \ No newline at end of file diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/newLanguageFileBuilder/T2CconfigWriterLanguage.java b/src/main/java/net/t2code/t2codelib/SPIGOT/newLanguageFileBuilder/T2CconfigWriterLanguage.java deleted file mode 100644 index 4842a88..0000000 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/newLanguageFileBuilder/T2CconfigWriterLanguage.java +++ /dev/null @@ -1,133 +0,0 @@ -// This class was created by JaTiTV. - -package net.t2code.t2codelib.SPIGOT.newLanguageFileBuilder; - -import net.t2code.t2codelib.SPIGOT.api.debug.T2Cdebug; -import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate; -import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain; - -import net.t2code.t2codelib.Util; -import org.bukkit.configuration.ConfigurationSection; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.configuration.file.YamlConfiguration; - -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -public class T2CconfigWriterLanguage { - - private static FileConfiguration config; - - public static void createConfig(File path, List languages, T2CconfigItemLanguages[] values, String loadConfig, String... header) { - - for (String l : languages) { - File configFile = new File(path, "languages/" + l + ".yml"); - if (!configFile.exists()) { - configFile.getParentFile().mkdirs(); - try { - configFile.createNewFile(); - } catch (IOException e) { - e.printStackTrace(); - return; - } - } - Map> comments = new LinkedHashMap<>(); - // Copy default values if they are missing - config = YamlConfiguration.loadConfiguration(configFile); - config.options().copyDefaults(true); - - for (T2CconfigItemLanguages item : values) { - for (T2ClanguageObject object : item.getLanguage()) { - if (object.getLanguage().equals(l)) { - config.addDefault(item.getPath(), object.getText()); - } - } - comments.put(item.getPath(), item.getComments()); - } - saveConfigWithComments(configFile, comments, header); - } - readConfig(values, loadConfig); - } - - private static void readConfig(T2CconfigItemLanguages[] values, String loadConfig) { - String selectMSG; - File msg; - msg = new File(T2CodeLibMain.getPath(), "languages/" + loadConfig + ".yml"); - if (!msg.isFile()) { - T2Ctemplate.onStartMsg(Util.getPrefix(), ""); - T2Ctemplate.onStartMsg(Util.getPrefix(), "§4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); - T2Ctemplate.onStartMsg(Util.getPrefix(), "§4The selected §c" + loadConfig + " §4language file was not found."); - T2Ctemplate.onStartMsg(Util.getPrefix(), "§6The default language §eEnglish §6is used!"); - T2Ctemplate.onStartMsg(Util.getPrefix(), "§4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); - T2Ctemplate.onStartMsg(Util.getPrefix(), ""); - msg = new File(T2CodeLibMain.getPath(), "languages/" + "english.yml"); - selectMSG = "english"; - } else selectMSG = loadConfig; - YamlConfiguration yml = YamlConfiguration.loadConfiguration(msg); - for (T2CconfigItemLanguages value : values) { - value.setValue(yml.get(value.getPath())); - } - T2Ctemplate.onStartMsg(Util.getPrefix(), "§2Language successfully selected to: §6" + selectMSG); - } - - private static void saveConfigWithComments(File file, Map> comments, String... headers) { - try { - StringBuilder configContent = new StringBuilder(); - for (String h : headers) { - configContent.append(h).append("\n"); - } - configContent.append("\n"); - addSection(config, comments, configContent, "", 0); - - // Write the content to the file - Files.write(file.toPath(), configContent.toString().getBytes()); - } catch (IOException e) { - e.printStackTrace(); - } - } - - private static void addSection(ConfigurationSection section, Map> comments, StringBuilder builder, String prefix, int indentLevel) { - String indent = " ".repeat(indentLevel); - - - for (String key : section.getKeys(false)) { - String fullKey = prefix.isEmpty() ? key : prefix + "." + key; - Object value = section.get(key); - - // Add comment if it exists for this key - List commentList = comments.get(fullKey); - if (commentList != null) { - for (String c : commentList) { - builder.append(indent).append("# ").append(c).append("\n"); - } - } - - // Check if the value is a section (nested map) - if (value instanceof ConfigurationSection) { - // Correctly add the section - builder.append(indent).append(key).append(":\n"); - addSection((ConfigurationSection) value, comments, builder, fullKey, indentLevel + 1); - } else { - // Add value with proper indentation - // builder.append(indent).append(key).append(": ").append(value).append("\n"); - if (value instanceof List) { - builder.append(indent).append(key).append(": ").append("\n"); - List zw = (List) value; - for (Object s : zw) { - if (s instanceof String) { - builder.append(indent).append("- \"").append(s).append("\"\n"); - } else builder.append(indent).append("- ").append(s).append("\n"); - } - } else { - if (value instanceof String) { - builder.append(indent).append(key).append(": \"").append(value).append("\"\n"); - } else builder.append(indent).append(key).append(": ").append(value).append("\n"); - } - } - } - } -} diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/newLanguageFileBuilder/T2ClanguageObject.java b/src/main/java/net/t2code/t2codelib/SPIGOT/newLanguageFileBuilder/T2ClanguageObject.java deleted file mode 100644 index 50c7af1..0000000 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/newLanguageFileBuilder/T2ClanguageObject.java +++ /dev/null @@ -1,20 +0,0 @@ -// This class was created by JaTiTV. - -package net.t2code.t2codelib.SPIGOT.newLanguageFileBuilder; - -import lombok.Getter; - -public class T2ClanguageObject { - - @Getter - private String language; - @Getter - private String text; - - public T2ClanguageObject(String language, - String text) { - this.language = language; - this.text = text; - - } -} diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/system/T2CodeLibMain.java b/src/main/java/net/t2code/t2codelib/SPIGOT/system/T2CodeLibMain.java index 6a692a2..5b192d9 100644 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/system/T2CodeLibMain.java +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/system/T2CodeLibMain.java @@ -19,7 +19,7 @@ import net.t2code.t2codelib.SPIGOT.system.cmd.CmdExecuter; import net.t2code.t2codelib.SPIGOT.system.cmd.Development; import net.t2code.t2codelib.SPIGOT.system.cmd.ReportLogStorage; import net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig; -import net.t2code.t2codelib.SPIGOT.newLanguageFileBuilder.Languages; +import net.t2code.t2codelib.SPIGOT.system.config.languages.Languages; import net.t2code.t2codelib.T2CplatformDetector; import net.t2code.t2codelib.Util; import org.bukkit.Bukkit; diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/system/cmd/CmdExecuter.java b/src/main/java/net/t2code/t2codelib/SPIGOT/system/cmd/CmdExecuter.java index d990225..4f00406 100644 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/system/cmd/CmdExecuter.java +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/system/cmd/CmdExecuter.java @@ -6,6 +6,7 @@ import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI; import net.t2code.t2codelib.SPIGOT.system.T2CbungeeCommandSenderReciver; import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain; import net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig; +import net.t2code.t2codelib.SPIGOT.system.config.languages.Languages; import net.t2code.t2codelib.T2CupdateObject; import net.t2code.t2codelib.Util; import org.bukkit.command.Command; @@ -70,6 +71,7 @@ public class CmdExecuter implements CommandExecutor, TabCompleter { return false; } T2CLibConfig.set(); + Languages.set(); T2Csend.sender(sender, Util.getPrefix() + " §2Config successfully reloaded"); return false; case "debug": diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/system/config/config/T2CLibConfig.java b/src/main/java/net/t2code/t2codelib/SPIGOT/system/config/config/T2CLibConfig.java index 9d4a19a..9ddf36e 100644 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/system/config/config/T2CLibConfig.java +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/system/config/config/T2CLibConfig.java @@ -2,64 +2,116 @@ package net.t2code.t2codelib.SPIGOT.system.config.config; import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate; import net.t2code.t2codelib.SPIGOT.api.yaml.T2CconfigWriter; +import net.t2code.t2codelib.T2CLanguageEnum; import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain; import net.t2code.t2codelib.T2CconfigItem; import net.t2code.t2codelib.Util; -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; import java.io.File; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.UUID; +import java.util.*; public class T2CLibConfig { public enum VALUES implements T2CconfigItem { - updateCheckOnJoin("plugin.updateCheck.onJoin", true, true,"In this option you can set if players with the permission 't2code.lib.updatemsg' will get an update message on join when an update for the plugin is available."), + updateCheckOnJoin("plugin.updateCheck.onJoin", true, true, + new HashMap<>() {{ + put(T2CLanguageEnum.english, List.of("In this option you can set if players with the permission 't2code.lib.updatemsg' will get an update message on join when an update for the plugin is available.")); + put(T2CLanguageEnum.german, List.of("Mit dieser Option können Sie festlegen, ob Spieler mit der Berechtigung 't2code.lib.updatemsg' beim Beitritt eine Update-Nachricht erhalten, wenn ein Update für das Plugin verfügbar ist.")); + }}), - updateCheckTimeInterval("plugin.updateCheck.timeInterval", 60, true,"In this option you can set the time interval in minutes in which updates should be checked."), + updateCheckTimeInterval("plugin.updateCheck.timeInterval", 60, true, + new HashMap<>() {{ + put(T2CLanguageEnum.english, List.of("In this option you can set the time interval in minutes in which updates should be checked.")); + put(T2CLanguageEnum.german, List.of("Mit dieser Option können Sie das Zeitintervall in Minuten festlegen, in dem Aktualisierungen überprüft werden sollen.")); + }}), - seePreReleaseUpdates("plugin.updateCheck.seePreReleaseUpdates", true, true,"In this option you can set whether you want to receive and display beta and snapshot versions in the update check."), + seePreReleaseUpdates("plugin.updateCheck.seePreReleaseUpdates", true, true, + new HashMap<>() {{ + put(T2CLanguageEnum.english, List.of("In this option you can set whether you want to receive and display beta and snapshot versions in the update check.")); + put(T2CLanguageEnum.german, List.of("In dieser Option können Sie einstellen, ob Sie Beta- und Snapshot-Versionen in der Update-Prüfung erhalten und anzeigen möchten.")); + }}), - updateCheckFullDisable("plugin.updateCheck.allPlugins.fullDisable", false, true,"This option deactivates all update checks for plugins that use the T2CodeLib."), + updateCheckFullDisable("plugin.updateCheck.allPlugins.fullDisable", false, true, + new HashMap<>() {{ + put(T2CLanguageEnum.english, List.of("This option deactivates all update checks for plugins that use the T2CodeLib.")); + put(T2CLanguageEnum.german, List.of("Diese Option deaktiviert alle Aktualisierungsprüfungen für Plugins, die die T2CodeLib verwenden.")); + }}), - debug("plugin.debug.debugModus", false,true, "The debug mode sends more detailed debug information to the console.", "In this version of the plugin no debug messages are built in!"), + debug("plugin.debug.debugModus", false, true, + new HashMap<>() {{ + put(T2CLanguageEnum.english, List.of("The debug mode sends more detailed debug information to the console.", "In this version of the plugin no debug messages are built in!")); + put(T2CLanguageEnum.german, List.of("Der Debug-Modus sendet ausführlichere Debug-Informationen an die Konsole.", "In dieser Version des Plugins sind keine Debug-Meldungen eingebaut!")); + }}), - developerTool("plugin.debug.developerTool", false, true,"This option activates advanced tools for the developers of plugins that use the T2CodeLib.", "If you don't know exactly what this is for, you should leave it deactivated!"), + developerTool("plugin.debug.developerTool", false, true, + new HashMap<>() {{ + put(T2CLanguageEnum.english, List.of("This option activates advanced tools for the developers of plugins that use the T2CodeLib.", "If you don't know exactly what this is for, you should leave it deactivated!")); + put(T2CLanguageEnum.german, List.of("Diese Option aktiviert erweiterte Werkzeuge für die Entwickler von Plugins, die die T2CodeLib verwenden.", "Wenn Sie nicht genau wissen, wozu das gut ist, sollten Sie es deaktiviert lassen!")); + }}), - language("plugin.language", "english", true,"In this option you can set the language of the plugin."), + language("plugin.language", "english", true, + new HashMap<>() {{ + put(T2CLanguageEnum.english, List.of("In this option you can set the language of the plugin.")); + put(T2CLanguageEnum.german, List.of("In dieser Option können Sie die Sprache des Plugins einstellen.")); + }}), - space_proxy("proxy", null, true,""), + space_proxy("proxy", null, true, + new HashMap<>() {{ + put(T2CLanguageEnum.english, List.of()); + put(T2CLanguageEnum.german, List.of()); + }}), + proxy("proxy.enable", T2CodeLibMain.getIsBungee(), true, + new HashMap<>() {{ + put(T2CLanguageEnum.english, List.of("This option must be activated if you use the T2CodeLib on a BungeeCord, Waterfall or Velocity Proxy as a bridge." + , "Please note that the individual APIs of the plugins that use a bridge on a proxy must be activated in the config.yml of the T2CodeLib on the proxy!")); + put(T2CLanguageEnum.german, List.of("Diese Option muss aktiviert werden, wenn Sie die T2CodeLib auf einem BungeeCord, Waterfall oder Velocity Proxy als Bridge verwenden." + , "Bitte beachten Sie, dass die einzelnen APIs der Plugins, die eine Bridge auf einem Proxy verwenden, in der config.yml der T2CodeLib auf dem Proxy aktiviert werden müssen!")); + }}), - proxy("proxy.enable", T2CodeLibMain.getIsBungee(), true,"This option must be activated if you use the T2CodeLib on a BungeeCord, Waterfall or Velocity Proxy as a bridge." - , "Please note that the individual APIs of the plugins that use a bridge on a proxy must be activated in the config.yml of the T2CodeLib on the proxy!"), + serverUUID("proxy.serverUUID", UUID.randomUUID(), true, + new HashMap<>() {{ + put(T2CLanguageEnum.english, List.of("This UUID is used for the communication of the plugins in a network with several servers.", "This UUID may only occur once in a network!")); + put(T2CLanguageEnum.german, List.of("Diese UUID wird für die Kommunikation der Plugins in einem Netzwerk mit mehreren Servern verwendet.", "Diese UUID darf nur einmal in einem Netz vorkommen!")); + }}), - serverUUID("proxy.serverUUID", UUID.randomUUID(),true, "This UUID is used for the communication of the plugins in a network with several servers.", "This UUID may only occur once in a network!"), + space_player("player", null, true, + new HashMap<>() {{ + put(T2CLanguageEnum.english, List.of()); + put(T2CLanguageEnum.german, List.of()); + }}), - space_player("player", null, true,""), + inventoriesCloseByServerStop("player.inventories.closeByServerStop", true, true, + new HashMap<>() {{ + put(T2CLanguageEnum.english, List.of("If this option is enabled, all players on the server (spigot, paper, etc.) will have their inventory / GUIs closed when the server is shut down or restarted.", + "This does not mean the entire network if a proxy is used),", "the inventory / GUIs are closed if players have them open when the server is shut down or restarted.")); + put(T2CLanguageEnum.german, List.of("Wenn diese Option aktiviert ist, werden alle Spieler auf dem Server (Spigot, Papier, etc.) ihr Inventar / GUIs geschlossen, wenn der Server heruntergefahren oder neu gestartet wird.", + "Damit ist nicht das gesamte Netz gemeint, wenn ein Proxy verwendet wird),", "das Inventar / die GUIs werden geschlossen, wenn Spieler sie geöffnet haben, wenn der Server heruntergefahren oder neu gestartet wird.")); + }}), - inventoriesCloseByServerStop("player.inventories.closeByServerStop", true, true,"If this option is enabled, all players on the server (spigot, paper, etc.) will have their inventory / GUIs closed when the server is shut down or restarted.", - "This does not mean the entire network if a proxy is used),", "the inventory / GUIs are closed if players have them open when the server is shut down or restarted."), + space_command("command", null, true, + new HashMap<>() {{ + put(T2CLanguageEnum.english, List.of()); + put(T2CLanguageEnum.german, List.of()); + }}), - space_command("command", null, true,""), - - commandPermToggleCommand("command.permToggle.permissionSetCommand", "lp user [player] permission set [perm] [value]", - true,"This option specifies which command is to be used for the T2CodeLib command '/t2code permtoggle '."), + commandPermToggleCommand("command.permToggle.permissionSetCommand", "lp user [player] permission set [perm] [value]", true, + new HashMap<>() {{ + put(T2CLanguageEnum.english, List.of("This option specifies which command is to be used for the T2CodeLib command '/t2code permtoggle '.")); + put(T2CLanguageEnum.german, List.of("Diese Option gibt an, welcher Befehl für den T2CodeLib-Befehl '/t2code permtoggle ' verwendet werden soll.")); + }}), ; private final String path; private Object value; private final boolean forceSet; - private final List comments; + private final HashMap> comments; - VALUES(String path, Object value,boolean forceSet, String... comments) { + VALUES(String path, Object value, boolean forceSet, HashMap> comments) { this.path = path; this.value = value; this.forceSet = forceSet; - this.comments = new ArrayList<>(Arrays.asList(comments)); + this.comments = comments; } @Override @@ -78,10 +130,15 @@ public class T2CLibConfig { } @Override - public List getComments() { + public HashMap> getComments() { return comments; } + @Override + public String getLanguagePath() { + return language.path; + } + @Override public void setValue(Object newValue) { value = newValue; diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/system/config/languages/Languages.java b/src/main/java/net/t2code/t2codelib/SPIGOT/system/config/languages/Languages.java new file mode 100644 index 0000000..4d6899b --- /dev/null +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/system/config/languages/Languages.java @@ -0,0 +1,99 @@ +// This class was created by JaTiTV. + +package net.t2code.t2codelib.SPIGOT.system.config.languages; + + +import net.t2code.t2codelib.T2CLanguageEnum; +import net.t2code.t2codelib.T2CconfigItemLanguages; +import net.t2code.t2codelib.SPIGOT.api.yaml.T2CconfigWriterLanguage; +import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain; +import net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig; +import net.t2code.t2codelib.Util; + +import java.util.*; + +public class Languages { + + public enum VALUES implements T2CconfigItemLanguages { + + + vaultNotSetUp("plugin.vaultNotSetUp", + null, + new HashMap<>() {{ + put(T2CLanguageEnum.english, "[prefix] &4Vault / Economy not set up!"); + put(T2CLanguageEnum.german, "[prefix] &4Vault / Economy nicht eingerichtet!"); + }}, + new HashMap<>() {{ + put(T2CLanguageEnum.english, List.of()); + put(T2CLanguageEnum.german, List.of()); + }}), + + votingPluginNotSetUp("plugin.votingPluginNotSetUp", + null, + new HashMap<>() {{ + put(T2CLanguageEnum.english, "[prefix] &4VotingPlugin is not present on the server!"); + put(T2CLanguageEnum.german, "[prefix] &4VotingPlugin ist auf dem Server nicht vorhanden!"); + }}, + new HashMap<>() {{ + put(T2CLanguageEnum.english, List.of()); + put(T2CLanguageEnum.german, List.of()); + }}), + soundNotFound("plugin.soundNotFound", + null, + new HashMap<>() {{ + put(T2CLanguageEnum.english, "[prefix] &4The sound &6[sound] &4was not found! Please check the settings."); + put(T2CLanguageEnum.german, "[prefix] &4Der Sound &6[sound] &4wurde nicht gefunden! Bitte [ue]berpr[ue]fe die Einstellungen."); + }}, + new HashMap<>() {{ + put(T2CLanguageEnum.english, List.of()); + put(T2CLanguageEnum.german, List.of()); + }}), + + ; + + private final String path; + private Object value; + private final HashMap lang; + private final HashMap> comments; + + VALUES(String path, Object value, HashMap lang, HashMap> comments) { + this.path = path; + this.value = value; + this.lang = lang; + this.comments = comments; + } + + @Override + public String getPath() { + return path; + } + + @Override + public Object getValue() { + if (value == null) { + return lang.get(T2CLanguageEnum.english); + } + return value; + } + + @Override + public HashMap getLanguage() { + return lang; + } + + @Override + public HashMap> getComments() { + return comments; + } + + @Override + public void setValue(Object newValue) { + value = newValue; + } + } + + public static void set() { + T2CconfigWriterLanguage.createConfig(T2CodeLibMain.getPath(), VALUES.values(), T2CLibConfig.VALUES.language.getValue().toString(), Util.getConfigLogo()); + + } +} \ No newline at end of file diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/system/config/languages/LanguagesCreate.java b/src/main/java/net/t2code/t2codelib/SPIGOT/system/config/languages/old/LanguagesCreate.java similarity index 96% rename from src/main/java/net/t2code/t2codelib/SPIGOT/system/config/languages/LanguagesCreate.java rename to src/main/java/net/t2code/t2codelib/SPIGOT/system/config/languages/old/LanguagesCreate.java index 5723e40..08491d3 100644 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/system/config/languages/LanguagesCreate.java +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/system/config/languages/old/LanguagesCreate.java @@ -1,4 +1,4 @@ -package net.t2code.t2codelib.SPIGOT.system.config.languages; +package net.t2code.t2codelib.SPIGOT.system.config.languages.old; import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend; import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate; diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/system/config/languages/MSG.java b/src/main/java/net/t2code/t2codelib/SPIGOT/system/config/languages/old/MSG.java similarity index 94% rename from src/main/java/net/t2code/t2codelib/SPIGOT/system/config/languages/MSG.java rename to src/main/java/net/t2code/t2codelib/SPIGOT/system/config/languages/old/MSG.java index becff7c..88642f6 100644 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/system/config/languages/MSG.java +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/system/config/languages/old/MSG.java @@ -1,6 +1,6 @@ // This claas was created by JaTiTV -package net.t2code.t2codelib.SPIGOT.system.config.languages; +package net.t2code.t2codelib.SPIGOT.system.config.languages.old; public class MSG { diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/system/config/languages/SelectLibMsg.java b/src/main/java/net/t2code/t2codelib/SPIGOT/system/config/languages/old/SelectLibMsg.java similarity index 97% rename from src/main/java/net/t2code/t2codelib/SPIGOT/system/config/languages/SelectLibMsg.java rename to src/main/java/net/t2code/t2codelib/SPIGOT/system/config/languages/old/SelectLibMsg.java index 35f91dd..6712152 100644 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/system/config/languages/SelectLibMsg.java +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/system/config/languages/old/SelectLibMsg.java @@ -1,4 +1,4 @@ -package net.t2code.t2codelib.SPIGOT.system.config.languages; +package net.t2code.t2codelib.SPIGOT.system.config.languages.old; import net.t2code.t2codelib.SPIGOT.api.messages.T2Creplace; import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend; diff --git a/src/main/java/net/t2code/t2codelib/T2CLanguageEnum.java b/src/main/java/net/t2code/t2codelib/T2CLanguageEnum.java new file mode 100644 index 0000000..6be098f --- /dev/null +++ b/src/main/java/net/t2code/t2codelib/T2CLanguageEnum.java @@ -0,0 +1,7 @@ +package net.t2code.t2codelib; + +public enum T2CLanguageEnum { + german, + english, + norwegian +} diff --git a/src/main/java/net/t2code/t2codelib/T2CconfigItem.java b/src/main/java/net/t2code/t2codelib/T2CconfigItem.java index 88dabdf..662841a 100644 --- a/src/main/java/net/t2code/t2codelib/T2CconfigItem.java +++ b/src/main/java/net/t2code/t2codelib/T2CconfigItem.java @@ -1,6 +1,7 @@ package net.t2code.t2codelib; +import java.util.HashMap; import java.util.List; public interface T2CconfigItem { @@ -24,7 +25,10 @@ public interface T2CconfigItem { /** * Set the description of the option here, the '# ' is automatically set in front of it */ - List getComments(); + HashMap> getComments(); + + + String getLanguagePath(); /** * This @void is used to reset the value of @getValue() @@ -33,61 +37,4 @@ public interface T2CconfigItem { } - - /** - * Set in your Class - * - * public enum VALUES implements T2CconfigItem { - * VALUE1("path", VALUE, true, "DESCRIPTION"), - * VALUE2("path", VALUE, true, "DESCRIPTION"), - * - * ; - * - * private final String path; - * private Object value; - * private final boolean forceSet; - * private final List comments; - * - * VALUES(String path, Object value,boolean forceSet, String... comments) { - * this.path = path; - * this.value = value; - * this.forceSet=forceSet; - * this.comments = new ArrayList<>(Arrays.asList(comments)); - * } - * - * @Override - * public String getPath() { - * return path; - * } - * - * @Override - * public Object getValue() { - * return value; - * } - * - * @Override - * public boolean getForceSet() { - * return forceSet; - * } - * - * @Override - * public List getComments() { - * return comments; - * } - * - * @Override - * public void setValue(Object newValue) { - * value = newValue; - * } - * } - * - * public static void set(){ - * try { - * ConvertT2CBlibConfig.convert(); - * } catch (IOException e) { - * throw new RuntimeException(e); - * } - * T2CBconfigWriter.createConfig(new File(getPlugin().getDataFolder(), "config.yml"), VALUES.values(), FILEHEADER); - * } - */ } diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/newLanguageFileBuilder/T2CconfigItemLanguages.java b/src/main/java/net/t2code/t2codelib/T2CconfigItemLanguages.java similarity index 79% rename from src/main/java/net/t2code/t2codelib/SPIGOT/newLanguageFileBuilder/T2CconfigItemLanguages.java rename to src/main/java/net/t2code/t2codelib/T2CconfigItemLanguages.java index fb54b9f..2c4149b 100644 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/newLanguageFileBuilder/T2CconfigItemLanguages.java +++ b/src/main/java/net/t2code/t2codelib/T2CconfigItemLanguages.java @@ -1,6 +1,7 @@ -package net.t2code.t2codelib.SPIGOT.newLanguageFileBuilder; +package net.t2code.t2codelib; +import java.util.HashMap; import java.util.List; public interface T2CconfigItemLanguages { @@ -18,13 +19,13 @@ public interface T2CconfigItemLanguages { */ Object getValue(); - List getLanguage(); + HashMap getLanguage(); /** * Set the description of the option here, the '# ' is automatically set in front of it */ - List getComments(); + HashMap> getComments(); /** diff --git a/src/main/java/net/t2code/t2codelib/VELOCITY/api/yml/T2CVconfigWriter.java b/src/main/java/net/t2code/t2codelib/VELOCITY/api/yml/T2CVconfigWriter.java index 376829a..09b47ec 100644 --- a/src/main/java/net/t2code/t2codelib/VELOCITY/api/yml/T2CVconfigWriter.java +++ b/src/main/java/net/t2code/t2codelib/VELOCITY/api/yml/T2CVconfigWriter.java @@ -1,6 +1,7 @@ package net.t2code.t2codelib.VELOCITY.api.yml;// This class was created by JaTiTV. +import net.t2code.t2codelib.T2CLanguageEnum; import net.t2code.t2codelib.T2CconfigItem; import org.slf4j.Logger; import org.yaml.snakeyaml.Yaml; @@ -32,11 +33,17 @@ public class T2CVconfigWriter { if (config == null) { config = new LinkedHashMap<>(); } + + T2CLanguageEnum lang = T2CLanguageEnum.english; + for (T2CconfigItem item : manager) { if (item.getForceSet() || !exist) { readValue(config, item.getPath(), item); addValue(config, item.getPath(), item.getValue()); - comments.put(item.getPath(), item.getComments()); + List commandList = item.getComments().get(lang); + if (commandList != null) { + comments.put(item.getPath(), commandList); + } } } diff --git a/src/main/java/net/t2code/t2codelib/VELOCITY/system/config/T2CVlibConfig.java b/src/main/java/net/t2code/t2codelib/VELOCITY/system/config/T2CVlibConfig.java index ebe10f8..822279c 100644 --- a/src/main/java/net/t2code/t2codelib/VELOCITY/system/config/T2CVlibConfig.java +++ b/src/main/java/net/t2code/t2codelib/VELOCITY/system/config/T2CVlibConfig.java @@ -1,6 +1,6 @@ package net.t2code.t2codelib.VELOCITY.system.config; -import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate; +import net.t2code.t2codelib.T2CLanguageEnum; import net.t2code.t2codelib.T2CconfigItem; import net.t2code.t2codelib.Util; import net.t2code.t2codelib.VELOCITY.api.messages.T2CVsend; @@ -10,33 +10,50 @@ import org.slf4j.Logger; import java.io.File; import java.io.IOException; import java.nio.file.Path; -import java.util.ArrayList; -import java.util.Arrays; +import java.util.HashMap; import java.util.List; public class T2CVlibConfig { public enum VALUES implements T2CconfigItem { - updateTimer("updateCheck.timerInMin", 60, true, "In this option you can set the time interval in minutes in which updates should be checked."), - seePreReleaseUpdates("updateCheck.seePreReleaseUpdates", true, true, "In this option you can set whether you want to receive and display beta and snapshot versions in the update check."), + updateTimer("updateCheck.timerInMin", 60, true, + new HashMap<>() {{ + put(T2CLanguageEnum.english, List.of("In this option you can set the time interval in minutes in which updates should be checked.")); + }}), + seePreReleaseUpdates("updateCheck.seePreReleaseUpdates", true, true, + new HashMap<>() {{ + put(T2CLanguageEnum.english, List.of("In this option you can set whether you want to receive and display beta and snapshot versions in the update check.")); + }}), - debug("plugin.debug.debugModus", false, true, "The debug mode sends more detailed debug information to the console."), + debug("plugin.debug.debugModus", false, true, + new HashMap<>() {{ + put(T2CLanguageEnum.english, List.of("The debug mode sends more detailed debug information to the console.")); + }}), - apiCommandGUIEnable("api.commandGUI.enable", false, true, "With this option you activate the api interface for the T2C-CommandGUI plugin."), - apiAutoResponse("api.autoResponse.enable", false, true, "With this option you activate the api interface for the T2C-AutoResponse plugin."), - apiOpSecurity("api.opSecurity.enable", false, true, "With this option you activate the api interface for the T2C-OPSecurity plugin."), + apiCommandGUIEnable("api.commandGUI.enable", false, true, + new HashMap<>() {{ + put(T2CLanguageEnum.english, List.of("With this option you activate the api interface for the T2C-CommandGUI plugin.")); + }}), + apiAutoResponse("api.autoResponse.enable", false, true, + new HashMap<>() {{ + put(T2CLanguageEnum.english, List.of("With this option you activate the api interface for the T2C-AutoResponse plugin.")); + }}), + apiOpSecurity("api.opSecurity.enable", false, true, + new HashMap<>() {{ + put(T2CLanguageEnum.english, List.of("With this option you activate the api interface for the T2C-OPSecurity plugin.")); + }}), ; private final String path; private Object value; private final boolean forceSet; - private final List comments; + private final HashMap> comments; - VALUES(String path, Object value, boolean forceSet, String... comments) { + VALUES(String path, Object value, boolean forceSet, HashMap> comments) { this.path = path; this.value = value; this.forceSet = forceSet; - this.comments = new ArrayList<>(Arrays.asList(comments)); + this.comments = comments; } @Override @@ -55,10 +72,15 @@ public class T2CVlibConfig { } @Override - public List getComments() { + public HashMap> getComments() { return comments; } + @Override + public String getLanguagePath() { + return null; + } + @Override public void setValue(Object newValue) { value = newValue;