Fix Everything

This commit is contained in:
2024-12-21 12:30:39 +01:00
parent 336915dd96
commit d08ccc3a98
12 changed files with 64 additions and 888 deletions
@@ -126,25 +126,29 @@ fun Route.configureSchematic() {
node = SchematicNode.createSchematic(user.id, schemName, 0)
}
val content = Base64.getDecoder().decode(file.content)
try {
val content = Base64.getDecoder().decode(file.content)
var schem = nbt.decodeFromByteArray<NbtCompound>(content)
var schem = nbt.decodeFromByteArray<NbtCompound>(content)
if (schem.size == 1) schem = schem[schem.keys.first()] as NbtCompound
if (schem.size == 1) schem = schem[schem.keys.first()] as NbtCompound
val version = schem.let {
if (it.containsKey("Materials"))
return@let SchematicFormat.MCEDIT
else if (it.containsKey("Blocks"))
return@let SchematicFormat.SPONGE_V3
else
return@let SchematicFormat.SPONGE_V2
val version = schem.let {
if (it.containsKey("Materials"))
return@let SchematicFormat.MCEDIT
else if (it.containsKey("Blocks"))
return@let SchematicFormat.SPONGE_V3
else
return@let SchematicFormat.SPONGE_V2
}
val data = NodeData(node.id, version)
data.saveFromStream(content.inputStream(), version)
call.respond(ResponseSchematic(node))
} catch (e: Exception) {
call.respond(HttpStatusCode.BadRequest)
}
val data = NodeData(node.id, version)
data.saveFromStream(content.inputStream(), version)
call.respond(ResponseSchematic(node))
}
}
}