finish T2ClibConfig create with coments

This commit is contained in:
JaTiTV 2024-07-01 06:32:37 +02:00
parent a05223333c
commit 9413f0f7c8
26 changed files with 346 additions and 362 deletions

View File

@ -38,10 +38,10 @@ public class T2CBconfigWriter {
Map<String, List<String>> comments = new LinkedHashMap<>();
for(T2CconfigItem item : values){
if(!config.contains(item.getKey())){
config.set(item.getKey(), item.getValue());
if(!config.contains(item.getPath())){
config.set(item.getPath(), item.getValue());
}
comments.put(item.getKey(), item.getComments());
comments.put(item.getPath(), item.getComments());
}
saveConfigWithComments(configFile, comments, header);
readConfig(config,values);
@ -49,7 +49,7 @@ public class T2CBconfigWriter {
private static void readConfig(Configuration config, T2CconfigItem[] values) {
for(T2CconfigItem item : values){
item.setValue(config.get(item.getKey()));
item.setValue(config.get(item.getPath()));
}
}

View File

@ -35,7 +35,7 @@ public class T2CBlibConfig {
}
@Override
public String getKey() {
public String getPath() {
return key;
}
@ -56,7 +56,7 @@ public class T2CBlibConfig {
}
public static void set(){
T2CBconfigWriter.createConfig(new File(T2CodeBMain.getPlugin().getDataFolder(), "config.yml"), VALUES.values(), Util.getLogo());
T2CBconfigWriter.createConfig(new File(T2CodeBMain.getPlugin().getDataFolder(), "config.yml"), VALUES.values(), Util.getConfigLogo());
}

View File

@ -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;
}
}

View File

@ -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 + " §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);
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╚════════════════════════════════════");
}
/**

View File

@ -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);
}
}

View File

@ -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(),

View File

@ -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();
}
}

View File

@ -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;

View File

@ -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);

View File

@ -1,6 +1,7 @@
package net.t2code.t2codelib.SPIGOT.system;
import net.t2code.t2codelib.SPIGOT.api.debug.T2Cdebug;
import net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig;
import net.t2code.t2codelib.Util;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
@ -27,7 +28,7 @@ public class T2CbungeeCommandSenderReciver {
}
}
output.writeUTF(information);
output.writeUTF(String.valueOf(Util.getServerUUID()));
output.writeUTF(String.valueOf(T2CLibConfig.manager.getValues(T2CLibConfig.key.serverUUID).getValue()));
} catch (IOException e) {
e.printStackTrace();
}

View File

@ -17,8 +17,7 @@ import net.t2code.t2codelib.SPIGOT.system.bstats.Metrics;
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.ConfigCreate;
import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig;
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.T2CplatformDetector;
@ -26,10 +25,12 @@ import net.t2code.t2codelib.Util;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginLogger;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
import java.util.List;
import java.util.logging.Logger;
public final class T2CodeLibMain extends JavaPlugin {
private static T2CodeLibMain plugin;
@ -44,11 +45,14 @@ public final class T2CodeLibMain extends JavaPlugin {
private static Boolean load = false;
private static T2CplatformDetector.PlatformType plattform;
public static Logger logger;
@Override
public void onEnable() {
// Plugin startup logic
plugin = this;
autor = plugin.getDescription().getAuthors();
logger = getLogger();
version = plugin.getDescription().getVersion();
plattform = T2CplatformDetector.detectPlatform();
try {
@ -56,7 +60,8 @@ public final class T2CodeLibMain extends JavaPlugin {
} catch (Exception e) {
mmIsLoad = false;
}
long long_ = T2Ctemplate.onLoadHeader(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord());
long long_ = T2Ctemplate.onLoadHeader(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord(), null, null);
checkIsBungee();
String prefix = Util.getPrefix();
@ -68,79 +73,81 @@ public final class T2CodeLibMain extends JavaPlugin {
T2CmcVersion.onCheck();
if (T2CnmsVersions.getT2CnmsEnum() == T2CnmsEnum.not_support) {
T2Csend.console(prefix + " §4!!!!!!!!!!!!!!!!!!!!");
T2Csend.console(prefix);
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");
T2Csend.console(prefix);
T2Csend.console(prefix + " §4!!!!!!!!!!!!!!!!!!!!");
if (!SelectLibConfig.getT2cTestDevelopment()) {
T2Ctemplate.onStartMsg(prefix, "");
T2Ctemplate.onStartMsg(prefix, "§4!!!!!!!!!!!!!!!!!!!!");
try {
Thread.sleep(5000);
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
if (T2CmcVersion.isMc1_21()) {
T2Csend.console(prefix + " §4!!!!!!!!!!!!!!!!!!!!");
T2Csend.console(prefix);
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");
T2Csend.console(prefix);
T2Csend.console(prefix + " §4!!!!!!!!!!!!!!!!!!!!");
if (!SelectLibConfig.getT2cTestDevelopment()) {
T2Ctemplate.onStartMsg(prefix, "");
T2Ctemplate.onStartMsg(prefix, "§4!!!!!!!!!!!!!!!!!!!!");
try {
Thread.sleep(5000);
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
T2Ctemplate.onLoadSeparateStroke(prefix);
T2Csend.console(prefix + " §2Server run on:");
T2Csend.console(prefix + " §3Platform: §6" + plattform.name());
T2Csend.console(prefix + " §3mcVersion: §6" + T2CmcVersion.getMcVersion());
T2Csend.console(prefix + " §3bukkitVersion: §6" + T2CmcVersion.getBukkitVersion());
T2Csend.console(prefix + " §3nms: §6" + T2CmcVersion.getNms());
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.onLoadSeparateStroke(prefix);
if (eco != null) {
String st = eco.getName();
if (eco.getName().equals("CMIEconomy")) st = "CMI";
if (Bukkit.getPluginManager().getPlugin(st) != null) {
T2Csend.console(prefix + " §3Economy: §6" + eco.getName() + " - " + Bukkit.getPluginManager().getPlugin(st).getDescription().getVersion() + " §7- §e" +
T2Ctemplate.onStartMsg(prefix, "§3Economy: §6" + eco.getName() + " - " + Bukkit.getPluginManager().getPlugin(st).getDescription().getVersion() + " §7- §e" +
(System.currentTimeMillis() - long_) + "ms");
} else
T2Csend.console(prefix + " §3Economy: §6" + eco.getName() + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
T2Ctemplate.onStartMsg(prefix, "§3Economy: §6" + eco.getName() + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
} else
T2Csend.console(prefix + " §3Economy: §4not connected via vault!" + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
T2Ctemplate.onStartMsg(prefix, "§3Economy: §4not connected via vault!" + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
if (perm != null) {
if (Bukkit.getPluginManager().getPlugin(perm.getName()) != null) {
T2Csend.console(prefix + " §3Permission plugin: §6" + perm.getName() + " - " + Bukkit.getPluginManager().getPlugin(perm.getName()).getDescription().getVersion()
T2Ctemplate.onStartMsg(prefix, "§3Permission plugin: §6" + perm.getName() + " - " + Bukkit.getPluginManager().getPlugin(perm.getName()).getDescription().getVersion()
+ " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
} else
T2Csend.console(prefix + " §3Permission plugin: §6" + perm.getName() + " - §7- §e" + (System.currentTimeMillis() - long_) + "ms");
T2Ctemplate.onStartMsg(prefix, "§3Permission plugin: §6" + perm.getName() + " - §7- §e" + (System.currentTimeMillis() - long_) + "ms");
} else
T2Csend.console(prefix + " §3Permission plugin: §4not connected via vault!" + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
T2Ctemplate.onStartMsg(prefix, "§3Permission plugin: §4not connected via vault!" + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
if (T2CpluginCheck.papi()) {
T2Csend.console(prefix + " §3PlaceholderAPI: §6connected" + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
T2Ctemplate.onStartMsg(prefix, "§3PlaceholderAPI: §6connected" + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
}
T2Csend.console(prefix + " §3Kyori MiniMessage Support: " + (getMmIsLoad() ? "§2load" : "§4not load") + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
T2Ctemplate.onStartMsg(prefix, "§3Kyori MiniMessage Support: " + (getMmIsLoad() ? "§2load" : "§4not load") + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
plugin.getCommand("t2code").setExecutor(new CmdExecuter());
ConfigCreate.set();
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.onLoadSeparateStroke(prefix);
T2CitemVersion.scan();
LanguagesCreate.langCreate();
SelectLibConfig.onSelect();
SelectLibMsg.onSelect();
T2CupdateAPI.onUpdateCheck(plugin, prefix, Util.getGit(), Util.getSpigotID(), Util.getDiscord(), SelectLibConfig.getUpdateCheckOnJoin(), SelectLibConfig.getSeePreReleaseUpdates(),
SelectLibConfig.getUpdateCheckTimeInterval());
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());
Metrics.Bstats(plugin, Util.getBstatsID());
if (SelectLibConfig.getBungee()) {
if ((boolean) T2CLibConfig.manager.getValues(T2CLibConfig.key.proxy).getValue()) {
Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "t2c:bcmd");
T2Csend.debug(plugin, "registerIncomingPluginChannel §et2c:bcmd");
@ -164,7 +171,7 @@ public final class T2CodeLibMain extends JavaPlugin {
// Plugin shutdown logic
if (!load) return;
ReportLogStorage.save();
if (SelectLibConfig.getInventoriesCloseByServerStop()) {
if ((boolean) T2CLibConfig.manager.getValues(T2CLibConfig.key.inventoriesCloseByServerStop).getValue()) {
for (Player player : Bukkit.getOnlinePlayers()) {
player.closeInventory();
}

View File

@ -3,6 +3,7 @@ package net.t2code.t2codelib.SPIGOT.system;
import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.permission.Permission;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
import net.t2code.t2codelib.Util;
import org.bukkit.plugin.RegisteredServiceProvider;
@ -22,14 +23,15 @@ public class Vault {
T2CodeLibMain.setEco(eco.getProvider());
if (T2CodeLibMain.getEco() != null) {
connected = true;
T2Csend.console(Util.getPrefix() + " §2Vault / Economy successfully connected!" + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
T2Ctemplate.onStartMsg(Util.getPrefix(), " §2Vault / Economy successfully connected!" + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
} else {
connected = false;
T2Csend.console(Util.getPrefix() + " §4Economy could not be connected / found! [1]" + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
T2Ctemplate.onStartMsg(Util.getPrefix(), " §4Economy could not be connected / found! [1]" + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
}
} else {
connected = false;
T2Csend.console(Util.getPrefix() + " §4Economy could not be connected / found! [2]" + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
T2Ctemplate.onStartMsg(Util.getPrefix(), " §4Economy could not be connected / found! [2]" + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
}
RegisteredServiceProvider<Permission> perm = T2CodeLibMain.getPlugin().getServer().getServicesManager().getRegistration(Permission.class);
if (perm != null) {
@ -38,13 +40,13 @@ public class Vault {
} else {
vaultEnable = false;
connected = false;
T2Csend.console(Util.getPrefix() + " §4Vault could not be connected! [3]" + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
T2Ctemplate.onStartMsg(Util.getPrefix()," §4Vault could not be connected! [3]" + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
}
}
public static void vaultDisable() {
if (!connected) return;
connected = false;
T2Csend.console(Util.getPrefix() + " §4Vault / Economy successfully deactivated.");
T2Ctemplate.onStartMsg(Util.getPrefix(), " §4Vault / Economy successfully deactivated.");
}
}

View File

@ -2,7 +2,7 @@
package net.t2code.t2codelib.SPIGOT.system.bstats;
import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig;
import net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
@ -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(SelectLibConfig.getUpdateCheckOnJoin())));
metrics.addCustomChart(new SimplePie("updatecheckonjoin", () -> String.valueOf(T2CLibConfig.manager.getValues(T2CLibConfig.key.updateCheckOnJoin).getValue())));
}
private final Plugin plugin;

View File

@ -2,13 +2,11 @@ package net.t2code.t2codelib.SPIGOT.system.cmd;
import net.t2code.t2codelib.SPIGOT.api.debug.T2Cdebug;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI;
import net.t2code.t2codelib.SPIGOT.api.bungeePlayers.T2CbungeePlayers;
import net.t2code.t2codelib.SPIGOT.system.T2CbungeeCommandSenderReciver;
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
import net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig;
import net.t2code.t2codelib.T2CupdateObject;
import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig;
import net.t2code.t2codelib.Util;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@ -71,7 +69,7 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
T2Csend.sender(sender, "§4No Permission §8t2code.admin");
return false;
}
SelectLibConfig.onSelect();
T2CLibConfig.set();
T2Csend.sender(sender, Util.getPrefix() + " §2Config successfully reloaded");
return false;
case "debug":
@ -94,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(Util.getServerUUID())));
"<click:copy_to_clipboard:[id]>[id]</click></hover></gold>").replace("[prefix]", Util.getPrefix()).replace("[id]", String.valueOf(T2CLibConfig.manager.getValues(T2CLibConfig.key.serverUUID).getValue())));
return false;
case "bcmd":
if (!sender.hasPermission("t2code.admin")) {

View File

@ -5,14 +5,12 @@ import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI;
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.Util;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import java.io.File;
import java.io.IOException;
public class Commands {
@ -95,10 +93,10 @@ public class Commands {
String permission = args[2];
if (player.hasPermission(permission)) {
T2Ccmd.console(SelectLibConfig.getCommandPermToggleCommand().replace("[player]",player.getName()).replace("[perm]",permission).replace("[value]", "false"));
T2Ccmd.console(String.valueOf(T2CLibConfig.manager.getValues(T2CLibConfig.key.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(SelectLibConfig.getCommandPermToggleCommand().replace("[player]",player.getName()).replace("[perm]",permission).replace("[value]", "true"));
T2Ccmd.console(String.valueOf(T2CLibConfig.manager.getValues(T2CLibConfig.key.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

@ -2,10 +2,9 @@ package net.t2code.t2codelib.SPIGOT.system.cmd;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig;
import net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig;
import net.t2code.t2codelib.Util;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@ -28,7 +27,7 @@ public class Development implements Listener {
if (!args[0].equals("_t2code_")) {
return;
}
if (!SelectLibConfig.getDeveloperTool()) {
if (!(boolean) T2CLibConfig.manager.getValues(T2CLibConfig.key.developerTool).getValue()) {
T2Csend.player(e.getPlayer(), Util.getPrefix() + " The Development Tool is disabled.");
}
e.setCancelled(true);

View File

@ -1,87 +0,0 @@
package net.t2code.t2codelib.SPIGOT.system.config.config;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
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;
public class ConfigCreate {
/**
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]"),
;
private final String key;
private Object value;
private final List<String> comments;
VALUES(String key, Object value, String... comments) {
this.key = key;
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;
}
}
*/
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

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

View File

@ -0,0 +1,53 @@
package net.t2code.t2codelib.SPIGOT.system.config.config;
import net.t2code.t2codelib.SPIGOT.api.yaml.T2CconfigEnumManager;
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
public class ConvertT2ClibConfig {
public static final T2CconfigEnumManager manager = T2CLibConfig.manager;
public static void convert() {
File config = new File(T2CodeLibMain.getPath(), "config.yml");
YamlConfiguration 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"));
}
config.delete();
}
}

