Skip to content

Commit

Permalink
Fix update checker using wrong schedulers
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikSzabo committed Oct 24, 2024
1 parent ba26efb commit 6c45092
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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);
}

}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<String> 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());
Expand Down

0 comments on commit 6c45092

Please sign in to comment.