From 68d54cef1cf410c51d026d22228de9b3e4a274fa Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Tue, 19 Mar 2024 09:54:19 +0100 Subject: code cleanup --- .../features/dungeon/DungeonFinderFeatures.kt | 28 +++++++++++----------- 1 file changed, 14 insertions(+), 14 deletions(-) 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 00f57b519..20dde4bcf 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 at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +// TODO Remove all removeColor calls in this class. Deal with the color code in regex. class DungeonFinderFeatures { private val config get() = SkyHanniMod.feature.dungeon.partyFinder @@ -145,6 +146,7 @@ class DungeonFinderFeatures { val name = stack.displayName.removeColor() map[slot] = if (anyFloorPattern.matches(name)) { "A" + } else if (entranceFloorPattern.matches(name)) { "E" } else if (floorPattern.matches(name)) { @@ -166,13 +168,8 @@ class DungeonFinderFeatures { val floorNum = floorNumberPattern.matchMatcher(floor) { group("floorNum").romanToDecimalIfNecessary() } - map[slot] = if (entranceFloorPattern.matches(floor)) { - "E" - } else if (masterModeFloorPattern.matches(dungeon)) { - "M$floorNum" - } else { - "F$floorNum" - } + + map[slot] = getFloorName(floor, dungeon, floorNum) } } @@ -194,17 +191,20 @@ class DungeonFinderFeatures { val floorNum = floorNumberPattern.matchMatcher(name) { group("floorNum").romanToDecimalIfNecessary() } ?: continue - map[slot] = if (entranceFloorPattern.matches(name)) { - "E" - } else if (masterModeFloorPattern.matches(name)) { - "M$floorNum" - } else { - "F$floorNum" - } + map[slot] = getFloorName(name, name, floorNum) } } + private fun getFloorName(floor: String, dungeon: String, floorNum: Int?): String = + if (entranceFloorPattern.matches(floor)) { + "E" + } else if (masterModeFloorPattern.matches(dungeon)) { + "M$floorNum" + } else { + "F$floorNum" + } + private fun highlightingHandler(event: InventoryOpenEvent): Map { val map = mutableMapOf() if (!partyFinderTitlePattern.matches(event.inventoryName)) return map -- cgit