mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-11 02:54:04 +09:00
serialiser for world
This commit is contained in:
@@ -7,6 +7,7 @@ import net.torvald.terrarum.console.ConsoleCommand
|
||||
import net.torvald.terrarum.console.Echo
|
||||
import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
||||
import net.torvald.terrarum.serialise.WriteMeta
|
||||
import net.torvald.terrarum.serialise.WriteWorld
|
||||
import net.torvald.terrarum.utils.JsonWriter
|
||||
import java.io.IOException
|
||||
|
||||
@@ -31,4 +32,25 @@ object ExportMeta : ConsoleCommand {
|
||||
override fun printUsage() {
|
||||
Echo("Usage: Exportmeta")
|
||||
}
|
||||
}
|
||||
|
||||
object ExportWorld : ConsoleCommand {
|
||||
override fun execute(args: Array<String>) {
|
||||
try {
|
||||
val world = Terrarum.ingame!!.world
|
||||
val str = WriteWorld(Terrarum.ingame!! as TerrarumIngame).invoke()
|
||||
val writer = java.io.FileWriter(AppLoader.defaultDir + "/Exports/world${world.worldIndex}.json", false)
|
||||
writer.write(str)
|
||||
writer.close()
|
||||
Echo("Exportworld: exported to world${world.worldIndex}.json")
|
||||
}
|
||||
catch (e: IOException) {
|
||||
Echo("Exportworld: IOException raised.")
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
override fun printUsage() {
|
||||
Echo("Usage: Exportworld")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user