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