Attempt to fix web viewer being unable to load NBT

This commit is contained in:
zontreck 2025-05-25 13:33:27 -07:00
parent 4a8d515f4d
commit b1063f5057
4 changed files with 16 additions and 7 deletions

View file

@ -35,10 +35,9 @@ switch($jsx['cmd']) {
$stmt->close();
// Prepare data as JSON and insert into `data` table
if(is_array($jsx['data'])) {
if($jsx['type'] == "json") {
$data = json_encode($jsx['data']);
} // else: The data is binary or NBT.
else {
}else if($jsx ['type'] == "nbt") {
$data = base64_decode($jsx['data']);
}
@ -79,12 +78,16 @@ switch($jsx['cmd']) {
$stmt->close();
// Decode the JSON blob (optional — if you want raw JSON output)
if(substr($sessionData, 0, 1) == "{") {
$testDecoded = json_decode($sessionData, true);
if(json_last_error() == JSON_ERROR_NONE) {
header("Content-Type: application/json");
die($sessionData);
}else {
header("Content-Type: application/nbt");
die(base64_encode($sessionData));
//die($sessionData);
}
break;
}