From 6e9650906966ec05636b7338c79ee4e8f05c4f40 Mon Sep 17 00:00:00 2001 From: JaTiTV Date: Sat, 8 Jul 2023 22:47:52 +0200 Subject: [PATCH] final 1.2.3_beta-1 --- .../alias/Spigot/config/config/Config.java | 2 +- .../alias/Spigot/config/config/Convert.java | 23 ++++------ .../Spigot/config/config/FileSelect.java | 5 ++- .../net/t2code/alias/Spigot/system/Load.java | 13 +++++- .../resources/Alias/X_aliasDeclaration_X.yml | 9 ++-- .../SubAlias/X_subAliasDeclaration_X.yml | 8 +++- src/main/resources/X_configDeclaration_X.yml | 44 +++++++++++++++++++ 7 files changed, 79 insertions(+), 25 deletions(-) create mode 100644 src/main/resources/X_configDeclaration_X.yml diff --git a/src/main/java/net/t2code/alias/Spigot/config/config/Config.java b/src/main/java/net/t2code/alias/Spigot/config/config/Config.java index e4c6705..93e8bcf 100644 --- a/src/main/java/net/t2code/alias/Spigot/config/config/Config.java +++ b/src/main/java/net/t2code/alias/Spigot/config/config/Config.java @@ -17,7 +17,7 @@ public enum Config { buyMessage("buy.message", true, ConfigParam.BOOLEAN), buyCurrency("buy.currency", "$", ConfigParam.STRING), - buyConfirmDefault("buy.confirm.default", Confirm.COMMAND, ConfigParam.CONFIRMENUM), + buyConfirmDefault("buy.confirm.use", Confirm.COMMAND, ConfigParam.CONFIRMENUM), buyConfirmGuiFillItemEnabled("buy.confirm.gui.fillItem.enabled", true, ConfigParam.BOOLEAN), buyConfirmGuiFillItem("buy.confirm.gui.fillItem.material", T2CitemVersion.getBlackStainedGlassPane().getType().toString(), ConfigParam.STRING), buyConfirmGuiConfirm("buy.confirm.gui.confirm.material", T2CitemVersion.getGreenWool().getType().toString(), ConfigParam.STRING), diff --git a/src/main/java/net/t2code/alias/Spigot/config/config/Convert.java b/src/main/java/net/t2code/alias/Spigot/config/config/Convert.java index aa02cc2..5ecc5f7 100644 --- a/src/main/java/net/t2code/alias/Spigot/config/config/Convert.java +++ b/src/main/java/net/t2code/alias/Spigot/config/config/Convert.java @@ -4,6 +4,7 @@ import com.google.common.base.Preconditions; import net.t2code.alias.Spigot.Main; import net.t2code.alias.Util; import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend; +import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate; import org.apache.commons.io.FileUtils; import org.bukkit.Bukkit; import org.bukkit.configuration.InvalidConfigurationException; @@ -16,24 +17,16 @@ import java.util.logging.Level; public class Convert { protected static void convert() { - convertTo4(); + File config = new File(Main.getPath(),""); + if (config.exists()) convertTo4(); } private static void convertTo4() { - // File dir = new File(Main.getPath(), "languages"); - // File newDir = new File(Main.getPath() + "/languages/old/configVersion3"); - // - // try { - // FileUtils.moveDirectory(dir, newDir); - // } catch (IOException e) { - // e.printStackTrace(); - // } + long long1 = System.currentTimeMillis(); File config = new File(Main.getPath(), "config.yml"); YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config); if (yamlConfiguration.get(Config.configVersion.path) == null || ((Integer) Config.configVersion.value) < Util.getConfigVersion() && new File(Main.getPath(), "config.yml").exists()) { - System.out.println("convert"); - yamlConfiguration.set("ConfigVersion", null); try { yamlConfiguration.save(config); @@ -52,6 +45,7 @@ public class Convert { File f = new File(Main.getPath() + "/OldConfig/Version3/languages/"); File[] fileArray = f.listFiles(); for (File file : fileArray) { + long long2 = System.currentTimeMillis(); String sub = file.getName().substring(file.getName().length() - 4); if (sub.equals(".yml")) { YamlConfiguration yamlConfigurationOld; @@ -90,10 +84,11 @@ public class Convert { T2Csend.warning(Main.getPlugin(), e.getMessage()); e.printStackTrace(); } + T2Csend.console(Util.getPrefix() + " §2The language file §6(" + newFile.getName() + ") &2was converted to the new config format §7- §e" + (System.currentTimeMillis() - long2) + "ms"); } } - } else System.out.println("not convert"); + } + T2Csend.console(Util.getPrefix() + " §2All files were successfully converted. §7- §e" + (System.currentTimeMillis() - long1) + "ms"); + T2Ctemplate.onLoadSeparateStroke(Util.getPrefix()); } - - } diff --git a/src/main/java/net/t2code/alias/Spigot/config/config/FileSelect.java b/src/main/java/net/t2code/alias/Spigot/config/config/FileSelect.java index aceb8a4..2558545 100644 --- a/src/main/java/net/t2code/alias/Spigot/config/config/FileSelect.java +++ b/src/main/java/net/t2code/alias/Spigot/config/config/FileSelect.java @@ -20,7 +20,7 @@ public class FileSelect { public static void config() { Convert.convert(); - + long long_ = System.currentTimeMillis(); File config = new File(Main.getPath(), "config.yml"); YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config); for (Config value : Config.values()) { @@ -70,6 +70,9 @@ public class FileSelect { } catch (IOException e) { e.printStackTrace(); } + T2Csend.console(Util.getPrefix() + " §2The config.yml was loaded successfully §7- §e" + (System.currentTimeMillis() - long_) + "ms"); + + } private static ArrayList defaultLanguages = new ArrayList<>(Arrays.asList("german", "english")); diff --git a/src/main/java/net/t2code/alias/Spigot/system/Load.java b/src/main/java/net/t2code/alias/Spigot/system/Load.java index ff3f86c..f50f454 100644 --- a/src/main/java/net/t2code/alias/Spigot/system/Load.java +++ b/src/main/java/net/t2code/alias/Spigot/system/Load.java @@ -44,6 +44,9 @@ public class Load { public static void loadReload() { HandlerList.unregisterAll(chatListener); HandlerList.unregisterAll(guiListener); + FileSelect.config(); + T2Ctemplate.onLoadSeparateStroke(Util.getPrefix()); + FileSelect.language(); if (!new File(Main.getPath(), "config.yml").exists()) { try { CreateExampleAliasConfig.configCreate(); @@ -56,19 +59,25 @@ public class Load { e.printStackTrace(); } } + try { plugin.saveResource("Alias/X_aliasDeclaration_X.yml", true); } catch (Exception e) { e.printStackTrace(); } + + try { + plugin.saveResource("X_configDeclaration_X.yml", true); + } catch (Exception e) { + e.printStackTrace(); + } + try { plugin.saveResource("SubAlias/X_subAliasDeclaration_X.yml", true); } catch (Exception e) { e.printStackTrace(); } - FileSelect.config(); - FileSelect.language(); T2Ctemplate.onLoadSeparateStroke(Util.getPrefix()); SelectAlias.onSelect(); T2Ctemplate.onLoadSeparateStroke(Util.getPrefix()); diff --git a/src/main/resources/Alias/X_aliasDeclaration_X.yml b/src/main/resources/Alias/X_aliasDeclaration_X.yml index 3362c53..a4a7ba2 100644 --- a/src/main/resources/Alias/X_aliasDeclaration_X.yml +++ b/src/main/resources/Alias/X_aliasDeclaration_X.yml @@ -1,8 +1,7 @@ #################################################################### -## The alias command is no longer the filename! ## -## Multiple alias commands can now be specified in one file, ## -## so there is no need to create multiple files! ## -## This option is under 'Alias.AliasList' ## +## This is an example file and serves only for the explanation ## +## of the individual options. ## +## Changes in this file are not considered and will be reset! ## #################################################################### Alias: @@ -29,7 +28,7 @@ Alias: # Here you define if the bypass is activated or if you have to pay despite the bypass (t2code.alias.buy.bypass). AllowByPass: true # Here you can set if you have to confirm if you want to pay before executing the command - # In the config.yml you can set at 'buy.confirm.command' if a command or a chatListener should be used for confirming the command. + # In the config.yml you can set under 'buy.confirm.use' if a command, a chatListener or a GUI should be used to confirm the command. Confirm: true Command: # Here you can tell the alias to execute one or more commands diff --git a/src/main/resources/SubAlias/X_subAliasDeclaration_X.yml b/src/main/resources/SubAlias/X_subAliasDeclaration_X.yml index b6bfe23..c0f8190 100644 --- a/src/main/resources/SubAlias/X_subAliasDeclaration_X.yml +++ b/src/main/resources/SubAlias/X_subAliasDeclaration_X.yml @@ -1,4 +1,8 @@ -# +#################################################################### +## This is an example file and serves only for the explanation ## +## of the individual options. ## +## Changes in this file are not considered and will be reset! ## +#################################################################### SubAlias: # Here you can disable the alias @@ -28,7 +32,7 @@ SubAlias: # Here you define if the bypass is activated or if you have to pay despite the bypass (t2code.alias.buy.bypass). AllowByPass: true # Here you can set if you have to confirm if you want to pay before executing the command - # In the config.yml you can set at 'buy.confirm.command' if a command or a chatListener should be used for confirming the command. + # In the config.yml you can set under 'buy.confirm.use' if a command, a chatListener or a GUI should be used to confirm the command. Confirm: true Command: # Here you can tell the alias to execute one or more commands diff --git a/src/main/resources/X_configDeclaration_X.yml b/src/main/resources/X_configDeclaration_X.yml new file mode 100644 index 0000000..145cdae --- /dev/null +++ b/src/main/resources/X_configDeclaration_X.yml @@ -0,0 +1,44 @@ +#################################################################### +## This is an example file and serves only for the explanation ## +## of the individual options. ## +## Changes in this file are not considered and will be reset! ## +#################################################################### + +# This option is only used for updates and file conversions. +configVersion: 4 +plugin: + # In this option you can set the language of the plugin. + language: english + updateCheck: + # In this option you can set if players with the permission 't2code.alias.updatemsg' will get an update message on join when an update for the plugin is available. + onJoin: true + # In this option you can set whether you want to receive and display beta and snapshot versions in the update check. + seePreReleaseUpdates: true + # In this option you can set the time interval in minutes in which updates should be checked. + timeInterval: 60 +buy: + # With this option you can set whether a confirmation should be sent after the payment for an alias for which you have to pay. + message: true + # With this option you set the currency. + currency: $ + confirm: + # Here you can choose which confirmation method you want to use. (COMMAND, CHAT, GUI) + use: COMMAND + gui: + # + # !! You can change the GUI name and the button texts in the language file !! + # + fillItem: + # Here you can set if a fillitem should be used in the Confirm GUI. + enabled: true + # Here you can set which fillitem should be used in the Confirm GUI + material: BLACK_STAINED_GLASS_PANE + confirm: + # Here you can set the material for the confirmation button. + material: GREEN_WOOL + cancel: + # Here you can set the material for the cancel button. + material: RED_WOOL +subAlias: + # Here you can set if subcommands should be displayed as tabComplete + tabComplete: true