diff options
author | NopoTheGamer <40329022+NopoTheGamer@users.noreply.github.com> | 2024-10-05 17:55:52 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-05 09:55:52 +0200 |
commit | 5a77e28bf9bd7f9d10eb561212ea5f68512892b7 (patch) | |
tree | b6e24f7ce4431251aca3e273be891f18fa3b444e /src/main/java/at | |
parent | c636d88309279ec458f96c6e6eadd93a39a6c912 (diff) | |
download | skyhanni-5a77e28bf9bd7f9d10eb561212ea5f68512892b7.tar.gz skyhanni-5a77e28bf9bd7f9d10eb561212ea5f68512892b7.tar.bz2 skyhanni-5a77e28bf9bd7f9d10eb561212ea5f68512892b7.zip |
Fix: error punctuation (#2651)
Diffstat (limited to 'src/main/java/at')
4 files changed, 16 insertions, 3 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/api/event/EventHandler.kt b/src/main/java/at/hannibal2/skyhanni/api/event/EventHandler.kt index 4b4c00852..d164e0e77 100644 --- a/src/main/java/at/hannibal2/skyhanni/api/event/EventHandler.kt +++ b/src/main/java/at/hannibal2/skyhanni/api/event/EventHandler.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.inAnyIsland +import at.hannibal2.skyhanni.utils.StringUtils import at.hannibal2.skyhanni.utils.chat.Text import java.lang.invoke.LambdaMetafactory import java.lang.invoke.MethodHandles @@ -91,7 +92,8 @@ class EventHandler<T : SkyHanniEvent> private constructor(val name: String, priv errors++ if (errors <= 3) { val errorName = throwable::class.simpleName ?: "error" - val message = "Caught an $errorName in ${listener.name} at $name: ${throwable.message}" + val aOrAn = StringUtils.optionalAn(errorName) + val message = "Caught $aOrAn $errorName in ${listener.name} at $name: ${throwable.message}" ErrorManager.logErrorWithData(throwable, message, ignoreErrorCache = onError != null) } onError?.invoke(throwable) diff --git a/src/main/java/at/hannibal2/skyhanni/events/LorenzEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/LorenzEvent.kt index 4a294a677..b567d9ae6 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/LorenzEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/LorenzEvent.kt @@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.mixins.hooks.setValue import at.hannibal2.skyhanni.mixins.transformers.AccessorEventBus import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.ChatUtils +import at.hannibal2.skyhanni.utils.StringUtils import at.hannibal2.skyhanni.utils.chat.Text import at.hannibal2.skyhanni.utils.system.PlatformUtils import net.minecraftforge.common.MinecraftForge @@ -57,7 +58,8 @@ abstract class LorenzEvent : Event() { if (printError && errors <= visibleErrors) { val callerName = listener.toString().split(" ")[1].split("@")[0].split(".").last() val errorName = throwable::class.simpleName ?: "error" - val message = "Caught an $errorName in $callerName at $eventName: ${throwable.message}" + val aOrAn = StringUtils.optionalAn(errorName) + val message = "Caught $aOrAn $errorName in $callerName at $eventName: ${throwable.message}" ErrorManager.logErrorWithData(throwable, message, ignoreErrorCache = ignoreErrorCache) } onError(throwable) diff --git a/src/main/java/at/hannibal2/skyhanni/test/command/ErrorManager.kt b/src/main/java/at/hannibal2/skyhanni/test/command/ErrorManager.kt index df3d85267..56a50eceb 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/command/ErrorManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/command/ErrorManager.kt @@ -154,8 +154,12 @@ object ErrorManager { fullErrorMessages[randomId] = "```\nSkyHanni ${SkyHanniMod.version}: $rawMessage\n(full stack trace)\n \n$fullStackTrace\n$extraDataString```" + var finalMessage = message + if (finalMessage.last() !in ".?!") { + finalMessage += "§c." + } ChatUtils.clickableChat( - "§c[SkyHanni-${SkyHanniMod.version}]: $message§c. Click here to copy the error into the clipboard.", + "§c[SkyHanni-${SkyHanniMod.version}]: $finalMessage Click here to copy the error into the clipboard.", onClick = { copyError(randomId) }, "§eClick to copy!", prefix = false, diff --git a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt index f118d5d66..c6de8c13f 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt @@ -569,4 +569,9 @@ object StringUtils { false } } + + fun optionalAn(string: String): String { + if (string.isEmpty()) return "" + return if (string[0] in "aeiou") "an" else "a" + } } |