Fix the perform restart settings flag not getting honored.

This commit is contained in:
zontreck 2024-07-02 16:19:09 -07:00
parent 825830dcad
commit c57382dfa4
3 changed files with 26 additions and 17 deletions

View file

@ -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"}");
if (!performRestart) {
return PacketResponse.nil;
}

View file

@ -17,7 +17,7 @@ class HomePage extends StatefulWidget {
class HomePageState extends State<HomePage> {
Settings settings = Settings();
bool requireRestart=false;
bool requireRestart = false;
HomePageState({required this.settings});
@ -113,23 +113,29 @@ class HomePageState extends State<HomePage> {
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) {
),
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"),)
},
title: Text("Perform Restart"),
subtitle: Text(
"Whether a immediate server restart should be performed in combination with this wrapper settings update"),
)
],
)),
);

View file

@ -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'