forked from SteamWar/SteamWar
Fix Everything
This commit is contained in:
@@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user