From ad36edd5cd95a20694bd654ccaf3446e18993685 Mon Sep 17 00:00:00 2001 From: Minecon724 Date: Tue, 31 Dec 2024 13:36:03 +0100 Subject: [PATCH] Use the new class here --- .../eu/m724/tweaks/updater/UpdateChecker.java | 17 +++++++---------- .../eu/m724/tweaks/updater/UpdaterManager.java | 2 +- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/main/java/eu/m724/tweaks/updater/UpdateChecker.java b/src/main/java/eu/m724/tweaks/updater/UpdateChecker.java index 61f0fb8..2687e32 100644 --- a/src/main/java/eu/m724/tweaks/updater/UpdateChecker.java +++ b/src/main/java/eu/m724/tweaks/updater/UpdateChecker.java @@ -6,9 +6,9 @@ package eu.m724.tweaks.updater; +import eu.m724.tweaks.DebugLogger; import eu.m724.tweaks.Language; import eu.m724.tweaks.updater.cache.VersionedResource; -import org.bukkit.plugin.Plugin; import org.bukkit.scheduler.BukkitRunnable; import java.io.FileOutputStream; @@ -19,18 +19,15 @@ import java.util.HashSet; import java.util.Objects; import java.util.Set; import java.util.concurrent.CompletionException; -import java.util.logging.Logger; import java.util.stream.Collectors; public class UpdateChecker extends BukkitRunnable { private final Set resources; - private final Logger logger; static final Set availableUpdates = new HashSet<>(); static LocalTime lastChecked = null; - UpdateChecker(Plugin plugin, Set resources) { - this.logger = Logger.getLogger(plugin.getLogger().getName() + "." + getClass().getSimpleName()); + UpdateChecker(Set resources) { this.resources = resources; // TODO make a copy? } @@ -49,9 +46,9 @@ public class UpdateChecker extends BukkitRunnable { if (!versionedResource.equals(newResource)) { resources.remove(versionedResource); if (newResource.running() == null) { - logger.info("Unable to find installed version of %s".formatted(pluginName)); + DebugLogger.info("Unable to find installed version of %s".formatted(pluginName)); if (versionedResource.running() != null) { - logger.info("Did you downgrade %s? If so, clear cache".formatted(pluginName)); + DebugLogger.info("Did you downgrade %s? If so, clear cache".formatted(pluginName)); } } else { if (!newResource.running().equals(newResource.latest())) { @@ -62,7 +59,7 @@ public class UpdateChecker extends BukkitRunnable { resources.add(newResource); } } catch (CompletionException e) { - logger.severe("Unable to refresh %s: %s".formatted(pluginName, e.getMessage())); + DebugLogger.severe("Unable to refresh %s: %s".formatted(pluginName, e.getMessage())); } } } @@ -70,11 +67,11 @@ public class UpdateChecker extends BukkitRunnable { private void alert() { int n = availableUpdates.size(); if (n == 0) return; - logger.info(Language.getString("updateAvailableNotice", n)); + DebugLogger.info(Language.getString("updateAvailableNotice", n)); availableUpdates.stream() .map(u -> "- %s (%s -> %s)".formatted(u.resource().name(), u.running().label(), u.latest().label())) - .forEach(logger::info); + .forEach(DebugLogger::info); } @Override diff --git a/src/main/java/eu/m724/tweaks/updater/UpdaterManager.java b/src/main/java/eu/m724/tweaks/updater/UpdaterManager.java index 6fa06b0..a535196 100644 --- a/src/main/java/eu/m724/tweaks/updater/UpdaterManager.java +++ b/src/main/java/eu/m724/tweaks/updater/UpdaterManager.java @@ -60,7 +60,7 @@ public class UpdaterManager { )).collect(Collectors.toSet()); - new UpdateChecker(plugin, versionedResources) + new UpdateChecker(versionedResources) .runTaskTimerAsynchronously(plugin, 600, 12 * 3600 * 20); updatesCommand.setExecutor(new UpdaterCommands());