View File

@ -1,89 +0,0 @@
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 {
@Getter
private static Boolean updateCheckOnJoin;
@Getter
private static Boolean t2cTestDevelopment = false;
@Getter
private static Integer updateCheckTimeInterval;
@Getter
private static Boolean seePreReleaseUpdates;
@Getter
private static Boolean updateCheckFullDisable;
@Getter
private static Boolean debug;
@Getter
private static String language;
@Getter
private static Boolean developerTool;
@Getter
private static Boolean bungee;
@Getter
private static Boolean inventoriesCloseByServerStop;
@Getter
private static String commandPermToggleCommand;
public static void onSelect() {
File config = new File(T2CodeLibMain.getPath(), "config.yml");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
if (yamlConfiguration.contains("t2cTestDevelopment")) {
t2cTestDevelopment = yamlConfiguration.getBoolean("t2cTestDevelopment");
}
updateCheckOnJoin = yamlConfiguration.getBoolean("Plugin.UpdateCheck.OnJoin");
updateCheckTimeInterval = yamlConfiguration.getInt("Plugin.UpdateCheck.TimeInterval");
seePreReleaseUpdates = yamlConfiguration.getBoolean("Plugin.UpdateCheck.SeePreReleaseUpdates");
updateCheckFullDisable = yamlConfiguration.getBoolean("Plugin.UpdateCheck.AllPlugins.FullDisable");
debug = yamlConfiguration.getBoolean("Plugin.Debug");
language = yamlConfiguration.getString("Plugin.language");
developerTool = yamlConfiguration.getBoolean("Plugin.Not recommended to disable.developerTool");
bungee = yamlConfiguration.getBoolean("BungeeCord.Enable");
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");
}
}

View File

@ -0,0 +1,71 @@
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.Util;
import java.io.File;
import java.util.UUID;
public class T2CLibConfig {
public static final T2CconfigEnumManager manager = new T2CconfigEnumManager();
public enum key {
updateCheckOnJoin,
updateCheckTimeInterval,
seePreReleaseUpdates,
updateCheckFullDisable,
debug,
developerTool,
language,
proxy,
serverUUID,
inventoriesCloseByServerStop,
commandPermToggleCommand
}
public static void set() {
long long_ = System.currentTimeMillis();
setEnum();
ConvertT2ClibConfig.convert();
T2CconfigWriter.createConfig(new File(T2CodeLibMain.getPath(), "config.yml"), manager, 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

@ -1,6 +1,7 @@
package net.t2code.t2codelib.SPIGOT.system.config.languages;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
import net.t2code.t2codelib.SPIGOT.api.yaml.T2Cconfig;
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
import net.t2code.t2codelib.Util;
@ -24,7 +25,7 @@ public class LanguagesCreate {
setFile("norwegian", MSG.NO_VaultNotSetUp, MSG.NO_VotingPluginNotSetUp, MSG.NO_SoundNotFound);
T2Csend.console(Util.getPrefix() + " §2Language files were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
T2Ctemplate.onStartMsg(Util.getPrefix(), "§2Language files were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
}
private static void setFile(String language, String vaultNotSetUp, String votingPluginNotSetUp, String soundNotFound) {

View File

@ -2,8 +2,9 @@ package net.t2code.t2codelib.SPIGOT.system.config.languages;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Creplace;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
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.Util;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.Plugin;
@ -27,23 +28,23 @@ public class SelectLibMsg {
File msg;
msg = new File(T2CodeLibMain.getPath(), "languages/" + SelectLibConfig.getLanguage() + ".yml");
msg = new File(T2CodeLibMain.getPath(), "languages/" + T2CLibConfig.manager.getValues(T2CLibConfig.key.language).getValue() + ".yml");
if (!msg.isFile()) {
T2Csend.console(prefix);
T2Csend.console(prefix + " §4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
T2Csend.console(prefix + " §4The selected §c" + SelectLibConfig.getLanguage() + " §4language file was not found.");
T2Csend.console(prefix + " §6The default language §eEnglish §6is used!");
T2Csend.console(prefix + " §4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
T2Csend.console(prefix);
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(), "§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 = SelectLibConfig.getLanguage();
} else selectMSG = (String) T2CLibConfig.manager.getValues(T2CLibConfig.key.language).getValue();
YamlConfiguration yamlConfiguration_msg = YamlConfiguration.loadConfiguration(msg);
vaultNotSetUp = T2Creplace.replace(prefix, yamlConfiguration_msg.getString("Plugin.VaultNotSetUp"));
votingPluginNotSetUp = T2Creplace.replace(prefix, yamlConfiguration_msg.getString("Plugin.VotingPluginNotSetUp"));
soundNotFound = T2Creplace.replace(prefix, yamlConfiguration_msg.getString("Plugin.SoundNotFound"));
T2Csend.console(prefix + " §2Language successfully selected to: §6" + selectMSG + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
T2Ctemplate.onStartMsg(Util.getPrefix(), "§2Language successfully selected to: §6" + selectMSG + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
}
}

View File

@ -4,7 +4,7 @@ package net.t2code.t2codelib;
import java.util.List;
public interface T2CconfigItem {
String getKey();
String getPath();
Object getValue();
List<String> getComments();
void setValue(Object newValue);

View File

@ -9,8 +9,8 @@ import java.util.UUID;
public class Util {
@Getter
private static final UUID serverUUID = UUID.randomUUID();
//@Getter
// private static final UUID serverUUID = UUID.randomUUID();
public static String getInfoText() {
@ -61,7 +61,7 @@ public class Util {
}
@Getter
private static final String[] logo = new String[]{
private static final String[] configLogo = new String[]{
"####################################################################################################################",
"## ##",
"## /$$$$$$$$ /$$$$$$ /$$$$$$ /$$ /$$ ##",
@ -77,4 +77,20 @@ public class Util {
"## ##",
"####################################################################################################################"
};
@Getter
public static String[] loadLogo = new String[]{
"################################################################################",
"## ##",
"## _______ ___ _____ _ _ ##",
"## |__ __| |__ \\ / ____| | | | | ##",
"## | | ) | | | ___ __| | ___ _ __ ___ | |_ ##",
"## | | / / | | / _ \\ / _` | / _ \\ | '_ \\ / _ \\ | __| ##",
"## | | / /_ | |____ | (_) | | (_| | | __/ _ | | | | | __/ | |_ ##",
"## |_| |____| \\_____| \\___/ \\__,_| \\___| (_) |_| |_| \\___| \\__| ##",
"## ##",
"## T2CodeLib from JaTiTV / T2Code.net. ##",
"## In case of problems please contact the Discord: https://dc.t2code.net ##",
"## ##",
"################################################################################"
};
}

View File

@ -31,5 +31,8 @@ permissions:
default: op
children:
t2code.permtoggle.use: true
t2code.lib.updatemsg: true
t2code.permtoggle.use:
default: op
t2code.lib.updatemsg:
default: op