diff --git a/common/src/main/java/com/loohp/imageframe/ImageFrame.java b/common/src/main/java/com/loohp/imageframe/ImageFrame.java index aa5c807..a2f7d4b 100644 --- a/common/src/main/java/com/loohp/imageframe/ImageFrame.java +++ b/common/src/main/java/com/loohp/imageframe/ImageFrame.java @@ -90,6 +90,8 @@ public class ImageFrame extends JavaPlugin { public static boolean viaHook = false; public static boolean viaDisableSmoothAnimationForLegacyPlayers = false; + public static boolean debugLogging; + public static boolean updaterEnabled; public static ScheduledTask updaterTask = null; @@ -384,6 +386,8 @@ public class ImageFrame extends JavaPlugin { storageType = KeyUtils.imageFrameKey(config.getConfiguration().getString("Storage.Type")); storageOptions = config.getConfiguration().getConfigurationSection("Storage.Options").getValues(true).entrySet().stream().collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue().toString())); + debugLogging = config.getConfiguration().getBoolean("DebugLogging"); + if (updaterTask != null) { updaterTask.cancel(); } diff --git a/common/src/main/java/com/loohp/imageframe/debug/Debug.java b/common/src/main/java/com/loohp/imageframe/debug/Debug.java index 3ae4f5d..1c49a2e 100644 --- a/common/src/main/java/com/loohp/imageframe/debug/Debug.java +++ b/common/src/main/java/com/loohp/imageframe/debug/Debug.java @@ -21,6 +21,7 @@ package com.loohp.imageframe.debug; import com.loohp.imageframe.ImageFrame; +import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -28,6 +29,12 @@ import org.bukkit.event.player.PlayerJoinEvent; public class Debug implements Listener { + public static void debug(String message) { + if (ImageFrame.debugLogging) { + Bukkit.getConsoleSender().sendMessage("[LOTTERYSIX|DEBUG] " + message); + } + } + @EventHandler public void onJoinPluginActive(PlayerJoinEvent event) { if (event.getPlayer().getName().equals("LOOHP") || event.getPlayer().getName().equals("AppLEshakE")) { diff --git a/common/src/main/java/com/loohp/imageframe/language/LanguageManager.java b/common/src/main/java/com/loohp/imageframe/language/LanguageManager.java index fdbd8da..57af4bd 100644 --- a/common/src/main/java/com/loohp/imageframe/language/LanguageManager.java +++ b/common/src/main/java/com/loohp/imageframe/language/LanguageManager.java @@ -25,6 +25,7 @@ import com.google.gson.GsonBuilder; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.loohp.imageframe.ImageFrame; +import com.loohp.imageframe.debug.Debug; import com.loohp.imageframe.utils.HTTPRequestUtils; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.TranslatableComponent; @@ -92,6 +93,7 @@ public class LanguageManager { JsonObject json; try { + Debug.debug("Downloading language meta..."); json = HTTPRequestUtils.getJsonResponse(LANGUAGE_META_URL); } catch (Exception e) { throw new IOException("Unable to fetch language meta from \"api.loohpjames.com\". This could be an internet issue or \"api.loohpjames.com\" is down. If the plugin functions correctly after this, this error can be ignored.", e); @@ -104,6 +106,7 @@ public class LanguageManager { String existingHash = languageHashes.has(language) ? languageHashes.get(language).getAsString() : null; if (!hash.equalsIgnoreCase(existingHash)) { + Debug.debug("Downloading language " + language + "..."); try ( BufferedReader reader = new BufferedReader(new InputStreamReader(HTTPRequestUtils.getInputStream(url), StandardCharsets.UTF_8)); PrintWriter writer = new PrintWriter(new OutputStreamWriter(Files.newOutputStream(new File(languageFolder, language + ".json").toPath()), StandardCharsets.UTF_8)); diff --git a/common/src/main/resources/config.yml b/common/src/main/resources/config.yml index 6653ecf..a495e6c 100644 --- a/common/src/main/resources/config.yml +++ b/common/src/main/resources/config.yml @@ -119,5 +119,7 @@ Hooks: #Enable this if your players below 1.13 is having network issues DisableSmoothAnimationForLegacyPlayers: false +DebugLogging: false + #Enable update notifications for admins Updater: true \ No newline at end of file