diff --git a/src/main/java/club/sk1er/patcher/Patcher.java b/src/main/java/club/sk1er/patcher/Patcher.java index f31ab46c4..eda50a1c1 100644 --- a/src/main/java/club/sk1er/patcher/Patcher.java +++ b/src/main/java/club/sk1er/patcher/Patcher.java @@ -59,13 +59,12 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import java.awt.*; import java.io.*; import java.util.List; import java.util.*; import java.util.stream.Collectors; -@Mod(modid = "@ID@", name = "@NAME@", version = Patcher.VERSION, clientSideOnly = true) +@Mod(modid = "@MOD_ID@", name = "@MOD_NAME@", version = Patcher.VERSION, clientSideOnly = true) public class Patcher { @Mod.Instance("patcher") @@ -77,7 +76,7 @@ public class Patcher { // extra branches will be 1.x.x+branch-y public static final String VERSION = "@VER@"; - private final Logger logger = LogManager.getLogger("Patcher"); + private static final Logger logger = LogManager.getLogger("Patcher"); private final File logsDirectory = new File(Minecraft.getMinecraft().mcDataDir + File.separator + "logs" + File.separator); /** @@ -421,7 +420,7 @@ public PatcherSoundConfig getPatcherSoundConfig() { return patcherSoundConfig; } - public Logger getLogger() { + public static Logger getLogger() { return logger; } diff --git a/src/main/java/club/sk1er/patcher/config/PatcherConfig.java b/src/main/java/club/sk1er/patcher/config/PatcherConfig.java index 7b59e06ce..d27470874 100644 --- a/src/main/java/club/sk1er/patcher/config/PatcherConfig.java +++ b/src/main/java/club/sk1er/patcher/config/PatcherConfig.java @@ -1839,7 +1839,7 @@ public PatcherConfig() { // try { // FileUtils.writeStringToFile(ConfigUtils.getProfileFile("patcher-not-migrated.json"), FileUtils.readFileToString(ConfigUtils.getProfileFile("patcher.json"), StandardCharsets.UTF_8), StandardCharsets.UTF_8); // } catch (IOException e) { - // Patcher.instance.getLogger().error("Failed to copy over Patcher config before migration.", e); + // Patcher.getLogger().error("Failed to copy over Patcher config before migration.", e); // } // save(); //} @@ -2019,7 +2019,7 @@ public PatcherConfig() { //hideIf("keyboardLayout", () -> !SystemUtils.IS_OS_LINUX); } catch (Exception e) { - Patcher.instance.getLogger().error("Failed to access property.", e); + Patcher.getLogger().error("Failed to access property.", e); } } diff --git a/src/main/java/club/sk1er/patcher/config/PatcherSoundConfig.java b/src/main/java/club/sk1er/patcher/config/PatcherSoundConfig.java index 374eb1589..3c47588ee 100644 --- a/src/main/java/club/sk1er/patcher/config/PatcherSoundConfig.java +++ b/src/main/java/club/sk1er/patcher/config/PatcherSoundConfig.java @@ -50,7 +50,7 @@ public class PatcherSoundConfig // try { // dummyField = getClass().getDeclaredField("dummyBooleanForMigratorDONTTOUCH"); // } catch (Exception e) { - // Patcher.instance.getLogger().error("Failed to get dummy field for migrator, this is a bug!", e); + // Patcher.getLogger().error("Failed to get dummy field for migrator, this is a bug!", e); // } // try { // for (Map.Entry entry : soundRegistry.entrySet()) { diff --git a/src/main/java/club/sk1er/patcher/hooks/FontRendererHook.java b/src/main/java/club/sk1er/patcher/hooks/FontRendererHook.java index 0e401d103..b543ee739 100644 --- a/src/main/java/club/sk1er/patcher/hooks/FontRendererHook.java +++ b/src/main/java/club/sk1er/patcher/hooks/FontRendererHook.java @@ -62,7 +62,7 @@ private void establishSize() { try (final InputStream stream = mc.getResourceManager().getResource(fontRendererAccessor.getLocationFontTexture()).getInputStream()) { specWidth = ImageIO.read(stream).getWidth(); } catch (IOException e) { - Patcher.instance.getLogger().error("Failed to read font texture while establishing size.", e); + Patcher.getLogger().error("Failed to read font texture while establishing size.", e); } regularCharDim = specWidth; @@ -98,7 +98,7 @@ public void create() { try (final InputStream stream = mc.getResourceManager().getResource(fontRendererAccessor.getLocationFontTexture()).getInputStream()) { bufferedImage.getGraphics().drawImage(ImageIO.read(stream), 0, 16 * texSheetDim, null); } catch (IOException e) { - Patcher.instance.getLogger().error("Failed to draw texture sheet.", e); + Patcher.getLogger().error("Failed to draw texture sheet.", e); } glTextureId = new DynamicTexture(bufferedImage).getGlTextureId(); diff --git a/src/main/java/club/sk1er/patcher/hooks/MinecraftHook.java b/src/main/java/club/sk1er/patcher/hooks/MinecraftHook.java index 439a970c9..babc3e6a4 100644 --- a/src/main/java/club/sk1er/patcher/hooks/MinecraftHook.java +++ b/src/main/java/club/sk1er/patcher/hooks/MinecraftHook.java @@ -78,7 +78,7 @@ public static boolean fullscreen() { Display.setResizable(true); return true; } catch (LWJGLException e) { - Patcher.instance.getLogger().error("Failed to toggle fullscreen.", e); + Patcher.getLogger().error("Failed to toggle fullscreen.", e); } return false; } @@ -118,7 +118,7 @@ public void fix(boolean fullscreen) { Display.setResizable(!fullscreen); } catch (LWJGLException e) { - Patcher.instance.getLogger().error("Failed to update screen type.", e); + Patcher.getLogger().error("Failed to update screen type.", e); } } } diff --git a/src/main/java/club/sk1er/patcher/hooks/NetHandlerPlayClientHook.java b/src/main/java/club/sk1er/patcher/hooks/NetHandlerPlayClientHook.java index 9c482818a..50e6e9925 100644 --- a/src/main/java/club/sk1er/patcher/hooks/NetHandlerPlayClientHook.java +++ b/src/main/java/club/sk1er/patcher/hooks/NetHandlerPlayClientHook.java @@ -32,7 +32,7 @@ public static boolean validateResourcePackUrl(S48PacketResourcePackSend packet) url = URLDecoder.decode(url.substring("level://".length()), StandardCharsets.UTF_8.toString()); if (isLevelProtocol && (url.contains("..") || !url.endsWith("/resources.zip"))) { - Patcher.instance.getLogger().warn("Malicious server tried to access {}", url); + Patcher.getLogger().warn("Malicious server tried to access {}", url); if (Minecraft.getMinecraft().thePlayer != null) { ChatUtilities.sendNotification("Patcher", "&c&lThe current server has attempted to be malicious but we have stopped them."); } diff --git a/src/main/java/club/sk1er/patcher/hooks/ResourceReloadHooks.java b/src/main/java/club/sk1er/patcher/hooks/ResourceReloadHooks.java index 71ac8b38f..cd3bb0b3f 100644 --- a/src/main/java/club/sk1er/patcher/hooks/ResourceReloadHooks.java +++ b/src/main/java/club/sk1er/patcher/hooks/ResourceReloadHooks.java @@ -37,7 +37,7 @@ public static void reloadOptiFineLanguage() { return; } catch (Exception e) { if (Patcher.instance != null) { - Patcher.instance.getLogger().error("Failed to reload OptiFine language. If this is causing issues, please report this to https://polyfrost.org/discord", e); + Patcher.getLogger().error("Failed to reload OptiFine language. If this is causing issues, please report this to https://polyfrost.org/discord", e); } return; } @@ -46,7 +46,7 @@ public static void reloadOptiFineLanguage() { langMethod.invoke(null); } catch (Exception e) { if (Patcher.instance != null) { - Patcher.instance.getLogger().error("Failed to reload OptiFine language. If this is causing issues, please report this to https://polyfrost.org/discord", e); + Patcher.getLogger().error("Failed to reload OptiFine language. If this is causing issues, please report this to https://polyfrost.org/discord", e); } } } diff --git a/src/main/java/club/sk1er/patcher/mixins/bugfixes/crashes/ServerListEntryNormalMixin_ResolveCrash.java b/src/main/java/club/sk1er/patcher/mixins/bugfixes/crashes/ServerListEntryNormalMixin_ResolveCrash.java index 760a910e7..89f35bc37 100644 --- a/src/main/java/club/sk1er/patcher/mixins/bugfixes/crashes/ServerListEntryNormalMixin_ResolveCrash.java +++ b/src/main/java/club/sk1er/patcher/mixins/bugfixes/crashes/ServerListEntryNormalMixin_ResolveCrash.java @@ -20,7 +20,7 @@ public abstract class ServerListEntryNormalMixin_ResolveCrash { try { prepareServerIcon(); } catch (Exception e) { - Patcher.instance.getLogger().error("Failed to prepare server icon, setting to default.", e); + Patcher.getLogger().error("Failed to prepare server icon, setting to default.", e); server.setBase64EncodedIconData(null); } } diff --git a/src/main/java/club/sk1er/patcher/mixins/performance/forge/ModelLoader_SkipFirstBaking.java b/src/main/java/club/sk1er/patcher/mixins/performance/forge/ModelLoader_SkipFirstBaking.java index 68dbf5de6..0f67d15ef 100644 --- a/src/main/java/club/sk1er/patcher/mixins/performance/forge/ModelLoader_SkipFirstBaking.java +++ b/src/main/java/club/sk1er/patcher/mixins/performance/forge/ModelLoader_SkipFirstBaking.java @@ -63,7 +63,7 @@ public ModelLoader_SkipFirstBaking(IResourceManager p_i46085_1_, TextureMap p_i4 private void patcher$skipFirstBaking(CallbackInfoReturnable> cir) { if (!patcher$firstLoad) { - Patcher.instance.getLogger().info("Saved " + (System.currentTimeMillis() - patcher$lastTime) + "ms by skipping first model baking."); + Patcher.getLogger().info("Saved " + (System.currentTimeMillis() - patcher$lastTime) + "ms by skipping first model baking."); } } diff --git a/src/main/java/club/sk1er/patcher/optifine/OptiFineFontRendererHandler.java b/src/main/java/club/sk1er/patcher/optifine/OptiFineFontRendererHandler.java index d4c64d663..32c284a0c 100644 --- a/src/main/java/club/sk1er/patcher/optifine/OptiFineFontRendererHandler.java +++ b/src/main/java/club/sk1er/patcher/optifine/OptiFineFontRendererHandler.java @@ -19,7 +19,7 @@ public static int getTextColor(int index, int originalColor) { return originalColor; } catch (Throwable t) { caughtError = true; - Patcher.instance.getLogger().error("Unable to get OptiFine's Custom Color", t); + Patcher.getLogger().error("Unable to get OptiFine's Custom Color", t); return originalColor; } } diff --git a/src/main/java/club/sk1er/patcher/screen/render/overlay/ImagePreview.java b/src/main/java/club/sk1er/patcher/screen/render/overlay/ImagePreview.java index 93a7b53a2..fb395e56a 100644 --- a/src/main/java/club/sk1er/patcher/screen/render/overlay/ImagePreview.java +++ b/src/main/java/club/sk1er/patcher/screen/render/overlay/ImagePreview.java @@ -74,7 +74,7 @@ private void handle(String value) { if (!found) return; } catch (MalformedURLException e) { - Patcher.instance.getLogger().error("Error during url lookup: " + value, e); + Patcher.getLogger().error("Error during url lookup: " + value, e); return; } } @@ -192,7 +192,7 @@ private void loadUrl(String url) { image = TextureUtil.readBufferedImage(stream); } } catch (Exception e) { - Patcher.instance.getLogger().error("Failed to load an image preview from {}", url, e); + Patcher.getLogger().error("Failed to load an image preview from {}", url, e); } finally { if (connection != null) connection.disconnect(); } diff --git a/src/main/java/club/sk1er/patcher/util/screenshot/AsyncScreenshots.java b/src/main/java/club/sk1er/patcher/util/screenshot/AsyncScreenshots.java index 8f15553e4..893c57fd3 100644 --- a/src/main/java/club/sk1er/patcher/util/screenshot/AsyncScreenshots.java +++ b/src/main/java/club/sk1er/patcher/util/screenshot/AsyncScreenshots.java @@ -92,7 +92,7 @@ public void run() { } } catch (Exception e) { ChatUtilities.sendNotification("Screenshot Manager", "Failed to capture screenshot. " + e.getMessage()); - Patcher.instance.getLogger().error("Failed to capture screenshot.", e); + Patcher.getLogger().error("Failed to capture screenshot.", e); } } @@ -261,7 +261,7 @@ public void main() { copyScreenshot(true); } catch (HeadlessException e) { ChatUtilities.sendNotification("Screenshot Manager", "&cFailed to copy screenshot to clipboard."); - Patcher.instance.getLogger().error("Failed to copy screenshot to clipboard.", e); + Patcher.getLogger().error("Failed to copy screenshot to clipboard.", e); } } diff --git a/src/main/java/club/sk1er/patcher/util/world/SavesWatcher.java b/src/main/java/club/sk1er/patcher/util/world/SavesWatcher.java index 8f4c2c8df..a94fcd18b 100644 --- a/src/main/java/club/sk1er/patcher/util/world/SavesWatcher.java +++ b/src/main/java/club/sk1er/patcher/util/world/SavesWatcher.java @@ -51,7 +51,7 @@ public void watch() { key.reset(); } } catch (Exception e) { - Patcher.instance.getLogger().error("Failed to watch for new saves.", e); + Patcher.getLogger().error("Failed to watch for new saves.", e); } }); } diff --git a/src/main/java/club/sk1er/patcher/util/world/render/culling/EntityCulling.java b/src/main/java/club/sk1er/patcher/util/world/render/culling/EntityCulling.java index 83a39ce2a..ff435b12a 100644 --- a/src/main/java/club/sk1er/patcher/util/world/render/culling/EntityCulling.java +++ b/src/main/java/club/sk1er/patcher/util/world/render/culling/EntityCulling.java @@ -140,7 +140,7 @@ private static int getQuery() { try { return GL15.glGenQueries(); } catch (Throwable throwable) { - Patcher.instance.getLogger().error( + Patcher.getLogger().error( "Failed to run GL15.glGenQueries(). User's computer is likely too old to support OpenGL 1.5, Entity Culling has been force disabled.", throwable ); @@ -157,7 +157,7 @@ private static int getQuery() { //try { // UDesktop.browse(new URI("https://polyfrost.org/discord")); //} catch (URISyntaxException e) { - // Patcher.instance.getLogger().error("Failed to open support discord.", e); + // Patcher.getLogger().error("Failed to open support discord.", e); // ChatUtilities.sendMessage("Failed to open https://polyfrost.org/discord."); //} //todo diff --git a/src/main/java/club/sk1er/patcher/util/world/sound/audioswitcher/AudioSwitcher.java b/src/main/java/club/sk1er/patcher/util/world/sound/audioswitcher/AudioSwitcher.java index cb2d350f9..a679ee15b 100644 --- a/src/main/java/club/sk1er/patcher/util/world/sound/audioswitcher/AudioSwitcher.java +++ b/src/main/java/club/sk1er/patcher/util/world/sound/audioswitcher/AudioSwitcher.java @@ -68,7 +68,7 @@ public void initGui(GuiScreenEvent.InitGuiEvent.Post event) { this.mc.getSoundHandler().onResourceManagerReload(this.mc.getResourceManager()); } catch (Exception e) { Notifications.enqueue(Notifications.Type.Error, "Patcher", "Failed to reinitialize OpenAL."); - Patcher.instance.getLogger().error("Failed to reinitialize OpenAL.", e); + Patcher.getLogger().error("Failed to reinitialize OpenAL.", e); } this.changedDevice = false; diff --git a/src/main/java/club/sk1er/patcher/util/world/sound/audioswitcher/LibraryLWJGLOpenALImpl.java b/src/main/java/club/sk1er/patcher/util/world/sound/audioswitcher/LibraryLWJGLOpenALImpl.java index 909de9d87..cea2e3917 100644 --- a/src/main/java/club/sk1er/patcher/util/world/sound/audioswitcher/LibraryLWJGLOpenALImpl.java +++ b/src/main/java/club/sk1er/patcher/util/world/sound/audioswitcher/LibraryLWJGLOpenALImpl.java @@ -31,7 +31,7 @@ public static void createAL() throws LWJGLException { AL.create(); } } catch (Throwable e) { - Patcher.instance.getLogger().error("Failed to create device, using system default.", e); + Patcher.getLogger().error("Failed to create device, using system default.", e); AL.destroy(); AL.create(); }