Skip to content

Commit

Permalink
feat: add minister data to MayorInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
My-Name-Is-Jeff committed Aug 15, 2024
1 parent 8e5c21f commit c5f1556
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ object ScoreCalculation {
init {
tickTimer(5, repeats = true) {
isPaul.set(
(MayorInfo.currentMayor == "Paul" && MayorInfo.mayorPerks.contains("EZPZ")) || MayorInfo.jerryMayor?.name == "Paul"
(MayorInfo.allPerks.contains("EZPZ")) || MayorInfo.jerryMayor?.name == "Paul"
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,11 @@ import kotlinx.coroutines.launch
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.JsonObject
import kotlinx.serialization.json.decodeFromJsonElement
import net.minecraft.event.HoverEvent
import net.minecraft.init.Items
import net.minecraft.inventory.ContainerChest
import net.minecraftforge.client.event.ClientChatReceivedEvent
import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import java.io.IOException
import java.net.URLEncoder
import java.util.*
import kotlin.math.abs
import kotlin.math.round
Expand All @@ -53,6 +50,10 @@ object MayorInfo {

var currentMayor: String? = null
var mayorPerks = HashSet<String>()
var currentMinister: String? = null
var ministerPerks = HashSet<String>()
var allPerks = HashSet<String>()

var jerryMayor: Mayor? = null
var newJerryPerks = 0L
private var lastCheckedElectionOver = 0L
Expand Down Expand Up @@ -133,13 +134,22 @@ object MayorInfo {
}

fun fetchMayorData() = Skytils.IO.launch {
val res = json.decodeFromJsonElement<Mayor>(client.get("https://api.hypixel.net/resources/skyblock/election").body<JsonObject>()["mayor"]!!)
val res = client.get("https://api.hypixel.net/resources/skyblock/election").body<JsonObject>()
val mayorObj = res["mayor"] as JsonObject
val newMayor = json.decodeFromJsonElement<Mayor>(mayorObj)
val newMinister = mayorObj["minister"]?.let { json.decodeFromJsonElement<Mayor>(it) }
tickTimer(1) {
currentMayor = res.name
currentMayor = newMayor.name
currentMinister = newMinister?.name
lastFetchedMayorData = System.currentTimeMillis()
if (currentMayor != "Jerry") jerryMayor = null
mayorPerks.clear()
mayorPerks.addAll(res.perks.map { it.name })
mayorPerks.addAll(newMayor.perks.map { it.name })
ministerPerks.clear()
if (newMinister != null) ministerPerks.addAll(newMinister.perks.map { it.name })
allPerks.clear()
allPerks.addAll(mayorPerks)
allPerks.addAll(ministerPerks)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ object CHWaypoints {
event.entity is EntityOtherPlayerMP &&
event.entity.name == "Team Treasurite" &&
mc.thePlayer.canEntityBeSeen(event.entity) &&
event.entity.baseMaxHealth == if (MayorInfo.mayorPerks.contains("DOUBLE MOBS HP!!!")) 2_000_000.0 else 1_000_000.0
event.entity.baseMaxHealth == if (MayorInfo.allPerks.contains("DOUBLE MOBS HP!!!")) 2_000_000.0 else 1_000_000.0
) {
if (!CrystalHollowsMap.Locations.Corleone.loc.exists()) {
CrystalHollowsMap.Locations.Corleone.apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ object SlayerFeatures : CoroutineScope {
val entity = event.target as? EntityLivingBase ?: return

if (!hasSlayerText || !Utils.inSkyblock || event.entity != mc.thePlayer || !Skytils.config.useSlayerHitMethod) return
if ((if (MayorInfo.mayorPerks.contains("DOUBLE MOBS HP!!!")) 2 else 1) * floor(entity.baseMaxHealth).toInt() == expectedMaxHp) {
if ((if (MayorInfo.allPerks.contains("DOUBLE MOBS HP!!!")) 2 else 1) * floor(entity.baseMaxHealth).toInt() == expectedMaxHp) {
printDevMessage("A valid entity was attacked", "slayer", "seraph", "seraphHit")
hitMap.compute(entity) { _, int ->
return@compute (int ?: 0).inc()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ open class Slayer<T : EntityLivingBase>(
get() = entity.javaClass
private val currentTier = SlayerFeatures.getTier(name)
private val expectedHealth =
(if ("DOUBLE MOBS HP!!!" in MayorInfo.mayorPerks) 2 else 1) * (SlayerFeatures.BossHealths[name.substringBefore(
(if ("DOUBLE MOBS HP!!!" in MayorInfo.allPerks) 2 else 1) * (SlayerFeatures.BossHealths[name.substringBefore(
" "
)]?.get(currentTier) ?: 0)

Expand Down

0 comments on commit c5f1556

Please sign in to comment.