Changes to the creation of config files

- Comments in multiple languages
- Language files with the new ConfigWriter
This commit is contained in:
JaTiTV 2024-07-03 23:48:51 +02:00
parent 5a49cc625a
commit 44c35bd185
24 changed files with 468 additions and 427 deletions

View File

@ -6,7 +6,7 @@
<groupId>net.t2code</groupId> <groupId>net.t2code</groupId>
<artifactId>T2CodeLib</artifactId> <artifactId>T2CodeLib</artifactId>
<version>16.7_dev-4</version> <version>16.7_dev-5</version>
<!--version>VERSION_snapshot-0</version--> <!--version>VERSION_snapshot-0</version-->
<!--version>VERSION_beta-0</version--> <!--version>VERSION_beta-0</version-->
<!--version>VERSION_dev-0</version--> <!--version>VERSION_dev-0</version-->

View File

@ -6,6 +6,7 @@ import net.md_5.bungee.config.ConfigurationProvider;
import net.md_5.bungee.config.YamlConfiguration; import net.md_5.bungee.config.YamlConfiguration;
import net.t2code.t2codelib.T2CconfigItem; import net.t2code.t2codelib.T2CconfigItem;
import net.md_5.bungee.config.Configuration; import net.md_5.bungee.config.Configuration;
import net.t2code.t2codelib.T2CLanguageEnum;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -38,14 +39,18 @@ public class T2CBconfigWriter {
} }
Map<String, List<String>> comments = new LinkedHashMap<>(); Map<String, List<String>> comments = new LinkedHashMap<>();
T2CLanguageEnum lang = T2CLanguageEnum.english;
for(T2CconfigItem item : values){ for(T2CconfigItem item : values){
if (item.getForceSet() || !exist) { if (item.getForceSet() || !exist) {
if(!config.contains(item.getPath())){ if(!config.contains(item.getPath())){
config.set(item.getPath(), item.getValue()); config.set(item.getPath(), item.getValue());
} }
comments.put(item.getPath(), item.getComments()); List<String> commandList = item.getComments().get(lang);
if (commandList != null){
comments.put(item.getPath(),commandList );
}
} }
} }
saveConfigWithComments(configFile, comments, header); saveConfigWithComments(configFile, comments, header);
readConfig(config,values); readConfig(config,values);

View File

