Send a webhook alert when restart is required for mod list changes

This commit is contained in:
zontreck 2024-11-23 16:00:04 -07:00
parent 5be57fbca5
commit d64a34605c
6 changed files with 25 additions and 4 deletions

View file

@ -1,3 +1,3 @@
class Consts { class Consts {
static const VERSION = "1.1.112324.1308"; static const VERSION = "1.1.112324.1559";
} }

View file

@ -353,6 +353,16 @@ class C2SUploadSettingsPacket implements IPacket {
if (!performRestart) { if (!performRestart) {
return PacketResponse.nil; return PacketResponse.nil;
} else {
// Send a webhook with all the mods listed
String modListText = "";
for (var entry in settings.inst!.mods) {
modListText += "${entry.mod_name}\n";
}
modListText = modListText.trim();
DiscordHookHelper.sendWebHook(settings.inst!.discord,
DiscordHookProps.INACTIVE, "Mod List Updated", modListText);
} }
// Check if server is running, if not, stop immediately // Check if server is running, if not, stop immediately

View file

@ -55,6 +55,8 @@ class ModManagerState extends State<ModManager> {
i++; i++;
} while (i < end - oldIndex); } while (i < end - oldIndex);
settings.inst!.mods[end] = item; settings.inst!.mods[end] = item;
settings.restartRequired = true;
} else if (oldIndex > newIndex) { } else if (oldIndex > newIndex) {
//From bottom to top //From bottom to top
Mod item = settings.inst!.mods[oldIndex]; Mod item = settings.inst!.mods[oldIndex];
@ -62,6 +64,8 @@ class ModManagerState extends State<ModManager> {
settings.inst!.mods[i] = settings.inst!.mods[i - 1]; settings.inst!.mods[i] = settings.inst!.mods[i - 1];
} }
settings.inst!.mods[newIndex] = item; settings.inst!.mods[newIndex] = item;
settings.restartRequired = true;
} }
setState(() { setState(() {
settings.Write(); settings.Write();
@ -92,11 +96,14 @@ class ModManagerState extends State<ModManager> {
if (MERA.delete) { if (MERA.delete) {
setState(() { setState(() {
settings.inst!.mods.removeAt(idx); settings.inst!.mods.removeAt(idx);
settings.restartRequired = true;
}); });
return; return;
} }
setState(() { setState(() {
settings.inst!.mods[idx] = MERA.mod!; settings.inst!.mods[idx] = MERA.mod!;
settings.restartRequired = true;
}); });
} }
}, },
@ -117,6 +124,8 @@ class ModManagerState extends State<ModManager> {
setState(() { setState(() {
settings.inst!.mods.add(MERA.mod!); settings.inst!.mods.add(MERA.mod!);
settings.restartRequired = true;
}); });
} }
}, },

View file

@ -141,7 +141,7 @@ class HomePageState extends State<HomePage> {
}, },
), ),
SwitchListTile( SwitchListTile(
value: requireRestart, value: requireRestart || settings.restartRequired,
onChanged: (V) { onChanged: (V) {
setState(() { setState(() {
requireRestart = V; requireRestart = V;
@ -149,7 +149,7 @@ class HomePageState extends State<HomePage> {
}, },
title: Text("Perform Restart"), title: Text("Perform Restart"),
subtitle: Text( subtitle: Text(
"Whether a immediate server restart should be performed in combination with this wrapper settings update"), "Whether a immediate server restart should be performed in combination with this wrapper settings update${settings.restartRequired ? "\n** A RESTART IS REQUIRED DUE TO MOD LIST CHANGES" : ""}"),
) )
], ],
)), )),

View file

@ -45,6 +45,8 @@ class Settings {
StateMachine subsys = StateMachine(); StateMachine subsys = StateMachine();
bool restartRequired = false;
factory Settings() { factory Settings() {
return Instance; return Instance;
} }

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 # 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 # 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. # of the product and file versions while build-number is used as the build suffix.
version: 1.1.112324+1308 version: 1.1.112324+1559
environment: environment:
sdk: ">=3.1.4 <4.0.0" sdk: ">=3.1.4 <4.0.0"