diff --git a/src/main/java/at/hannibal2/skyhanni/tweaker/DownloadSourceChecker.java b/src/main/java/at/hannibal2/skyhanni/tweaker/DownloadSourceChecker.java index 8596b5fb2e47..8148b75064de 100644 --- a/src/main/java/at/hannibal2/skyhanni/tweaker/DownloadSourceChecker.java +++ b/src/main/java/at/hannibal2/skyhanni/tweaker/DownloadSourceChecker.java @@ -1,5 +1,6 @@ package at.hannibal2.skyhanni.tweaker; +import at.hannibal2.skyhanni.utils.ChatUtils; import at.hannibal2.skyhanni.utils.OSUtils; import javax.swing.JFrame; @@ -82,7 +83,8 @@ private static void openMenu(URI host) { // Compile the regex pattern for matching an empty host Pattern pattern = Pattern.compile("https:\\/\\/.*.com\\/$|about:internet"); - Matcher matcher = pattern.matcher(uriToSimpleString(host)); + String readableHost = uriToSimpleString(host); + Matcher matcher = pattern.matcher(readableHost); // Check if the host is empty (Brave is cutting everything past .com/ from the host) String cutHostMessage = ""; @@ -91,9 +93,10 @@ private static void openMenu(URI host) { "Try downloading the file using a different browser (Microsoft Edge, Google Chrome, etc.)."; } + ChatUtils.INSTANCE.consoleError("detected a untrusted download source host: '" + readableHost + "'"); JOptionPane.showOptionDialog( frame, - String.format(String.join("\n", SECURITY_POPUP), uriToSimpleString(host)) + cutHostMessage, + String.format(String.join("\n", SECURITY_POPUP), readableHost) + cutHostMessage, "SkyHanni " + MOD_VERSION + " Security Error", JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE, diff --git a/src/main/java/at/hannibal2/skyhanni/tweaker/ModLoadingTweaker.java b/src/main/java/at/hannibal2/skyhanni/tweaker/ModLoadingTweaker.java index 418fa62efe27..78383dcf0c6f 100644 --- a/src/main/java/at/hannibal2/skyhanni/tweaker/ModLoadingTweaker.java +++ b/src/main/java/at/hannibal2/skyhanni/tweaker/ModLoadingTweaker.java @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.tweaker; +import at.hannibal2.skyhanni.utils.ChatUtils; import net.minecraft.launchwrapper.ITweaker; import net.minecraft.launchwrapper.LaunchClassLoader; import net.minecraftforge.fml.relauncher.CoreModManager; @@ -29,7 +30,7 @@ public void acceptOptions(List args, File gameDir, File assetsDir, Strin CoreModManager.getIgnoredMods().remove(file); CoreModManager.getReparseableCoremods().add(file); } catch (URISyntaxException e) { - System.err.println("SkyHanni could not re-add itself as mod."); + ChatUtils.INSTANCE.consoleError("could not re-add itself as mod."); e.printStackTrace(); } } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ChatUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ChatUtils.kt index f3cd1e1e3e46..a01f1c281806 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/ChatUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/ChatUtils.kt @@ -1,5 +1,6 @@ package at.hannibal2.skyhanni.utils +import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.MessageSendToServerEvent import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule @@ -316,4 +317,8 @@ object ChatUtils { replaceSameMessage = true, ) } + + fun consoleError(message: String) { + System.err.println(" \nSkyHanni-${SkyHanniMod.version} $message\n ") + } } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt index 57f05df9f85d..376406e8c4b0 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt @@ -319,10 +319,9 @@ object LorenzUtils { inline fun > T.isAnyOf(vararg array: T): Boolean = array.contains(this) fun shutdownMinecraft(reason: String? = null) { - System.err.println("SkyHanni-${SkyHanniMod.version} forced the game to shutdown.") - reason?.let { - System.err.println("Reason: $it") - } + val reasonLine = reason?.let { " Reason: $it" }.orEmpty() + ChatUtils.consoleError("forced the game to shutdown.$reasonLine") + FMLCommonHandler.instance().handleExit(-1) } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NEUVersionCheck.kt b/src/main/java/at/hannibal2/skyhanni/utils/NEUVersionCheck.kt index be5bad5311ad..705231447d0f 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/NEUVersionCheck.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/NEUVersionCheck.kt @@ -39,6 +39,7 @@ object NEUVersionCheck { } private fun neuWarning(what: String) { + ChatUtils.consoleError("failed to find NotEnoughUpdates! Reason: $what") openPopupWindow( "NotEnoughUpdates is $what!\n" + "SkyHanni requires the latest version of NotEnoughUpdates to work.\n" +