Add a patch for updating to NBT
This commit is contained in:
parent
5c67ec76b2
commit
a686412ec7
1 changed files with 13 additions and 5 deletions
|
@ -35,7 +35,12 @@ switch($jsx['cmd']) {
|
|||
$stmt->close();
|
||||
|
||||
// Prepare data as JSON and insert into `data` table
|
||||
$data = json_encode($jsx['data']);
|
||||
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)
|
||||
header("Content-Type: application/json");
|
||||
echo $sessionData;
|
||||
if(substr($sessionData, 0, 1) == "{") {
|
||||
header("Content-Type: application/json");
|
||||
die($sessionData);
|
||||
}else {
|
||||
header("Content-Type: application/nbt");
|
||||
die(base64_encode($sessionData));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
?>
|
Loading…
Add table
Add a link
Reference in a new issue