Attempt to fix web viewer being unable to load NBT
This commit is contained in:
parent
4a8d515f4d
commit
b1063f5057
4 changed files with 16 additions and 7 deletions
|
@ -9,7 +9,7 @@ class TTConsts {
|
|||
static get SESSION_SERVER =>
|
||||
"https://api.zontreck.com/timetrack/$UPDATE_CHANNEL/timetrack.php";
|
||||
|
||||
static const VERSION = "1.0.0-beta.17";
|
||||
static const VERSION = "1.0.0-beta.18";
|
||||
|
||||
static bool UPDATE_AVAILABLE = false;
|
||||
static UpdateChannel UPDATE_CHANNEL = UpdateChannel.beta;
|
||||
|
|
|
@ -264,6 +264,7 @@ class SessionData {
|
|||
|
||||
Map<String, dynamic> payload = {
|
||||
"cmd": "create",
|
||||
"type": "nbt",
|
||||
"data": base64Encoder.encode(nbtData),
|
||||
};
|
||||
|
||||
|
@ -444,6 +445,7 @@ class SessionData {
|
|||
if (cType == "application/json") {
|
||||
return LoadData(reply.data as Map<String, dynamic>);
|
||||
} else if (cType == "application/nbt") {
|
||||
print("Data is in NBT Format");
|
||||
Uint8List lst = base64Encoder.decode(reply.data as String);
|
||||
// Convert this to a CompoundTag
|
||||
CompoundTag ct = await NbtIo.readFromStream(lst) as CompoundTag;
|
||||
|
@ -451,7 +453,11 @@ class SessionData {
|
|||
return true;
|
||||
} else
|
||||
return false;
|
||||
} catch (E) {
|
||||
} catch (E, stack) {
|
||||
print(E);
|
||||
|
||||
print(stack);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev
|
|||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||
# In Windows, build-name is used as the major, minor, and patch parts
|
||||
# of the product and file versions while build-number is used as the build suffix.
|
||||
version: 1.0.0-beta.17
|
||||
version: 1.0.0-beta.18
|
||||
|
||||
environment:
|
||||
sdk: ^3.7.2
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue