From d32b4ee35ac98f1ae585b1cb9cf251c5dfdd1831 Mon Sep 17 00:00:00 2001 From: zontreck Date: Wed, 28 Aug 2024 17:23:26 -0700 Subject: [PATCH] Fix failure to load settings NBT due to new values --- lib/structs/settings.dart | 14 ++++++++++++-- pubspec.yaml | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/structs/settings.dart b/lib/structs/settings.dart index 73db217..f1f15cb 100644 --- a/lib/structs/settings.dart +++ b/lib/structs/settings.dart @@ -85,7 +85,11 @@ class Settings { FTS = NbtUtils.readBoolean(tag, "fts"); // First Time Setup. // FTS should be disabled by the client when sending it back to the server in a C2SApplySettingsPacket - superuser = User.deserialize(tag.get("superuser")!.asCompoundTag()); + if (tag.containsKey("superuser")) + superuser = User.deserialize(tag.get("superuser")!.asCompoundTag()); + + if (tag.containsKey("wine_init")) + wineInitialized = NbtUtils.readBoolean(tag, "wine_init"); if (tag.containsKey("main")) { inst = SettingsEntry.deserialize(tag.get("main")!.asCompoundTag()); @@ -100,7 +104,13 @@ class Settings { var tag = await NbtIo.read("settings.dat"); inst = SettingsEntry.deserialize(tag.get("entry") as CompoundTag); - wineInitialized = NbtUtils.readBoolean(tag, "wine_init"); + + if (tag.containsKey("wine_init")) + wineInitialized = NbtUtils.readBoolean(tag, "wine_init"); + + if (tag.containsKey("superuser")) + superuser = User.deserialize(tag.get("superuser")!.asCompoundTag()); + FTS = NbtUtils.readBoolean(tag, "fts"); } catch (E) { print("No existing settings file found, initializing default settings"); diff --git a/pubspec.yaml b/pubspec.yaml index 47a220f..ec744fa 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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.1.0+39 +version: 1.1.0+41 environment: sdk: '>=3.1.4 <4.0.0'