development status

add EnumManager
This commit is contained in:
2024-07-01 03:18:32 +02:00
parent 2ac9c890f6
commit a05223333c
15 changed files with 488 additions and 100 deletions

View File

@@ -131,7 +131,7 @@ public final class T2CodeLibMain extends JavaPlugin {
plugin.getCommand("t2code").setExecutor(new CmdExecuter());
ConfigCreate.configCreate();
ConfigCreate.set();
T2CitemVersion.scan();
LanguagesCreate.langCreate();
SelectLibConfig.onSelect();

View File

@@ -1,46 +1,87 @@
package net.t2code.t2codelib.SPIGOT.system.config.config;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.SPIGOT.api.yaml.T2Cconfig;
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 org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class ConfigCreate {
public static void configCreate() {
long long_ = System.currentTimeMillis();
if (new File(T2CodeLibMain.getPath(), "config.yml").exists()){
if (T2CodeLibMain.getPlugin().getConfig().getBoolean("Plugin.Debug")) T2Csend.console(Util.getPrefix() + " §5DEBUG: §6" + " §4config.yml are created / updated...");
} else T2Csend.console(Util.getPrefix() + " §4config.yml are created...");
/**
public enum VALUES implements T2CconfigItem {
updateCheckOnJoin("plugin.updateCheck.onJoin", true),
updateCheckTimeInterval("plugin.updateCheck.timeInterval", 60),
seePreReleaseUpdates("plugin.updateCheck.seePreReleaseUpdates", true),
updateCheckFullDisable("plugin.updateCheck.allPlugins.FullDisable", false),
debug("plugin.debug.debugModus", false),
developerTool("plugin.debug.developerTool", true),
language("plugin.language", "english"),
bungee("proxy.enable", T2CodeLibMain.getIsBungee()),
inventoriesCloseByServerStop("player.inventories.closeByServerStop", true),
commandPermToggleCommand("command.permToggle.permissionSetCommand", "lp user [player] permission set [perm] [value]"),
;
File config = new File(T2CodeLibMain.getPath(), "config.yml");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
private final String key;
private Object value;
private final List<String> comments;
T2Cconfig.set("Plugin.UpdateCheck.OnJoin", true, yamlConfiguration);
T2Cconfig.set("Plugin.UpdateCheck.TimeInterval", 60, yamlConfiguration);
T2Cconfig.set("Plugin.UpdateCheck.SeePreReleaseUpdates", true, yamlConfiguration);
T2Cconfig.set("Plugin.UpdateCheck.AllPlugins.FullDisable", false, yamlConfiguration);
T2Cconfig.set("Plugin.language", "english", yamlConfiguration);
T2Cconfig.set("Plugin.Not recommended to disable.developerTool", true, yamlConfiguration);
T2Cconfig.set("BungeeCord.Enable", T2CodeLibMain.getIsBungee(), yamlConfiguration);
T2Cconfig.set("Player.Inventories.CloseByServerStop", true, yamlConfiguration);
T2Cconfig.set("Command.PermToggle.PermissionSetCommand","lp user [player] permission set [perm] [value]",yamlConfiguration);
try {
yamlConfiguration.save(config);
} catch (IOException e) {
e.printStackTrace();
VALUES(String key, Object value, String... comments) {
this.key = key;
this.value = value;
this.comments = new ArrayList<>(Arrays.asList(comments));
}
T2Csend.console(Util.getPrefix() + " §2config.yml were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
@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;
}
}
*/
public static final T2CconfigEnumManager manager = new T2CconfigEnumManager();
public static void set() {
long long_ = System.currentTimeMillis();
manager.addOrChangeEnum(ConfigKey.updateCheckOnJoin, "plugin.updateCheck.onJoin", true);
manager.addOrChangeEnum(ConfigKey.updateCheckTimeInterval, "plugin.updateCheck.timeInterval", 60);
manager.addOrChangeEnum(ConfigKey.seePreReleaseUpdates, "plugin.updateCheck.seePreReleaseUpdates", true);
manager.addOrChangeEnum(ConfigKey.updateCheckFullDisable, "plugin.updateCheck.allPlugins.FullDisable", false);
manager.addOrChangeEnum(ConfigKey.debug, "plugin.debug.debugModus", false);
manager.addOrChangeEnum(ConfigKey.developerTool, "plugin.debug.developerTool", true);
manager.addOrChangeEnum(ConfigKey.language, "plugin.language", "english");
manager.addOrChangeEnum(ConfigKey.bungee, "proxy.enable", T2CodeLibMain.getIsBungee());
manager.addOrChangeEnum(ConfigKey.inventoriesCloseByServerStop, "player.inventories.closeByServerStop", true);
manager.addOrChangeEnum(ConfigKey.commandPermToggleCommand, "command.permToggle.permissionSetCommand", "lp user [player] permission set [perm] [value]");
T2CconfigWriter.createConfig(new File(T2CodeLibMain.getPath(), "config.yml"), manager.getAllEnums(), "PL von", "Jattitv");
T2CconfigWriter.createConfig(new File(T2CodeLibMain.getPath(), "config.yml"), VALUES.values(), "PL von", "Jattitv");
T2Csend.console(Util.getPrefix() + " §2config.yml were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
}
}

View File

@@ -0,0 +1,14 @@
package net.t2code.t2codelib.SPIGOT.system.config.config;
public enum ConfigKey {
updateCheckOnJoin,
updateCheckTimeInterval,
seePreReleaseUpdates,
updateCheckFullDisable,
debug,
developerTool,
language,
bungee,
inventoriesCloseByServerStop,
commandPermToggleCommand
}

View File

@@ -1,10 +1,14 @@
package net.t2code.t2codelib.SPIGOT.system.config.config;
import lombok.Getter;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.SPIGOT.api.yaml.T2Cconfig;
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
import net.t2code.t2codelib.Util;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
import java.io.IOException;
public class SelectLibConfig {
@@ -50,4 +54,36 @@ public class SelectLibConfig {
inventoriesCloseByServerStop = yamlConfiguration.getBoolean("Player.Inventories.CloseByServerStop");
commandPermToggleCommand = yamlConfiguration.getString("Command.PermToggle.PermissionSetCommand");
}
public static void configCreate() {
long long_ = System.currentTimeMillis();
if (new File(T2CodeLibMain.getPath(), "config.yml").exists()){
if (T2CodeLibMain.getPlugin().getConfig().getBoolean("Plugin.Debug")) T2Csend.console(Util.getPrefix() + " §5DEBUG: §6" + " §4config.yml are created / updated...");
} else T2Csend.console(Util.getPrefix() + " §4config.yml are created...");
File config = new File(T2CodeLibMain.getPath(), "config.yml");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
T2Cconfig.set("Plugin.UpdateCheck.OnJoin", true, yamlConfiguration);
T2Cconfig.set("Plugin.UpdateCheck.TimeInterval", 60, yamlConfiguration);
T2Cconfig.set("Plugin.UpdateCheck.SeePreReleaseUpdates", true, yamlConfiguration);
T2Cconfig.set("Plugin.UpdateCheck.AllPlugins.FullDisable", false, yamlConfiguration);
T2Cconfig.set("Plugin.language", "english", yamlConfiguration);
T2Cconfig.set("Plugin.Not recommended to disable.developerTool", true, yamlConfiguration);
T2Cconfig.set("BungeeCord.Enable", T2CodeLibMain.getIsBungee(), yamlConfiguration);
T2Cconfig.set("Player.Inventories.CloseByServerStop", true, yamlConfiguration);
T2Cconfig.set("Command.PermToggle.PermissionSetCommand","lp user [player] permission set [perm] [value]",yamlConfiguration);
try {
yamlConfiguration.save(config);
} catch (IOException e) {
e.printStackTrace();
}
T2Csend.console(Util.getPrefix() + " §2config.yml were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
}
}