add ConfigWriter for Language Files / smal changes
This commit is contained in:
parent
e9a43889cb
commit
5a49cc625a
@ -5,6 +5,9 @@
|
||||
<item index="0" class="java.lang.String" itemvalue="net.md_5.bungee.event.EventHandler" />
|
||||
<item index="1" class="java.lang.String" itemvalue="org.bukkit.event.EventHandler" />
|
||||
</list>
|
||||
<writeAnnotations>
|
||||
<writeAnnotation name="lombok.Getter" />
|
||||
</writeAnnotations>
|
||||
</component>
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="MavenProjectsManager">
|
||||
|
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>net.t2code</groupId>
|
||||
<artifactId>T2CodeLib</artifactId>
|
||||
<version>16.7_dev-3</version>
|
||||
<version>16.7_dev-4</version>
|
||||
<!--version>VERSION_snapshot-0</version-->
|
||||
<!--version>VERSION_beta-0</version-->
|
||||
<!--version>VERSION_dev-0</version-->
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -28,4 +28,5 @@ public enum T2CnmsEnum {
|
||||
v1_20_R3,
|
||||
v1_20_R4,
|
||||
v1_21_R1,
|
||||
v1_21_R2,
|
||||
}
|
||||
|
@ -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<Object> zw = (List<Object>) value;
|
||||
|
@ -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<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());
|
||||
|
||||
}
|
||||
}
|
@ -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<T2ClanguageObject> getLanguage();
|
||||
|
||||
|
||||
/**
|
||||
* Set the description of the option here, the '# ' is automatically set in front of it
|
||||
*/
|
||||
List<String> getComments();
|
||||
|
||||
|
||||
/**
|
||||
* This @void is used to reset the value of @getValue()
|
||||
*/
|
||||
default void setValue(Object newValue) {
|
||||
|
||||
}
|
||||
}
|
@ -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<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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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;
|
||||
|
||||
}
|
||||
}
|
@ -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<String> autor;
|
||||
@Getter
|
||||
private static String version;
|
||||
|
||||
@Getter
|
||||
private static Boolean mmIsLoad = true;
|
||||
@Getter
|
||||
private static Boolean load = false;
|
||||
@Getter
|
||||
private static T2CplatformDetector.PlatformType plattform;
|
||||
@ -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<String> 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;
|
||||
}
|
||||
}
|
||||
|
@ -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(),"");
|
||||
|
@ -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<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);
|
||||
* }
|
||||
*/
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ public class Util {
|
||||
public static String getPrefix() {
|
||||
return "<dark_gray>[<dark_red>T2Code</dark_red><dark_purple>Lib</dark_purple>]</dark_gray>";
|
||||
}
|
||||
|
||||
@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 ║",
|
||||
"╠═════════════════════════════════════════════════════════════════════════════╝"
|
||||
};
|
||||
}
|
||||
|
@ -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<Object> zw = (List<Object>) 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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user