diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-10-05 00:13:38 +0200 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-10-05 00:13:38 +0200 |
commit | 0cfc19d890cac15b49433d170a16ae6d56dcfb16 (patch) | |
tree | 028f717bbe8a7a40e9784d7944e7a14624a1f61f /src/main/java/at/hannibal2 | |
parent | ab992664490f6ffd3ad9b7f7aba529a6b6e928a9 (diff) | |
download | skyhanni-0cfc19d890cac15b49433d170a16ae6d56dcfb16.tar.gz skyhanni-0cfc19d890cac15b49433d170a16ae6d56dcfb16.tar.bz2 skyhanni-0cfc19d890cac15b49433d170a16ae6d56dcfb16.zip |
Added support for burning desert, using the slayer api more, only show slayer features while inside the correct SkyBlock area, add slayer info to debug command
Diffstat (limited to 'src/main/java/at/hannibal2')
7 files changed, 74 insertions, 55 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/SlayerAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/SlayerAPI.kt index 1989c5442..e02bc693d 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/SlayerAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/SlayerAPI.kt @@ -14,10 +14,12 @@ import at.hannibal2.skyhanni.utils.NEUItems.getItemStack import at.hannibal2.skyhanni.utils.NEUItems.getNpcPriceOrNull import at.hannibal2.skyhanni.utils.NEUItems.getPrice import at.hannibal2.skyhanni.utils.NumberUtil +import at.hannibal2.skyhanni.utils.RecalculatingValue import at.hannibal2.skyhanni.utils.StringUtils.removeColor import com.google.common.cache.CacheBuilder import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.util.concurrent.TimeUnit +import kotlin.time.Duration.Companion.seconds object SlayerAPI { @@ -26,7 +28,7 @@ object SlayerAPI { .build<Pair<NEUInternalName, Int>, Pair<String, Double>>() var questStartTime = 0L - var isInSlayerArea = false + var isInCorrectArea = false var latestSlayerCategory = "" private var latestProgressChangeTime = 0L var latestWrongAreaWarning = 0L @@ -96,6 +98,24 @@ object SlayerAPI { } } + fun getActiveSlayer() = activeSlayer.getValue() + + private val activeSlayer = RecalculatingValue(1.seconds) { + grabActiveSlayer() + } + + private fun grabActiveSlayer(): SlayerType? { + for (line in ScoreboardData.sidebarLinesFormatted) { + for (type in SlayerType.entries) { + if (line.contains(type.displayName)) { + return type + } + } + } + + return null + } + @SubscribeEvent fun onTick(event: LorenzTickEvent) { if (!LorenzUtils.inSkyBlock) return @@ -118,11 +138,43 @@ object SlayerAPI { } if (event.isMod(5)) { - isInSlayerArea = if (LorenzUtils.isStrandedProfile) { + isInCorrectArea = if (LorenzUtils.isStrandedProfile) { true } else { - SlayerType.getByArea(LorenzUtils.skyBlockArea) != null + getSlayerTypeForCurrentArea() == getActiveSlayer() } } } + + fun getSlayerTypeForCurrentArea() = when (LorenzUtils.skyBlockArea) { + "Graveyard", + "Coal Mine", + -> SlayerType.REVENANT + + "Spider Mound", + "Arachne's Burrow", + "Arachne's Sanctuary", + "Burning Desert", + -> SlayerType.TARANTULA + + "Ruins", + "Howling Cave", + -> SlayerType.SVEN + + "The End", + "Void Sepulture", + "Zealot Bruiser Hideout", + -> SlayerType.VOID + + "Stronghold", + "The Wasteland", + "Smoldering Tomb", + -> SlayerType.INFERNO + + "Stillgore Château", + "Oubliette", + -> SlayerType.VAMPIRE + + else -> null + } }
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemProfitTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemProfitTracker.kt index 4f1f92ca0..a4d18aaa9 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemProfitTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemProfitTracker.kt @@ -76,7 +76,7 @@ object SlayerItemProfitTracker { fun onPurseChange(event: PurseChangeEvent) { if (!isEnabled()) return val coins = event.coins - if (event.reason == PurseChangeCause.GAIN_MOB_KILL && SlayerAPI.isInSlayerArea) { + if (event.reason == PurseChangeCause.GAIN_MOB_KILL && SlayerAPI.isInCorrectArea) { logger.log("Coins gained for killing mobs: ${coins.addSeparators()}") addMobKillCoins(coins.toInt()) } @@ -141,7 +141,7 @@ object SlayerItemProfitTracker { @SubscribeEvent fun onSackChange(event: SackChangeEvent) { if (!isEnabled()) return - if (!SlayerAPI.isInSlayerArea) return + if (!SlayerAPI.isInCorrectArea) return if (!SlayerAPI.hasActiveSlayerQuest()) return for (sackChange in event.sackChanges) { @@ -156,7 +156,7 @@ object SlayerItemProfitTracker { @SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true) fun onChatPacket(event: PacketEvent.ReceiveEvent) { if (!isEnabled()) return - if (!SlayerAPI.isInSlayerArea) return + if (!SlayerAPI.isInCorrectArea) return if (!SlayerAPI.hasActiveSlayerQuest()) return val packet = event.packet @@ -357,7 +357,7 @@ object SlayerItemProfitTracker { @SubscribeEvent fun onRenderOverlay(event: GuiRenderEvent) { if (!isEnabled()) return - if (!SlayerAPI.isInSlayerArea) return + if (!SlayerAPI.isInCorrectArea) return val currentlyOpen = Minecraft.getMinecraft().currentScreen is GuiInventory if (inventoryOpen != currentlyOpen) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemsOnGround.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemsOnGround.kt index de2e43627..23108044a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemsOnGround.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerItemsOnGround.kt @@ -29,7 +29,7 @@ class SlayerItemsOnGround { fun onRenderWorld(event: RenderWorldLastEvent) { if (!LorenzUtils.inSkyBlock) return if (!config.enabled) return - if (!SlayerAPI.isInSlayerArea) return + if (!SlayerAPI.isInCorrectArea) return if (!SlayerAPI.hasActiveSlayerQuest()) return for (entityItem in EntityUtils.getEntities<EntityItem>()) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerQuestWarning.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerQuestWarning.kt index 9fd8c5887..60fde86a5 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerQuestWarning.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerQuestWarning.kt @@ -24,7 +24,6 @@ class SlayerQuestWarning { private var currentReason = "" private var dirtySidebar = false private var hasAutoSlayer = false - private var activeSlayer: SlayerType? = null //TODO add check if player has clicked on an item, before mobs around you gets damage @@ -53,7 +52,6 @@ class SlayerQuestWarning { } if (message == "§aYour Slayer Quest has been cancelled!") { - activeSlayer = null needSlayerQuest = false } @@ -102,8 +100,6 @@ class SlayerQuestWarning { } } - activeSlayer = SlayerType.getByDisplayName(slayerTypeName) - if (loaded) { dirtySidebar = false if (slayerQuest && !needSlayerQuest) { @@ -154,18 +150,18 @@ class SlayerQuestWarning { } private fun isSlayerMob(entity: EntityLivingBase): Boolean { - val area = LorenzUtils.skyBlockArea - val slayerType = SlayerType.getByArea(area) ?: return false + val slayerType = SlayerAPI.getSlayerTypeForCurrentArea() ?: return false + + val activeSlayer = SlayerAPI.getActiveSlayer() if (activeSlayer != null) { - val activeSlayer = activeSlayer!! if (slayerType != activeSlayer) { val activeSlayerName = activeSlayer.displayName val slayerName = slayerType.displayName SlayerAPI.latestWrongAreaWarning = System.currentTimeMillis() warn( "Wrong Slayer!", - "Wrong slayer selected! You have $activeSlayerName selected and are in the $slayerName area!" + "Wrong slayer selected! You have $activeSlayerName selected and you are in an $slayerName area!" ) } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerRngMeterDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerRngMeterDisplay.kt index 9118184ec..c55468be3 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerRngMeterDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerRngMeterDisplay.kt @@ -53,7 +53,7 @@ class SlayerRngMeterDisplay { if (!isEnabled()) return - if (config.hideChat && SlayerAPI.isInSlayerArea) { + if (config.hideChat && SlayerAPI.isInCorrectArea) { changedItemPattern.matchMatcher(event.message) { event.blockedReason = "slayer_rng_meter" } @@ -167,7 +167,7 @@ class SlayerRngMeterDisplay { @SubscribeEvent fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) { if (!isEnabled()) return - if (!SlayerAPI.isInSlayerArea) return + if (!SlayerAPI.isInCorrectArea) return if (!SlayerAPI.hasActiveSlayerQuest()) return config.pos.renderString(display, posLabel = "Rng Meter Display") diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerType.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerType.kt index 8319bfb3a..4d5d9fa34 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerType.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerType.kt @@ -17,41 +17,5 @@ enum class SlayerType(val displayName: String, val clazz: Class<*>) { ; companion object { - fun getByArea(skyBlockArea: String): SlayerType? { - return when (skyBlockArea) { - "Graveyard", - "Coal Mine", - -> REVENANT - - "Spider Mound", - "Arachne's Burrow", - "Arachne's Sanctuary", - -> TARANTULA - - "Ruins", - "Howling Cave", - -> SVEN - - "The End", - "Void Sepulture", - "Zealot Bruiser Hideout", - -> VOID - - "Stronghold", - "The Wasteland", - "Smoldering Tomb", - -> INFERNO - - "Stillgore Château", - "Oubliette", - -> VAMPIRE - - else -> return null - } - } - - fun getByDisplayName(text: String): SlayerType? { - return entries.firstOrNull { text.startsWith(it.displayName) } - } } }
\ 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 a50d684de..cfb892f84 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.test import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.HypixelData +import at.hannibal2.skyhanni.data.SlayerAPI import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.PlaySoundEvent @@ -227,11 +228,17 @@ class SkyHanniDebugsAndTests { if (LorenzUtils.inDungeons) { builder.append("\n") - builder.append("in dungeon!\n") + builder.append("In dungeon!\n") builder.append(" dungeonFloor: ${DungeonAPI.dungeonFloor}\n") builder.append(" started: ${DungeonAPI.started}\n") builder.append(" inBossRoom: ${DungeonAPI.inBossRoom}\n") } + if (SlayerAPI.hasActiveSlayerQuest()) { + builder.append("\n") + builder.append("Doing slayer!\n") + builder.append(" activeSlayer: ${SlayerAPI.getActiveSlayer()}\n") + builder.append(" isInCorrectArea: ${SlayerAPI.isInCorrectArea}\n") + } } builder.append("```") |