From 5a49cc625a8b52efb2831805c1bc4acfe988e0f0 Mon Sep 17 00:00:00 2001 From: JaTiTV Date: Wed, 3 Jul 2024 03:28:17 +0200 Subject: [PATCH] add ConfigWriter for Language Files / smal changes --- .idea/misc.xml | 3 + pom.xml | 2 +- .../SPIGOT/api/messages/T2Csend.java | 15 ++ .../SPIGOT/api/messages/T2Ctemplate.java | 16 ++- .../api/minecraftVersion/T2CmcVersion.java | 8 ++ .../api/minecraftVersion/T2CnmsEnum.java | 1 + .../SPIGOT/api/yaml/T2CconfigWriter.java | 1 + .../newLanguageFileBuilder/Languages.java | 82 +++++++++++ .../T2CconfigItemLanguages.java | 36 +++++ .../T2CconfigWriterLanguage.java | 133 ++++++++++++++++++ .../T2ClanguageObject.java | 20 +++ .../SPIGOT/system/T2CodeLibMain.java | 93 ++++++------ .../system/config/languages/SelectLibMsg.java | 1 - .../net/t2code/t2codelib/T2CconfigItem.java | 58 ++++++++ src/main/java/net/t2code/t2codelib/Util.java | 22 ++- .../VELOCITY/api/yml/T2CVconfigWriter.java | 6 +- 16 files changed, 438 insertions(+), 59 deletions(-) create mode 100644 src/main/java/net/t2code/t2codelib/SPIGOT/newLanguageFileBuilder/Languages.java create mode 100644 src/main/java/net/t2code/t2codelib/SPIGOT/newLanguageFileBuilder/T2CconfigItemLanguages.java create mode 100644 src/main/java/net/t2code/t2codelib/SPIGOT/newLanguageFileBuilder/T2CconfigWriterLanguage.java create mode 100644 src/main/java/net/t2code/t2codelib/SPIGOT/newLanguageFileBuilder/T2ClanguageObject.java diff --git a/.idea/misc.xml b/.idea/misc.xml index 63ea76a..eb70eb9 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -5,6 +5,9 @@ + + + diff --git a/pom.xml b/pom.xml index 46d0628..f22c1bd 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ net.t2code T2CodeLib - 16.7_dev-3 + 16.7_dev-4 diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/api/messages/T2Csend.java b/src/main/java/net/t2code/t2codelib/SPIGOT/api/messages/T2Csend.java index 8fb8196..2e5ee82 100644 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/api/messages/T2Csend.java +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/api/messages/T2Csend.java @@ -58,15 +58,30 @@ public class T2Csend { player.sendTitle(title, subtitle, fadeIn, stay, fadeOut); } + /** + * + * Use: T2Cdebug.debug(Plugin plugin, String msg) or T2Cdebug.debug(Plugin plugin, String msg, Integer stage) + */ + @Deprecated public static void debug(Plugin plugin, String msg) { debug(plugin, msg, null); } + /** + * + * Use: T2Cdebug.debug(Plugin plugin, String msg) or T2Cdebug.debug(Plugin plugin, String msg, Integer stage) + */ + @Deprecated public static void debug(Plugin plugin, String msg, Integer stage) { // if (!new File(Main.getPath(), "config.yml").exists()) return; T2Cdebug.debug(plugin, msg, stage); } + /** + * + * Use: T2Cdebug.debugmsg(plugin, msg) + */ + @Deprecated public static void debugmsg(Plugin plugin, String msg) { T2Cdebug.debugmsg(plugin, msg); } 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 3d77367..abb9886 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,6 +2,7 @@ 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; @@ -35,10 +36,9 @@ public class T2Ctemplate { */ - T2Csend.console(prefix + " §e╔════════════════════════════════════"); - onStartMsg(prefix,""); + for (String s : Util.getLoadLogo()) { - onStartMsg(prefix, s); + T2Csend.console(prefix + " §e" + s); } onStartMsg(prefix,""); onStartMsg(prefix,"§2Author §6" + String.valueOf(autor).replace("[", "").replace("]", "")); @@ -58,8 +58,14 @@ public class T2Ctemplate { onLoadSeparateStroke(prefix); if (version.toLowerCase().contains("dev") || version.toLowerCase().contains("snapshot") || version.toLowerCase().contains("beta")) { - T2Csend.console(prefix + " §eYou are running §4" + version + " §eof " + prefix + "§e! Some features may not be working as expected. Please report all" + - " bugs here: http://dc.t2code.net §4UpdateChecker & bStats may be disabled!"); + T2Csend.warning(T2CodeLibMain.getPlugin(), ""); + T2Csend.warning(T2CodeLibMain.getPlugin(), ""); + onStartMsg(prefix, "§eYou are running §4" + version + " §eof " + prefix + "§e!"); + onStartMsg(prefix, "§eSome features may not be working as expected."); + onStartMsg(prefix, "§ePlease report all bugs here: http://dc.t2code.net"); + onStartMsg(prefix, "§4UpdateChecker & bStats may be disabled!"); + T2Csend.warning(T2CodeLibMain.getPlugin(), ""); + T2Csend.warning(T2CodeLibMain.getPlugin(), ""); onLoadSeparateStroke(prefix); try { diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/api/minecraftVersion/T2CmcVersion.java b/src/main/java/net/t2code/t2codelib/SPIGOT/api/minecraftVersion/T2CmcVersion.java index 7d49a5f..7abd124 100644 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/api/minecraftVersion/T2CmcVersion.java +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/api/minecraftVersion/T2CmcVersion.java @@ -31,6 +31,7 @@ public class T2CmcVersion { mc1_19 = mcVersion.contains("MC: 1.19"); mc1_20 = mcVersion.contains("MC: 1.20"); mc1_21 = mcVersion.contains("MC: 1.21"); + mc1_22 = mcVersion.contains("MC: 1.22"); nms1_8_R1 = nms.contains("1_8_R1"); nms1_8_R2 = nms.contains("1_8_R2"); @@ -57,6 +58,7 @@ public class T2CmcVersion { nms1_20_R3 = nms.contains("1_20_R3"); nms1_20_R4 = nms.contains("1_20_R4"); nms1_21_R1 = nms.contains("1_21_R1"); + nms1_21_R2 = nms.contains("1_21_R2"); } private static String mcVersion; @@ -75,6 +77,7 @@ public class T2CmcVersion { private static boolean mc1_19; private static boolean mc1_20; private static boolean mc1_21; + private static boolean mc1_22; private static String nms; private static boolean nms1_8_R1; @@ -102,6 +105,7 @@ public class T2CmcVersion { private static boolean nms1_20_R3; private static boolean nms1_20_R4; private static boolean nms1_21_R1; + private static boolean nms1_21_R2; public static String getMcVersion() { return mcVersion; @@ -167,6 +171,10 @@ public class T2CmcVersion { return mc1_21; } + public static boolean isMc1_22() { + return mc1_22; + } + public static String getNms() { return nms; } diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/api/minecraftVersion/T2CnmsEnum.java b/src/main/java/net/t2code/t2codelib/SPIGOT/api/minecraftVersion/T2CnmsEnum.java index f22f553..fa97c67 100644 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/api/minecraftVersion/T2CnmsEnum.java +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/api/minecraftVersion/T2CnmsEnum.java @@ -28,4 +28,5 @@ public enum T2CnmsEnum { v1_20_R3, v1_20_R4, v1_21_R1, + v1_21_R2, } 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 c83214a..654548c 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 @@ -93,6 +93,7 @@ public class T2CconfigWriter { 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; diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/newLanguageFileBuilder/Languages.java b/src/main/java/net/t2code/t2codelib/SPIGOT/newLanguageFileBuilder/Languages.java new file mode 100644 index 0000000..07605e3 --- /dev/null +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/newLanguageFileBuilder/Languages.java @@ -0,0 +1,82 @@ +// 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/T2CconfigItemLanguages.java b/src/main/java/net/t2code/t2codelib/SPIGOT/newLanguageFileBuilder/T2CconfigItemLanguages.java new file mode 100644 index 0000000..fb54b9f --- /dev/null +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/newLanguageFileBuilder/T2CconfigItemLanguages.java @@ -0,0 +1,36 @@ +package net.t2code.t2codelib.SPIGOT.newLanguageFileBuilder; + + +import java.util.List; + +public interface T2CconfigItemLanguages { + /** + * Returns the path of the option for the config + * + * @return Config path of the option + */ + String getPath(); + + /** + * Returns the default value of the option and, after reading the config, the value from the config + * + * @return Value of the option + */ + Object getValue(); + + List getLanguage(); + + + /** + * Set the description of the option here, the '# ' is automatically set in front of it + */ + List getComments(); + + + /** + * This @void is used to reset the value of @getValue() + */ + default void setValue(Object newValue) { + + } +} diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/newLanguageFileBuilder/T2CconfigWriterLanguage.java b/src/main/java/net/t2code/t2codelib/SPIGOT/newLanguageFileBuilder/T2CconfigWriterLanguage.java new file mode 100644 index 0000000..4842a88 --- /dev/null +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/newLanguageFileBuilder/T2CconfigWriterLanguage.java @@ -0,0 +1,133 @@ +// 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 new file mode 100644 index 0000000..50c7af1 --- /dev/null +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/newLanguageFileBuilder/T2ClanguageObject.java @@ -0,0 +1,20 @@ +// 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 05c8679..6a692a2 100644 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/system/T2CodeLibMain.java +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/system/T2CodeLibMain.java @@ -5,6 +5,7 @@ import net.kyori.adventure.platform.bukkit.BukkitAudiences; import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.permission.Permission; import net.t2code.t2codelib.SPIGOT.api.bungeePlayers.T2CbungeePlayers; +import net.t2code.t2codelib.SPIGOT.api.debug.T2Cdebug; import net.t2code.t2codelib.SPIGOT.api.items.T2CitemVersion; import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend; import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate; @@ -18,8 +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.system.config.languages.LanguagesCreate; -import net.t2code.t2codelib.SPIGOT.system.config.languages.SelectLibMsg; +import net.t2code.t2codelib.SPIGOT.newLanguageFileBuilder.Languages; import net.t2code.t2codelib.T2CplatformDetector; import net.t2code.t2codelib.Util; import org.bukkit.Bukkit; @@ -31,15 +31,21 @@ import java.io.File; import java.util.List; public final class T2CodeLibMain extends JavaPlugin { + @Getter private static T2CodeLibMain plugin; + @Getter private static Economy eco = null; + @Getter private static Permission perm = null; + @Getter private static List autor; + @Getter private static String version; @Getter private static Boolean mmIsLoad = true; + @Getter private static Boolean load = false; @Getter private static T2CplatformDetector.PlatformType plattform; @@ -49,7 +55,7 @@ public final class T2CodeLibMain extends JavaPlugin { // Plugin startup logic plugin = this; autor = plugin.getDescription().getAuthors(); - // logger = getLogger(); + // logger = getLogger(); version = plugin.getDescription().getVersion(); try { @@ -71,25 +77,40 @@ public final class T2CodeLibMain extends JavaPlugin { T2CmcVersion.onCheck(); if (T2CnmsVersions.getT2CnmsEnum() == T2CnmsEnum.not_support) { + T2Csend.warning(plugin, ""); + T2Csend.warning(plugin, ""); + T2Csend.warning(plugin, ""); T2Ctemplate.onStartMsg(prefix, "§4!!!!!!!!!!!!!!!!!!!!"); T2Ctemplate.onStartMsg(prefix, ""); - T2Csend.warning(plugin, "The " + T2CmcVersion.getMcVersion() + " is a very fresh / new version."); - T2Csend.warning(plugin, "The plugin may not yet be supported on this server! If there are any bugs in our plugins, please report them to us via our Discord: http://dc.t2code.net"); + T2Ctemplate.onStartMsg(prefix, "The " + T2CmcVersion.getMcVersion() + " is a very fresh / new version."); + T2Ctemplate.onStartMsg(prefix, "The plugin may not yet be supported on this server!"); + T2Ctemplate.onStartMsg(prefix, "If there are any bugs in our plugins,"); + T2Ctemplate.onStartMsg(prefix, "please report them to us via our Discord: http://dc.t2code.net"); T2Ctemplate.onStartMsg(prefix, ""); T2Ctemplate.onStartMsg(prefix, "§4!!!!!!!!!!!!!!!!!!!!"); + T2Csend.warning(plugin, ""); + T2Csend.warning(plugin, ""); + T2Csend.warning(plugin, ""); try { - Thread.sleep(2000); + Thread.sleep(5000); } catch (InterruptedException e) { e.printStackTrace(); } - } - if (T2CmcVersion.isMc1_21()) { + if (T2CmcVersion.isMc1_22()) { + T2Csend.warning(plugin, ""); + T2Csend.warning(plugin, ""); + T2Csend.warning(plugin, ""); T2Ctemplate.onStartMsg(prefix, "§4!!!!!!!!!!!!!!!!!!!!"); T2Ctemplate.onStartMsg(prefix, ""); - T2Csend.warning(plugin, "The 1.21 is a very fresh / new version. If there are any bugs in our plugins, please report them to us via our Discord: http://dc.t2code.net"); + T2Ctemplate.onStartMsg(prefix, "The 1.22 is a very fresh / new version."); + T2Ctemplate.onStartMsg(prefix, "If there are any bugs in our plugins,"); + T2Ctemplate.onStartMsg(prefix, "please report them to us via our Discord: http://dc.t2code.net"); T2Ctemplate.onStartMsg(prefix, ""); T2Ctemplate.onStartMsg(prefix, "§4!!!!!!!!!!!!!!!!!!!!"); + T2Csend.warning(plugin, ""); + T2Csend.warning(plugin, ""); + T2Csend.warning(plugin, ""); try { Thread.sleep(2000); } catch (InterruptedException e) { @@ -99,9 +120,9 @@ public final class T2CodeLibMain extends JavaPlugin { T2Ctemplate.onLoadSeparateStroke(prefix); T2Ctemplate.onStartMsg(prefix, "§2Server run on:"); T2Ctemplate.onStartMsg(prefix, "§3Platform: §6" + plattform.name()); - T2Ctemplate.onStartMsg(prefix, "§3mcVersion: §6" + T2CmcVersion.getMcVersion()); - T2Ctemplate.onStartMsg(prefix, "§3bukkitVersion: §6" + T2CmcVersion.getBukkitVersion()); - T2Ctemplate.onStartMsg(prefix, "§3nms: §6" + T2CmcVersion.getNms()); + T2Ctemplate.onStartMsg(prefix, "§3Server Version: §6" + T2CmcVersion.getMcVersion()); + T2Ctemplate.onStartMsg(prefix, "§3Bukkit Version: §6" + T2CmcVersion.getBukkitVersion()); + T2Ctemplate.onStartMsg(prefix, "§3NMS: §6" + T2CmcVersion.getNms()); T2Ctemplate.onLoadSeparateStroke(prefix); if (eco != null) { String st = eco.getName(); @@ -131,14 +152,18 @@ public final class T2CodeLibMain extends JavaPlugin { plugin.getCommand("t2code").setExecutor(new CmdExecuter()); + + T2Ctemplate.onLoadSeparateStroke(prefix); T2CLibConfig.set(); - T2Ctemplate.onLoadSeparateStroke(prefix); - T2Ctemplate.onStartMsg(prefix, "§3Use Proxy: §6" + (boolean)T2CLibConfig.VALUES.proxy.getValue()); - T2Ctemplate.onStartMsg(prefix, "§3serverUUID: §6" + T2CLibConfig.VALUES.serverUUID.getValue()); - T2Ctemplate.onLoadSeparateStroke(prefix); + T2CitemVersion.scan(); - LanguagesCreate.langCreate(); - SelectLibMsg.onSelect(); + // LanguagesCreate.langCreate(); todo + // SelectLibMsg.onSelect(); + Languages.set(); + + T2Ctemplate.onLoadSeparateStroke(prefix); + T2Ctemplate.onStartMsg(prefix, "§3Use Proxy: §6" + (boolean) T2CLibConfig.VALUES.proxy.getValue()); + T2Ctemplate.onStartMsg(prefix, "§3serverUUID: §6" + T2CLibConfig.VALUES.serverUUID.getValue()); T2CupdateAPI.onUpdateCheck(plugin, prefix, Util.getGit(), Util.getSpigotID(), Util.getDiscord(), (boolean) T2CLibConfig.VALUES.updateCheckOnJoin.getValue(), @@ -147,11 +172,11 @@ public final class T2CodeLibMain extends JavaPlugin { Metrics.Bstats(plugin, Util.getBstatsID()); if ((boolean) T2CLibConfig.VALUES.proxy.getValue()) { Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "t2c:bcmd"); - T2Csend.debug(plugin, "registerIncomingPluginChannel §et2c:bcmd"); + T2Cdebug.debug(plugin, "registerIncomingPluginChannel §et2c:bcmd"); Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "t2c:bonlp"); if (!Bukkit.getMessenger().isIncomingChannelRegistered(plugin, "t2c:bonlp")) { - T2Csend.debug(plugin, "registerIncomingPluginChannel §et2c:bonlp"); + T2Cdebug.debug(plugin, "registerIncomingPluginChannel §et2c:bonlp"); Bukkit.getMessenger().registerIncomingPluginChannel(plugin, "t2c:bonlp", new T2CbungeePlayers()); T2CbungeePlayers.callAllBungeePlayers(); } @@ -197,26 +222,6 @@ public final class T2CodeLibMain extends JavaPlugin { T2CodeLibMain.perm = perm; } - public static T2CodeLibMain getPlugin() { - return plugin; - } - - public static Economy getEco() { - return eco; - } - - public static Permission getPerm() { - return perm; - } - - public static List getAutor() { - return autor; - } - - public static String getVersion() { - return version; - } - private static BukkitAudiences adventure; public BukkitAudiences getAdventure() { @@ -233,13 +238,7 @@ public final class T2CodeLibMain extends JavaPlugin { isBungee = yamlConfiguration.getBoolean("settings.bungeecord"); } + @Getter private static Boolean isBungee; - public static Boolean getIsBungee() { - return isBungee; - } - - public static Boolean getMmIsLoad() { - return mmIsLoad; - } } 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/SelectLibMsg.java index f6cd1ac..35f91dd 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/SelectLibMsg.java @@ -27,7 +27,6 @@ public class SelectLibMsg { long long_ = System.currentTimeMillis(); File msg; - msg = new File(T2CodeLibMain.getPath(), "languages/" + T2CLibConfig.VALUES.language.getValue() + ".yml"); if (!msg.isFile()) { T2Ctemplate.onStartMsg(Util.getPrefix(),""); diff --git a/src/main/java/net/t2code/t2codelib/T2CconfigItem.java b/src/main/java/net/t2code/t2codelib/T2CconfigItem.java index af9fccb..88dabdf 100644 --- a/src/main/java/net/t2code/t2codelib/T2CconfigItem.java +++ b/src/main/java/net/t2code/t2codelib/T2CconfigItem.java @@ -32,4 +32,62 @@ public interface T2CconfigItem { default void setValue(Object newValue){ } + + + /** + * 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/Util.java b/src/main/java/net/t2code/t2codelib/Util.java index adf2d93..f852bef 100644 --- a/src/main/java/net/t2code/t2codelib/Util.java +++ b/src/main/java/net/t2code/t2codelib/Util.java @@ -10,7 +10,7 @@ import java.util.UUID; public class Util { //@Getter - // private static final UUID serverUUID = UUID.randomUUID(); + // private static final UUID serverUUID = UUID.randomUUID(); public static String getInfoText() { @@ -20,6 +20,7 @@ public class Util { public static String getPrefix() { return "[T2CodeLib]"; } + @Getter private static String vPrefix = "[T2CodeLib]"; @@ -79,8 +80,9 @@ public class Util { "## ##", "####################################################################################################################" }; + @Getter - public static String[] loadLogo = new String[]{ + private static String[] loadLogo2 = new String[]{ "################################################################################", "## ##", "## _______ ___ _____ _ _ ##", @@ -95,4 +97,20 @@ public class Util { "## ##", "################################################################################" }; + + @Getter + private static String[] loadLogo = new String[]{ + "╔═════════════════════════════════════════════════════════════════════════════╗", + "║ _______ ___ _____ _ _ ║", + "║ |__ __| |__ \\ / ____| | | | | ║", + "║ | | ) | | | ___ __| | ___ _ __ ___ | |_ ║", + "║ | | / / | | / _ \\ / _` | / _ \\ | '_ \\ / _ \\ | __| ║", + "║ | | / /_ | |____ | (_) | | (_| | | __/ _ | | | | | __/ | |_ ║", + "║ |_| |____| \\_____| \\___/ \\__,_| \\___| (_) |_| |_| \\___| \\__| ║", + "║ ║", + "║ This plugin is from T2Code.net ║", + "║ Development Team: JaTiTV & Jkobs ║", + "║ Feel free to come to our Discord for support: https://dc.t2code.net ║", + "╠═════════════════════════════════════════════════════════════════════════════╝" + }; } 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 5ed330c..376829a 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 @@ -138,7 +138,7 @@ public class T2CVconfigWriter { // Add value with proper indentation // builder.append(indent).append(key.getKey()).append(": ").append(value).append("\n"); if (value instanceof List) { - builder.append(indent).append(key).append(": ").append("\n"); + builder.append(indent).append(key.getKey()).append(": ").append("\n"); List zw = (List) value; for (Object s : zw) { if (s instanceof String) { @@ -147,8 +147,8 @@ public class T2CVconfigWriter { } } 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"); + builder.append(indent).append(key.getKey()).append(": \"").append(value).append("\"\n"); + } else builder.append(indent).append(key.getKey()).append(": ").append(value).append("\n"); } } }