diff --git a/pom.xml b/pom.xml index e741e9c..83fab12 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ net.t2code Alias - 1.0.5 + 1.0.6 jar T2C-Alias @@ -56,16 +56,21 @@ - Builders-Paradise - https://dojagames.net:8081/repository/Builders-Paradise/ + T2Code + https://repo.t2code.net/repository/T2Code/ - T2Code - https://dojagames.net:8081/repository/T2Code/ + Builders-Paradise + https://repo.t2code.net/repository/Builders-Paradise/ + + net.t2code + T2CodeLib + 11.0 + net.t2code bungee @@ -76,11 +81,6 @@ PlugmanGUI 3.0 - - net.t2code - T2CodeLib - 7.4 - net.t2code.minecraft.1_18.r1 spigot diff --git a/src/main/java/net/t2code/alias/Bungee/BMain.java b/src/main/java/net/t2code/alias/Bungee/BMain.java index d610b04..bfa114f 100644 --- a/src/main/java/net/t2code/alias/Bungee/BMain.java +++ b/src/main/java/net/t2code/alias/Bungee/BMain.java @@ -15,13 +15,6 @@ public final class BMain extends Plugin { public static String version; public static String autor; - public static String prefix = Util.Prefix; - public static Integer spigotID = Util.SpigotID; - public static Integer bstatsID = Util.BstatsID; - public static String spigot = Util.Spigot; - public static String discord = Util.Discord; - - @Override public void onEnable() { // Plugin startup logic @@ -30,18 +23,18 @@ public final class BMain extends Plugin { autor = plugin.getDescription().getAuthor(); if (ProxyServer.getInstance().getPluginManager().getPlugin("T2CodeLib") == null) { plugin.getLogger().log(Level.SEVERE, "Plugin can not be loaded!"); - ProxyServer.getInstance().getConsole().sendMessage(prefix + " §eT2CodeLib §4could not be found. Please download it here: " + + ProxyServer.getInstance().getConsole().sendMessage(Util.getPrefix() + " §eT2CodeLib §4could not be found. Please download it here: " + "§6https://www.spigotmc.org/resources/t2codelib.96388/ §4to be able to use this plugin."); getProxy().getPluginManager().getPlugin(plugin.getDescription().getName()).onDisable(); return; } - BLoad.onLoad(plugin, prefix, autor, version, spigot, discord, spigotID, bstatsID); + BLoad.onLoad(plugin, Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord(), Util.getSpigotID(), Util.getBstatsID()); } @Override public void onDisable() { // Plugin shutdown logic if (ProxyServer.getInstance().getPluginManager().getPlugin("T2CodeLib") == null) return; - BT2CodeTemplate.onDisable(prefix, autor, version, spigot, discord); + BT2CodeTemplate.onDisable(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord()); } } diff --git a/src/main/java/net/t2code/alias/Spigot/Main.java b/src/main/java/net/t2code/alias/Spigot/Main.java index f5a4f3b..fb11d9c 100644 --- a/src/main/java/net/t2code/alias/Spigot/Main.java +++ b/src/main/java/net/t2code/alias/Spigot/Main.java @@ -11,6 +11,7 @@ import java.io.File; import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.Objects; import java.util.logging.Level; public final class Main extends JavaPlugin { @@ -18,13 +19,6 @@ public final class Main extends JavaPlugin { return plugin.getDataFolder(); } - public static String prefix = Util.Prefix; - public static Integer spigotID = Util.SpigotID; - public static Integer bstatsID = Util.BstatsID; - public static String spigot = Util.Spigot; - public static String discord = Util.Discord; - - public static String version; public static List autor; @@ -39,14 +33,8 @@ public final class Main extends JavaPlugin { plugin = this; autor = plugin.getDescription().getAuthors(); version = plugin.getDescription().getVersion(); - isPlugin("T2CodeLib",96388); - Load.onLoad(prefix, autor, version, spigot, spigotID, discord, bstatsID); - } - - - public void saveConfig() { - if (!new File(getPath(), "config.yml").exists()) - plugin.saveResource("config.yml", false); + if (pluginNotFound("T2CodeLib", 96388, Util.getRequiredT2CodeLibVersion())) return; + Load.onLoad(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getSpigotID(), Util.getDiscord(), Util.getBstatsID()); } @Override @@ -55,16 +43,24 @@ public final class Main extends JavaPlugin { aliasHashMap.clear(); allAliases.clear(); if (Bukkit.getPluginManager().getPlugin("T2CodeLib") == null) return; - T2CodeTemplate.onDisable(prefix, autor, version, spigot, discord); + T2CodeTemplate.onDisable(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord()); } - public static void isPlugin(String pl, Integer spigotID) { + public static Boolean pluginNotFound(String pl, Integer spigotID, double ver) { if (Bukkit.getPluginManager().getPlugin(pl) == null) { plugin.getLogger().log(Level.SEVERE, "Plugin can not be loaded!"); - Bukkit.getConsoleSender().sendMessage(prefix + " §e" + pl + " §4could not be found. Please download it here: " + + Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §e" + pl + " §4could not be found. Please download it here: " + "§6https://spigotmc.org/resources/" + pl + "." + spigotID + " §4to be able to use this plugin."); Main.plugin.getPluginLoader().disablePlugin(Main.plugin); - return; + return true; + } else { + if (Double.parseDouble(Objects.requireNonNull(Bukkit.getPluginManager().getPlugin(pl)).getDescription().getVersion()) < ver) { + plugin.getLogger().log(Level.SEVERE, "Plugin can not be loaded!"); + Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §e" + pl + " §4is out of date! This plugin requires at least version §2" + ver + " §4of §6" + pl + " §4Please update it here: §6https://spigotmc.org/resources/" + pl + "." + spigotID + " §4to use this version of " + plugin.getDescription().getName() + "."); + Main.plugin.getPluginLoader().disablePlugin(Main.plugin); + return true; + } + return false; } } } diff --git a/src/main/java/net/t2code/alias/Spigot/cmdManagement/Alias_CmdExecuter.java b/src/main/java/net/t2code/alias/Spigot/cmdManagement/Alias_CmdExecuter.java index d0b15d3..3f9c239 100644 --- a/src/main/java/net/t2code/alias/Spigot/cmdManagement/Alias_CmdExecuter.java +++ b/src/main/java/net/t2code/alias/Spigot/cmdManagement/Alias_CmdExecuter.java @@ -19,7 +19,6 @@ public class Alias_CmdExecuter implements CommandExecutor, TabCompleter { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - Prefix = Main.prefix; if (args.length == 0) { // Command @@ -38,7 +37,7 @@ public class Alias_CmdExecuter implements CommandExecutor, TabCompleter { break; case "info": case "plugin": - case "veraion": + case "version": if (sender.hasPermission("t2code.alias.command.info")) { Commands.info(sender); } else send.sender(sender, SelectMessages.NoPermissionForCommand.replace("[cmd]", "/t2code-alias info") diff --git a/src/main/java/net/t2code/alias/Spigot/cmdManagement/Commands.java b/src/main/java/net/t2code/alias/Spigot/cmdManagement/Commands.java index 4e45ec0..471f120 100644 --- a/src/main/java/net/t2code/alias/Spigot/cmdManagement/Commands.java +++ b/src/main/java/net/t2code/alias/Spigot/cmdManagement/Commands.java @@ -3,6 +3,7 @@ package net.t2code.alias.Spigot.cmdManagement; import net.t2code.alias.Spigot.Main; import net.t2code.alias.Spigot.config.languages.SelectMessages; import net.t2code.alias.Spigot.system.Load; +import net.t2code.alias.Util; import net.t2code.lib.Spigot.Lib.messages.T2CodeTemplate; import net.t2code.lib.Spigot.Lib.messages.send; import net.t2code.lib.Spigot.Lib.update.UpdateAPI; @@ -13,26 +14,19 @@ import org.bukkit.plugin.Plugin; import java.util.List; public class Commands { - private static Plugin plugin = Main.plugin; - private static String prefix = Main.prefix; - private static List autor = Main.autor; - private static String version = Main.version; - private static String spigot = Main.spigot; - private static String discord = Main.discord; - public static void info(CommandSender sender) { - T2CodeTemplate.sendInfo(sender,prefix,spigot,discord,autor,version, UpdateAPI.PluginVersionen.get(plugin.getName()).publicVersion); + T2CodeTemplate.sendInfo(sender, Util.getPrefix(),Util.getSpigot(),Util.getDiscord(),Main.autor,Main.version, UpdateAPI.PluginVersionen.get(Main.plugin.getName()).publicVersion); } public static void reload(CommandSender sender) { if (sender instanceof Player) sender.sendMessage(SelectMessages.ReloadStart); - send.console(prefix + "§8-------------------------------"); - send.console(prefix + " §6Plugin reload..."); - send.console(prefix + "§8-------------------------------"); + send.console(Util.getPrefix() + "§8-------------------------------"); + send.console(Util.getPrefix() + " §6Plugin reload..."); + send.console(Util.getPrefix() + "§8-------------------------------"); Load.loadReload(); if (sender instanceof Player) sender.sendMessage(SelectMessages.ReloadEnd); - send.console(prefix + "§8-------------------------------"); - send.console(prefix + " §2Plugin successfully reloaded."); - send.console(prefix + "§8-------------------------------"); + send.console(Util.getPrefix() + "§8-------------------------------"); + send.console(Util.getPrefix() + " §2Plugin successfully reloaded."); + send.console(Util.getPrefix() + "§8-------------------------------"); } } diff --git a/src/main/java/net/t2code/alias/Spigot/cmdManagement/RegisterCommands.java b/src/main/java/net/t2code/alias/Spigot/cmdManagement/RegisterCommands.java index 1e2665e..a6ca8df 100644 --- a/src/main/java/net/t2code/alias/Spigot/cmdManagement/RegisterCommands.java +++ b/src/main/java/net/t2code/alias/Spigot/cmdManagement/RegisterCommands.java @@ -6,6 +6,7 @@ import net.t2code.alias.Spigot.config.config.SelectConfig; import net.t2code.alias.Spigot.config.languages.SelectMessages; import net.t2code.alias.Spigot.objects.Alias_Objekt; import net.t2code.alias.Spigot.system.*; +import net.t2code.alias.Util; import net.t2code.lib.Spigot.Lib.commands.Cmd; import net.t2code.lib.Spigot.Lib.messages.TextBuilder; import net.t2code.lib.Spigot.Lib.messages.send; @@ -17,7 +18,7 @@ import org.bukkit.entity.Player; public class RegisterCommands extends Command { private String alias; - private String prefix = Main.prefix; + private String prefix = Util.getPrefix(); public RegisterCommands(String alias) { super(alias); @@ -46,8 +47,8 @@ public class RegisterCommands extends Command { } else BCommand_Sender_Reciver.sendToBungee(player, cmd.replace("[player]", player.getName()), false); } else { - send.console(Main.prefix + " §4To use bungee commands, enable the Bungee option in the config."); - send.player(player, Main.prefix + " §4To use bungee commands, enable the Bungee option in the config."); + send.console(Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config."); + send.player(player, Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config."); } } else { if (Alias.AdminCommandAsConsole) { @@ -101,8 +102,8 @@ public class RegisterCommands extends Command { } else BCommand_Sender_Reciver.sendToBungee(player, cmd.replace("[player]", player.getName()), false); } else { - send.console(Main.prefix + " §4To use bungee commands, enable the Bungee option in the config."); - send.player(player, Main.prefix + " §4To use bungee commands, enable the Bungee option in the config."); + send.console(Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config."); + send.player(player, Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config."); } } else { if (Alias.CommandAsConsole) { @@ -144,8 +145,8 @@ public class RegisterCommands extends Command { if (SelectConfig.Bungee) { BCommand_Sender_Reciver.sendToBungee(sender, cmd.replace("[player]", sender.getName()), true); } else { - send.console(Main.prefix + " §4To use bungee commands, enable the Bungee option in the config."); - send.sender(sender, Main.prefix + " §4To use bungee commands, enable the Bungee option in the config."); + send.console(Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config."); + send.sender(sender, Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config."); } } else { Cmd.console(cmd.replace("[player]", sender.getName())); 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 a58104f..4eeb06b 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 @@ -1,6 +1,7 @@ package net.t2code.alias.Spigot.config.config; import net.t2code.alias.Spigot.Main; +import net.t2code.alias.Util; import net.t2code.lib.Spigot.Lib.messages.send; import net.t2code.lib.Spigot.Lib.yamlConfiguration.Config; import org.bukkit.configuration.file.YamlConfiguration; @@ -19,8 +20,8 @@ public class CreateConfig { public static void configCreate() { Long long_ = Long.valueOf(System.currentTimeMillis()); if (new File(Main.getPath(), "config.yml").exists()) { - if (Main.plugin.getConfig().getBoolean("Plugin.Debug")) send.console(Main.prefix + " §5DEBUG: §6" + " §4config.yml are created / updated..."); - } else send.console(Main.prefix + " §4config.yml are created..."); + if (Main.plugin.getConfig().getBoolean("Plugin.Debug")) send.console(Util.getPrefix() + " §5DEBUG: §6" + " §4config.yml are created / updated..."); + } else send.console(Util.getPrefix() + " §4config.yml are created..."); File config = new File(Main.getPath(), "config.yml"); @@ -40,6 +41,6 @@ public class CreateConfig { } catch (IOException e) { e.printStackTrace(); } - send.console(Main.prefix + " §2config.yml were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms"); + send.console(Util.getPrefix() + " §2config.yml were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms"); } } diff --git a/src/main/java/net/t2code/alias/Spigot/config/config/CreateExampleAliasConfig.java b/src/main/java/net/t2code/alias/Spigot/config/config/CreateExampleAliasConfig.java index f4b5181..956be7b 100644 --- a/src/main/java/net/t2code/alias/Spigot/config/config/CreateExampleAliasConfig.java +++ b/src/main/java/net/t2code/alias/Spigot/config/config/CreateExampleAliasConfig.java @@ -1,6 +1,7 @@ package net.t2code.alias.Spigot.config.config; import net.t2code.alias.Spigot.Main; +import net.t2code.alias.Util; import net.t2code.lib.Spigot.Lib.messages.send; import net.t2code.lib.Spigot.Lib.yamlConfiguration.Config; import org.bukkit.configuration.file.YamlConfiguration; @@ -54,8 +55,8 @@ public class CreateExampleAliasConfig { public static void configCreate() { Long long_ = Long.valueOf(System.currentTimeMillis()); if (new File(Main.getPath(), "config.yml").exists()) { - if (Main.plugin.getConfig().getBoolean("Plugin.Debug")) send.console(Main.prefix + " §5DEBUG: §6" + " §4config.yml are created / updated..."); - } else send.console(Main.prefix + " §4config.yml are created..."); + if (Main.plugin.getConfig().getBoolean("Plugin.Debug")) send.console(Util.getPrefix() + " §5DEBUG: §6" + " §4config.yml are created / updated..."); + } else send.console(Util.getPrefix() + " §4config.yml are created..."); File config = new File(Main.getPath(), "Alias/aliasexample.yml"); @@ -106,6 +107,6 @@ public class CreateExampleAliasConfig { } catch (IOException e) { e.printStackTrace(); } - send.console(Main.prefix + " §2config.yml were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms"); + send.console(Util.getPrefix() + " §2config.yml were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms"); } } diff --git a/src/main/java/net/t2code/alias/Spigot/config/config/SelectAlias.java b/src/main/java/net/t2code/alias/Spigot/config/config/SelectAlias.java index 0280c59..24ebb63 100644 --- a/src/main/java/net/t2code/alias/Spigot/config/config/SelectAlias.java +++ b/src/main/java/net/t2code/alias/Spigot/config/config/SelectAlias.java @@ -3,23 +3,23 @@ package net.t2code.alias.Spigot.config.config; import net.t2code.alias.Spigot.Main; import net.t2code.alias.Spigot.system.AliasRegister; import net.t2code.alias.Spigot.objects.Alias_Objekt; +import net.t2code.alias.Util; import org.bukkit.configuration.file.YamlConfiguration; import java.io.File; public class SelectAlias { - private static String Prefix = Main.prefix; + private static String Prefix = Util.getPrefix(); public static void onSelect() { Main.aliasHashMap.clear(); Main.allAliases.clear(); File f = new File(Main.getPath() + "/Alias/"); File[] fileArray = f.listFiles(); - for (File config_gui : fileArray) { - Main.allAliases.add(config_gui.getName().replace(".yml", "")); String sub = config_gui.getName().substring(config_gui.getName().length() - 4); if (sub.equals(".yml")) { + Main.allAliases.add(config_gui.getName().replace(".yml", "")); YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config_gui); Alias_Objekt alias = new Alias_Objekt( diff --git a/src/main/java/net/t2code/alias/Spigot/config/languages/LanguagesCreate.java b/src/main/java/net/t2code/alias/Spigot/config/languages/LanguagesCreate.java index 839b940..82a6111 100644 --- a/src/main/java/net/t2code/alias/Spigot/config/languages/LanguagesCreate.java +++ b/src/main/java/net/t2code/alias/Spigot/config/languages/LanguagesCreate.java @@ -1,6 +1,7 @@ package net.t2code.alias.Spigot.config.languages; import net.t2code.alias.Spigot.Main; +import net.t2code.alias.Util; import net.t2code.lib.Spigot.Lib.messages.send; import net.t2code.lib.Spigot.Lib.yamlConfiguration.Config; import org.bukkit.configuration.file.YamlConfiguration; @@ -86,7 +87,7 @@ public class LanguagesCreate { } - send.console(Main.prefix + " §2Language files were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms"); + send.console(Util.getPrefix() + " §2Language files were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms"); } } 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 d46948b..d1fe41f 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 @@ -2,6 +2,7 @@ package net.t2code.alias.Spigot.config.languages; import net.t2code.alias.Spigot.Main; import net.t2code.alias.Spigot.config.config.SelectConfig; +import net.t2code.alias.Util; import net.t2code.lib.Spigot.Lib.messages.send; import net.t2code.lib.Spigot.Lib.yamlConfiguration.Config; import org.bukkit.configuration.file.YamlConfiguration; @@ -9,7 +10,7 @@ import org.bukkit.configuration.file.YamlConfiguration; import java.io.File; public class SelectMessages { - private static String prefix = Main.prefix; + private static String prefix = Util.getPrefix(); public static String selectMSG; diff --git a/src/main/java/net/t2code/alias/Spigot/system/AliasRegister.java b/src/main/java/net/t2code/alias/Spigot/system/AliasRegister.java index 22a46bf..35785af 100644 --- a/src/main/java/net/t2code/alias/Spigot/system/AliasRegister.java +++ b/src/main/java/net/t2code/alias/Spigot/system/AliasRegister.java @@ -98,7 +98,7 @@ public class AliasRegister { craftServer.getCommandMap().register(alias, new RegisterCommands(alias)); } } - } else send.warning(plugin, " §4AliasHashmap is null!"); + } else send.warning(plugin, " §4AliasHashmap is null! - " + alias); } } } diff --git a/src/main/java/net/t2code/alias/Spigot/system/Alias_RegisterPermissions.java b/src/main/java/net/t2code/alias/Spigot/system/Alias_RegisterPermissions.java index f67cd3a..b87dcb1 100644 --- a/src/main/java/net/t2code/alias/Spigot/system/Alias_RegisterPermissions.java +++ b/src/main/java/net/t2code/alias/Spigot/system/Alias_RegisterPermissions.java @@ -12,10 +12,6 @@ public class Alias_RegisterPermissions { if (Bukkit.getPluginManager().getPermission("t2code.alias.use." + alias.toLowerCase()) == null) { Register.permission("t2code.alias.use." + alias.toLowerCase(), Main.plugin); } - - //if (Bukkit.getPluginManager().getPermission(Main.aliasHashMap.get(alias).AdminPermission) == null){ - // Bukkit.getPluginManager().addPermission(new Permission(Main.aliasHashMap.get(alias).AdminPermission)); - //} } } } \ No newline at end of file diff --git a/src/main/java/net/t2code/alias/Spigot/system/BCommand_Sender_Reciver.java b/src/main/java/net/t2code/alias/Spigot/system/BCommand_Sender_Reciver.java index ce4e405..1b62ab5 100644 --- a/src/main/java/net/t2code/alias/Spigot/system/BCommand_Sender_Reciver.java +++ b/src/main/java/net/t2code/alias/Spigot/system/BCommand_Sender_Reciver.java @@ -16,10 +16,10 @@ public class BCommand_Sender_Reciver { ByteArrayOutputStream stream = new ByteArrayOutputStream(); DataOutputStream output = new DataOutputStream(stream); try { - if (console){ + if (console) { output.writeUTF("T2Code-Console"); } else { - if (sender instanceof Player){ + if (sender instanceof Player) { output.writeUTF(sender.getName()); } else { output.writeUTF("T2Code-Console"); @@ -29,7 +29,15 @@ public class BCommand_Sender_Reciver { } catch (IOException e) { e.printStackTrace(); } - Bukkit.getServer().sendPluginMessage(Main.plugin, "t2codealias:bungee", stream.toByteArray()); + if (sender instanceof Player) { + Player player = (Player) sender; + player.sendPluginMessage(Main.plugin, "t2codealias:bungee", stream.toByteArray()); + }else { + for(Player player : Bukkit.getOnlinePlayers()){ + player.sendPluginMessage(Main.plugin, "t2codealias:bungee", stream.toByteArray()); + return; + } + } } } diff --git a/src/main/java/net/t2code/alias/Spigot/system/JoinEvent.java b/src/main/java/net/t2code/alias/Spigot/system/JoinEvent.java index b2a18fc..38bd916 100644 --- a/src/main/java/net/t2code/alias/Spigot/system/JoinEvent.java +++ b/src/main/java/net/t2code/alias/Spigot/system/JoinEvent.java @@ -3,6 +3,7 @@ package net.t2code.alias.Spigot.system; import net.t2code.alias.Spigot.Main; +import net.t2code.alias.Util; import net.t2code.lib.Spigot.Lib.messages.send; import net.t2code.lib.Spigot.Lib.update.UpdateAPI; import net.t2code.lib.Spigot.system.config.SelectLibConfig; @@ -24,7 +25,7 @@ public class JoinEvent implements Listener { if (player.hasPermission("alias.updatemsg") || player.isOp()) { if (!Main.version.equals(publicVersion)) { if (SelectLibConfig.UpdateCheckOnJoin) { - UpdateAPI.sendUpdateMsg(Main.prefix, Main.spigot, Main.discord, Main.version, publicVersion, player); + UpdateAPI.sendUpdateMsg(Util.getPrefix(), Util.getSpigot(), Util.getDiscord(), Main.version, publicVersion, player); } } } 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 1fa2fd5..7e36840 100644 --- a/src/main/java/net/t2code/alias/Spigot/system/Load.java +++ b/src/main/java/net/t2code/alias/Spigot/system/Load.java @@ -8,6 +8,7 @@ import net.t2code.alias.Spigot.config.config.SelectAlias; import net.t2code.alias.Spigot.config.config.SelectConfig; import net.t2code.alias.Spigot.config.languages.LanguagesCreate; import net.t2code.alias.Spigot.config.languages.SelectMessages; +import net.t2code.alias.Util; import net.t2code.lib.Spigot.Lib.messages.T2CodeTemplate; import net.t2code.lib.Spigot.Lib.update.UpdateAPI; import org.bukkit.Bukkit; @@ -21,7 +22,7 @@ public class Load { static Plugin plugin = Main.plugin; public static void onLoad(String prefix, List autor, String version, String spigot, int spigotID, String discord, int bstatsID) { Long long_ = T2CodeTemplate.onLoadHeader(prefix, autor, version, spigot, discord); - Main.plugin.getCommand("alias").setExecutor(new Alias_CmdExecuter()); + Main.plugin.getCommand("t2code-alias").setExecutor(new Alias_CmdExecuter()); loadReload(); UpdateAPI.onUpdateCheck(plugin, prefix, spigot, spigotID, discord); Bukkit.getServer().getPluginManager().registerEvents(new JoinEvent(), plugin); @@ -43,7 +44,7 @@ public class Load { CreateConfig.configCreate(); LanguagesCreate.langCreate(); SelectConfig.onSelect(); - SelectMessages.onSelect(Main.prefix); + SelectMessages.onSelect(Util.getPrefix()); SelectAlias.onSelect(); if (SelectConfig.Bungee) { @@ -51,8 +52,5 @@ public class Load { Bukkit.getMessenger().registerOutgoingPluginChannel(Main.plugin, "t2codealias:bungee"); } Alias_RegisterPermissions.onPermRegister(); - - } - } diff --git a/src/main/java/net/t2code/alias/Spigot/system/UpdateChecker.java b/src/main/java/net/t2code/alias/Spigot/system/UpdateChecker.java deleted file mode 100644 index 8906c53..0000000 --- a/src/main/java/net/t2code/alias/Spigot/system/UpdateChecker.java +++ /dev/null @@ -1,116 +0,0 @@ -// This claas was created by JaTiTV - -package net.t2code.alias.Spigot.system; - -import net.md_5.bungee.api.chat.ClickEvent; -import net.md_5.bungee.api.chat.TextComponent; -import net.t2code.alias.Spigot.Main; -import net.t2code.lib.Spigot.Lib.messages.TextBuilder; -import net.t2code.lib.Spigot.Lib.messages.send; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; -import org.bukkit.plugin.java.JavaPlugin; -import org.bukkit.scheduler.BukkitRunnable; - -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.util.Scanner; -import java.util.function.Consumer; - -public class UpdateChecker { - - public static void sendUpdateMsg(String Prefix, String foundVersion, String update_version) { - send.console("§4=========== " + Prefix + " §4==========="); - send.console("§6A new version was found!"); - send.console("§6Your version: §c" + foundVersion + " §7- §6Current version: §a" + update_version); - send.console("§6You can download it here: §e" + Main.spigot); - send.console("§6You can find more information on Discord: §e" + Main.discord); - send.console("§4=========== " + Prefix + " §4==========="); - } - - public static void sendUpdateMsg(String Prefix, String foundVersion, String update_version, Player player) { - TextComponent comp = new TextBuilder(Prefix + " §6A new version was found!") - .addHover("§6You can download it here: §e" + Main.spigot).addClickEvent(ClickEvent.Action.OPEN_URL, Main.spigot).build(); - player.spigot().sendMessage(comp); - TextComponent comp1 = new TextBuilder(Prefix + " §c" + foundVersion + " §7-> §a" + update_version) - .addHover("§6You can download it here: §e" + Main.spigot).addClickEvent(ClickEvent.Action.OPEN_URL, Main.spigot).build(); - player.spigot().sendMessage(comp1); - TextComponent comp2 = new TextBuilder(Prefix + " §6You can find more information on Discord.") - .addHover("§e" + Main.discord).addClickEvent(ClickEvent.Action.OPEN_URL, Main.discord).build(); - player.spigot().sendMessage(comp2); - } - - private static Boolean noUpdate = true; - public static void onUpdateCheck() { - int taskID = Bukkit.getScheduler().scheduleSyncRepeatingTask(Main.plugin, new Runnable() { - public void run() { - (new UpdateChecker(Main.plugin, Main.spigotID)).getVersion((update_version) -> { - String foundVersion = Main.plugin.getDescription().getVersion(); - // Main.update_version = update_version; - if (!foundVersion.equalsIgnoreCase(update_version)) { - new BukkitRunnable() { - @Override - public void run() { - sendUpdateMsg(Main.prefix, foundVersion, update_version); - } - }.runTaskLater(Main.plugin, 600L); - }else { - if (noUpdate) { - send.console(Main.prefix + " §2No update found."); - noUpdate = false; - } - } - }); - } - }, 0L, 20 * 60 * 60L); - } - - private JavaPlugin plugin; - private int resourceId; - - public UpdateChecker(JavaPlugin plugin, int resourceId) { - this.plugin = plugin; - this.resourceId = resourceId; - } - - public void getVersion(Consumer consumer) { - Bukkit.getScheduler().runTaskAsynchronously(this.plugin, () -> { - try { - InputStream inputStream = (new URL("https://api.spigotmc.org/legacy/update.php?resource=" + this.resourceId)).openStream(); - try { - Scanner scanner = new Scanner(inputStream); - - try { - if (scanner.hasNext()) { - consumer.accept(scanner.next()); - } - } catch (Throwable var8) { - try { - scanner.close(); - } catch (Throwable var7) { - var8.addSuppressed(var7); - } - throw var8; - } - scanner.close(); - } catch (Throwable var9) { - if (inputStream != null) { - try { - inputStream.close(); - } catch (Throwable var6) { - var9.addSuppressed(var6); - } - } - throw var9; - } - if (inputStream != null) { - inputStream.close(); - } - } catch (IOException var10) { - // Main.update_version = " §4No public version found!"; - this.plugin.getLogger().severe(Main.prefix + "§4 Cannot look for updates: " + var10.getMessage()); - } - }); - } -} diff --git a/src/main/java/net/t2code/alias/Util.java b/src/main/java/net/t2code/alias/Util.java index c5c6b06..8e47679 100644 --- a/src/main/java/net/t2code/alias/Util.java +++ b/src/main/java/net/t2code/alias/Util.java @@ -1,9 +1,34 @@ package net.t2code.alias; public class Util { - public static String Prefix = "§8[§4T2Code§7-§aAlias§8]"; - public static Integer SpigotID = 96389; - public static Integer BstatsID = 12517; - public static String Spigot = "https://www.spigotmc.org/resources/" + SpigotID; - public static String Discord = "http://dc.t2code.net"; + private static double requiredT2CodeLibVersion = 11.0; + private static String Prefix = "§8[§4T2Code§7-§aAlias§8]"; + private static Integer SpigotID = 96389; + private static Integer BstatsID = 12517; + private static String Spigot = "https://www.spigotmc.org/resources/" + SpigotID; + private static String Discord = "http://dc.t2code.net"; + + public static double getRequiredT2CodeLibVersion() { + return requiredT2CodeLibVersion; + } + + public static String getPrefix() { + return Prefix; + } + + public static Integer getSpigotID() { + return SpigotID; + } + + public static Integer getBstatsID() { + return BstatsID; + } + + public static String getSpigot() { + return Spigot; + } + + public static String getDiscord() { + return Discord; + } }