mirror of
https://gitlab.com/2009scape/tools/rs09-thanos-tool.git
synced 2026-08-01 14:39:20 -06:00
Merge branch 'deduplicate-entries' into 'master'
Thanos tool will now detect and ignore duplicate drop table, npc config, and item config entries Closes #1 See merge request 2009scape/tools/rs09-thanos-tool!3
This commit is contained in:
commit
6e57d28642
1 changed files with 25 additions and 2 deletions
|
|
@ -8,6 +8,7 @@ import java.io.IOException
|
|||
import java.lang.Exception
|
||||
import java.lang.StringBuilder
|
||||
import javax.script.ScriptEngineManager
|
||||
import kotlin.io.println
|
||||
|
||||
enum class Editors(val data: EditorData) {
|
||||
DROP_TABLES(object : EditorData("drop_tables.json"){
|
||||
|
|
@ -15,10 +16,19 @@ enum class Editors(val data: EditorData) {
|
|||
override fun parse() {
|
||||
Logger.logInfo("Parsing Drop Tables")
|
||||
configureParser()
|
||||
data.forEach { dropTableRaw ->
|
||||
val dropTable = dropTableRaw as org.json.simple.JSONObject
|
||||
val usedIds = ArrayList<Int>()
|
||||
data.forEach dataLoop@ { dropTableRaw ->
|
||||
val dropTable = dropTableRaw as JSONObject
|
||||
val table = NPCDropTable()
|
||||
table.ids = dropTable["ids"].toString()
|
||||
table.ids.split(",").map { it.toInt() }.forEach {id ->
|
||||
if(usedIds.contains(id)) {
|
||||
println("Detected duplicate ID, ignoring table: ")
|
||||
println(dropTableRaw.toJSONString())
|
||||
return@dataLoop
|
||||
}
|
||||
usedIds.add(id)
|
||||
}
|
||||
parseTable(dropTable["main"] as JSONArray,table,false)
|
||||
parseTable(dropTable["default"] as JSONArray,table,true)
|
||||
parseTable(dropTable["charm"] as JSONArray,table.charmTable,false)
|
||||
|
|
@ -70,9 +80,16 @@ enum class Editors(val data: EditorData) {
|
|||
override fun parse() {
|
||||
Logger.logInfo("Parsing NPC configs")
|
||||
configureParser()
|
||||
val usedIds = ArrayList<Int>()
|
||||
data.forEach { npcDataRaw ->
|
||||
val npcData = npcDataRaw as JSONObject
|
||||
val id = npcData["id"].toString().toInt()
|
||||
if (usedIds.contains(id)) {
|
||||
println("Duplicate NPC Config detected, ignoring config entry:")
|
||||
println(npcDataRaw.toJSONString())
|
||||
return@forEach
|
||||
}
|
||||
usedIds.add(id)
|
||||
val name = npcData["name"].toString()
|
||||
TableData.npcNames[id] = name
|
||||
TableData.npcConfigKeys.addAll(npcData.keys.toHashSet() as HashSet<String>)
|
||||
|
|
@ -104,9 +121,15 @@ enum class Editors(val data: EditorData) {
|
|||
ITEM_CONFIGS(object : EditorData("item_configs.json"){
|
||||
override fun parse() {
|
||||
configureParser()
|
||||
val usedIds = ArrayList<Int>()
|
||||
data.forEach { itemDataRaw ->
|
||||
val itemData = itemDataRaw as JSONObject
|
||||
val id = itemData["id"].toString().toInt()
|
||||
if (usedIds.contains(id)) {
|
||||
println("Duplicate Item Config detected, ignoring config entry:")
|
||||
println(itemDataRaw.toJSONString())
|
||||
return@forEach
|
||||
}
|
||||
val name = itemData["name"].toString()
|
||||
TableData.itemConfigKeys.addAll(itemData.keys.toHashSet() as HashSet<String>)
|
||||
TableData.itemNames[id] = name
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue