From 4559e5ff05e19817a21ae49f1c0d8a97d273f6a1 Mon Sep 17 00:00:00 2001 From: Thunderblade73 <85900443+Thunderblade73@users.noreply.github.com> Date: Sat, 10 Feb 2024 00:24:52 +0100 Subject: Splitting many utils functions from LorenzUtils up into other classes: ChatUtils, CollectionUtils, ConditionalUtils. And code cleanup #978 --- .../java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt | 10 ++++++---- .../hannibal2/skyhanni/features/dungeon/DungeonBossMessages.kt | 2 +- .../hannibal2/skyhanni/features/dungeon/DungeonChatFilter.kt | 2 +- .../at/hannibal2/skyhanni/features/dungeon/DungeonCleanEnd.kt | 4 ++-- .../hannibal2/skyhanni/features/dungeon/DungeonDeathCounter.kt | 3 ++- .../skyhanni/features/dungeon/DungeonFinderFeatures.kt | 2 +- .../hannibal2/skyhanni/features/dungeon/DungeonLividFinder.kt | 1 + .../skyhanni/features/dungeon/DungeonMilestonesDisplay.kt | 1 + .../skyhanni/features/dungeon/DungeonRankTabListColor.kt | 1 + .../skyhanni/features/dungeon/DungeonTeammateOutlines.kt | 2 +- .../at/hannibal2/skyhanni/features/dungeon/TerracottaPhase.kt | 1 + 11 files changed, 18 insertions(+), 11 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni/features/dungeon') diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt index c1d8415e0..bb38d09b9 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt @@ -10,12 +10,11 @@ import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent +import at.hannibal2.skyhanni.utils.CollectionUtils.addOrPut +import at.hannibal2.skyhanni.utils.CollectionUtils.equalsOneOf import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.LorenzUtils.addOrPut -import at.hannibal2.skyhanni.utils.LorenzUtils.equalsOneOf -import at.hannibal2.skyhanni.utils.LorenzUtils.getOrNull import at.hannibal2.skyhanni.utils.NumberUtil.formatNumber import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNecessary import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher @@ -25,6 +24,7 @@ import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class DungeonAPI { + private val floorPattern = " §7⏣ §cThe Catacombs §7\\((?.*)\\)".toPattern() private val uniqueClassBonus = "^Your ([A-Za-z]+) stats are doubled because you are the only player using this class!$".toRegex() @@ -37,6 +37,7 @@ class DungeonAPI { private val totalKillsPattern = "§7Total Kills: §e(?.*)".toPattern() companion object { + var dungeonFloor: String? = null var started = false var inBossRoom = false @@ -170,7 +171,7 @@ class DungeonAPI { private fun readOneMaxCollection( bossCollections: MutableMap, inventoryItems: Map, - inventoryName: String + inventoryName: String, ) { inventoryItems[48]?.let { item -> if (item.name == "§aGo Back") { @@ -248,6 +249,7 @@ class DungeonAPI { F7("Necron"); companion object { + fun byBossName(bossName: String) = DungeonFloor.entries.firstOrNull { it.bossName == bossName } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonBossMessages.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonBossMessages.kt index 51ee98029..48765a095 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonBossMessages.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonBossMessages.kt @@ -16,7 +16,7 @@ class DungeonBossMessages { ) private val messageList = listOf( - //M7 – Dragons + // M7 – Dragons "§cThe Crystal withers your soul as you hold it in your hands!", "§cIt doesn't seem like that is supposed to go there." ) diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonChatFilter.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonChatFilter.kt index a133cb6be..acdc50f95 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonChatFilter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonChatFilter.kt @@ -224,7 +224,7 @@ class DungeonChatFilter { } } - private fun String.isFiltered(key: MessageTypes) : Boolean { + private fun String.isFiltered(key: MessageTypes): Boolean { return config.dungeonFilteredMessageTypes.contains(key) && this.isPresent(key) } diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonCleanEnd.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonCleanEnd.kt index 4ee2c8761..7e436eb36 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonCleanEnd.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonCleanEnd.kt @@ -9,6 +9,7 @@ import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.PlaySoundEvent import at.hannibal2.skyhanni.events.ReceiveParticleEvent +import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern @@ -78,7 +79,7 @@ class DungeonCleanEnd { if (event.health <= 0.5) { val dungeonFloor = DungeonAPI.dungeonFloor - LorenzUtils.chat("§eFloor $dungeonFloor done!", false) + ChatUtils.chat("§eFloor $dungeonFloor done!", false) bossDone = true } } @@ -126,5 +127,4 @@ class DungeonCleanEnd { event.move(3, "dungeon.cleanEndToggle", "dungeon.cleanEnd.enabled") event.move(3, "dungeon.cleanEndF3IgnoreGuardians", "dungeon.cleanEnd.F3IgnoreGuardians") } - } diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonDeathCounter.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonDeathCounter.kt index 794736954..8510b6b6c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonDeathCounter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonDeathCounter.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.events.DungeonStartEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent +import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RenderUtils.renderString import at.hannibal2.skyhanni.utils.StringUtils.matches @@ -55,7 +56,7 @@ class DungeonDeathCounter { if (isDeathMessage(event.message)) { deaths++ - LorenzUtils.chat("§c§l$deaths. DEATH!", false) + ChatUtils.chat("§c§l$deaths. DEATH!", false) update() } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonFinderFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonFinderFeatures.kt index 0413be873..4521aa2b9 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonFinderFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonFinderFeatures.kt @@ -21,6 +21,7 @@ import net.minecraft.inventory.ContainerChest import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class DungeonFinderFeatures { + private val config get() = SkyHanniMod.feature.dungeon.partyFinder private val pricePattern = "([0-9]{2,3}K|[0-9]{1,3}M|[0-9]+\\.[0-9]M|[0-9] ?mil)".toRegex(RegexOption.IGNORE_CASE) @@ -170,7 +171,6 @@ class DungeonFinderFeatures { fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { event.move(2, "dungeon.partyFinderColoredClassLevel", "dungeon.partyFinder.coloredClassLevel") } - } fun getColor(level: Int): String { diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLividFinder.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLividFinder.kt index 0c5b4fc52..291b7775b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLividFinder.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLividFinder.kt @@ -29,6 +29,7 @@ import net.minecraft.util.AxisAlignedBB import net.minecraftforge.fml.common.eventhandler.SubscribeEvent object DungeonLividFinder { + private val config get() = SkyHanniMod.feature.dungeon.lividFinder private val blockLocation = LorenzVec(6, 109, 43) diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonMilestonesDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonMilestonesDisplay.kt index fc5462901..3547a4827 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonMilestonesDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonMilestonesDisplay.kt @@ -12,6 +12,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.concurrent.fixedRateTimer class DungeonMilestonesDisplay { + private val config get() = SkyHanniMod.feature.dungeon companion object { diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonRankTabListColor.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonRankTabListColor.kt index 46e2e0514..eda282161 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonRankTabListColor.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonRankTabListColor.kt @@ -9,6 +9,7 @@ import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class DungeonRankTabListColor { + private val config get() = SkyHanniMod.feature.dungeon.tabList private val pattern = "§r(?.*) §r§f\\(§r§d(?.*) (?.*)§r§f\\)§r".toPattern() diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonTeammateOutlines.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonTeammateOutlines.kt index 445b9676f..103bf35df 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonTeammateOutlines.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonTeammateOutlines.kt @@ -12,6 +12,7 @@ import net.minecraft.scoreboard.Team import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class DungeonTeammateOutlines { + private val config get() = SkyHanniMod.feature.dungeon @SubscribeEvent @@ -35,5 +36,4 @@ class DungeonTeammateOutlines { Minecraft.getMinecraft().fontRendererObj.getColorCode(colorFormat[1]) else null } - } diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/TerracottaPhase.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/TerracottaPhase.kt index 9cc992922..4447db0b4 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/TerracottaPhase.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/TerracottaPhase.kt @@ -11,6 +11,7 @@ import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class TerracottaPhase { + private val config get() = SkyHanniMod.feature.dungeon.terracottaPhase private var inTerracottaPhase = false -- cgit