diff --git a/pom.xml b/pom.xml index 64eb3eb..54df8fc 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ net.t2code T2CodeLib - 11.5 + 11.6 jar T2CodeLib diff --git a/src/main/java/net/t2code/lib/Spigot/Lib/update/UpdateAPI.java b/src/main/java/net/t2code/lib/Spigot/Lib/update/UpdateAPI.java index 2868374..552fbf0 100644 --- a/src/main/java/net/t2code/lib/Spigot/Lib/update/UpdateAPI.java +++ b/src/main/java/net/t2code/lib/Spigot/Lib/update/UpdateAPI.java @@ -25,22 +25,27 @@ public class UpdateAPI { public static HashMap PluginVersionen = new HashMap<>(); public static void join(Plugin plugin, String prefix, String perm, Player player, String spigot, String discord) { - String pluginVersion = plugin.getDescription().getVersion(); - if (!player.hasPermission(perm) && !player.isOp()) { - return; - } - if (UpdateAPI.PluginVersionen.get(plugin.getName()) == null) { - new BukkitRunnable() { - @Override - public void run() { - join(plugin, prefix, perm, player, spigot, discord); + Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() { + @Override + public void run() { + String pluginVersion = plugin.getDescription().getVersion(); + if (!player.hasPermission(perm) && !player.isOp()) { + return; } - }.runTaskLater(plugin, 20L); - } else use(plugin, prefix, player, pluginVersion, UpdateAPI.PluginVersionen.get(plugin.getName()).publicVersion, spigot, discord); + if (UpdateAPI.PluginVersionen.get(plugin.getName()) == null) { + new BukkitRunnable() { + @Override + public void run() { + join(plugin, prefix, perm, player, spigot, discord); + } + }.runTaskLater(plugin, 20L); + } else use(plugin, prefix, player, pluginVersion, UpdateAPI.PluginVersionen.get(plugin.getName()).publicVersion, spigot, discord); + } + }); } private static void use(Plugin plugin, String prefix, Player player, String pluginVersion, String publicVersion, String spigot, String discord) { - new BukkitRunnable() { + Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() { @Override public void run() { if (!pluginVersion.equals(publicVersion)) { @@ -49,19 +54,19 @@ public class UpdateAPI { } } } - }.runTaskLater(plugin, 200L); + }, 200L); } public static void sendUpdateMsg(String Prefix, String Spigot, String Discord, String pluginVersion, String publicVersion) { send.console("§4=========== " + Prefix + " §4==========="); - if (publicVersion.toLowerCase().contains("dev") || publicVersion.toLowerCase().contains("beta") || publicVersion.toLowerCase().contains("snapshot")){ - if (publicVersion.toLowerCase().contains("dev")){ + if (publicVersion.toLowerCase().contains("dev") || publicVersion.toLowerCase().contains("beta") || publicVersion.toLowerCase().contains("snapshot")) { + if (publicVersion.toLowerCase().contains("dev")) { send.console("§6A new §4DEV§6 version was found!"); } - if (publicVersion.toLowerCase().contains("beta")){ + if (publicVersion.toLowerCase().contains("beta")) { send.console("§6A new §2BETA§6 version was found!"); } - if (publicVersion.toLowerCase().contains("snapshot")){ + if (publicVersion.toLowerCase().contains("snapshot")) { send.console("§6A new §eSNAPSHOT§6 version was found!"); } } else { @@ -78,18 +83,18 @@ public class UpdateAPI { return; } send.player(player, Prefix); - if (publicVersion.toLowerCase().contains("dev") || publicVersion.toLowerCase().contains("beta") || publicVersion.toLowerCase().contains("snapshot")){ - if (publicVersion.toLowerCase().contains("dev")){ + if (publicVersion.toLowerCase().contains("dev") || publicVersion.toLowerCase().contains("beta") || publicVersion.toLowerCase().contains("snapshot")) { + if (publicVersion.toLowerCase().contains("dev")) { TextComponent comp = new TextBuilder(Prefix + " §6A new §4DEV§6 version was found!") .addHover("§6You can download it here: §e" + Spigot).addClickEvent(ClickEvent.Action.OPEN_URL, Spigot).build(); player.spigot().sendMessage(comp); } - if (publicVersion.toLowerCase().contains("beta")){ + if (publicVersion.toLowerCase().contains("beta")) { TextComponent comp = new TextBuilder(Prefix + " §6A new §2BETA§6 version was found!") .addHover("§6You can download it here: §e" + Spigot).addClickEvent(ClickEvent.Action.OPEN_URL, Spigot).build(); player.spigot().sendMessage(comp); } - if (publicVersion.toLowerCase().contains("snapshot")){ + if (publicVersion.toLowerCase().contains("snapshot")) { TextComponent comp = new TextBuilder(Prefix + " §6A new §eSNAPSHOT§6 version was found!") .addHover("§6You can download it here: §e" + Spigot).addClickEvent(ClickEvent.Action.OPEN_URL, Spigot).build(); player.spigot().sendMessage(comp); @@ -152,7 +157,7 @@ public class UpdateAPI { } public void getVersion(Consumer consumer, String Prefix, String pluginVersion) { - if (!plugin.isEnabled()){ + if (!plugin.isEnabled()) { return; } Bukkit.getScheduler().runTaskAsynchronously(this.plugin, () -> { diff --git a/src/main/java/net/t2code/lib/Spigot/system/JoinEvent.java b/src/main/java/net/t2code/lib/Spigot/system/JoinEvent.java index 9fac496..1a4f412 100644 --- a/src/main/java/net/t2code/lib/Spigot/system/JoinEvent.java +++ b/src/main/java/net/t2code/lib/Spigot/system/JoinEvent.java @@ -13,7 +13,6 @@ public class JoinEvent implements Listener { @EventHandler public void onJoinEvent(PlayerLoginEvent event) { - Player player = event.getPlayer(); UpdateAPI.join(Main.plugin, Util.getPrefix(), "t2code.lib.updatemsg", event.getPlayer(), Main.spigot, Main.discord); } } \ No newline at end of file