diff options
author | Linnea Gräf <nea@nea.moe> | 2025-06-23 00:38:40 +0200 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2025-06-23 00:38:40 +0200 |
commit | 5094885767147e8d9939dce2fd24d158dab9f1e5 (patch) | |
tree | cd02a3f735c2e733c17a85006cf0b6fc0262b273 /src | |
parent | cd81fc6b189a14422e0a70324be65b6618ef04a6 (diff) | |
download | Firmament-5094885767147e8d9939dce2fd24d158dab9f1e5.tar.gz Firmament-5094885767147e8d9939dce2fd24d158dab9f1e5.tar.bz2 Firmament-5094885767147e8d9939dce2fd24d158dab9f1e5.zip |
feat: Allow reexporting all items
Diffstat (limited to 'src')
-rw-r--r-- | src/main/kotlin/features/debug/itemeditor/ItemExporter.kt | 57 |
1 files changed, 45 insertions, 12 deletions
diff --git a/src/main/kotlin/features/debug/itemeditor/ItemExporter.kt b/src/main/kotlin/features/debug/itemeditor/ItemExporter.kt index 5066942..b31f8ca 100644 --- a/src/main/kotlin/features/debug/itemeditor/ItemExporter.kt +++ b/src/main/kotlin/features/debug/itemeditor/ItemExporter.kt @@ -1,6 +1,7 @@ package moe.nea.firmament.features.debug.itemeditor import com.mojang.brigadier.arguments.StringArgumentType +import kotlinx.coroutines.launch import kotlinx.serialization.json.JsonArray import kotlinx.serialization.json.JsonObject import kotlinx.serialization.json.JsonPrimitive @@ -110,19 +111,34 @@ object ItemExporter { ) ) } - modifyJson(itemid) { - val mutJson = it.toMutableMap() - val legacyTag = LegacyTagParser.parse(mutJson["nbttag"]!!.jsonPrimitive.content) - val display = legacyTag.getCompoundOrEmpty("display") - legacyTag.put("display", display) - display.putString("Name", mutJson["displayname"]!!.jsonPrimitive.content) - display.put( - "Lore", - (mutJson["lore"] as JsonArray).map { NbtString.of(it.jsonPrimitive.content) } - .toNbtList() + fixLoreNbtFor(itemid) + MC.sendChat( + tr( + "firmament.repo.export.relore", + "Updated lore / display name for $itemid" ) - mutJson["nbttag"] = JsonPrimitive(legacyTag.toLegacyString()) - JsonObject(mutJson) + ) + } + } + thenLiteral("all") { + thenExecute { + var i = 0 + val chunkSize = 100 + val items = RepoManager.neuRepo.items.items.keys + Firmament.coroutineScope.launch { + items.chunked(chunkSize).forEach { key -> + MC.sendChat( + tr( + "firmament.repo.export.relore.progress", + "Updated lore / display for ${i * chunkSize} / ${items.size}." + ) + ) + i++ + key.forEach { + fixLoreNbtFor(SkyblockId(it)) + } + } + MC.sendChat(tr("firmament.repo.export.relore.alldone", "All lores updated.")) } } } @@ -130,6 +146,23 @@ object ItemExporter { } } + fun fixLoreNbtFor(itemid: SkyblockId) { + modifyJson(itemid) { + val mutJson = it.toMutableMap() + val legacyTag = LegacyTagParser.parse(mutJson["nbttag"]!!.jsonPrimitive.content) + val display = legacyTag.getCompoundOrEmpty("display") + legacyTag.put("display", display) + display.putString("Name", mutJson["displayname"]!!.jsonPrimitive.content) + display.put( + "Lore", + (mutJson["lore"] as JsonArray).map { NbtString.of(it.jsonPrimitive.content) } + .toNbtList() + ) + mutJson["nbttag"] = JsonPrimitive(legacyTag.toLegacyString()) + JsonObject(mutJson) + } + } + @Subscribe fun onKeyBind(event: HandledScreenKeyPressedEvent) { if (event.matches(PowerUserTools.TConfig.exportItemStackToRepo)) { |