Add a patch for updating to NBT

This commit is contained in:
zontreck 2025-05-25 10:36:46 -07:00
parent 5c67ec76b2
commit a686412ec7

View file

@ -35,7 +35,12 @@ switch($jsx['cmd']) {
$stmt->close();
// Prepare data as JSON and insert into `data` table
if(is_array($jsx['data'])) {
$data = json_encode($jsx['data']);
} // else: The data is binary or NBT.
else {
$data = base64_decode($jsx['data']);
}
$stmt = $DB->prepare("INSERT INTO `data` (`ID`, `SessionData`) VALUES (?, ?)");
$null = NULL; // Required for bind_param with blob
@ -74,11 +79,14 @@ switch($jsx['cmd']) {
$stmt->close();
// Decode the JSON blob (optional — if you want raw JSON output)
if(substr($sessionData, 0, 1) == "{") {
header("Content-Type: application/json");
echo $sessionData;
die($sessionData);
}else {
header("Content-Type: application/nbt");
die(base64_encode($sessionData));
}
break;
}
}
?>