From e96447d4fa7fb5232383f197e1f4a6a55882874b Mon Sep 17 00:00:00 2001 From: JaTiTV Date: Tue, 15 Nov 2022 14:58:46 +0100 Subject: [PATCH] 1.1.5 --- pom.xml | 4 +- .../java/net/t2code/alias/Spigot/Main.java | 2 +- .../Spigot/cmdManagement/ExecuteAlias.java | 16 ++--- .../Spigot/config/config/CreateConfig.java | 3 + .../Spigot/config/config/SelectConfig.java | 63 ++++++++++++++++--- .../config/languages/SelectMessages.java | 6 +- .../net/t2code/alias/Spigot/system/Load.java | 11 ++-- .../t2code/alias/Spigot/system/Metrics.java | 2 - src/main/java/net/t2code/alias/Util.java | 6 +- 9 files changed, 83 insertions(+), 30 deletions(-) diff --git a/pom.xml b/pom.xml index c859bde..f20ea64 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ net.t2code Alias - 1.1.4 + 1.1.5 jar T2C-Alias @@ -69,7 +69,7 @@ net.t2code T2CodeLib - 13.2 + 13.4 net.t2code diff --git a/src/main/java/net/t2code/alias/Spigot/Main.java b/src/main/java/net/t2code/alias/Spigot/Main.java index d0df49a..0de788b 100644 --- a/src/main/java/net/t2code/alias/Spigot/Main.java +++ b/src/main/java/net/t2code/alias/Spigot/Main.java @@ -35,7 +35,7 @@ public final class Main extends JavaPlugin { autor = plugin.getDescription().getAuthors(); version = plugin.getDescription().getVersion(); if (pluginNotFound("T2CodeLib", 96388, Util.getRequiredT2CodeLibVersion())) return; - Load.onLoad(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getSpigotID(), Util.getDiscord(), Util.getBstatsID()); + Load.onLoad(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord(), Util.getBstatsID()); } @Override diff --git a/src/main/java/net/t2code/alias/Spigot/cmdManagement/ExecuteAlias.java b/src/main/java/net/t2code/alias/Spigot/cmdManagement/ExecuteAlias.java index 7b837d6..de23f6d 100644 --- a/src/main/java/net/t2code/alias/Spigot/cmdManagement/ExecuteAlias.java +++ b/src/main/java/net/t2code/alias/Spigot/cmdManagement/ExecuteAlias.java @@ -53,7 +53,7 @@ public class ExecuteAlias { T2Csend.player(player, SelectMessages.noMoney); return; } - if (SelectConfig.buyMessage) T2Csend.player(player, SelectMessages.buy.replace("[price]", aliasObject.costPrice.toString())); + if (SelectConfig.getBuyMessage()) T2Csend.player(player, SelectMessages.buy.replace("[price]", aliasObject.costPrice.toString())); } } if (aliasObject.commandEnable) { @@ -102,7 +102,7 @@ public class ExecuteAlias { T2Csend.player(player, SelectMessages.noMoney); return; } - if (SelectConfig.buyMessage) T2Csend.player(player, SelectMessages.buy.replace("[price]", aliasObject.costPrice.toString())); + if (SelectConfig.getBuyMessage()) T2Csend.player(player, SelectMessages.buy.replace("[price]", aliasObject.costPrice.toString())); } } if (aliasObject.commandEnable) { @@ -122,7 +122,7 @@ public class ExecuteAlias { if (alias.consoleCommandEnable) { for (String cmd : alias.consoleCommands) { if (alias.consoleBungeeCommand) { - if (SelectConfig.Bungee) { + if (SelectConfig.getBungee()) { BCommandSenderReciver.sendToBungee(sender, cmd, true); } else { T2Csend.console(Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config."); @@ -151,7 +151,7 @@ public class ExecuteAlias { if (alias.consoleCommandEnable) { for (String cmd : alias.consoleCommands) { if (alias.consoleBungeeCommand) { - if (SelectConfig.Bungee) { + if (SelectConfig.getBungee()) { BCommandSenderReciver.sendToBungee(sender, cmd.replace("[target]", targetSt), true); } else { T2Csend.console(Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config."); @@ -179,7 +179,7 @@ public class ExecuteAlias { } for (String cmd : alias.adminCommands) { if (alias.adminBungeeCommand) { - if (SelectConfig.Bungee) { + if (SelectConfig.getBungee()) { BCommandSenderReciver.sendToBungee(player, cmd.replace("[player]", player.getName()).replace("[target]", targetSt), alias.adminCommandAsConsole); } else { @@ -206,7 +206,7 @@ public class ExecuteAlias { } for (String cmd : alias.adminCommands) { if (alias.adminBungeeCommand) { - if (SelectConfig.Bungee) { + if (SelectConfig.getBungee()) { BCommandSenderReciver.sendToBungee(player, cmd.replace("[player]", player.getName()).replace("[target]", targetSt), alias.adminCommandAsConsole); } else { @@ -271,7 +271,7 @@ public class ExecuteAlias { } for (String cmd : alias.command) { if (alias.bungeeCommand) { - if (SelectConfig.Bungee) { + if (SelectConfig.getBungee()) { BCommandSenderReciver.sendToBungee(player, cmd.replace("[player]", player.getName()).replace("[target]", targetSt), alias.commandAsConsole); } else { @@ -298,7 +298,7 @@ public class ExecuteAlias { } for (String cmd : alias.command) { if (alias.bungeeCommand) { - if (SelectConfig.Bungee) { + if (SelectConfig.getBungee()) { BCommandSenderReciver.sendToBungee(player, cmd.replace("[player]", player.getName()).replace("[target]", targetSt), alias.commandAsConsole); } else { diff --git a/src/main/java/net/t2code/alias/Spigot/config/config/CreateConfig.java b/src/main/java/net/t2code/alias/Spigot/config/config/CreateConfig.java index 2d41c97..73faeb0 100644 --- a/src/main/java/net/t2code/alias/Spigot/config/config/CreateConfig.java +++ b/src/main/java/net/t2code/alias/Spigot/config/config/CreateConfig.java @@ -22,6 +22,9 @@ public class CreateConfig { YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config); T2Cconfig.set("Plugin.language", "english", yamlConfiguration); + T2Cconfig.set("Plugin.updateCheck.onJoin", true, yamlConfiguration); + T2Cconfig.set("Plugin.updateCheck.seePreReleaseUpdates", true, yamlConfiguration); + T2Cconfig.set("Plugin.updateCheck.timeInterval", 60, yamlConfiguration); T2Cconfig.set("BungeeCord.Enable", false, yamlConfiguration); T2Cconfig.set("BungeeCord.ThisServer", "server", yamlConfiguration); diff --git a/src/main/java/net/t2code/alias/Spigot/config/config/SelectConfig.java b/src/main/java/net/t2code/alias/Spigot/config/config/SelectConfig.java index 9acdbc6..aa48466 100644 --- a/src/main/java/net/t2code/alias/Spigot/config/config/SelectConfig.java +++ b/src/main/java/net/t2code/alias/Spigot/config/config/SelectConfig.java @@ -1,6 +1,7 @@ package net.t2code.alias.Spigot.config.config; import net.t2code.alias.Spigot.Main; +import net.t2code.t2codelib.SPIGOT.api.yaml.T2Cconfig; import org.bukkit.configuration.file.YamlConfiguration; import java.io.File; @@ -8,14 +9,16 @@ import java.io.IOException; public class SelectConfig { private static Integer ConfigVersion = 3; - public static Integer isConfigVersion; - public static Boolean UpdateCheckOnJoin; - public static String language; - public static Boolean Bungee; - public static String thisServer; + private static Integer isConfigVersion; + private static Boolean updateCheckOnJoin; + private static Boolean updateCheckSeePreReleaseUpdates; + private static Integer updateCheckTimeInterval; + private static String language; + private static Boolean Bungee; + private static String thisServer; - public static Boolean buyMessage; - public static Boolean subAliasTab; + private static Boolean buyMessage; + private static Boolean subAliasTab; public static void onSelect() { File config = new File(Main.getPath(), "config.yml"); @@ -23,7 +26,11 @@ public class SelectConfig { isConfigVersion = yamlConfiguration.getInt("ConfigVersion"); - UpdateCheckOnJoin = yamlConfiguration.getBoolean("Plugin.UpdateCheckOnJoin"); + updateCheckOnJoin = yamlConfiguration.getBoolean("Plugin.updateCheck.onJoin"); + updateCheckSeePreReleaseUpdates = yamlConfiguration.getBoolean("Plugin.updateCheck.seePreReleaseUpdates"); + updateCheckTimeInterval = yamlConfiguration.getInt("Plugin.updateCheck.timeInterval"); + + language = yamlConfiguration.getString("Plugin.language"); Bungee = yamlConfiguration.getBoolean("BungeeCord.Enable"); thisServer = yamlConfiguration.getString("BungeeCord.ThisServer"); @@ -41,4 +48,44 @@ public class SelectConfig { e.printStackTrace(); } } + + public static Integer getConfigVersion() { + return ConfigVersion; + } + + public static Integer getIsConfigVersion() { + return isConfigVersion; + } + + public static Boolean getUpdateCheckOnJoin() { + return updateCheckOnJoin; + } + + public static Boolean getUpdateCheckSeePreReleaseUpdates() { + return updateCheckSeePreReleaseUpdates; + } + + public static Integer getUpdateCheckTimeInterval() { + return updateCheckTimeInterval; + } + + public static String getLanguage() { + return language; + } + + public static Boolean getBungee() { + return Bungee; + } + + public static String getThisServer() { + return thisServer; + } + + public static Boolean getBuyMessage() { + return buyMessage; + } + + public static Boolean getSubAliasTab() { + return subAliasTab; + } } diff --git a/src/main/java/net/t2code/alias/Spigot/config/languages/SelectMessages.java b/src/main/java/net/t2code/alias/Spigot/config/languages/SelectMessages.java index 737a39d..db87333 100644 --- a/src/main/java/net/t2code/alias/Spigot/config/languages/SelectMessages.java +++ b/src/main/java/net/t2code/alias/Spigot/config/languages/SelectMessages.java @@ -31,17 +31,17 @@ public class SelectMessages { File msg; - msg = new File(Main.getPath(), "languages/" + SelectConfig.language + "_messages.yml"); + msg = new File(Main.getPath(), "languages/" + SelectConfig.getLanguage() + "_messages.yml"); if (!msg.isFile()) { T2Csend.console(Prefix); T2Csend.console(Prefix + " §4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); - T2Csend.console(Prefix + " §4The selected §c" + SelectConfig.language + " §4language file was not found."); + T2Csend.console(Prefix + " §4The selected §c" + SelectConfig.getLanguage() + " §4language file was not found."); T2Csend.console(Prefix + " §6The default language §eEnglish §6is used!"); T2Csend.console(Prefix + " §4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); T2Csend.console(Prefix); msg = new File(Main.getPath(), "languages/" + "english_messages.yml"); selectMSG = "english"; - } else selectMSG = SelectConfig.language; + } else selectMSG = SelectConfig.getLanguage(); YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(msg); if (yamlConfiguration.get("Plugin.Prefix") != null) { 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 b735679..1d1a648 100644 --- a/src/main/java/net/t2code/alias/Spigot/system/Load.java +++ b/src/main/java/net/t2code/alias/Spigot/system/Load.java @@ -20,13 +20,14 @@ import java.io.File; import java.util.List; public class Load { - private static Main plugin = Main.getPlugin(); + private static final Main plugin = Main.getPlugin(); - public static void onLoad(String prefix, List autor, String version, String spigot, int spigotID, String discord, int bstatsID) { + public static void onLoad(String prefix, List autor, String version, String spigot, String discord, int bstatsID) { Long long_ = T2Ctemplate.onLoadHeader(prefix, autor, version, spigot, discord); plugin.getCommand("t2code-alias").setExecutor(new AliasCmdExecuter()); loadReload(); - T2CupdateAPI.onUpdateCheck(plugin, prefix, spigotID, discord); + T2CupdateAPI.onUpdateCheck(plugin,prefix,Util.getGit(),Util.getSpigotID(),Util.getDiscord(), + SelectConfig.getUpdateCheckOnJoin(),SelectConfig.getUpdateCheckSeePreReleaseUpdates(),SelectConfig.getUpdateCheckTimeInterval()); Bukkit.getServer().getPluginManager().registerEvents(new JoinEvent(), plugin); T2Ctemplate.onLoadFooter(prefix, long_, version); @@ -65,11 +66,11 @@ public class Load { T2Ctemplate.onLoadSeparateStroke(Util.getPrefix()); SelectSubAlias.onSelect(); SelectConfig.setConfigVersion(); - if (SelectConfig.subAliasTab) { + if (SelectConfig.getSubAliasTab()) { T2Cregister.listener(new TabEvent(), plugin); } - if (SelectConfig.Bungee) { + if (SelectConfig.getBungee()) { Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "t2c:bcmd"); } AliasRegisterPermissions.onPermRegister(); diff --git a/src/main/java/net/t2code/alias/Spigot/system/Metrics.java b/src/main/java/net/t2code/alias/Spigot/system/Metrics.java index d459b9a..2d405f2 100644 --- a/src/main/java/net/t2code/alias/Spigot/system/Metrics.java +++ b/src/main/java/net/t2code/alias/Spigot/system/Metrics.java @@ -3,7 +3,6 @@ package net.t2code.alias.Spigot.system; -import net.t2code.alias.Spigot.Main; import net.t2code.alias.Spigot.config.config.SelectConfig; import org.bukkit.Bukkit; import org.bukkit.configuration.file.YamlConfiguration; @@ -34,7 +33,6 @@ 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(SelectConfig.UpdateCheckOnJoin))); } private final Plugin plugin; diff --git a/src/main/java/net/t2code/alias/Util.java b/src/main/java/net/t2code/alias/Util.java index 4c6d2e3..279c5ed 100644 --- a/src/main/java/net/t2code/alias/Util.java +++ b/src/main/java/net/t2code/alias/Util.java @@ -8,7 +8,7 @@ public class Util { } public static String getRequiredT2CodeLibVersion() { - return "13.0"; + return "13.4"; } public static String getPrefix() { @@ -19,6 +19,10 @@ public class Util { return 96389; } + public static String getGit() { + return "JaTiTV/T2Code-Alias"; + } + public static Integer getBstatsID() { return 12517; }