From 2cc7d668eacba1919208ba6b131b01fe10bbf0ed Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Thu, 16 Jan 2025 20:46:41 +0100 Subject: refactor: Move some basetypes and fix: Kuudra chest and dungeon chest detection mixing --- basetypes/src/main/kotlin/moe/nea/ledger/ItemId.kt | 35 ++++++++++++++++++++++ .../kotlin/moe/nea/ledger/utils/RemoveInRelease.kt | 4 +++ build-src/build.gradle.kts | 1 + .../main/kotlin/ledger-staged-proguard.gradle.kts | 1 + build.gradle.kts | 10 +------ mod/ledger-rules.pro | 2 +- mod/src/main/kotlin/moe/nea/ledger/ItemId.kt | 35 ---------------------- .../kotlin/moe/nea/ledger/modules/BitsDetection.kt | 1 - .../moe/nea/ledger/modules/BitsShopDetection.kt | 8 ++--- .../ledger/modules/DragonEyePlacementDetection.kt | 1 - .../nea/ledger/modules/DragonSacrificeDetection.kt | 1 - .../nea/ledger/modules/DungeonChestDetection.kt | 2 +- .../moe/nea/ledger/modules/EyedropsDetection.kt | 1 - .../moe/nea/ledger/modules/GambleDetection.kt | 1 - .../moe/nea/ledger/modules/GodPotionDetection.kt | 1 - .../moe/nea/ledger/modules/KuudraChestDetection.kt | 3 ++ .../moe/nea/ledger/modules/VisitorDetection.kt | 3 -- .../kotlin/moe/nea/ledger/utils/NoSideEffects.kt | 4 --- 18 files changed, 51 insertions(+), 63 deletions(-) create mode 100644 basetypes/src/main/kotlin/moe/nea/ledger/ItemId.kt create mode 100644 basetypes/src/main/kotlin/moe/nea/ledger/utils/RemoveInRelease.kt create mode 100644 build-src/src/main/kotlin/ledger-staged-proguard.gradle.kts delete mode 100644 mod/src/main/kotlin/moe/nea/ledger/ItemId.kt delete mode 100644 mod/src/main/kotlin/moe/nea/ledger/utils/NoSideEffects.kt diff --git a/basetypes/src/main/kotlin/moe/nea/ledger/ItemId.kt b/basetypes/src/main/kotlin/moe/nea/ledger/ItemId.kt new file mode 100644 index 0000000..8dcfa27 --- /dev/null +++ b/basetypes/src/main/kotlin/moe/nea/ledger/ItemId.kt @@ -0,0 +1,35 @@ +package moe.nea.ledger + +import moe.nea.ledger.utils.RemoveInRelease + +data class ItemId( + val string: String +) { + @RemoveInRelease + fun singleItem(): Pair { + return withStackSize(1) + } + + @RemoveInRelease + fun withStackSize(size: Number): Pair { + return Pair(this, size.toDouble()) + } + + + companion object { + + @JvmStatic + @RemoveInRelease + fun forName(string: String) = ItemId(string) + fun skill(skill: String) = ItemId("SKYBLOCK_SKILL_$skill") + + val GARDEN = skill("GARDEN") + val FARMING = skill("FARMING") + + + val COINS = ItemId("SKYBLOCK_COIN") + val GEMSTONE_POWDER = ItemId("SKYBLOCK_POWDER_GEMSTONE") + val MITHRIL_POWDER = ItemId("SKYBLOCK_POWDER_MITHRIL") + val NIL = ItemId("SKYBLOCK_NIL") + } +} \ No newline at end of file diff --git a/basetypes/src/main/kotlin/moe/nea/ledger/utils/RemoveInRelease.kt b/basetypes/src/main/kotlin/moe/nea/ledger/utils/RemoveInRelease.kt new file mode 100644 index 0000000..319fb63 --- /dev/null +++ b/basetypes/src/main/kotlin/moe/nea/ledger/utils/RemoveInRelease.kt @@ -0,0 +1,4 @@ +package moe.nea.ledger.utils + +@Retention(AnnotationRetention.BINARY) +annotation class RemoveInRelease diff --git a/build-src/build.gradle.kts b/build-src/build.gradle.kts index 5e53bfc..8e90b7f 100644 --- a/build-src/build.gradle.kts +++ b/build-src/build.gradle.kts @@ -8,4 +8,5 @@ repositories { dependencies { implementation("com.google.code.gson:gson:2.9.1") // Match loom :) implementation(gradleApi()) + api("com.guardsquare:proguard-gradle:7.6.1") } diff --git a/build-src/src/main/kotlin/ledger-staged-proguard.gradle.kts b/build-src/src/main/kotlin/ledger-staged-proguard.gradle.kts new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/build-src/src/main/kotlin/ledger-staged-proguard.gradle.kts @@ -0,0 +1 @@ + diff --git a/build.gradle.kts b/build.gradle.kts index b4583f1..171c811 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,19 +1,11 @@ import com.github.gmazzo.buildconfig.BuildConfigExtension import java.io.ByteArrayOutputStream -buildscript { - repositories { - mavenCentral() - } - dependencies { - classpath("com.guardsquare:proguard-gradle:7.6.1") - } -} - plugins { kotlin("jvm") version "2.0.20" apply false id("com.github.gmazzo.buildconfig") version "5.5.0" apply false id("ledger-globals") + id("com.github.johnrengelman.shadow") version "8.1.1" apply false } allprojects { diff --git a/mod/ledger-rules.pro b/mod/ledger-rules.pro index 32cd337..faa10c2 100644 --- a/mod/ledger-rules.pro +++ b/mod/ledger-rules.pro @@ -1,4 +1,4 @@ -keep class !moe.nea.ledger.gen.** {*;} -dontobfuscate --assumenosideeffects class ** { @moe.nea.ledger.utils.NoSideEffects ; } +-assumenosideeffects class ** { @moe.nea.ledger.utils.RemoveInRelease ; } #-dontoptimize diff --git a/mod/src/main/kotlin/moe/nea/ledger/ItemId.kt b/mod/src/main/kotlin/moe/nea/ledger/ItemId.kt deleted file mode 100644 index 8211cd3..0000000 --- a/mod/src/main/kotlin/moe/nea/ledger/ItemId.kt +++ /dev/null @@ -1,35 +0,0 @@ -package moe.nea.ledger - -import moe.nea.ledger.utils.NoSideEffects - -data class ItemId( - val string: String -) { - @NoSideEffects - fun singleItem(): Pair { - return withStackSize(1) - } - - @NoSideEffects - fun withStackSize(size: Number): Pair { - return Pair(this, size.toDouble()) - } - - - companion object { - - @JvmStatic - @NoSideEffects - fun forName(string: String) = ItemId(string) - fun skill(skill: String) = ItemId("SKYBLOCK_SKILL_$skill") - - val GARDEN = skill("GARDEN") - val FARMING = skill("FARMING") - - - val COINS = ItemId("SKYBLOCK_COIN") - val GEMSTONE_POWDER = ItemId("SKYBLOCK_POWDER_GEMSTONE") - val MITHRIL_POWDER = ItemId("SKYBLOCK_POWDER_MITHRIL") - val NIL = ItemId("SKYBLOCK_NIL") - } -} \ No newline at end of file diff --git a/mod/src/main/kotlin/moe/nea/ledger/modules/BitsDetection.kt b/mod/src/main/kotlin/moe/nea/ledger/modules/BitsDetection.kt index 44a0050..f0f5369 100644 --- a/mod/src/main/kotlin/moe/nea/ledger/modules/BitsDetection.kt +++ b/mod/src/main/kotlin/moe/nea/ledger/modules/BitsDetection.kt @@ -1,7 +1,6 @@ package moe.nea.ledger.modules import moe.nea.ledger.ItemChange -import moe.nea.ledger.ItemId import moe.nea.ledger.events.ChatReceived import moe.nea.ledger.events.LateWorldLoadEvent import moe.nea.ledger.LedgerEntry diff --git a/mod/src/main/kotlin/moe/nea/ledger/modules/BitsShopDetection.kt b/mod/src/main/kotlin/moe/nea/ledger/modules/BitsShopDetection.kt index 553bebf..84185bf 100644 --- a/mod/src/main/kotlin/moe/nea/ledger/modules/BitsShopDetection.kt +++ b/mod/src/main/kotlin/moe/nea/ledger/modules/BitsShopDetection.kt @@ -22,10 +22,10 @@ class BitsShopDetection @Inject constructor(val ledger: LedgerLogger) { data class BitShopEntry( - val id: ItemId, - val stackSize: Int, - val bitPrice: Int, - val timestamp: Long = System.currentTimeMillis() + val id: ItemId, + val stackSize: Int, + val bitPrice: Int, + val timestamp: Long = System.currentTimeMillis() ) var lastClickedBitShopItem: BitShopEntry? = null diff --git a/mod/src/main/kotlin/moe/nea/ledger/modules/DragonEyePlacementDetection.kt b/mod/src/main/kotlin/moe/nea/ledger/modules/DragonEyePlacementDetection.kt index e389ffb..b7b9de1 100644 --- a/mod/src/main/kotlin/moe/nea/ledger/modules/DragonEyePlacementDetection.kt +++ b/mod/src/main/kotlin/moe/nea/ledger/modules/DragonEyePlacementDetection.kt @@ -1,7 +1,6 @@ package moe.nea.ledger.modules import moe.nea.ledger.ItemChange -import moe.nea.ledger.ItemId import moe.nea.ledger.LedgerEntry import moe.nea.ledger.LedgerLogger import moe.nea.ledger.TransactionType diff --git a/mod/src/main/kotlin/moe/nea/ledger/modules/DragonSacrificeDetection.kt b/mod/src/main/kotlin/moe/nea/ledger/modules/DragonSacrificeDetection.kt index 574cfcf..3bf36f9 100644 --- a/mod/src/main/kotlin/moe/nea/ledger/modules/DragonSacrificeDetection.kt +++ b/mod/src/main/kotlin/moe/nea/ledger/modules/DragonSacrificeDetection.kt @@ -2,7 +2,6 @@ package moe.nea.ledger.modules import moe.nea.ledger.DebouncedValue import moe.nea.ledger.ItemChange -import moe.nea.ledger.ItemId import moe.nea.ledger.ItemIdProvider import moe.nea.ledger.LedgerEntry import moe.nea.ledger.LedgerLogger diff --git a/mod/src/main/kotlin/moe/nea/ledger/modules/DungeonChestDetection.kt b/mod/src/main/kotlin/moe/nea/ledger/modules/DungeonChestDetection.kt index e747be9..37d0e9c 100644 --- a/mod/src/main/kotlin/moe/nea/ledger/modules/DungeonChestDetection.kt +++ b/mod/src/main/kotlin/moe/nea/ledger/modules/DungeonChestDetection.kt @@ -76,7 +76,7 @@ class DungeonChestDetection @Inject constructor(val logger: LedgerLogger) : Ches } } - val rewardMessage = " (WOOD|GOLD|DIAMOND|EMERALD|OBSIDIAN|BEDROCK) CHEST REWARDS".toPattern() + val rewardMessage = " *(WOOD|GOLD|DIAMOND|EMERALD|OBSIDIAN|BEDROCK) CHEST REWARDS".toPattern() @SubscribeEvent fun onChatMessage(event: ChatReceived) { diff --git a/mod/src/main/kotlin/moe/nea/ledger/modules/EyedropsDetection.kt b/mod/src/main/kotlin/moe/nea/ledger/modules/EyedropsDetection.kt index 04dbe80..1c36ae4 100644 --- a/mod/src/main/kotlin/moe/nea/ledger/modules/EyedropsDetection.kt +++ b/mod/src/main/kotlin/moe/nea/ledger/modules/EyedropsDetection.kt @@ -1,7 +1,6 @@ package moe.nea.ledger.modules import moe.nea.ledger.ItemChange -import moe.nea.ledger.ItemId import moe.nea.ledger.LedgerEntry import moe.nea.ledger.LedgerLogger import moe.nea.ledger.TransactionType diff --git a/mod/src/main/kotlin/moe/nea/ledger/modules/GambleDetection.kt b/mod/src/main/kotlin/moe/nea/ledger/modules/GambleDetection.kt index a8f79c1..9149e14 100644 --- a/mod/src/main/kotlin/moe/nea/ledger/modules/GambleDetection.kt +++ b/mod/src/main/kotlin/moe/nea/ledger/modules/GambleDetection.kt @@ -1,7 +1,6 @@ package moe.nea.ledger.modules import moe.nea.ledger.ItemChange -import moe.nea.ledger.ItemId import moe.nea.ledger.LedgerEntry import moe.nea.ledger.LedgerLogger import moe.nea.ledger.TransactionType diff --git a/mod/src/main/kotlin/moe/nea/ledger/modules/GodPotionDetection.kt b/mod/src/main/kotlin/moe/nea/ledger/modules/GodPotionDetection.kt index ae86519..e858a6b 100644 --- a/mod/src/main/kotlin/moe/nea/ledger/modules/GodPotionDetection.kt +++ b/mod/src/main/kotlin/moe/nea/ledger/modules/GodPotionDetection.kt @@ -1,7 +1,6 @@ package moe.nea.ledger.modules import moe.nea.ledger.ItemChange -import moe.nea.ledger.ItemId import moe.nea.ledger.LedgerEntry import moe.nea.ledger.LedgerLogger import moe.nea.ledger.TransactionType diff --git a/mod/src/main/kotlin/moe/nea/ledger/modules/KuudraChestDetection.kt b/mod/src/main/kotlin/moe/nea/ledger/modules/KuudraChestDetection.kt index e0e9322..88c45d2 100644 --- a/mod/src/main/kotlin/moe/nea/ledger/modules/KuudraChestDetection.kt +++ b/mod/src/main/kotlin/moe/nea/ledger/modules/KuudraChestDetection.kt @@ -36,6 +36,9 @@ class KuudraChestDetection : ChestDetection() { if (requiredKey != null && !hasKey(requiredKey)) { return } + if (requiredKey == null && event.slotIn.inventory.name != "Free Chest") { + return + } log.logEntry(LedgerEntry( TransactionType.KUUDRA_CHEST_OPEN, diffs.timestamp, diff --git a/mod/src/main/kotlin/moe/nea/ledger/modules/VisitorDetection.kt b/mod/src/main/kotlin/moe/nea/ledger/modules/VisitorDetection.kt index f457ae4..5178e9f 100644 --- a/mod/src/main/kotlin/moe/nea/ledger/modules/VisitorDetection.kt +++ b/mod/src/main/kotlin/moe/nea/ledger/modules/VisitorDetection.kt @@ -5,15 +5,12 @@ import moe.nea.ledger.ItemId import moe.nea.ledger.ItemIdProvider import moe.nea.ledger.LedgerEntry import moe.nea.ledger.LedgerLogger -import moe.nea.ledger.SHORT_NUMBER_PATTERN import moe.nea.ledger.TransactionType import moe.nea.ledger.events.ExtraSupplyIdEvent import moe.nea.ledger.events.GuiClickEvent import moe.nea.ledger.getDisplayNameU import moe.nea.ledger.getLore -import moe.nea.ledger.parseShortNumber import moe.nea.ledger.unformattedString -import moe.nea.ledger.useMatcher import moe.nea.ledger.utils.di.Inject import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.time.Instant diff --git a/mod/src/main/kotlin/moe/nea/ledger/utils/NoSideEffects.kt b/mod/src/main/kotlin/moe/nea/ledger/utils/NoSideEffects.kt deleted file mode 100644 index 9b0e7a3..0000000 --- a/mod/src/main/kotlin/moe/nea/ledger/utils/NoSideEffects.kt +++ /dev/null @@ -1,4 +0,0 @@ -package moe.nea.ledger.utils - -@Retention(AnnotationRetention.BINARY) -annotation class NoSideEffects -- cgit