From c57382dfa4299f5c32105b66b4db65f3167b1a2f Mon Sep 17 00:00:00 2001 From: zontreck Date: Tue, 2 Jul 2024 16:19:09 -0700 Subject: [PATCH] Fix the perform restart settings flag not getting honored. --- lib/packets/ClientPackets.dart | 17 ++++++++++------- lib/pages/home.dart | 24 +++++++++++++++--------- pubspec.yaml | 2 +- 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/lib/packets/ClientPackets.dart b/lib/packets/ClientPackets.dart index 4b756e9..219e0e5 100644 --- a/lib/packets/ClientPackets.dart +++ b/lib/packets/ClientPackets.dart @@ -295,7 +295,10 @@ class C2SUploadSettingsPacket implements IPacket { @override void decodeTag(Tag tag) { - srvSettings = tag.asCompoundTag().get("settings")!.asCompoundTag(); + CompoundTag ct = tag.asCompoundTag(); + + srvSettings = ct.get("settings")!.asCompoundTag(); + performRestart = NbtUtils.readBoolean(ct, "restart"); } @override @@ -339,13 +342,13 @@ class C2SUploadSettingsPacket implements IPacket { settings.deserialize(srvSettings); settings.Write(); - if (!performRestart) { - DiscordHookHelper.sendWebHook( - settings.inst!.discord, - DiscordHookProps.ONLINE_ALERT, - "Server Wrapper Settings", - "Server wrapper settings have been updated.\n\n${performRestart ? "A restart has been requested" : "A restart is not needed"}"); + DiscordHookHelper.sendWebHook( + settings.inst!.discord, + DiscordHookProps.ONLINE_ALERT, + "Server Wrapper Settings", + "Server wrapper settings have been updated.\n\n${performRestart ? "A restart has been requested" : "A restart is not needed"}"); + if (!performRestart) { return PacketResponse.nil; } diff --git a/lib/pages/home.dart b/lib/pages/home.dart index 8b149f6..6bbe22e 100644 --- a/lib/pages/home.dart +++ b/lib/pages/home.dart @@ -17,7 +17,7 @@ class HomePage extends StatefulWidget { class HomePageState extends State { Settings settings = Settings(); - bool requireRestart=false; + bool requireRestart = false; HomePageState({required this.settings}); @@ -113,23 +113,29 @@ class HomePageState extends State { C2SUploadSettingsPacket upload = C2SUploadSettingsPacket(); upload.srvSettings = settings.serialize(); - upload.performRestart=requireRestart; + upload.performRestart = requireRestart; - await settings.client!.send(upload, false); + await settings.client!.send(upload, !requireRestart); Settings.Clear(); setState(() {}); - if(requireRestart) { + if (requireRestart) { Navigator.pop(context); } }, + ), + SwitchListTile( + value: requireRestart, + onChanged: (V) { + setState(() { + requireRestart = V; + }); + }, + title: Text("Perform Restart"), + subtitle: Text( + "Whether a immediate server restart should be performed in combination with this wrapper settings update"), ) - , SwitchListTile(value: requireRestart, onChanged: (V) { - setState(() { - requireRestart = V; - }); - }, title: Text("Perform Restart"), subtitle: Text("Whether a immediate server restart should be performed in combination with this wrapper settings update"),) ], )), ); diff --git a/pubspec.yaml b/pubspec.yaml index c29d06b..c094963 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+34 +version: 1.1.0+35 environment: sdk: '>=3.1.4 <4.0.0'