@ -3,35 +3,50 @@ package net.t2code.t2codelib.BUNGEE.system.config;
import net.t2code.t2codelib.BUNGEE.api.yaml.T2CBconfigWriter; import net.t2code.t2codelib.BUNGEE.api.yaml.T2CBconfigWriter;
import net.t2code.t2codelib.BUNGEE.system.T2CodeBMain; import net.t2code.t2codelib.BUNGEE.system.T2CodeBMain;
import net.t2code.t2codelib.T2CconfigItem; import net.t2code.t2codelib.T2CconfigItem;
import net.t2code.t2codelib.T2CLanguageEnum;
import net.t2code.t2codelib.Util; import net.t2code.t2codelib.Util;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.HashMap;
import java.util.Arrays;
import java.util.List; import java.util.List;
public class T2CBlibConfig { public class T2CBlibConfig {
public enum VALUES implements T2CconfigItem { 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."), updateTimer("updateCheck.timerInMin", 60, true,
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."), 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."), apiCommandGUIEnable("api.commandGUI.enable", false, true,
apiAutoResponse("api.autoResponse.enable", false,true,"With this option you activate the api interface for the T2C-AutoResponse plugin."), new HashMap<>() {{
apiOpSecurity("api.opSecurity.enable", false,true,"With this option you activate the api interface for the T2C-OPSecurity plugin."), 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 final String path;
private Object value; private Object value;
private final boolean forceSet; private final boolean forceSet;
private final List<String> comments; private final HashMap<T2CLanguageEnum, List<String>> comments;
VALUES(String path, Object value,boolean forceSet, String... comments) { VALUES(String path, Object value, boolean forceSet, HashMap<T2CLanguageEnum, List<String>> comments) {
this.path = path; this.path = path;
this.value = value; this.value = value;
this.forceSet = forceSet; this.forceSet = forceSet;
this.comments = new ArrayList<>(Arrays.asList(comments)); this.comments = comments;
} }
@Override @Override
@ -50,10 +65,15 @@ public class T2CBlibConfig {
} }
@Override @Override
public List<String> getComments() { public HashMap<T2CLanguageEnum, List<String>> getComments() {
return comments; return comments;
} }
@Override
public String getLanguagePath() {
return null;
}
@Override @Override
public void setValue(Object newValue) { public void setValue(Object newValue) {
value = newValue; value = newValue;

View File

@ -4,7 +4,7 @@ import com.bencodez.votingplugin.VotingPluginMain;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend; import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.SPIGOT.api.plugins.T2CpluginCheck; import net.t2code.t2codelib.SPIGOT.api.plugins.T2CpluginCheck;
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain; 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.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -2,17 +2,13 @@ package net.t2code.t2codelib.SPIGOT.api.messages;
import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI; import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI;
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain; import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
import net.t2code.t2codelib.T2CconfigItem;
import net.t2code.t2codelib.T2CupdateWebData; import net.t2code.t2codelib.T2CupdateWebData;
import net.t2code.t2codelib.Util; import net.t2code.t2codelib.Util;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginLogger;
import org.jetbrains.annotations.NotNull;
import java.util.List; import java.util.List;
import java.util.logging.Level;
public class T2Ctemplate { public class T2Ctemplate {
public static Long onLoadHeader(String prefix, List<String> autor, String version, String spigot, String discord) { public static Long onLoadHeader(String prefix, List<String> autor, String version, String spigot, String discord) {

View File

@ -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.T2Creplace;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend; import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion; 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.Sound;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;

View File

@ -2,14 +2,13 @@
package net.t2code.t2codelib.SPIGOT.api.yaml; package net.t2code.t2codelib.SPIGOT.api.yaml;
import net.t2code.t2codelib.T2CLanguageEnum;
import net.t2code.t2codelib.T2CconfigItem; import net.t2code.t2codelib.T2CconfigItem;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -18,7 +17,6 @@ public class T2CconfigWriter {
private static FileConfiguration config; private static FileConfiguration config;
public static void createConfig(File configFile, T2CconfigItem[] values, String... header) { public static void createConfig(File configFile, T2CconfigItem[] values, String... header) {
boolean exist = configFile.exists(); boolean exist = configFile.exists();
if (!exist) { if (!exist) {
@ -34,17 +32,27 @@ public class T2CconfigWriter {
config = YamlConfiguration.loadConfiguration(configFile); config = YamlConfiguration.loadConfiguration(configFile);
Map<String, List<String>> comments = new LinkedHashMap<>(); Map<String, List<String>> 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) { for (T2CconfigItem item : values) {
if (item.getForceSet() || !exist) { if (item.getForceSet() || !exist) {
config.addDefault(item.getPath(), item.getValue()); config.addDefault(item.getPath(), item.getValue());
comments.put(item.getPath(), item.getComments());
List<String> commandList = item.getComments().get(lang);
if (commandList != null) {
comments.put(item.getPath(), commandList);
}
} }
} }
// Copy default values if they are missing // Copy default values if they are missing
config.options().copyDefaults(true); config.options().copyDefaults(true);
saveConfigWithComments(configFile, comments, header); T2CymlWriter.saveConfigWithComments(configFile, config, comments, header);
readConfig(config, values); readConfig(config, values);
} }
@ -53,61 +61,4 @@ public class T2CconfigWriter {
value.setValue(config.get(value.getPath())); value.setValue(config.get(value.getPath()));
} }
} }
private static void saveConfigWithComments(File file, Map<String, List<String>> 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<String, List<String>> 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<String> 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<Object> zw = (List<Object>) 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");
}
}
}
}
} }

View File

@ -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<File> 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<String, List<String>> 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<String> 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);
}
}

View File

@ -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<String, List<String>> 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<String, List<String>> 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<String> 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<Object> zw = (List<Object>) 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");
}
}
}
}
}

View File

@ -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<T2ClanguageObject> lang;
private final List<String> comments;
VALUES(String path, Object value, List<T2ClanguageObject> 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<T2ClanguageObject> getLanguage() {
return lang;
}
@Override
public List<String> 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());
}
}

View File

@ -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<String> 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<String, List<String>> 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<String, List<String>> 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<String, List<String>> 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<String> 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<Object> zw = (List<Object>) 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");
}
}
}
}
}

View File

@ -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;
}
}

View File

