mirror of
https://gitlab.com/2009scape/rt4-client.git
synced 2025-12-20 05:20:24 -07:00
Update to use a centralized fetcher
This commit is contained in:
parent
6adc5135bc
commit
03a205f64b
9 changed files with 169 additions and 128 deletions
|
|
@ -23,6 +23,7 @@ import KondoKit.plugin.Companion.playerXPMultiplier
|
|||
import KondoKit.plugin.Companion.primaryColor
|
||||
import KondoKit.plugin.Companion.secondaryColor
|
||||
import KondoKit.plugin.StateManager.focusedView
|
||||
import KondoKit.util.JsonParser
|
||||
import plugin.api.API
|
||||
import java.awt.*
|
||||
import java.awt.image.BufferedImage
|
||||
|
|
@ -43,20 +44,10 @@ object XPTrackerView : View, OnUpdateCallback, OnXPUpdateCallback {
|
|||
|
||||
val npcHitpointsMap: Map<Int, Int> = try {
|
||||
val json = Helpers.readResourceText("res/npc_hitpoints_map.json") ?: "{}"
|
||||
val pairs = json.trim().removeSurrounding("{", "}").split(",")
|
||||
val map = mutableMapOf<Int, Int>()
|
||||
|
||||
for (pair in pairs) {
|
||||
val keyValue = pair.split(":")
|
||||
val id = keyValue[0].trim().trim('\"').toIntOrNull()
|
||||
val hitpoints = keyValue[1].trim()
|
||||
|
||||
if (id != null && hitpoints.isNotEmpty()) {
|
||||
map[id] = hitpoints.toIntOrNull() ?: 0
|
||||
}
|
||||
}
|
||||
|
||||
map
|
||||
val parsed: Map<String, Int> = JsonParser.fromJson(json)
|
||||
parsed.mapNotNull { (key, value) ->
|
||||
key.toIntOrNull()?.let { it to value }
|
||||
}.toMap()
|
||||
} catch (e: Exception) {
|
||||
println("XPTracker Error parsing NPC HP: ${e.message}")
|
||||
emptyMap()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue