diff --git a/src/net/torvald/terrarum/debuggerapp/SavegameCracker.kt b/src/net/torvald/terrarum/debuggerapp/SavegameCracker.kt index ce62f345f..5af45c8a6 100644 --- a/src/net/torvald/terrarum/debuggerapp/SavegameCracker.kt +++ b/src/net/torvald/terrarum/debuggerapp/SavegameCracker.kt @@ -6,8 +6,11 @@ import net.torvald.terrarum.savegame.VDUtil import net.torvald.terrarum.savegame.VirtualDisk import net.torvald.terrarum.savegame.diskIDtoReadableFilename import net.torvald.terrarum.serialise.Common +import net.torvald.terrarum.utils.JsonFetcher import java.io.File +import java.io.FileNotFoundException import java.io.PrintStream +import java.io.StringReader import java.nio.charset.Charset import java.util.* import java.util.logging.Level @@ -269,6 +272,27 @@ class SavegameCracker( VDUtil.dumpToRealMachine(it, file!!) } } + + @Command("Retrieves all UUIDs found (player UUID, current world UUID, etc.") + fun uuid(args: List) { + letdisk { + val jsonFile = it.getFile(-1) ?: throw FileNotFoundException("savegameinfo.json (entry ID -1) not found") + val jsonStr = jsonFile.bytes.toByteArray().toString(Common.CHARSET) + val json = JsonFetcher.readFromJsonString(StringReader(jsonStr)) + var playerUUID = "" + var worldCurrentlyPlaying = "" + var worldIndex = "" + JsonFetcher.forEachSiblings(json) { name, value -> + if (name == "uuid") playerUUID = value.asString() + if (name == "worldCurrentlyPlaying") worldCurrentlyPlaying = value.asString() + if (name == "worldIndex") worldIndex = value.asString() + } + + if (playerUUID.isNotBlank()) println("${ccNoun}Player UUID: $ccNoun2$playerUUID") + if (worldCurrentlyPlaying.isNotBlank()) println("${ccNoun}worldCurrentlyPlaying: $ccNoun2$worldCurrentlyPlaying") + if (worldIndex.isNotBlank()) println("${ccNoun}World UUID: $ccNoun2$worldIndex") + } + } } internal annotation class Command(val help: String = "", val synopsis: String = "")