@ -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.Development;
import net.t2code.t2codelib.SPIGOT.system.cmd.ReportLogStorage; import net.t2code.t2codelib.SPIGOT.system.cmd.ReportLogStorage;
import net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig; 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.T2CplatformDetector;
import net.t2code.t2codelib.Util; import net.t2code.t2codelib.Util;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;

View File

@ -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.T2CbungeeCommandSenderReciver;
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain; import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
import net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig; 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.T2CupdateObject;
import net.t2code.t2codelib.Util; import net.t2code.t2codelib.Util;
import org.bukkit.command.Command; import org.bukkit.command.Command;
@ -70,6 +71,7 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
return false; return false;
} }
T2CLibConfig.set(); T2CLibConfig.set();
Languages.set();
T2Csend.sender(sender, Util.getPrefix() + " §2Config successfully reloaded"); T2Csend.sender(sender, Util.getPrefix() + " §2Config successfully reloaded");
return false; return false;
case "debug": case "debug":

View File

@ -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.messages.T2Ctemplate;
import net.t2code.t2codelib.SPIGOT.api.yaml.T2CconfigWriter; import net.t2code.t2codelib.SPIGOT.api.yaml.T2CconfigWriter;
import net.t2code.t2codelib.T2CLanguageEnum;
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain; import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
import net.t2code.t2codelib.T2CconfigItem; import net.t2code.t2codelib.T2CconfigItem;
import net.t2code.t2codelib.Util; import net.t2code.t2codelib.Util;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.*;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
public class T2CLibConfig { public class T2CLibConfig {
public enum VALUES implements T2CconfigItem { 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." serverUUID("proxy.serverUUID", UUID.randomUUID(), true,
, "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!"), 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.", space_command("command", null, true,
"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."), 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,
new HashMap<>() {{
commandPermToggleCommand("command.permToggle.permissionSetCommand", "lp user [player] permission set [perm] [value]", put(T2CLanguageEnum.english, List.of("This option specifies which command is to be used for the T2CodeLib command '/t2code permtoggle <player> <permission>'."));
true,"This option specifies which command is to be used for the T2CodeLib command '/t2code permtoggle <player> <permission>'."), put(T2CLanguageEnum.german, List.of("Diese Option gibt an, welcher Befehl für den T2CodeLib-Befehl '/t2code permtoggle <player> <permission>' verwendet werden soll."));
}}),
; ;
private final String path; private final String path;
private Object value; private Object value;
private final boolean forceSet; private final boolean forceSet;
private final List<String> comments; private final HashMap<T2CLanguageEnum, List<String>> comments;
VALUES(String path, Object value,boolean forceSet, String... comments) { VALUES(String path, Object value, boolean forceSet, HashMap<T2CLanguageEnum, List<String>> comments) {
this.path = path; this.path = path;
this.value = value; this.value = value;
this.forceSet = forceSet; this.forceSet = forceSet;
this.comments = new ArrayList<>(Arrays.asList(comments)); this.comments = comments;
} }
@Override @Override
@ -78,10 +130,15 @@ public class T2CLibConfig {
} }
@Override @Override
public List<String> getComments() { public HashMap<T2CLanguageEnum, List<String>> getComments() {
return comments; return comments;
} }
@Override
public String getLanguagePath() {
return language.path;
}
@Override @Override
public void setValue(Object newValue) { public void setValue(Object newValue) {
value = newValue; value = newValue;

View File

@ -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<T2CLanguageEnum, String> lang;
private final HashMap<T2CLanguageEnum, List<String>> comments;
VALUES(String path, Object value, HashMap<T2CLanguageEnum, String> lang, HashMap<T2CLanguageEnum, List<String>> 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<T2CLanguageEnum, String> getLanguage() {
return lang;
}
@Override
public HashMap<T2CLanguageEnum, List<String>> 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());
}
}

View File

@ -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.T2Csend;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate; import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;

View File

@ -1,6 +1,6 @@
// This claas was created by JaTiTV // 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 { public class MSG {

View File

@ -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.T2Creplace;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend; import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;

View File

@ -0,0 +1,7 @@
package net.t2code.t2codelib;
public enum T2CLanguageEnum {
german,
english,
norwegian
}

View File

@ -1,6 +1,7 @@
package net.t2code.t2codelib; package net.t2code.t2codelib;
import java.util.HashMap;
import java.util.List; import java.util.List;
public interface T2CconfigItem { 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 * Set the description of the option here, the '# ' is automatically set in front of it
*/ */
List<String> getComments(); HashMap<T2CLanguageEnum,List<String>> getComments();
String getLanguagePath();
/** /**
* This @void is used to reset the value of @getValue() * 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<String> 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<String> 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);
* }
*/
} }

