finish T2ClibConfig create with coments
This commit is contained in:
@@ -3,6 +3,7 @@ package net.t2code.t2codelib.SPIGOT.api.bungeePlayers;
|
||||
import lombok.Getter;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
|
||||
import net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig;
|
||||
import net.t2code.t2codelib.Util;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -37,7 +38,7 @@ public class T2CbungeePlayers implements PluginMessageListener {
|
||||
bungeePlayers.remove(input);
|
||||
break;
|
||||
case GIVEALL:
|
||||
if (!Util.getServerUUID().toString().equals(uuid)) {
|
||||
if (!T2CLibConfig.manager.getValues(T2CLibConfig.key.serverUUID).getValue().equals(uuid)) {
|
||||
return;
|
||||
}
|
||||
bungeePlayers.clear();
|
||||
@@ -67,7 +68,7 @@ public class T2CbungeePlayers implements PluginMessageListener {
|
||||
DataOutputStream output = new DataOutputStream(stream);
|
||||
try {
|
||||
output.writeUTF(T2CbungeePlayersEnum.GIVEALL.name());
|
||||
output.writeUTF(Util.getServerUUID().toString());
|
||||
output.writeUTF(T2CLibConfig.manager.getValues(T2CLibConfig.key.serverUUID).getValue().toString());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -76,7 +77,7 @@ public class T2CbungeePlayers implements PluginMessageListener {
|
||||
player.sendPluginMessage(T2CodeLibMain.getPlugin(), "t2c:bonlp", stream.toByteArray());
|
||||
T2Csend.debug(T2CodeLibMain.getPlugin(), "PluginMessage received channel: t2c:bonlp");
|
||||
T2Csend.debug(T2CodeLibMain.getPlugin(), "PluginMessage send subChannel: " + T2CbungeePlayersEnum.GIVEALL.name());
|
||||
T2Csend.debug(T2CodeLibMain.getPlugin(), "PluginMessage send output/uuid: " + Util.getServerUUID().toString());
|
||||
T2Csend.debug(T2CodeLibMain.getPlugin(), "PluginMessage send output/uuid: " + T2CLibConfig.manager.getValues(T2CLibConfig.key.serverUUID).getValue().toString());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@@ -1,60 +1,73 @@
|
||||
package net.t2code.t2codelib.SPIGOT.api.messages;
|
||||
|
||||
import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI;
|
||||
import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig;
|
||||
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
|
||||
import net.t2code.t2codelib.T2CupdateWebData;
|
||||
import net.t2code.t2codelib.UpdateType;
|
||||
import net.t2code.t2codelib.Util;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginLogger;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class T2Ctemplate {
|
||||
public static Long onLoadHeader(String prefix, List<String> autor, String version, String spigot, String discord) {
|
||||
public static @NotNull Long onLoadHeader(String prefix, List<String> autor, String version, String spigot, String discord) {
|
||||
return onLoadHeader(prefix, autor, version, spigot, discord, null, null);
|
||||
}
|
||||
|
||||
public static Long onLoadHeader(String prefix, List<String> autor, String version, String spigot, String discord, Boolean isPremium) {
|
||||
public static @NotNull Long onLoadHeader(String prefix, List<String> autor, String version, String spigot, String discord, Boolean isPremium) {
|
||||
return onLoadHeader(prefix, autor, version, spigot, discord, isPremium, null);
|
||||
}
|
||||
|
||||
public static Long onLoadHeader(String prefix, List<String> autor, String version, String spigot, String discord, Boolean isPremium, Boolean isVerify) {
|
||||
public static Long onLoadHeader(@NotNull String prefix, @NotNull List<String> autor, @NotNull String version, @NotNull String spigot, @NotNull String discord, Boolean isPremium, Boolean isVerify) {
|
||||
Long long_ = System.currentTimeMillis();
|
||||
T2Csend.console(prefix + " <dark_red> _______ </dark_red><gray>___ </gray><dark_red>_____ </dark_red>");
|
||||
T2Csend.console(prefix + " <dark_red> |__ __|</dark_red><gray>__ \\ </gray><dark_red>/ ____|</dark_red>");
|
||||
T2Csend.console(prefix + " <dark_red> | | </dark_red><gray> ) </gray><dark_red>| | </dark_red>");
|
||||
T2Csend.console(prefix + " <dark_red> | | </dark_red><gray> / /</gray><dark_red>| | </dark_red>");
|
||||
T2Csend.console(prefix + " <dark_red> | | </dark_red><gray>/ /_</gray><dark_red>| |____ </dark_red>");
|
||||
T2Csend.console(prefix + " <dark_red> |_| </dark_red><gray>|____|</gray><dark_red>\\_____|</dark_red>");
|
||||
T2Csend.console(prefix + " §4 §e╔══════════════════════════");
|
||||
T2Csend.console(prefix + " §4 §e║ §2Autor: §6" + String.valueOf(autor).replace("[", "").replace("]", ""));
|
||||
T2Csend.console(prefix + " §4 §e║ §2Version: §6" + version);
|
||||
T2Csend.console(prefix + " §4 §e║ §2Spigot: §6" + spigot);
|
||||
T2Csend.console(prefix + " §4 §e║ §2Discord: §6" + discord);
|
||||
|
||||
/**
|
||||
T2Csend.console(prefix + " <dark_red> _______ </dark_red><gray>___ </gray><dark_red>_____ </dark_red>");
|
||||
T2Csend.console(prefix + " <dark_red> |__ __|</dark_red><gray>__ \\ </gray><dark_red>/ ____|</dark_red>");
|
||||
T2Csend.console(prefix + " <dark_red> | | </dark_red><gray> ) </gray><dark_red>| | </dark_red>");
|
||||
T2Csend.console(prefix + " <dark_red> | | </dark_red><gray> / /</gray><dark_red>| | </dark_red>");
|
||||
T2Csend.console(prefix + " <dark_red> | | </dark_red><gray>/ /_</gray><dark_red>| |____ </dark_red>");
|
||||
T2Csend.console(prefix + " <dark_red> |_| </dark_red><gray>|____|</gray><dark_red>\\_____|</dark_red>");
|
||||
*/
|
||||
|
||||
|
||||
T2Csend.console(prefix + " §e╔════════════════════════════════════");
|
||||
onStartMsg(prefix,"");
|
||||
for (String s : Util.getLoadLogo()) {
|
||||
onStartMsg(prefix, s);
|
||||
}
|
||||
onStartMsg(prefix,"");
|
||||
onStartMsg(prefix,"§2Author §6" + String.valueOf(autor).replace("[", "").replace("]", ""));
|
||||
onStartMsg(prefix,"§2Version: §6" + version);
|
||||
onStartMsg(prefix,"§2Spigot: §6" + spigot);
|
||||
onStartMsg(prefix,"§2Discord: §6" + discord);
|
||||
if (isPremium != null) {
|
||||
if (isPremium) {
|
||||
T2Csend.console(prefix + " §4 §e║ §6Premium: §2true");
|
||||
} else T2Csend.console(prefix + " §4 §e║ §6Premium: §4false");
|
||||
onStartMsg(prefix,"§6Premium: §2true");
|
||||
} else onStartMsg(prefix,"§6Premium: §4false");
|
||||
if (isVerify != null) {
|
||||
if (isVerify) {
|
||||
T2Csend.console(prefix + " §4 §e║ §6Verify: §2true");
|
||||
} else T2Csend.console(prefix + " §4 §e║ §6Verify: §4false");
|
||||
} else T2Csend.console(prefix + " §4 §e║ §6Verify: §4false");
|
||||
onStartMsg(prefix,"§6Verify: §2true");
|
||||
} else onStartMsg(prefix,"§6Verify: §4false");
|
||||
} else onStartMsg(prefix,"§6Verify: §4false");
|
||||
}
|
||||
|
||||
T2Csend.console(prefix + " §4 §e╚══════════════════════════");
|
||||
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!");
|
||||
onLoadSeparateStroke(prefix);
|
||||
if (!SelectLibConfig.getT2cTestDevelopment()) {
|
||||
try {
|
||||
Thread.sleep(5000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
Thread.sleep(2000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return long_;
|
||||
@@ -67,7 +80,11 @@ public class T2Ctemplate {
|
||||
}
|
||||
|
||||
public static void onLoadSeparateStroke(String prefix) {
|
||||
T2Csend.console(prefix + " §8-------------------------------");
|
||||
onStartMsg(prefix,"§8-------------------------------");
|
||||
}
|
||||
|
||||
public static void onStartMsg(String prefix, String msg) {
|
||||
T2Csend.console(prefix + " §e║ " + msg);
|
||||
}
|
||||
|
||||
public static void onLoadFooter(String prefix, Long long_, String v) {
|
||||
@@ -76,7 +93,8 @@ public class T2Ctemplate {
|
||||
|
||||
public static void onLoadFooter(String prefix, Long long_) {
|
||||
onLoadSeparateStroke(prefix);
|
||||
T2Csend.console(prefix + " §2Plugin loaded successfully." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
||||
onStartMsg(prefix, "§2Plugin loaded successfully." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
||||
T2Csend.console(prefix + " §e╚════════════════════════════════════");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -134,7 +152,7 @@ public class T2Ctemplate {
|
||||
|
||||
String stUpdate = "<dark_red>║</dark_red> <yellow>New version available:</yellow> [up]".replace("[up]", webData != null ? update ?
|
||||
"<dark_green>YES</dark_green>" : "<red>no</red>" : "<b><dark_red>It could not be checked for updates!</dark_red></b>");
|
||||
stNVersion = update ? "<br><dark_red>║</dark_red> <yellow>Newest Version:</yellow> <gold>[nver]</gold>".replace("[nver]",player ? "<hover:show_text:'<yellow>Click for the update information</yellow>'><click:run_command:'/t2code updateinfo "+plugin.getName()+"'>"+publicVersion+"</click></hover>":publicVersion) : "";
|
||||
stNVersion = update ? "<br><dark_red>║</dark_red> <yellow>Newest Version:</yellow> <gold>[nver]</gold>".replace("[nver]", player ? "<hover:show_text:'<yellow>Click for the update information</yellow>'><click:run_command:'/t2code updateinfo " + plugin.getName() + "'>" + publicVersion + "</click></hover>" : publicVersion) : "";
|
||||
String stLinkPlayer = "<dark_red>║</dark_red> <yellow><hover:show_text:'<green>Go to the Spigot page</green>'><click:open_url:'[slink]'>Spigot</click></hover></yellow> "
|
||||
.replace("[slink]", "https://www.spigotmc.org/resources/" + spigotID)
|
||||
+ "<dark_red>-</dark_red> <dark_purple><hover:show_text:'<green>Go to the T2Code Support Discord</green>'><click:open_url:'[dlink]'>Discord</click></hover></dark_purple>"
|
||||
|
@@ -2,7 +2,7 @@ package net.t2code.t2codelib.SPIGOT.api.update;
|
||||
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
|
||||
import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig;
|
||||
import net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig;
|
||||
import net.t2code.t2codelib.UpdateType;
|
||||
import net.t2code.t2codelib.T2CupdateObject;
|
||||
import net.t2code.t2codelib.T2CupdateWebData;
|
||||
@@ -186,7 +186,7 @@ public class T2CupdateAPI {
|
||||
}
|
||||
|
||||
public static void onUpdateCheck(Plugin plugin, String prefix, String gitKey, Integer spigotID, String discord, Boolean updateCheckOnJoin, Boolean seePreReleaseUpdates, Integer timeInterval) {
|
||||
if (SelectLibConfig.getUpdateCheckFullDisable()) return;
|
||||
if ((boolean) T2CLibConfig.manager.getValues(T2CLibConfig.key.updateCheckFullDisable).getValue()) return;
|
||||
new T2CupdateCheckerGit((JavaPlugin) plugin, prefix, gitKey, spigotID, discord, updateCheckOnJoin, seePreReleaseUpdates, timeInterval);
|
||||
}
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@ package net.t2code.t2codelib.SPIGOT.api.update;
|
||||
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
|
||||
import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig;
|
||||
import net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig;
|
||||
import net.t2code.t2codelib.T2CupdateObject;
|
||||
import net.t2code.t2codelib.T2CupdateWebData;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -15,7 +15,6 @@ import java.io.*;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@@ -41,7 +40,7 @@ public class T2CupdateCheckerGit {
|
||||
Bukkit.getScheduler().runTaskTimerAsynchronously(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (SelectLibConfig.getUpdateCheckFullDisable()) return;
|
||||
if ((boolean) T2CLibConfig.manager.getValues(T2CLibConfig.key.updateCheckFullDisable).getValue()) return;
|
||||
getVersion((webData) -> {
|
||||
T2CupdateObject update = new T2CupdateObject(
|
||||
plugin.getName(),
|
||||
@@ -53,8 +52,8 @@ public class T2CupdateCheckerGit {
|
||||
);
|
||||
|
||||
T2CupdateAPI.pluginVersions.put(plugin.getName(), update);
|
||||
if (T2CupdateAPI.pluginVersions.get(plugin.getName()) == null){
|
||||
T2Csend.debugmsg(T2CodeLibMain.getPlugin(),"'"+plugin.getName() + "' UpdateAPI T2CupdateAPI.pluginVersions.get(plugin.getName()) == null");
|
||||
if (T2CupdateAPI.pluginVersions.get(plugin.getName()) == null) {
|
||||
T2Csend.debugmsg(T2CodeLibMain.getPlugin(), "'" + plugin.getName() + "' UpdateAPI T2CupdateAPI.pluginVersions.get(plugin.getName()) == null");
|
||||
return;
|
||||
}
|
||||
if (T2CupdateAPI.pluginVersions.get(plugin.getName()).updateAvailable) {
|
||||
@@ -146,7 +145,7 @@ public class T2CupdateCheckerGit {
|
||||
);
|
||||
T2CupdateAPI.pluginVersions.put(plugin.getName(), update);
|
||||
|
||||
T2Csend.error(this.plugin,"§4 Cannot look for updates: " + exception.getMessage());
|
||||
T2Csend.error(this.plugin, "§4 Cannot look for updates: " + exception.getMessage());
|
||||
exception.printStackTrace();
|
||||
}
|
||||
});
|
||||
|
@@ -1,37 +1,60 @@
|
||||
package net.t2code.t2codelib.SPIGOT.api.yaml;
|
||||
|
||||
import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig;
|
||||
|
||||
public class T2CLibConfig {
|
||||
|
||||
/**
|
||||
* @deprecated since version 16.7, use the manager directly instead as with the return.
|
||||
*/
|
||||
@Deprecated(since = "16.7", forRemoval = true)
|
||||
public static Boolean getUpdateCheckOnJoin() {
|
||||
return SelectLibConfig.getUpdateCheckOnJoin();
|
||||
}
|
||||
|
||||
public static Boolean getT2cTestDevelopment() {
|
||||
return SelectLibConfig.getT2cTestDevelopment();
|
||||
return (boolean) net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig.manager.getValues(net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig.key.updateCheckOnJoin).getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since version 16.7, use the manager directly instead as with the return.
|
||||
*/
|
||||
@Deprecated(since = "16.7", forRemoval = true)
|
||||
public static Integer getUpdateCheckTimeInterval() {
|
||||
return SelectLibConfig.getUpdateCheckTimeInterval();
|
||||
return (Integer) net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig.manager.getValues(net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig.key.updateCheckTimeInterval).getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since version 16.7, use the manager directly instead as with the return.
|
||||
*/
|
||||
@Deprecated(since = "16.7", forRemoval = true)
|
||||
public static Boolean getSeePreReleaseUpdates() {
|
||||
return SelectLibConfig.getSeePreReleaseUpdates();
|
||||
return (boolean) net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig.manager.getValues(net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig.key.seePreReleaseUpdates).getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since version 16.7, use the manager directly instead as with the return.
|
||||
*/
|
||||
@Deprecated(since = "16.7", forRemoval = true)
|
||||
public static Boolean getDebug() {
|
||||
return SelectLibConfig.getDebug();
|
||||
return (boolean) net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig.manager.getValues(net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig.key.debug).getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since version 16.7, use the manager directly instead as with the return.
|
||||
*/
|
||||
@Deprecated(since = "16.7", forRemoval = true)
|
||||
public static String getLanguage() {
|
||||
return SelectLibConfig.getLanguage();
|
||||
return (String) net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig.manager.getValues(net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig.key.language).getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since version 16.7, use the manager directly instead as with the return.
|
||||
*/
|
||||
@Deprecated(since = "16.7", forRemoval = true)
|
||||
public static Boolean getBungee() {
|
||||
return SelectLibConfig.getBungee();
|
||||
return (boolean) net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig.manager.getValues(net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig.key.proxy).getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since version 16.7, use the manager directly instead as with the return.
|
||||
*/
|
||||
@Deprecated(since = "16.7", forRemoval = true)
|
||||
public static Boolean getInventoriesCloseByServerStop() {
|
||||
return SelectLibConfig.getInventoriesCloseByServerStop();
|
||||
return (boolean) net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig.manager.getValues(net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig.key.inventoriesCloseByServerStop).getValue();
|
||||
}
|
||||
}
|
||||
|
@@ -2,7 +2,9 @@
|
||||
|
||||
package net.t2code.t2codelib.SPIGOT.api.yaml;
|
||||
|
||||
import net.t2code.t2codelib.T2CconfigItem;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -12,9 +14,11 @@ public class T2CconfigEnumManager {
|
||||
|
||||
private final List<AdditionalEnum> additionalEnums = new ArrayList<>();
|
||||
|
||||
public static class AdditionalEnum implements T2CconfigItem {
|
||||
@Getter
|
||||
public static class AdditionalEnum {
|
||||
private final String key;
|
||||
private String path;
|
||||
@Setter
|
||||
private Object value;
|
||||
private List<String> comments;
|
||||
|
||||
@@ -24,30 +28,10 @@ public class T2CconfigEnumManager {
|
||||
this.value = value;
|
||||
this.comments = new ArrayList<>(Arrays.asList(comments));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getComments() {
|
||||
return comments;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(Object newValue) {
|
||||
value = newValue;
|
||||
}
|
||||
}
|
||||
|
||||
// Method to add or change an "enum" value
|
||||
public void addOrChangeEnum(Object key, String path, Object value, String... comments) {
|
||||
public void set(@NotNull Object key, @NotNull String path, Object value, String... comments) {
|
||||
// Check if the key already exists
|
||||
for (AdditionalEnum enumValue : additionalEnums) {
|
||||
if (enumValue.key.equals(key)) {
|
||||
@@ -70,7 +54,7 @@ public class T2CconfigEnumManager {
|
||||
}
|
||||
|
||||
// Method to retrieve specific enum details
|
||||
public AdditionalEnum getEnumDetails(Object key) {
|
||||
public AdditionalEnum getValues(Object key) {
|
||||
for (AdditionalEnum e : additionalEnums) {
|
||||
if (e.key.equals(key.toString())) {
|
||||
return e;
|
||||
|
@@ -2,7 +2,6 @@
|
||||
|
||||
package net.t2code.t2codelib.SPIGOT.api.yaml;
|
||||
|
||||
import net.t2code.t2codelib.T2CconfigItem;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
@@ -33,20 +32,20 @@ public class T2CconfigWriter {
|
||||
config = YamlConfiguration.loadConfiguration(configFile);
|
||||
Map<String, List<String>> comments = new LinkedHashMap<>();
|
||||
|
||||
for(T2CconfigEnumManager.AdditionalEnum item : manager.getAllEnums()){
|
||||
config.addDefault(item.getKey(), item.getValue());
|
||||
comments.put(item.getKey(), item.getComments());
|
||||
for(T2CconfigEnumManager.AdditionalEnum value : manager.getAllEnums()){
|
||||
config.addDefault(value.getPath(), value.getValue());
|
||||
comments.put(value.getPath(), value.getComments());
|
||||
}
|
||||
|
||||
// Copy default values if they are missing
|
||||
config.options().copyDefaults(true);
|
||||
saveConfigWithComments(configFile, comments, header);
|
||||
readConfig(config,values);
|
||||
readConfig(config,manager);
|
||||
}
|
||||
|
||||
private static void readConfig(FileConfiguration config, T2CconfigItem[] values) {
|
||||
for(T2CconfigItem item : values){
|
||||
item.setValue(config.get(item.getKey()));
|
||||
private static void readConfig(FileConfiguration config, T2CconfigEnumManager manager) {
|
||||
for(T2CconfigEnumManager.AdditionalEnum value : manager.getAllEnums()){
|
||||
value.setValue(config.get(value.getPath()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +53,7 @@ public class T2CconfigWriter {
|
||||
try {
|
||||
StringBuilder configContent = new StringBuilder();
|
||||
for(String h : headers){
|
||||
configContent.append("# ").append(h).append("\n");
|
||||
configContent.append(h).append("\n");
|
||||
}
|
||||
configContent.append("\n");
|
||||
addSection(config, comments, configContent, "", 0);
|
||||
|
Reference in New Issue
Block a user