remove EnumManager

This commit is contained in:
JaTiTV 2024-07-01 15:01:08 +02:00
parent 9413f0f7c8
commit bbe8fbce49
16 changed files with 131 additions and 184 deletions

View File

@ -13,6 +13,12 @@ import java.util.List;
public class T2CBlibConfig {
public enum VALUES implements T2CconfigItem{
/**
* TODO Converter !!!!!
*/
updateTimer("UpdateCheck.TimerInMin", 60),
seePreReleaseUpdates("UpdateCheck.SeePreReleaseUpdates", true),
updateCheckFullDisable("Plugin.UpdateCheck.AllPlugins.FullDisable", false),
@ -24,19 +30,19 @@ public class T2CBlibConfig {
;
private final String key;
private final String path;
private Object value;
private final List<String> comments;
VALUES(String key, Object value, String... comments) {
this.key = key;
VALUES(String path, Object value, String... comments) {
this.path = path;
this.value = value;
this.comments = new ArrayList<>(Arrays.asList(comments));
}
@Override
public String getPath() {
return key;
return path;
}
@Override
@ -57,7 +63,6 @@ public class T2CBlibConfig {
public static void set(){
T2CBconfigWriter.createConfig(new File(T2CodeBMain.getPlugin().getDataFolder(), "config.yml"), VALUES.values(), Util.getConfigLogo());
}
}

View File

@ -38,7 +38,7 @@ public class T2CbungeePlayers implements PluginMessageListener {
bungeePlayers.remove(input);
break;
case GIVEALL:
if (!T2CLibConfig.manager.getValues(T2CLibConfig.key.serverUUID).getValue().equals(uuid)) {
if (!T2CLibConfig.VALUES.serverUUID.getValue().equals(uuid)) {
return;
}
bungeePlayers.clear();
@ -68,7 +68,7 @@ public class T2CbungeePlayers implements PluginMessageListener {
DataOutputStream output = new DataOutputStream(stream);
try {
output.writeUTF(T2CbungeePlayersEnum.GIVEALL.name());
output.writeUTF(T2CLibConfig.manager.getValues(T2CLibConfig.key.serverUUID).getValue().toString());
output.writeUTF(T2CLibConfig.VALUES.serverUUID.getValue().toString());
} catch (IOException e) {
e.printStackTrace();
}
@ -77,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: " + T2CLibConfig.manager.getValues(T2CLibConfig.key.serverUUID).getValue().toString());
T2Csend.debug(T2CodeLibMain.getPlugin(), "PluginMessage send output/uuid: " + T2CLibConfig.VALUES.serverUUID.getValue().toString());
return;
}
}

View File

@ -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 ((boolean) T2CLibConfig.manager.getValues(T2CLibConfig.key.updateCheckFullDisable).getValue()) return;
if ((boolean) T2CLibConfig.VALUES.updateCheckFullDisable.getValue()) return;
new T2CupdateCheckerGit((JavaPlugin) plugin, prefix, gitKey, spigotID, discord, updateCheckOnJoin, seePreReleaseUpdates, timeInterval);
}
}

View File

@ -40,7 +40,7 @@ public class T2CupdateCheckerGit {
Bukkit.getScheduler().runTaskTimerAsynchronously(plugin, new Runnable() {
@Override
public void run() {
if ((boolean) T2CLibConfig.manager.getValues(T2CLibConfig.key.updateCheckFullDisable).getValue()) return;
if ((boolean) T2CLibConfig.VALUES.updateCheckFullDisable.getValue()) return;
getVersion((webData) -> {
T2CupdateObject update = new T2CupdateObject(
plugin.getName(),

View File

@ -7,7 +7,7 @@ public class T2CLibConfig {
*/
@Deprecated(since = "16.7", forRemoval = true)
public static Boolean getUpdateCheckOnJoin() {
return (boolean) net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig.manager.getValues(net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig.key.updateCheckOnJoin).getValue();
return (boolean) net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig.VALUES.updateCheckOnJoin.getValue();
}
/**
@ -15,7 +15,7 @@ public class T2CLibConfig {
*/
@Deprecated(since = "16.7", forRemoval = true)
public static Integer getUpdateCheckTimeInterval() {
return (Integer) net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig.manager.getValues(net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig.key.updateCheckTimeInterval).getValue();
return (Integer) net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig.VALUES.updateCheckTimeInterval.getValue();
}
/**
@ -23,7 +23,7 @@ public class T2CLibConfig {
*/
@Deprecated(since = "16.7", forRemoval = true)
public static Boolean getSeePreReleaseUpdates() {
return (boolean) net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig.manager.getValues(net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig.key.seePreReleaseUpdates).getValue();
return (boolean) net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig.VALUES.seePreReleaseUpdates.getValue();
}
/**
@ -31,7 +31,7 @@ public class T2CLibConfig {
*/
@Deprecated(since = "16.7", forRemoval = true)
public static Boolean getDebug() {
return (boolean) net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig.manager.getValues(net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig.key.debug).getValue();
return (boolean) net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig.VALUES.debug.getValue();
}
/**
@ -39,7 +39,7 @@ public class T2CLibConfig {
*/
@Deprecated(since = "16.7", forRemoval = true)
public static String getLanguage() {
return (String) net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig.manager.getValues(net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig.key.language).getValue();
return (String) net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig.VALUES.language.getValue();
}
/**
@ -47,7 +47,7 @@ public class T2CLibConfig {
*/
@Deprecated(since = "16.7", forRemoval = true)
public static Boolean getBungee() {
return (boolean) net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig.manager.getValues(net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig.key.proxy).getValue();
return (boolean) net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig.VALUES.proxy.getValue();
}
/**
@ -55,6 +55,6 @@ public class T2CLibConfig {
*/
@Deprecated(since = "16.7", forRemoval = true)
public static Boolean getInventoriesCloseByServerStop() {
return (boolean) net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig.manager.getValues(net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig.key.inventoriesCloseByServerStop).getValue();
return (boolean) net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig.VALUES.inventoriesCloseByServerStop.getValue();
}
}

View File

@ -1,65 +0,0 @@
// This class was created by JaTiTV.
package net.t2code.t2codelib.SPIGOT.api.yaml;
import lombok.Getter;
import lombok.Setter;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class T2CconfigEnumManager {
private final List<AdditionalEnum> additionalEnums = new ArrayList<>();
@Getter
public static class AdditionalEnum {
private final String key;
private String path;
@Setter
private Object value;
private List<String> comments;
public AdditionalEnum(String key, String path, Object value, String... comments) {
this.key = key;
this.path = path;
this.value = value;
this.comments = new ArrayList<>(Arrays.asList(comments));
}
}
// Method to add or change an "enum" value
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)) {
// Update existing enum
enumValue.path = path;
enumValue.value = value;
enumValue.comments = Arrays.asList(comments);
return;
}
}
// Add new enum
AdditionalEnum newEnum = new AdditionalEnum(key.toString(), path, value, comments);
additionalEnums.add(newEnum);
}
// Method to retrieve all enums (original and additional)
public List<AdditionalEnum> getAllEnums() {
return new ArrayList<>(additionalEnums);
}
// Method to retrieve specific enum details
public AdditionalEnum getValues(Object key) {
for (AdditionalEnum e : additionalEnums) {
if (e.key.equals(key.toString())) {
return e;
}
}
return null;
}
}

View File

@ -2,6 +2,7 @@
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;
@ -18,7 +19,7 @@ public class T2CconfigWriter {
private static FileConfiguration config;
public static void createConfig(File configFile, T2CconfigEnumManager manager, String... header) {
public static void createConfig(File configFile, T2CconfigItem[] values, String... header) {
if (!configFile.exists()) {
configFile.getParentFile().mkdirs();
try {
@ -32,7 +33,7 @@ public class T2CconfigWriter {
config = YamlConfiguration.loadConfiguration(configFile);
Map<String, List<String>> comments = new LinkedHashMap<>();
for(T2CconfigEnumManager.AdditionalEnum value : manager.getAllEnums()){
for(T2CconfigItem value : values){
config.addDefault(value.getPath(), value.getValue());
comments.put(value.getPath(), value.getComments());
}
@ -40,11 +41,11 @@ public class T2CconfigWriter {
// Copy default values if they are missing
config.options().copyDefaults(true);
saveConfigWithComments(configFile, comments, header);
readConfig(config,manager);
readConfig(config,values);
}
private static void readConfig(FileConfiguration config, T2CconfigEnumManager manager) {
for(T2CconfigEnumManager.AdditionalEnum value : manager.getAllEnums()){
private static void readConfig(FileConfiguration config, T2CconfigItem[] values) {
for(T2CconfigItem value : values){
value.setValue(config.get(value.getPath()));
}
}

View File

@ -28,7 +28,7 @@ public class T2CbungeeCommandSenderReciver {
}
}
output.writeUTF(information);
output.writeUTF(String.valueOf(T2CLibConfig.manager.getValues(T2CLibConfig.key.serverUUID).getValue()));
output.writeUTF(String.valueOf(T2CLibConfig.VALUES.serverUUID.getValue()));
} catch (IOException e) {
e.printStackTrace();
}

View File

@ -135,19 +135,19 @@ public final class T2CodeLibMain extends JavaPlugin {
plugin.getCommand("t2code").setExecutor(new CmdExecuter());
T2CLibConfig.set();
T2Ctemplate.onLoadSeparateStroke(prefix);
T2Ctemplate.onStartMsg(prefix, "§3Use Proxy: §6" + (boolean)T2CLibConfig.manager.getValues(T2CLibConfig.key.proxy).getValue());
T2Ctemplate.onStartMsg(prefix, "§3serverUUID: §6" + T2CLibConfig.manager.getValues(T2CLibConfig.key.serverUUID).getValue());
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();
T2CupdateAPI.onUpdateCheck(plugin, prefix, Util.getGit(), Util.getSpigotID(), Util.getDiscord(),
(boolean) T2CLibConfig.manager.getValues(T2CLibConfig.key.updateCheckOnJoin).getValue(),
(boolean) T2CLibConfig.manager.getValues(T2CLibConfig.key.seePreReleaseUpdates).getValue(),
(int) T2CLibConfig.manager.getValues(T2CLibConfig.key.updateCheckTimeInterval).getValue());
(boolean) T2CLibConfig.VALUES.updateCheckOnJoin.getValue(),
(boolean) T2CLibConfig.VALUES.seePreReleaseUpdates.getValue(),
(int) T2CLibConfig.VALUES.updateCheckTimeInterval.getValue());
Metrics.Bstats(plugin, Util.getBstatsID());
if ((boolean) T2CLibConfig.manager.getValues(T2CLibConfig.key.proxy).getValue()) {
if ((boolean) T2CLibConfig.VALUES.proxy.getValue()) {
Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "t2c:bcmd");
T2Csend.debug(plugin, "registerIncomingPluginChannel §et2c:bcmd");
@ -171,7 +171,7 @@ public final class T2CodeLibMain extends JavaPlugin {
// Plugin shutdown logic
if (!load) return;
ReportLogStorage.save();
if ((boolean) T2CLibConfig.manager.getValues(T2CLibConfig.key.inventoriesCloseByServerStop).getValue()) {
if ((boolean) T2CLibConfig.VALUES.inventoriesCloseByServerStop.getValue()) {
for (Player player : Bukkit.getOnlinePlayers()) {
player.closeInventory();
}

View File

@ -31,7 +31,7 @@ public class Metrics {
public static void Bstats(Plugin plugin, int bstatsID) {
int pluginId = bstatsID; // <-- Replace with the id of your plugin!
Metrics metrics = new Metrics((JavaPlugin) plugin, pluginId);
metrics.addCustomChart(new SimplePie("updatecheckonjoin", () -> String.valueOf(T2CLibConfig.manager.getValues(T2CLibConfig.key.updateCheckOnJoin).getValue())));
metrics.addCustomChart(new SimplePie("updatecheckonjoin", () -> String.valueOf(T2CLibConfig.VALUES.updateCheckOnJoin.getValue())));
}
private final Plugin plugin;

View File

@ -92,7 +92,7 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
return false;
}
T2Csend.sender(sender, ("[prefix] <red>T2C ServerID:</red> <gold><hover:show_text:'<yellow>copy</yellow>'>" +
"<click:copy_to_clipboard:[id]>[id]</click></hover></gold>").replace("[prefix]", Util.getPrefix()).replace("[id]", String.valueOf(T2CLibConfig.manager.getValues(T2CLibConfig.key.serverUUID).getValue())));
"<click:copy_to_clipboard:[id]>[id]</click></hover></gold>").replace("[prefix]", Util.getPrefix()).replace("[id]", String.valueOf(T2CLibConfig.VALUES.serverUUID.getValue())));
return false;
case "bcmd":
if (!sender.hasPermission("t2code.admin")) {

View File

@ -93,10 +93,10 @@ public class Commands {
String permission = args[2];
if (player.hasPermission(permission)) {
T2Ccmd.console(String.valueOf(T2CLibConfig.manager.getValues(T2CLibConfig.key.commandPermToggleCommand).getValue()).replace("[player]",player.getName()).replace("[perm]",permission).replace("[value]", "false"));
T2Ccmd.console(String.valueOf(T2CLibConfig.VALUES.commandPermToggleCommand.getValue()).replace("[player]",player.getName()).replace("[perm]",permission).replace("[value]", "false"));
T2Csend.sender(sender, "§2Permission §8'§6" + permission + "§8' §2was set to §6false §2for the player §6" + player.getName() + "§2.");
} else {
T2Ccmd.console(String.valueOf(T2CLibConfig.manager.getValues(T2CLibConfig.key.commandPermToggleCommand).getValue()).replace("[player]",player.getName()).replace("[perm]",permission).replace("[value]", "true"));
T2Ccmd.console(String.valueOf(T2CLibConfig.VALUES.commandPermToggleCommand.getValue()).replace("[player]",player.getName()).replace("[perm]",permission).replace("[value]", "true"));
T2Csend.sender(sender, "§2Permission §8'§6" + permission + "§8' §2was set to §6true §2for the player §6" + player.getName() + "§2.");
}

View File

@ -27,7 +27,7 @@ public class Development implements Listener {
if (!args[0].equals("_t2code_")) {
return;
}
if (!(boolean) T2CLibConfig.manager.getValues(T2CLibConfig.key.developerTool).getValue()) {
if (!(boolean) T2CLibConfig.VALUES.developerTool.getValue()) {
T2Csend.player(e.getPlayer(), Util.getPrefix() + " The Development Tool is disabled.");
}
e.setCancelled(true);

View File

@ -1,53 +1,40 @@
package net.t2code.t2codelib.SPIGOT.system.config.config;
import net.t2code.t2codelib.SPIGOT.api.yaml.T2CconfigEnumManager;
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
import net.t2code.t2codelib.T2CconfigItem;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
public class ConvertT2ClibConfig {
public static final T2CconfigEnumManager manager = T2CLibConfig.manager;
public static YamlConfiguration yamlConfiguration;
public static void convert() {
File config = new File(T2CodeLibMain.getPath(), "config.yml");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
yamlConfiguration = YamlConfiguration.loadConfiguration(config);
if (!config.exists()) return;
if (yamlConfiguration.contains("plugin.updateCheck.onJoin")) return;
if (yamlConfiguration.contains("Plugin.UpdateCheck.OnJoin")){
manager.getValues(T2CLibConfig.key.updateCheckOnJoin).setValue(yamlConfiguration.get("Plugin.UpdateCheck.OnJoin"));
}
if (yamlConfiguration.contains("Plugin.UpdateCheck.TimeInterval")){
manager.getValues(T2CLibConfig.key.updateCheckTimeInterval).setValue(yamlConfiguration.get("Plugin.UpdateCheck.TimeInterval"));
}
if (yamlConfiguration.contains("Plugin.UpdateCheck.SeePreReleaseUpdates")){
manager.getValues(T2CLibConfig.key.seePreReleaseUpdates).setValue(yamlConfiguration.get("Plugin.UpdateCheck.SeePreReleaseUpdates"));
}
if (yamlConfiguration.contains("Plugin.UpdateCheck.AllPlugins.FullDisable")){
manager.getValues(T2CLibConfig.key.updateCheckFullDisable).setValue(yamlConfiguration.get("Plugin.UpdateCheck.AllPlugins.FullDisable"));
}
if (yamlConfiguration.contains("Plugin.Debug")){
manager.getValues(T2CLibConfig.key.debug).setValue(yamlConfiguration.get("Plugin.Debug"));
}
if (yamlConfiguration.contains("Plugin.language")){
manager.getValues(T2CLibConfig.key.language).setValue(yamlConfiguration.get("Plugin.language"));
}
if (yamlConfiguration.contains("Plugin.Not recommended to disable.developerTool")){
manager.getValues(T2CLibConfig.key.developerTool).setValue(yamlConfiguration.get("Plugin.Not recommended to disable.developerTool"));
}
if (yamlConfiguration.contains("BungeeCord.Enable")){
manager.getValues(T2CLibConfig.key.proxy).setValue(yamlConfiguration.get("BungeeCord.Enable"));
}
if (yamlConfiguration.contains("Player.Inventories.CloseByServerStop")){
manager.getValues(T2CLibConfig.key.inventoriesCloseByServerStop).setValue(yamlConfiguration.get("Player.Inventories.CloseByServerStop"));
}
if (yamlConfiguration.contains("Command.PermToggle.PermissionSetCommand")){
manager.getValues(T2CLibConfig.key.commandPermToggleCommand).setValue(yamlConfiguration.get("Command.PermToggle.PermissionSetCommand"));
}
set("Plugin.UpdateCheck.OnJoin",T2CLibConfig.VALUES.updateCheckOnJoin);
set("Plugin.UpdateCheck.TimeInterval",T2CLibConfig.VALUES.updateCheckTimeInterval);
set("Plugin.UpdateCheck.SeePreReleaseUpdates",T2CLibConfig.VALUES.seePreReleaseUpdates);
set("Plugin.UpdateCheck.AllPlugins.FullDisable",T2CLibConfig.VALUES.updateCheckFullDisable);
set("Plugin.Debug",T2CLibConfig.VALUES.debug);
set("Plugin.language",T2CLibConfig.VALUES.language);
set("Plugin.Not recommended to disable.developerTool",T2CLibConfig.VALUES.developerTool);
set("BungeeCord.Enable",T2CLibConfig.VALUES.proxy);
set("Player.Inventories.CloseByServerStop",T2CLibConfig.VALUES.inventoriesCloseByServerStop);
set("Command.PermToggle.PermissionSetCommand",T2CLibConfig.VALUES.updateCheckOnJoin);
config.delete();
}
private static void set(String path, T2CconfigItem item){
if (yamlConfiguration.contains(path)){
item.setValue(yamlConfiguration.get(path));
}
}
}

View File

@ -1,71 +1,90 @@
package net.t2code.t2codelib.SPIGOT.system.config.config;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
import net.t2code.t2codelib.SPIGOT.api.yaml.T2CconfigEnumManager;
import net.t2code.t2codelib.SPIGOT.api.yaml.T2CconfigWriter;
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
import net.t2code.t2codelib.T2CconfigItem;
import net.t2code.t2codelib.Util;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
public class T2CLibConfig {
public static final T2CconfigEnumManager manager = new T2CconfigEnumManager();
public static enum VALUES implements T2CconfigItem {
public enum key {
updateCheckOnJoin,
updateCheckTimeInterval,
seePreReleaseUpdates,
updateCheckFullDisable,
debug,
developerTool,
language,
proxy,
serverUUID,
inventoriesCloseByServerStop,
commandPermToggleCommand
updateCheckOnJoin("plugin.updateCheck.onJoin", 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."),
updateCheckTimeInterval("plugin.updateCheck.timeInterval", 60, "In this option you can set the time interval in minutes in which updates should be checked."),
seePreReleaseUpdates("plugin.updateCheck.seePreReleaseUpdates", true, "In this option you can set whether you want to receive and display beta and snapshot versions in the update check."),
updateCheckFullDisable("plugin.updateCheck.allPlugins.fullDisable", false, "This option deactivates all update checks for plugins that use the T2CodeLib."),
debug("plugin.debug.debugModus", false, "The debug mode sends more detailed debug information to the console.", "In this version of the plugin no debug messages are built in!"),
developerTool("plugin.debug.developerTool", false, "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!"),
language("plugin.language", "english", "In this option you can set the language of the plugin."),
space_proxy("proxy", null, ""),
proxy("proxy.enable", T2CodeLibMain.getIsBungee(), "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!"),
serverUUID("proxy.serverUUID", UUID.randomUUID(), "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, ""),
inventoriesCloseByServerStop("player.inventories.closeByServerStop", 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.",
"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."),
space_command("command", null, ""),
commandPermToggleCommand("command.permToggle.permissionSetCommand", "lp user [player] permission set [perm] [value]",
"This option specifies which command is to be used for the T2CodeLib command '/t2code permtoggle <player> <permission>'."),
;
private final String path;
private Object value;
private final List<String> comments;
VALUES(String path, Object value, String... comments) {
this.path = path;
this.value = value;
this.comments = new ArrayList<>(Arrays.asList(comments));
}
@Override
public String getPath() {
return path;
}
@Override
public Object getValue() {
return value;
}
@Override
public List<String> getComments() {
return comments;
}
@Override
public void setValue(Object newValue) {
value = newValue;
}
}
public static void set() {
long long_ = System.currentTimeMillis();
setEnum();
ConvertT2ClibConfig.convert();
T2CconfigWriter.createConfig(new File(T2CodeLibMain.getPath(), "config.yml"), manager, Util.getConfigLogo());
T2CconfigWriter.createConfig(new File(T2CodeLibMain.getPath(), "config.yml"), VALUES.values(), Util.getConfigLogo());
T2Ctemplate.onStartMsg(Util.getPrefix(), "§2config.yml were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
}
private static void setEnum() {
manager.set(key.updateCheckOnJoin, "plugin.updateCheck.onJoin", 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.");
manager.set(key.updateCheckTimeInterval, "plugin.updateCheck.timeInterval", 60, "In this option you can set the time interval in minutes in which updates should be checked.");
manager.set(key.seePreReleaseUpdates, "plugin.updateCheck.seePreReleaseUpdates", true, "In this option you can set whether you want to receive and display beta and snapshot versions in the update check.");
manager.set(key.updateCheckFullDisable, "plugin.updateCheck.allPlugins.fullDisable", false, "This option deactivates all update checks for plugins that use the T2CodeLib.");
manager.set(key.debug, "plugin.debug.debugModus", false, "The debug mode sends more detailed debug information to the console.", "In this version of the plugin no debug messages are built in!");
manager.set(key.developerTool, "plugin.debug.developerTool", false, "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!");
manager.set(key.language, "plugin.language", "english", "In this option you can set the language of the plugin.");
manager.set("space-proxy", "proxy", null, "");
manager.set(key.proxy, "proxy.enable", T2CodeLibMain.getIsBungee(), "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!");
manager.set(key.serverUUID, "proxy.serverUUID", UUID.randomUUID(), "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!");
manager.set("space-player", "player", null, "");
manager.set(key.inventoriesCloseByServerStop, "player.inventories.closeByServerStop", 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.", "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.");
manager.set("space-command", "command", null, "");
manager.set(key.commandPermToggleCommand, "command.permToggle.permissionSetCommand", "lp user [player] permission set [perm] [value]",
"This option specifies which command is to be used for the T2CodeLib command '/t2code permtoggle <player> <permission>'.");
}
}

View File

@ -28,17 +28,17 @@ public class SelectLibMsg {
File msg;
msg = new File(T2CodeLibMain.getPath(), "languages/" + T2CLibConfig.manager.getValues(T2CLibConfig.key.language).getValue() + ".yml");
msg = new File(T2CodeLibMain.getPath(), "languages/" + T2CLibConfig.VALUES.language.getValue() + ".yml");
if (!msg.isFile()) {
T2Ctemplate.onStartMsg(Util.getPrefix(),"");
T2Ctemplate.onStartMsg(Util.getPrefix(), "§4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
T2Ctemplate.onStartMsg(Util.getPrefix(), "§4The selected §c" + T2CLibConfig.manager.getValues(T2CLibConfig.key.language).getValue() + " §4language file was not found.");
T2Ctemplate.onStartMsg(Util.getPrefix(), "§4The selected §c" + T2CLibConfig.VALUES.language.getValue() + " §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 = (String) T2CLibConfig.manager.getValues(T2CLibConfig.key.language).getValue();
} else selectMSG = (String) T2CLibConfig.VALUES.language.getValue();
YamlConfiguration yamlConfiguration_msg = YamlConfiguration.loadConfiguration(msg);
vaultNotSetUp = T2Creplace.replace(prefix, yamlConfiguration_msg.getString("Plugin.VaultNotSetUp"));