View File

@ -1,6 +1,7 @@
package net.t2code.t2codelib.SPIGOT.newLanguageFileBuilder; package net.t2code.t2codelib;
import java.util.HashMap;
import java.util.List; import java.util.List;
public interface T2CconfigItemLanguages { public interface T2CconfigItemLanguages {
@ -18,13 +19,13 @@ public interface T2CconfigItemLanguages {
*/ */
Object getValue(); Object getValue();
List<T2ClanguageObject> getLanguage(); HashMap<T2CLanguageEnum, String> getLanguage();
/** /**
* Set the description of the option here, the '# ' is automatically set in front of it * Set the description of the option here, the '# ' is automatically set in front of it
*/ */
List<String> getComments(); HashMap<T2CLanguageEnum, List<String>> getComments();
/** /**

View File

@ -1,6 +1,7 @@
package net.t2code.t2codelib.VELOCITY.api.yml;// This class was created by JaTiTV. package net.t2code.t2codelib.VELOCITY.api.yml;// This class was created by JaTiTV.
import net.t2code.t2codelib.T2CLanguageEnum;
import net.t2code.t2codelib.T2CconfigItem; import net.t2code.t2codelib.T2CconfigItem;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.Yaml;
@ -32,11 +33,17 @@ public class T2CVconfigWriter {
if (config == null) { if (config == null) {
config = new LinkedHashMap<>(); config = new LinkedHashMap<>();
} }
T2CLanguageEnum lang = T2CLanguageEnum.english;
for (T2CconfigItem item : manager) { for (T2CconfigItem item : manager) {
if (item.getForceSet() || !exist) { if (item.getForceSet() || !exist) {
readValue(config, item.getPath(), item); readValue(config, item.getPath(), item);
addValue(config, item.getPath(), item.getValue()); addValue(config, item.getPath(), item.getValue());
comments.put(item.getPath(), item.getComments()); List<String> commandList = item.getComments().get(lang);
if (commandList != null) {
comments.put(item.getPath(), commandList);
}
} }
} }

View File

@ -1,6 +1,6 @@
package net.t2code.t2codelib.VELOCITY.system.config; 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.T2CconfigItem;
import net.t2code.t2codelib.Util; import net.t2code.t2codelib.Util;
import net.t2code.t2codelib.VELOCITY.api.messages.T2CVsend; import net.t2code.t2codelib.VELOCITY.api.messages.T2CVsend;
@ -10,33 +10,50 @@ import org.slf4j.Logger;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.ArrayList; import java.util.HashMap;
import java.util.Arrays;
import java.util.List; import java.util.List;
public class T2CVlibConfig { public class T2CVlibConfig {
public enum VALUES implements T2CconfigItem { 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."), updateTimer("updateCheck.timerInMin", 60, true,
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."), 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."), apiCommandGUIEnable("api.commandGUI.enable", false, true,
apiAutoResponse("api.autoResponse.enable", false, true, "With this option you activate the api interface for the T2C-AutoResponse plugin."), new HashMap<>() {{
apiOpSecurity("api.opSecurity.enable", false, true, "With this option you activate the api interface for the T2C-OPSecurity plugin."), 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 final String path;
private Object value; private Object value;
private final boolean forceSet; private final boolean forceSet;
private final List<String> comments; private final HashMap<T2CLanguageEnum, List<String>> comments;
VALUES(String path, Object value, boolean forceSet, String... comments) { VALUES(String path, Object value, boolean forceSet, HashMap<T2CLanguageEnum, List<String>> comments) {
this.path = path; this.path = path;
this.value = value; this.value = value;
this.forceSet = forceSet; this.forceSet = forceSet;
this.comments = new ArrayList<>(Arrays.asList(comments)); this.comments = comments;
} }
@Override @Override
@ -55,10 +72,15 @@ public class T2CVlibConfig {
} }
@Override @Override
public List<String> getComments() { public HashMap<T2CLanguageEnum, List<String>> getComments() {
return comments; return comments;
} }
@Override
public String getLanguagePath() {
return null;
}
@Override @Override
public void setValue(Object newValue) { public void setValue(Object newValue) {
value = newValue; value = newValue;