diff options
author | NetheriteMiner <88792142+NetheriteMiner@users.noreply.github.com> | 2023-09-26 04:10:19 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-26 10:10:19 +0200 |
commit | 2b2c1cc43c08874a82123356adc7af24cfe09227 (patch) | |
tree | dbf6986ff16f16c1ee3946aa21b624db8813cb85 /src | |
parent | 0ecab5ab4f94dce8b4b01bdad5d4b03a590e8345 (diff) | |
download | skyhanni-2b2c1cc43c08874a82123356adc7af24cfe09227.tar.gz skyhanni-2b2c1cc43c08874a82123356adc7af24cfe09227.tar.bz2 skyhanni-2b2c1cc43c08874a82123356adc7af24cfe09227.zip |
Rich Presence Dynamic Priority Box and Dungeons #429
* Rich Presence Dynamic Priority Box and Dungeons
* Merge branch 'beta' into discordrpc
* Merge branch 'beta' into discordrpc
* code cleanup
* Fix according to requested changes
* I blame IntelliJ auto formatting
* Merge branch 'beta' into discordrpc
* resolve merge conflict
Diffstat (limited to 'src')
16 files changed, 196 insertions, 53 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 997ff28fd..29179b902 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -107,7 +107,7 @@ import at.hannibal2.skyhanni.features.summonings.SummoningSoulsName import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper import at.hannibal2.skyhanni.test.* import at.hannibal2.skyhanni.test.command.CopyNearbyParticlesCommand -import at.hannibal2.skyhanni.utils.EntityOutlineRenderer +import at.hannibal2.skyhanni.utils.* import at.hannibal2.skyhanni.utils.MinecraftConsoleFilter.Companion.initLogging import at.hannibal2.skyhanni.utils.NEUVersionCheck.checkIfNeuIsLoaded import at.hannibal2.skyhanni.utils.TabListData @@ -143,7 +143,7 @@ class SkyHanniMod { loadModule(this) loadModule(ChatManager) loadModule(HypixelData()) - loadModule(DungeonData()) + loadModule(DungeonAPI()) loadModule(ScoreboardData()) loadModule(SeaCreatureFeatures()) loadModule(SeaCreatureManager()) diff --git a/src/main/java/at/hannibal2/skyhanni/config/Storage.java b/src/main/java/at/hannibal2/skyhanni/config/Storage.java index 0fc83a5b8..a49dd7aea 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/Storage.java +++ b/src/main/java/at/hannibal2/skyhanni/config/Storage.java @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.config; import at.hannibal2.skyhanni.data.model.ComposterUpgrade; +import at.hannibal2.skyhanni.features.dungeon.DungeonAPI; import at.hannibal2.skyhanni.features.fishing.trophy.TrophyRarity; import at.hannibal2.skyhanni.features.garden.CropAccessory; import at.hannibal2.skyhanni.features.garden.CropType; @@ -426,5 +427,14 @@ public class Storage { @Expose public Map<TrevorTracker.TrapperMobRarity, Integer> animalRarities= new HashMap<>(); } + + @Expose + public DungeonStorage dungeons = new DungeonStorage(); + + public static class DungeonStorage { + + @Expose + public Map<DungeonAPI.DungeonFloor, Integer> bosses = new HashMap<>(); + } } }
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/MiscConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/MiscConfig.java index 10bae9f74..ff7032b43 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/MiscConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/MiscConfig.java @@ -259,7 +259,19 @@ public class MiscConfig { public Property<String> customText = Property.of(""); @Expose - @ConfigOption(name = "Dynamic", desc = "\"Dynamic\" above shows your Crop Milestone, Slayer progress, or Stacking enchantment when possible, but this if you're doing none of them.") + @ConfigOption(name = "Dynamic Priority", desc = "Disable certain dynamic statuses, or change the priority in case two are triggered at the same time (higher up means higher priority).") + @ConfigEditorDraggableList( + exampleText = { + "Crop Milestones", + "Slayer", + "Stacking Enchantment", + "Dungeon", + } + ) + public List<Integer> autoPriority = new ArrayList<>(Arrays.asList(0, 1, 2, 3)); + + @Expose + @ConfigOption(name = "Dynamic Fallback", desc = "What to show when none of your \"Dynamic Priority\" statuses are active.") @ConfigEditorDropdown(values = { "Nothing", "Location", diff --git a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt b/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt index 39a506892..78fcec31e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt @@ -4,7 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.data.ScoreboardData import at.hannibal2.skyhanni.events.* -import at.hannibal2.skyhanni.features.dungeon.DungeonData +import at.hannibal2.skyhanni.features.dungeon.DungeonAPI import at.hannibal2.skyhanni.features.slayer.blaze.HellionShield import at.hannibal2.skyhanni.features.slayer.blaze.setHellionShield import at.hannibal2.skyhanni.utils.* @@ -370,7 +370,7 @@ class DamageIndicatorManager { BossType.DUNGEON_F4_THORN -> { val thorn = checkThorn(health, maxHealth) if (thorn == null) { - val floor = DungeonData.dungeonFloor + val floor = DungeonAPI.dungeonFloor LorenzUtils.error("problems with thorn detection! ($floor, $health/$maxHealth)") } return thorn @@ -661,7 +661,7 @@ class DamageIndicatorManager { entityData: EntityData, health: Int, maxHealth: Int, - ): String? { + ): String { val config = config.vampireSlayer if (config.percentage) { @@ -699,7 +699,7 @@ class DamageIndicatorManager { println(" ") println("realHealth: $realHealth") println("realMaxHealth: $realMaxHealth") - val health = if (DungeonData.isOneOf("F4")) { + val health = if (DungeonAPI.isOneOf("F4")) { maxHealth = 4 if (realMaxHealth == 300_000L) { @@ -725,7 +725,7 @@ class DamageIndicatorManager { else -> return null } } - } else if (DungeonData.isOneOf("M4")) { + } else if (DungeonAPI.isOneOf("M4")) { maxHealth = 6 if (realMaxHealth == 900_000L) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/MobFinder.kt b/src/main/java/at/hannibal2/skyhanni/features/damageindicator/MobFinder.kt index 03f10e333..0d9792265 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/MobFinder.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/damageindicator/MobFinder.kt @@ -1,7 +1,7 @@ package at.hannibal2.skyhanni.features.damageindicator import at.hannibal2.skyhanni.data.IslandType -import at.hannibal2.skyhanni.features.dungeon.DungeonData +import at.hannibal2.skyhanni.features.dungeon.DungeonAPI import at.hannibal2.skyhanni.features.dungeon.DungeonLividFinder import at.hannibal2.skyhanni.features.rift.RiftAPI import at.hannibal2.skyhanni.utils.EntityUtils @@ -66,7 +66,7 @@ class MobFinder { internal fun tryAdd(entity: EntityLivingBase): EntityResult? { if (LorenzUtils.inDungeons) { - if (DungeonData.isOneOf("F1", "M1")) { + if (DungeonAPI.isOneOf("F1", "M1")) { if (floor1bonzo1) { if (entity is EntityOtherPlayerMP) { if (entity.name == "Bonzo ") { @@ -83,7 +83,7 @@ class MobFinder { } } - if (DungeonData.isOneOf("F2", "M2")) { + if (DungeonAPI.isOneOf("F2", "M2")) { if (entity.name == "Summon ") { if (entity is EntityOtherPlayerMP) { if (floor2summons1) { @@ -112,7 +112,7 @@ class MobFinder { } } - if (DungeonData.isOneOf("F3", "M3")) { + if (DungeonAPI.isOneOf("F3", "M3")) { if (entity is EntityGuardian) { if (floor3GuardianShield) { if (guardians.size == 4) { @@ -160,7 +160,7 @@ class MobFinder { } } - if (DungeonData.isOneOf("F4", "M4")) { + if (DungeonAPI.isOneOf("F4", "M4")) { if (entity is EntityGhast) { return EntityResult( bossType = BossType.DUNGEON_F4_THORN, @@ -170,7 +170,7 @@ class MobFinder { } } - if (DungeonData.isOneOf("F5", "M5")) { + if (DungeonAPI.isOneOf("F5", "M5")) { if (entity is EntityOtherPlayerMP) { if (entity == DungeonLividFinder.livid) { return EntityResult( @@ -182,7 +182,7 @@ class MobFinder { } } - if (DungeonData.isOneOf("F6", "M6")) { + if (DungeonAPI.isOneOf("F6", "M6")) { if (entity is EntityGiantZombie && !entity.isInvisible) { if (floor6Giants && entity.posY > 68) { val extraDelay = checkExtraF6GiantsDelay(entity) @@ -565,4 +565,4 @@ class MobFinder { } } } -}
\ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonData.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt index 52a7e3cba..3abb4c813 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonData.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt @@ -1,7 +1,10 @@ package at.hannibal2.skyhanni.features.dungeon +import at.hannibal2.skyhanni.data.ProfileStorageData import at.hannibal2.skyhanni.data.ScoreboardData import at.hannibal2.skyhanni.events.* +import at.hannibal2.skyhanni.features.dungeon.DungeonAPI.DungeonFloor.Companion.toFloor +import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.equalsOneOf import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNeeded @@ -10,11 +13,21 @@ import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.TabListData import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class DungeonData { +class DungeonAPI { private val floorPattern = " §7⏣ §cThe Catacombs §7\\((?<floor>.*)\\)".toPattern() private val uniqueClassBonus = "^Your ([A-Za-z]+) stats are doubled because you are the only player using this class!$".toRegex() + private val bossPattern = + "View all your (?<name>\\w+) Collection".toPattern() + private val levelPattern = + " +(?<kills>\\d+).*".toPattern() + private val killPattern = " +☠ Defeated (?<boss>\\w+).*".toPattern() + private val bossList = listOf("Bonzo", "Scarf", "The Professor", "Thorn", "Livid", "Sadan", "Necron") + + private var bossCollections: MutableMap<DungeonFloor, Int> = mutableMapOf() + + companion object { var dungeonFloor: String? = null var started = false @@ -23,6 +36,11 @@ class DungeonData { var playerClassLevel = -1 var isUniqueClass = false + val bossStorage: MutableMap<DungeonFloor, Int>? get() = ProfileStorageData.profileSpecific?.dungeons?.bosses + private val areaPattern = "The Catacombs \\((?<floor>.+)\\)".toPattern() + private val timePattern = + "Time Elapsed:( )?(?:(?<minutes>\\d+)m)? (?<seconds>\\d+)s".toPattern() // Examples: Time Elapsed: 10m 10s, Time Elapsed: 2s + fun inDungeon() = dungeonFloor != null fun isOneOf(vararg floors: String) = dungeonFloor?.equalsOneOf(floors) == true @@ -55,6 +73,24 @@ class DungeonData { // Livid has a prefix in front of the name, so we check ends with to cover all the livids return bossName.endsWith(correctBoss) } + + fun getFloor(): Int? { + val area = LorenzUtils.skyBlockArea + areaPattern.matchMatcher(area) { + if (matches()) return group("floor").last().digitToInt() + } + return null + } + + fun getTime(): String { + loop@ for (line in ScoreboardData.sidebarLinesFormatted) { + timePattern.matchMatcher(line.removeColor()) { + if (!matches()) continue@loop + return "${group("minutes") ?: "00"}:${group("seconds")}" // 03:14 + } + } + return "" + } } @SubscribeEvent @@ -108,6 +144,67 @@ class DungeonData { } } + // This returns a map of boss name to the integer for the amount of kills the user has in the collection + @SubscribeEvent + fun onInventoryOpen(event: InventoryFullyOpenedEvent) { + if (event.inventoryName != "Boss Collections") return + nextItem@ for ((_, stack) in event.inventoryItems) { + var name = "" + var kills = 0 + nextLine@ for (line in stack.getLore()) { + val colorlessLine = line.removeColor() + bossPattern.matchMatcher(colorlessLine) { + if (matches()) { + name = group("name") + if (!bossList.contains(name)) continue@nextItem // to avoid kuudra, etc. + } + } + levelPattern.matchMatcher(colorlessLine) { + if (matches()) { + kills = group("kills").toInt() + break@nextLine + } + } + } + val floor = name.toFloor() + if (floor != null) bossCollections[floor] = kills + } + ProfileStorageData.profileSpecific?.dungeons?.bosses = bossCollections + } + + @SubscribeEvent + fun onChat(event: LorenzChatEvent) { + if (!LorenzUtils.inDungeons) return + killPattern.matchMatcher(event.message.removeColor()) { + val boss = group("boss").toFloor() + if (matches() && boss != null && bossCollections[boss] != null) { + bossCollections[boss] = bossCollections[boss]!! + 1 + ProfileStorageData.profileSpecific?.dungeons?.bosses = bossCollections + } + } + } + + enum class DungeonFloor(private val bossName: String) { + ENTRANCE("The Watcher"), + F1("Bonzo"), + F2("Scarf"), + F3("The Professor"), + F4("Thorn"), + F5("Livid"), + F6("Sadan"), + F7("Necron"); + + companion object { + fun Int.toBoss(): DungeonFloor { + return entries[this] + } + + fun String.toFloor(): DungeonFloor? { + return entries.firstOrNull { it.bossName == this } + } + } + } + enum class DungeonClass(val scoreboardName: String) { ARCHER("Archer"), BERSERK("Berserk"), diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonBossHideDamageSplash.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonBossHideDamageSplash.kt index 101e2dd08..c14e717a5 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonBossHideDamageSplash.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonBossHideDamageSplash.kt @@ -14,7 +14,7 @@ class DungeonBossHideDamageSplash { fun onRenderLiving(event: RenderLivingEvent.Specials.Pre<EntityLivingBase>) { if (!LorenzUtils.inDungeons) return if (!SkyHanniMod.feature.dungeon.damageSplashBoss) return - if (!DungeonData.inBossRoom) return + if (!DungeonAPI.inBossRoom) return if (DamageIndicatorManager.isDamageSplash(event.entity)) { event.isCanceled = true 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 60fd79f6d..b49839471 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonBossMessages.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonBossMessages.kt @@ -13,7 +13,7 @@ class DungeonBossMessages { if (!LorenzUtils.inDungeons) return if (!isBoss(event.message)) return - DungeonData.handleBossMessage(event.message) + DungeonAPI.handleBossMessage(event.message) if (SkyHanniMod.feature.chat.dungeonBossMessages) { event.blockedReason = "dungeon_boss" 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 254a3d607..d3be56797 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonCleanEnd.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonCleanEnd.kt @@ -63,7 +63,7 @@ class DungeonCleanEnd { if (event.entity.entityId != lastBossId) return if (event.health <= 0) { - val dungeonFloor = DungeonData.dungeonFloor + val dungeonFloor = DungeonAPI.dungeonFloor LorenzUtils.chat("§eFloor $dungeonFloor done!") bossDone = true } @@ -78,7 +78,7 @@ class DungeonCleanEnd { if (entity == Minecraft.getMinecraft().thePlayer) return if (SkyHanniMod.feature.dungeon.cleanEndF3IgnoreGuardians) { - if (DungeonData.isOneOf("F3", "M3")) { + if (DungeonAPI.isOneOf("F3", "M3")) { if (entity is EntityGuardian) { if (entity.entityId != lastBossId) { if (Minecraft.getMinecraft().thePlayer.isSneaking) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonHighlightClickedBlocks.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonHighlightClickedBlocks.kt index 3807c3ab1..02f9dd2fb 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonHighlightClickedBlocks.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonHighlightClickedBlocks.kt @@ -42,7 +42,7 @@ class DungeonHighlightClickedBlocks { fun onBlockClick(event: BlockClickEvent) { if (!SkyHanniMod.feature.dungeon.highlightClickedBlocks) return if (!LorenzUtils.inDungeons) return - if (DungeonData.inBossRoom) return + if (DungeonAPI.inBossRoom) return if (event.clickType != ClickType.RIGHT_CLICK) return val position = event.position 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 b35fd6f3f..39c1373cb 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLividFinder.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLividFinder.kt @@ -25,9 +25,9 @@ object DungeonLividFinder { @SubscribeEvent fun onTick(event: LorenzTickEvent) { - if (!LorenzUtils.inDungeons || !DungeonData.inBossRoom) return - if (DungeonData.dungeonFloor != "F5" && DungeonData.dungeonFloor != "M5") return - if (DungeonData.dungeonFloor == "F5" && livid != null) return + if (!LorenzUtils.inDungeons || !DungeonAPI.inBossRoom) return + if (DungeonAPI.dungeonFloor != "F5" && DungeonAPI.dungeonFloor != "M5") return + if (DungeonAPI.dungeonFloor == "F5" && livid != null) return if (!event.repeatSeconds(2)) return if (!gotBlinded) { gotBlinded = Minecraft.getMinecraft().thePlayer.isPotionActive(Potion.blindness) diff --git a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbility.kt b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbility.kt index fb1169d83..64288cbcf 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbility.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbility.kt @@ -1,6 +1,6 @@ package at.hannibal2.skyhanni.features.itemabilities.abilitycooldown -import at.hannibal2.skyhanni.features.dungeon.DungeonData +import at.hannibal2.skyhanni.features.dungeon.DungeonAPI import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NEUInternalName @@ -125,17 +125,17 @@ enum class ItemAbility( private fun ItemAbility.getMageCooldownReduction(): Double? { if (ignoreMageCooldownReduction) return null if (!LorenzUtils.inDungeons) return null - if (DungeonData.playerClass != DungeonData.DungeonClass.MAGE) return null + if (DungeonAPI.playerClass != DungeonAPI.DungeonClass.MAGE) return null var abilityCooldownMultiplier = 1.0 - abilityCooldownMultiplier -= if (DungeonData.isUniqueClass) { + abilityCooldownMultiplier -= if (DungeonAPI.isUniqueClass) { 0.5 // 50% base reduction at level 0 } else { 0.25 // 25% base reduction at level 0 } // 1% ability reduction every other level - abilityCooldownMultiplier -= 0.01 * floor(DungeonData.playerClassLevel / 2f) + abilityCooldownMultiplier -= 0.01 * floor(DungeonAPI.playerClassLevel / 2f) return abilityCooldownMultiplier } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/ParticleHider.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/ParticleHider.kt index 74d33cbd9..4b177722d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/ParticleHider.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/ParticleHider.kt @@ -2,7 +2,7 @@ package at.hannibal2.skyhanni.features.misc import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.ReceiveParticleEvent -import at.hannibal2.skyhanni.features.dungeon.DungeonData +import at.hannibal2.skyhanni.features.dungeon.DungeonAPI import at.hannibal2.skyhanni.utils.EntityUtils import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.getLorenzVec @@ -12,7 +12,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class ParticleHider { - private fun inM7Boss() = LorenzUtils.inDungeons && DungeonData.dungeonFloor == "M7" && DungeonData.inBossRoom + private fun inM7Boss() = LorenzUtils.inDungeons && DungeonAPI.dungeonFloor == "M7" && DungeonAPI.inBossRoom @SubscribeEvent fun onHypExplosions(event: ReceiveParticleEvent) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt index 9b1c920bd..69574b486 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt @@ -6,12 +6,17 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.* import at.hannibal2.skyhanni.data.GardenCropMilestones.getCounter import at.hannibal2.skyhanni.data.GardenCropMilestones.getTierForCropCount +import at.hannibal2.skyhanni.data.GardenCropMilestones.isMaxed import at.hannibal2.skyhanni.data.GardenCropMilestones.progressToNextLevel +import at.hannibal2.skyhanni.features.dungeon.DungeonAPI +import at.hannibal2.skyhanni.features.dungeon.DungeonAPI.DungeonFloor +import at.hannibal2.skyhanni.features.dungeon.DungeonAPI.DungeonFloor.Companion.toBoss import at.hannibal2.skyhanni.features.garden.GardenAPI.getCropType import at.hannibal2.skyhanni.features.rift.RiftAPI import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.colorCodeToRarity +import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.StringUtils.firstLetterUppercase import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.TabListData.Companion.getTabList @@ -235,7 +240,7 @@ enum class DiscordStatus(private val displayMessageSupplier: Supplier<String>?) else if (noColorLine == "Boss slain!") bossAlive = "slain" } - if (slayerLevel == "") "Planning to do a slayer quest"// selected slayer in rpc but hasn't started a quest + if (slayerLevel == "") AutoStatus.SLAYER.placeholderText // selected slayer in rpc but hasn't started a quest else if (bossAlive == "spawning") "Spawning a $slayerName $slayerLevel boss." else if (bossAlive == "slaying") "Slaying a $slayerName $slayerLevel boss." else if (bossAlive == "slain") "Finished slaying a $slayerName $slayerLevel boss." @@ -247,17 +252,22 @@ enum class DiscordStatus(private val displayMessageSupplier: Supplier<String>?) }), AUTO({ - val slayerResult = SLAYER.displayMessageSupplier!!.get() - val stackingResult = STACKING.displayMessageSupplier!!.get() - val milestoneResult = CROP_MILESTONES.displayMessageSupplier!!.get() - if (slayerResult != "Planning to do a slayer quest") slayerResult - else if (milestoneResult != "Not farming!") milestoneResult - else if (stackingResult != "") stackingResult - else { - val statusNoAuto = entries.toMutableList() + var autoReturn = "" + for (statusID in SkyHanniMod.feature.misc.discordRPC.autoPriority) { // for every dynamic that the user wants to see... + val autoStatus = AutoStatus.entries[statusID] + val result = + autoStatus.correspondingDiscordStatus.getDisplayString() // get what would happen if we were to display it + if (result != autoStatus.placeholderText) { // if that value is useful, display it + autoReturn = result + break + } + } + if (autoReturn == "") { // if we didn't find any useful information, display the fallback + val statusNoAuto = DiscordStatus.entries.toMutableList() statusNoAuto.remove(AUTO) - statusNoAuto[SkyHanniMod.feature.misc.discordRPC.auto.get()].getDisplayString() + autoReturn = statusNoAuto[SkyHanniMod.feature.misc.discordRPC.auto.get()].getDisplayString() } + autoReturn }), CROP_MILESTONES({ @@ -270,10 +280,8 @@ enum class DiscordStatus(private val displayMessageSupplier: Supplier<String>?) } ?: 100 // percentage to next milestone if (tier != null) { - "${crop.cropName}: Milestone $tier ($progress)" - } else { - "Not farming!" - } + "${crop.cropName}: ${if (!crop.isMaxed()) "Milestone $tier ($progress)" else "MAXED (${cropCounter.addSeparators()} crops collected"})" + } else AutoStatus.CROP_MILESTONES.placeholderText }), PETS({ @@ -319,7 +327,7 @@ enum class DiscordStatus(private val displayMessageSupplier: Supplier<String>?) return percent } - var stackingReturn = "" + var stackingReturn = AutoStatus.STACKING.placeholderText if (extraAttributes != null) { val enchantments = extraAttributes.getCompoundTag("enchantments") var stackingEnchant = "" @@ -335,11 +343,20 @@ enum class DiscordStatus(private val displayMessageSupplier: Supplier<String>?) val stackingPercent = getProgressPercent(amount, levels) stackingReturn = - if (stackingPercent == "" || amount == 0) "" // outdated info is useless for AUTO; empty strings are manually ignored + if (stackingPercent == "" || amount == 0) AutoStatus.STACKING.placeholderText // outdated info is useless for AUTO else "$itemName: ${stackingEnchant.firstLetterUppercase()} $level ($stackingPercent)" // Hecatomb 100: (55.55%) } stackingReturn + }), + + DUNGEONS({ + val floor = DungeonAPI.getFloor() ?: -1 // -1 if not in dungeons/failed to find a floor + val boss: DungeonFloor? = if (floor != -1) floor.toBoss() else null + if (floor == -1) AutoStatus.DUNGEONS.placeholderText + else if (boss == null) "Unknown boss" + else "$boss Kills: ${DungeonAPI.bossStorage?.get(boss) ?: "Unknown"} (${DungeonAPI.getTime()})" + }) ; @@ -350,3 +367,10 @@ enum class DiscordStatus(private val displayMessageSupplier: Supplier<String>?) return "" } } + +enum class AutoStatus(val placeholderText: String, val correspondingDiscordStatus: DiscordStatus) { + CROP_MILESTONES("Not farming!", DiscordStatus.CROP_MILESTONES), + SLAYER("Planning to do a slayer quest", DiscordStatus.SLAYER), + STACKING("Stacking placeholder (should never be visible)", DiscordStatus.STACKING), + DUNGEONS("Dungeons placeholder (should never be visible)", DiscordStatus.DUNGEONS); +}
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt b/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt index 8870e2d79..475e9123c 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt @@ -6,7 +6,7 @@ import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.PlaySoundEvent import at.hannibal2.skyhanni.events.ReceiveParticleEvent -import at.hannibal2.skyhanni.features.dungeon.DungeonData +import at.hannibal2.skyhanni.features.dungeon.DungeonAPI import at.hannibal2.skyhanni.features.garden.visitor.GardenVisitorColorNames import at.hannibal2.skyhanni.utils.* import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName @@ -224,9 +224,9 @@ class SkyHanniDebugsAndTests { if (LorenzUtils.inDungeons) { builder.append("\n") builder.append("in dungeon!\n") - builder.append(" dungeonFloor: ${DungeonData.dungeonFloor}\n") - builder.append(" started: ${DungeonData.started}\n") - builder.append(" inBossRoom: ${DungeonData.inBossRoom}\n") + builder.append(" dungeonFloor: ${DungeonAPI.dungeonFloor}\n") + builder.append(" started: ${DungeonAPI.started}\n") + builder.append(" inBossRoom: ${DungeonAPI.inBossRoom}\n") } } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt index 8bf8041a2..009ca293d 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt @@ -4,7 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.HypixelData import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.data.MayorElection -import at.hannibal2.skyhanni.features.dungeon.DungeonData +import at.hannibal2.skyhanni.features.dungeon.DungeonAPI import at.hannibal2.skyhanni.mixins.transformers.AccessorGuiEditSign import at.hannibal2.skyhanni.test.TestBingo import at.hannibal2.skyhanni.utils.NEUItems.getItemStackOrNull @@ -48,7 +48,7 @@ object LorenzUtils { val inSkyBlock get() = onHypixel && HypixelData.skyBlock - val inDungeons get() = inSkyBlock && DungeonData.inDungeon() + val inDungeons get() = inSkyBlock && DungeonAPI.inDungeon() val skyBlockIsland get() = HypixelData.skyBlockIsland |