diff options
author | J10a1n15 <45315647+j10a1n15@users.noreply.github.com> | 2024-08-11 14:03:26 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-11 14:03:26 +0200 |
commit | fae0e04865eaad9111d994b7d5810c296ecae371 (patch) | |
tree | 4aebaada36aa06d10421fe713cdbe399dedaf3c2 /src | |
parent | 091b939ea277d22da7fe46eba7d2834af71463e0 (diff) | |
download | skyhanni-fae0e04865eaad9111d994b7d5810c296ecae371.tar.gz skyhanni-fae0e04865eaad9111d994b7d5810c296ecae371.tar.bz2 skyhanni-fae0e04865eaad9111d994b7d5810c296ecae371.zip |
Backend: Add Minister to MayorAPI (#2313)
Diffstat (limited to 'src')
4 files changed, 24 insertions, 4 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/MayorConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/MayorConfig.java index a704efc42..5621d7571 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/MayorConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/MayorConfig.java @@ -16,8 +16,7 @@ public class MayorConfig { public boolean showTimeTillNextMayor = true; @Expose - // TODO: Same Toggle toggles ministers - @ConfigOption(name = "Show Extra Mayor", desc = "Show the Perkpocalypse Mayor without their perks.") + @ConfigOption(name = "Show Extra Mayor", desc = "Show the Perkpocalypse Mayor without their perks and the minister with their perk.") @ConfigEditorBoolean public boolean showExtraMayor = true; } diff --git a/src/main/java/at/hannibal2/skyhanni/data/MayorAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/MayorAPI.kt index c484f4071..53539adb4 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/MayorAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/MayorAPI.kt @@ -86,6 +86,8 @@ object MayorAPI { var currentMayor: Mayor? = null private set + var currentMinister: Mayor? = null + private set private var lastMayor: Mayor? = null var jerryExtraMayor: Pair<Mayor?, SimpleTimeMark> = null to SimpleTimeMark.farPast() private set @@ -216,6 +218,7 @@ object MayorAPI { val currentMayorName = data.mayor.name if (lastMayor?.name != currentMayorName) { currentMayor = setAssumeMayorJson(currentMayorName, data.mayor.perks) + currentMinister = setAssumeMayorJson(data.mayor.minister.name, data.mayor.minister.perk) } } } @@ -246,6 +249,8 @@ object MayorAPI { add("Active Perks: ${currentMayor?.activePerks}") add("Last Update: $lastUpdate (${lastUpdate.passedSince()} ago)") add("Time Till Next Mayor: ${nextMayorTimestamp.timeUntil()}") + add("Current Minister: ${currentMinister?.name ?: "Unknown"}") + add("Current Minister Perk: ${currentMinister?.activePerks}") if (jerryExtraMayor.first != null) { add("Jerry Mayor: ${jerryExtraMayor.first?.name} expiring at: ${jerryExtraMayor.second.timeUntil()}") } diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/other/MayorJson.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/other/MayorJson.kt index d8f0df279..f54c7daf4 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/other/MayorJson.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/other/MayorJson.kt @@ -11,6 +11,7 @@ data class MayorInfo( @Expose val key: String, @Expose val name: String, @Expose val perks: List<MayorPerk>, + @Expose val minister: Minister, @Expose val election: MayorElection, ) @@ -26,7 +27,14 @@ data class MayorCandidate( @Expose val votes: Int, ) +data class Minister( + @Expose val key: String, + @Expose val name: String, + @Expose val perk: List<MayorPerk>, +) + data class MayorPerk( @Expose val name: String, @Expose val description: String, + @Expose val minister: Boolean = false, ) diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardElements.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardElements.kt index 6562edaf3..7c9757da2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardElements.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardElements.kt @@ -747,7 +747,7 @@ private fun getEventsDisplayPair(): List<ScoreboardElementType> = ScoreboardEven private fun getEventsShowWhen() = ScoreboardEvent.getEvent().isNotEmpty() private fun getMayorDisplayPair() = buildList { - val currentMayorName = MayorAPI.currentMayor?.mayorName?.let { MayorAPI.mayorNameWithColorCode(it) } ?: "<hidden>" + val currentMayorName = MayorAPI.currentMayor?.mayorName?.let { MayorAPI.mayorNameWithColorCode(it) } ?: return@buildList val timeTillNextMayor = if (mayorConfig.showTimeTillNextMayor) { "§7 (§e${MayorAPI.nextMayorTimestamp.timeUntil().format(maxUnits = 2)}§7)" } else { @@ -763,6 +763,15 @@ private fun getMayorDisplayPair() = buildList { } if (!mayorConfig.showExtraMayor) return@buildList + val ministerName = MayorAPI.currentMinister?.mayorName?.let { MayorAPI.mayorNameWithColorCode(it) } ?: return@buildList + add(ministerName to HorizontalAlignment.LEFT) + + if (mayorConfig.showMayorPerks) { + MayorAPI.currentMinister?.activePerks?.forEach { perk -> + add(" §7- §e${perk.perkName}" to HorizontalAlignment.LEFT) + } + } + val jerryExtraMayor = MayorAPI.jerryExtraMayor val extraMayor = jerryExtraMayor.first ?: return@buildList @@ -774,7 +783,6 @@ private fun getMayorDisplayPair() = buildList { } add((extraMayorName + extraTimeTillNextMayor) to HorizontalAlignment.LEFT) - } private fun getMayorShowWhen() = |