Skip to content

Commit

Permalink
fix: score calc never checks for spirit pet
Browse files Browse the repository at this point in the history
  • Loading branch information
My-Name-Is-Jeff committed Jan 14, 2024
1 parent b34d9b6 commit fae535b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
29 changes: 14 additions & 15 deletions src/main/kotlin/gg/skytils/skytilsmod/listeners/DungeonListener.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ import gg.essential.lib.caffeine.cache.Cache
import gg.essential.lib.caffeine.cache.Caffeine
import gg.essential.lib.caffeine.cache.Expiry
import gg.essential.universal.UChat
import gg.skytils.hypixel.types.skyblock.Pet
import gg.skytils.skytilsmod.Skytils
import gg.skytils.skytilsmod.Skytils.Companion.failPrefix
import gg.skytils.skytilsmod.Skytils.Companion.mc
import gg.skytils.skytilsmod.commands.impl.RepartyCommand
import gg.skytils.skytilsmod.core.API
import gg.skytils.skytilsmod.core.tickTimer
import gg.skytils.skytilsmod.events.impl.MainReceivePacketEvent
import gg.skytils.skytilsmod.events.impl.skyblock.DungeonEvent
Expand All @@ -39,7 +41,7 @@ import kotlinx.coroutines.launch
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.network.play.server.S02PacketChat
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import skytils.hylin.skyblock.Pet
import skytils.hylin.extension.nonDashedString
import skytils.hylin.skyblock.dungeons.DungeonClass

object DungeonListener {
Expand Down Expand Up @@ -284,22 +286,19 @@ object DungeonListener {
}

fun checkSpiritPet() {
if (Skytils.hylinAPI.key.isNotEmpty()) {
Skytils.IO.launch {
runCatching {
for (teammate in team.values) {
val name = teammate.playerName
if (hutaoFans.getIfPresent(name) != null) continue
val uuid = teammate.player?.uniqueID ?: MojangUtil.getUUIDFromUsername(name) ?: continue
val profile = Skytils.hylinAPI.getLatestSkyblockProfileForMemberSync(
uuid
) ?: continue
hutaoFans[name] = profile.pets.any(Pet::isSpirit)
Skytils.IO.launch {
runCatching {
for (teammate in team.values) {
val name = teammate.playerName
if (hutaoFans.getIfPresent(name) != null) continue
val uuid = teammate.player?.uniqueID ?: MojangUtil.getUUIDFromUsername(name) ?: continue
API.getSelectedSkyblockProfile(uuid)?.members?.get(uuid.nonDashedString())?.pets_data?.pets?.any(Pet::isSpirit)?.let {
hutaoFans[name] = it
}
printDevMessage(hutaoFans.asMap().toString(), "spiritpet")
}.onFailure {
it.printStackTrace()
}
printDevMessage(hutaoFans.asMap().toString(), "spiritpet")
}.onFailure {
it.printStackTrace()
}
}
}
Expand Down
5 changes: 2 additions & 3 deletions src/main/kotlin/gg/skytils/skytilsmod/utils/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import gg.essential.universal.wrappers.message.UMessage
import gg.essential.universal.wrappers.message.UTextComponent
import gg.essential.vigilance.Vigilant
import gg.essential.vigilance.gui.settings.CheckboxComponent
import gg.skytils.hypixel.types.skyblock.Pet
import gg.skytils.skytilsmod.Skytils
import gg.skytils.skytilsmod.Skytils.Companion.mc
import gg.skytils.skytilsmod.asm.SkytilsTransformer
Expand Down Expand Up @@ -57,8 +58,6 @@ import org.objectweb.asm.tree.MethodInsnNode
import skytils.hylin.extension.getString
import skytils.hylin.player.Player
import skytils.hylin.player.rank.PackageRank
import skytils.hylin.skyblock.Pet
import skytils.hylin.skyblock.item.Tier
import java.awt.Color
import java.io.File
import java.io.IOException
Expand Down Expand Up @@ -382,7 +381,7 @@ val gg.skytils.hypixel.types.player.Player.formattedName
get() = "${rank_prefix}${" ".toStringIfTrue(rank != "NONE")}$display_name"

val Pet.isSpirit
get() = type == "SPIRIT" && (tier == Tier.LEGENDARY || (heldItem == "PET_ITEM_TIER_BOOST" && tier == Tier.EPIC))
get() = type == "SPIRIT" && (tier == "LEGENDARY" || (heldItem == "PET_ITEM_TIER_BOOST" && tier == "EPIC"))

val <E> MutableMap<E, Boolean>.asSet: MutableSet<E>
get() = Collections.newSetFromMap(this)
Expand Down

0 comments on commit fae535b

Please sign in to comment.