mirror of
https://gitlab.com/2009scape/rt4-client.git
synced 2025-12-10 10:20:44 -07:00
GroundItems 1.3
This commit is contained in:
parent
8076568083
commit
310c88600a
3 changed files with 67 additions and 68 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
package GroundItems
|
package GroundItems
|
||||||
|
|
||||||
|
import KondoKit.Exposed
|
||||||
import plugin.Plugin
|
import plugin.Plugin
|
||||||
import plugin.annotations.PluginMeta
|
|
||||||
import plugin.api.API.*
|
import plugin.api.API.*
|
||||||
import plugin.api.FontColor.fromColor
|
import plugin.api.FontColor.fromColor
|
||||||
import plugin.api.FontType
|
import plugin.api.FontType
|
||||||
|
|
@ -18,27 +18,26 @@ import java.nio.charset.StandardCharsets
|
||||||
import java.text.DecimalFormat
|
import java.text.DecimalFormat
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
@PluginMeta(
|
class plugin : Plugin() {
|
||||||
author = "downthecrop",
|
|
||||||
description =
|
@Exposed(description = "Default: true, Use Local JSON or the prices from the Live/Stable server API")
|
||||||
"""
|
private var useLiveGEPrices = true
|
||||||
Ground Items Overlay. Just like Runelite!
|
@Exposed( "Default: 5,000 (blue)")
|
||||||
cmds ::set(low,med,high,insane,hide), ::(tag,ignore)item ID, ::(reset)groundconfig
|
private var lowValue = 5000
|
||||||
Special thanks to Chisato for the original skeleton.
|
@Exposed( "Default: 20,000 (green)")
|
||||||
""",
|
private var mediumValue = 20000
|
||||||
version = 1.2
|
@Exposed( "Default: 50,000 (orange)")
|
||||||
)
|
private var highValue = 50000
|
||||||
open class plugin : Plugin() {
|
@Exposed( "Default: 100,000 (pink)")
|
||||||
|
private var insaneValue = 100000
|
||||||
|
@Exposed("Default: 0, No labels will be drawn for items below this value (unless tagged)")
|
||||||
|
private var hideBelowValue = 0
|
||||||
|
@Exposed("Tag Items (purple) add/remove with Ctrl+RightClick Tag/Ignore")
|
||||||
|
private lateinit var taggedItems: List<Int>
|
||||||
|
@Exposed("Ignore items add/remove with Ctrl+RightClick Tag/Ignore")
|
||||||
|
private lateinit var ignoredItems: List<Int>
|
||||||
|
|
||||||
private var kondoExposed_lowValue = 5000
|
|
||||||
private var kondoExposed_mediumValue = 20000
|
|
||||||
private var kondoExposed_highValue = 50000
|
|
||||||
private var kondoExposed_insaneValue = 100000
|
|
||||||
private var kondoExposed_hideBelowValue = 0
|
|
||||||
private var kondoExposed_useLiveGEPrices = true
|
|
||||||
private val coindId = 995
|
private val coindId = 995
|
||||||
private lateinit var kondoExposed_taggedItems: List<Int>
|
|
||||||
private lateinit var kondoExposed_ignoredItems: List<Int>
|
|
||||||
|
|
||||||
private var gePriceMap = loadGEPrices()
|
private var gePriceMap = loadGEPrices()
|
||||||
|
|
||||||
|
|
@ -60,23 +59,23 @@ open class plugin : Plugin() {
|
||||||
)
|
)
|
||||||
|
|
||||||
override fun Init() {
|
override fun Init() {
|
||||||
kondoExposed_lowValue = GetData("low-value") as? Int ?: 5000
|
lowValue = GetData("low-value") as? Int ?: 5000
|
||||||
kondoExposed_mediumValue = GetData("medium-value") as? Int ?: 20000
|
mediumValue = GetData("medium-value") as? Int ?: 20000
|
||||||
kondoExposed_highValue = GetData("high-value") as? Int ?: 50000
|
highValue = GetData("high-value") as? Int ?: 50000
|
||||||
kondoExposed_insaneValue = GetData("insane-value") as? Int ?: 100000
|
insaneValue = GetData("insane-value") as? Int ?: 100000
|
||||||
kondoExposed_hideBelowValue = GetData("hide-below-value") as? Int ?: 0
|
hideBelowValue = GetData("hide-below-value") as? Int ?: 0
|
||||||
kondoExposed_useLiveGEPrices = GetData("ground-item-use-remote") as? Boolean ?: true
|
useLiveGEPrices = GetData("ground-item-use-remote") as? Boolean ?: true
|
||||||
kondoExposed_taggedItems = GetData("ground-item-tags")?.let { it.toString().split(",").mapNotNull { it.toIntOrNull() } } ?: emptyList()
|
taggedItems = GetData("ground-item-tags")?.let { it.toString().split(",").mapNotNull { it.toIntOrNull() } } ?: emptyList()
|
||||||
kondoExposed_ignoredItems = GetData("ground-item-ignore")?.let { it.toString().split(",").mapNotNull { it.toIntOrNull() } } ?: emptyList()
|
ignoredItems = GetData("ground-item-ignore")?.let { it.toString().split(",").mapNotNull { it.toIntOrNull() } } ?: emptyList()
|
||||||
if (gePriceMap.isEmpty()) SendMessage("Ground Items unable to load GE Prices, Remote: $kondoExposed_useLiveGEPrices")
|
if (gePriceMap.isEmpty()) SendMessage("Ground Items unable to load GE Prices, Remote: $useLiveGEPrices")
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun isTagged(itemId: Int): Boolean {
|
private fun isTagged(itemId: Int): Boolean {
|
||||||
return kondoExposed_taggedItems.contains(itemId)
|
return taggedItems.contains(itemId)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun isHidden(itemId: Int): Boolean {
|
private fun isHidden(itemId: Int): Boolean {
|
||||||
return kondoExposed_ignoredItems.contains(itemId)
|
return ignoredItems.contains(itemId)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun Draw(timeDelta: Long) = renderGroundItemNames()
|
override fun Draw(timeDelta: Long) = renderGroundItemNames()
|
||||||
|
|
@ -141,10 +140,10 @@ open class plugin : Plugin() {
|
||||||
val screenY = screenPos[1]
|
val screenY = screenPos[1]
|
||||||
val color = when {
|
val color = when {
|
||||||
isTagged(itemDef.id) -> colorMap["tagged"]
|
isTagged(itemDef.id) -> colorMap["tagged"]
|
||||||
highestValue < kondoExposed_lowValue -> "#FFFFFF"
|
highestValue < lowValue -> "#FFFFFF"
|
||||||
highestValue < kondoExposed_mediumValue -> colorMap["lowValue"]
|
highestValue < mediumValue -> colorMap["lowValue"]
|
||||||
highestValue < kondoExposed_highValue -> colorMap["mediumValue"]
|
highestValue < highValue -> colorMap["mediumValue"]
|
||||||
highestValue < kondoExposed_insaneValue -> colorMap["highValue"]
|
highestValue < insaneValue -> colorMap["highValue"]
|
||||||
else -> colorMap["insaneValue"]
|
else -> colorMap["insaneValue"]
|
||||||
} ?: "#FFFFFF"
|
} ?: "#FFFFFF"
|
||||||
val colorInt = color.drop(1).toInt(16)
|
val colorInt = color.drop(1).toInt(16)
|
||||||
|
|
@ -183,7 +182,7 @@ open class plugin : Plugin() {
|
||||||
val haValue = if (itemDef.id == coindId) item.value.amount else (itemDef.cost * 0.6 * item.value.amount).roundToInt()
|
val haValue = if (itemDef.id == coindId) item.value.amount else (itemDef.cost * 0.6 * item.value.amount).roundToInt()
|
||||||
val geValue = (gePriceMap[itemDef.id.toString()]?.toInt() ?: 0) * item.value.amount
|
val geValue = (gePriceMap[itemDef.id.toString()]?.toInt() ?: 0) * item.value.amount
|
||||||
val highestValue = maxOf(haValue, geValue)
|
val highestValue = maxOf(haValue, geValue)
|
||||||
return !((highestValue < kondoExposed_hideBelowValue || isHidden(itemDef.id)) && !isTagged(itemDef.id))
|
return !((highestValue < hideBelowValue || isHidden(itemDef.id)) && !isTagged(itemDef.id))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun OnMiniMenuCreate(currentEntries: Array<out MiniMenuEntry>?) {
|
override fun OnMiniMenuCreate(currentEntries: Array<out MiniMenuEntry>?) {
|
||||||
|
|
@ -200,7 +199,7 @@ open class plugin : Plugin() {
|
||||||
|
|
||||||
private fun ignoreItem(itemId: Int): Runnable {
|
private fun ignoreItem(itemId: Int): Runnable {
|
||||||
return Runnable {
|
return Runnable {
|
||||||
val existingIgnores = kondoExposed_ignoredItems.toMutableList()
|
val existingIgnores = ignoredItems.toMutableList()
|
||||||
|
|
||||||
if (existingIgnores.contains(itemId)) {
|
if (existingIgnores.contains(itemId)) {
|
||||||
existingIgnores.remove(itemId)
|
existingIgnores.remove(itemId)
|
||||||
|
|
@ -215,7 +214,7 @@ open class plugin : Plugin() {
|
||||||
|
|
||||||
private fun tagItem(itemId: Int): Runnable {
|
private fun tagItem(itemId: Int): Runnable {
|
||||||
return Runnable {
|
return Runnable {
|
||||||
val existingTags = kondoExposed_taggedItems.toMutableList()
|
val existingTags = taggedItems.toMutableList()
|
||||||
|
|
||||||
if (existingTags.contains(itemId)) {
|
if (existingTags.contains(itemId)) {
|
||||||
existingTags.remove(itemId)
|
existingTags.remove(itemId)
|
||||||
|
|
@ -230,28 +229,28 @@ open class plugin : Plugin() {
|
||||||
|
|
||||||
|
|
||||||
private fun resetConfig() {
|
private fun resetConfig() {
|
||||||
kondoExposed_lowValue = 5000
|
lowValue = 5000
|
||||||
kondoExposed_mediumValue = 20000
|
mediumValue = 20000
|
||||||
kondoExposed_highValue = 50000
|
highValue = 50000
|
||||||
kondoExposed_insaneValue = 100000
|
insaneValue = 100000
|
||||||
kondoExposed_hideBelowValue = 0
|
hideBelowValue = 0
|
||||||
kondoExposed_useLiveGEPrices = true
|
useLiveGEPrices = true
|
||||||
StoreData("ground-item-tags","");
|
StoreData("ground-item-tags","");
|
||||||
StoreData("ground-item-ignore","");
|
StoreData("ground-item-ignore","");
|
||||||
StoreData("low-value", kondoExposed_lowValue)
|
StoreData("low-value", lowValue)
|
||||||
StoreData("ground-item-use-remote", kondoExposed_useLiveGEPrices)
|
StoreData("ground-item-use-remote", useLiveGEPrices)
|
||||||
StoreData("medium-value", kondoExposed_mediumValue)
|
StoreData("medium-value", mediumValue)
|
||||||
StoreData("high-value", kondoExposed_highValue)
|
StoreData("high-value", highValue)
|
||||||
StoreData("insane-value", kondoExposed_insaneValue)
|
StoreData("insane-value", insaneValue)
|
||||||
StoreData("hide-below-value", kondoExposed_hideBelowValue)
|
StoreData("hide-below-value", hideBelowValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun displayRanges() {
|
private fun displayRanges() {
|
||||||
val low = kondoExposed_lowValue
|
val low = lowValue
|
||||||
val medium = kondoExposed_mediumValue
|
val medium = mediumValue
|
||||||
val high = kondoExposed_highValue
|
val high = highValue
|
||||||
val insane = kondoExposed_insaneValue
|
val insane = insaneValue
|
||||||
val hide = kondoExposed_hideBelowValue
|
val hide = hideBelowValue
|
||||||
|
|
||||||
SendMessage("== Ground Item Config ==")
|
SendMessage("== Ground Item Config ==")
|
||||||
SendMessage("Low: $low")
|
SendMessage("Low: $low")
|
||||||
|
|
@ -260,12 +259,12 @@ open class plugin : Plugin() {
|
||||||
SendMessage("Insane: $insane")
|
SendMessage("Insane: $insane")
|
||||||
SendMessage("Hide Below: $hide")
|
SendMessage("Hide Below: $hide")
|
||||||
SendMessage("-- Ignored Items --")
|
SendMessage("-- Ignored Items --")
|
||||||
for(item in kondoExposed_ignoredItems){
|
for(item in ignoredItems){
|
||||||
val itemDef = ObjTypeList.get(item)
|
val itemDef = ObjTypeList.get(item)
|
||||||
SendMessage("Ignored: ${itemDef.name} ${itemDef.id}")
|
SendMessage("Ignored: ${itemDef.name} ${itemDef.id}")
|
||||||
}
|
}
|
||||||
SendMessage("-- Tagged Items --")
|
SendMessage("-- Tagged Items --")
|
||||||
for(item in kondoExposed_taggedItems){
|
for(item in taggedItems){
|
||||||
val itemDef = ObjTypeList.get(item)
|
val itemDef = ObjTypeList.get(item)
|
||||||
SendMessage("Tagged: ${itemDef.name} ${itemDef.id}")
|
SendMessage("Tagged: ${itemDef.name} ${itemDef.id}")
|
||||||
}
|
}
|
||||||
|
|
@ -278,19 +277,19 @@ open class plugin : Plugin() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun OnKondoValueUpdated() {
|
fun OnKondoValueUpdated() {
|
||||||
StoreData("ground-item-tags",kondoExposed_taggedItems);
|
StoreData("ground-item-tags",taggedItems);
|
||||||
StoreData("ground-item-ignore",kondoExposed_ignoredItems);
|
StoreData("ground-item-ignore",ignoredItems);
|
||||||
StoreData("low-value", kondoExposed_lowValue)
|
StoreData("low-value", lowValue)
|
||||||
StoreData("medium-value", kondoExposed_mediumValue)
|
StoreData("medium-value", mediumValue)
|
||||||
StoreData("high-value", kondoExposed_highValue)
|
StoreData("high-value", highValue)
|
||||||
StoreData("insane-value", kondoExposed_insaneValue)
|
StoreData("insane-value", insaneValue)
|
||||||
StoreData("ground-item-use-remote", kondoExposed_useLiveGEPrices)
|
StoreData("ground-item-use-remote", useLiveGEPrices)
|
||||||
StoreData("hide-below-value", kondoExposed_hideBelowValue)
|
StoreData("hide-below-value", hideBelowValue)
|
||||||
gePriceMap = loadGEPrices();
|
gePriceMap = loadGEPrices();
|
||||||
}
|
}
|
||||||
|
|
||||||
fun loadGEPrices(): Map<String, String> {
|
fun loadGEPrices(): Map<String, String> {
|
||||||
return if (kondoExposed_useLiveGEPrices) {
|
return if (useLiveGEPrices) {
|
||||||
try {
|
try {
|
||||||
println("GroundItems: Loading Remote GE Prices")
|
println("GroundItems: Loading Remote GE Prices")
|
||||||
val url = URL("https://cdn.2009scape.org/gedata/latest.json")
|
val url = URL("https://cdn.2009scape.org/gedata/latest.json")
|
||||||
|
|
@ -325,7 +324,7 @@ open class plugin : Plugin() {
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
println("GroundItems: Loading Local GE Prices")
|
println("GroundItems: Loading Local GE Prices")
|
||||||
BufferedReader(InputStreamReader(GroundItems.plugin::class.java.getResourceAsStream("item_configs.json"), StandardCharsets.UTF_8))
|
BufferedReader(InputStreamReader(plugin::class.java.getResourceAsStream("res/item_configs.json"), StandardCharsets.UTF_8))
|
||||||
.useLines { lines ->
|
.useLines { lines ->
|
||||||
val json = lines.joinToString("\n")
|
val json = lines.joinToString("\n")
|
||||||
val items = json.trim().removeSurrounding("[", "]").split("},").map { it.trim() + "}" }
|
val items = json.trim().removeSurrounding("[", "]").split("},").map { it.trim() + "}" }
|
||||||
|
|
|
||||||
|
|
@ -5,4 +5,4 @@ Commands:\
|
||||||
::(tag,ignore)item ID\
|
::(tag,ignore)item ID\
|
||||||
::(reset)groundconfig\
|
::(reset)groundconfig\
|
||||||
Special thanks to Chisato for the original skeleton.
|
Special thanks to Chisato for the original skeleton.
|
||||||
VERSION=1.2
|
VERSION=1.3
|
||||||
Loading…
Add table
Add a link
Reference in a new issue