diff options
author | Linnea Gräf <nea@nea.moe> | 2024-11-13 13:40:50 +0100 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2024-11-13 13:40:50 +0100 |
commit | d267913e206f5f7bfc16607c0dc058290e6b556f (patch) | |
tree | ae586ff39bb970f51b84f89c7e0b96130e9f4e3b /src/main/kotlin/util | |
parent | db87e5293846e27dc684dd141744390ae6e8bc67 (diff) | |
download | Firmament-d267913e206f5f7bfc16607c0dc058290e6b556f.tar.gz Firmament-d267913e206f5f7bfc16607c0dc058290e6b556f.tar.bz2 Firmament-d267913e206f5f7bfc16607c0dc058290e6b556f.zip |
test: Add sack util test
Diffstat (limited to 'src/main/kotlin/util')
-rw-r--r-- | src/main/kotlin/util/ErrorUtil.kt | 2 | ||||
-rw-r--r-- | src/main/kotlin/util/MC.kt | 2 | ||||
-rw-r--r-- | src/main/kotlin/util/TestUtil.kt | 5 | ||||
-rw-r--r-- | src/main/kotlin/util/skyblock/SackUtil.kt | 7 | ||||
-rw-r--r-- | src/main/kotlin/util/skyblock/SkyBlockItems.kt | 10 |
5 files changed, 23 insertions, 3 deletions
diff --git a/src/main/kotlin/util/ErrorUtil.kt b/src/main/kotlin/util/ErrorUtil.kt index b06093b..5dc44d3 100644 --- a/src/main/kotlin/util/ErrorUtil.kt +++ b/src/main/kotlin/util/ErrorUtil.kt @@ -10,7 +10,7 @@ import moe.nea.firmament.Firmament @Suppress("NOTHING_TO_INLINE") // Suppressed since i want the logger to not pick up the ErrorUtil stack-frame object ErrorUtil { var aggressiveErrors = run { - Thread.currentThread().stackTrace.any { it.className.startsWith("org.junit.") } || Firmament.DEBUG + TestUtil.isInTest || Firmament.DEBUG || ErrorUtil::class.java.desiredAssertionStatus() } diff --git a/src/main/kotlin/util/MC.kt b/src/main/kotlin/util/MC.kt index cbcd8ae..3f5d633 100644 --- a/src/main/kotlin/util/MC.kt +++ b/src/main/kotlin/util/MC.kt @@ -102,7 +102,7 @@ object MC { inline val handledScreen: HandledScreen<*>? get() = instance.currentScreen as? HandledScreen<*> inline val window get() = instance.window inline val currentRegistries: RegistryWrapper.WrapperLookup? get() = world?.registryManager - val defaultRegistries: RegistryWrapper.WrapperLookup = BuiltinRegistries.createWrapperLookup() + val defaultRegistries: RegistryWrapper.WrapperLookup by lazy { BuiltinRegistries.createWrapperLookup() } inline val currentOrDefaultRegistries get() = currentRegistries ?: defaultRegistries val defaultItems: RegistryWrapper.Impl<Item> = defaultRegistries.getOrThrow(RegistryKeys.ITEM) var lastWorld: World? = null diff --git a/src/main/kotlin/util/TestUtil.kt b/src/main/kotlin/util/TestUtil.kt new file mode 100644 index 0000000..68a406f --- /dev/null +++ b/src/main/kotlin/util/TestUtil.kt @@ -0,0 +1,5 @@ +package moe.nea.firmament.util + +object TestUtil { + val isInTest = Thread.currentThread().stackTrace.any { it.className.startsWith("org.junit.") } +} diff --git a/src/main/kotlin/util/skyblock/SackUtil.kt b/src/main/kotlin/util/skyblock/SackUtil.kt index 2679949..fd67c44 100644 --- a/src/main/kotlin/util/skyblock/SackUtil.kt +++ b/src/main/kotlin/util/skyblock/SackUtil.kt @@ -60,8 +60,13 @@ object SackUtil { @Subscribe fun updateFromChat(event: ProcessChatEvent) { if (!event.unformattedString.startsWith("[Sacks]")) return + getUpdatesFromMessage(event.text) + } + + fun getUpdatesFromMessage(text: Text): List<SackUpdate> { val update = ChatUpdate() - event.text.siblings.forEach(update::updateFromHoverText) + text.siblings.forEach(update::updateFromHoverText) + return update.updates } data class SackUpdate( diff --git a/src/main/kotlin/util/skyblock/SkyBlockItems.kt b/src/main/kotlin/util/skyblock/SkyBlockItems.kt new file mode 100644 index 0000000..c94ebfe --- /dev/null +++ b/src/main/kotlin/util/skyblock/SkyBlockItems.kt @@ -0,0 +1,10 @@ +package moe.nea.firmament.util.skyblock + +import moe.nea.firmament.util.SkyblockId + +object SkyBlockItems { + val ROTTEN_FLESH = SkyblockId("ROTTEN_FLESH") + val ENCHANTED_DIAMOND = SkyblockId("ENCHANTED_DIAMOND") + val DIAMOND = SkyblockId("DIAMOND") + val ANCESTRAL_SPADE = SkyblockId("ANCESTRAL_SPADE") +} |