From 6c450920264f89e49853d35710d8f57df70f0791 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Szab=C3=B3?= Date: Thu, 24 Oct 2024 15:41:08 +0200 Subject: [PATCH] Fix update checker using wrong schedulers --- .../auraskills/bukkit/listeners/PlayerJoinQuit.java | 4 ++-- .../aurelium/auraskills/bukkit/util/UpdateChecker.java | 9 ++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/listeners/PlayerJoinQuit.java b/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/listeners/PlayerJoinQuit.java index 506a3b097..aed8e7a0e 100644 --- a/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/listeners/PlayerJoinQuit.java +++ b/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/listeners/PlayerJoinQuit.java @@ -96,7 +96,7 @@ private void detectUserLanguage(User user, Player player) { private void sendUpdateMessage(Player player) { // Use a delayed task to give time for permission plugins to load data - plugin.getServer().getScheduler().runTaskLater(plugin, () -> { + plugin.getScheduler().scheduleSync(() -> { if (!plugin.configBoolean(Option.CHECK_FOR_UPDATES)) { return; } @@ -111,7 +111,7 @@ private void sendUpdateMessage(Player player) { player.sendMessage(plugin.getPrefix(plugin.getDefaultLanguage()) + ChatColor.WHITE + "Download it on Spigot: " + ChatColor.YELLOW + "" + ChatColor.UNDERLINE + "https://spigotmc.org/resources/" + plugin.getResourceId()); } }); - }, 40L); + }, 2L, TimeUnit.SECONDS); } } diff --git a/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/util/UpdateChecker.java b/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/util/UpdateChecker.java index cb1b9c0e6..b7cc985e0 100644 --- a/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/util/UpdateChecker.java +++ b/bukkit/src/main/java/dev/aurelium/auraskills/bukkit/util/UpdateChecker.java @@ -1,7 +1,6 @@ package dev.aurelium.auraskills.bukkit.util; -import org.bukkit.Bukkit; -import org.bukkit.plugin.Plugin; +import dev.aurelium.auraskills.bukkit.AuraSkills; import java.io.IOException; import java.io.InputStream; @@ -11,16 +10,16 @@ public class UpdateChecker { - private final Plugin plugin; + private final AuraSkills plugin; private final int resourceId; - public UpdateChecker(Plugin plugin, int resourceId) { + public UpdateChecker(AuraSkills plugin, int resourceId) { this.plugin = plugin; this.resourceId = resourceId; } public void getVersion(final Consumer consumer) { - Bukkit.getScheduler().runTaskAsynchronously(this.plugin, () -> { + plugin.getScheduler().executeAsync(() -> { try (InputStream inputStream = new URL("https://api.spigotmc.org/legacy/update.php?resource=" + this.resourceId).openStream(); Scanner scanner = new Scanner(inputStream)) { if (scanner.hasNext()) { consumer.accept(scanner.nextLine());