Skip to content

Commit

Permalink
[+] Hook force offline in DisableReboot
Browse files Browse the repository at this point in the history
  • Loading branch information
Menci committed Jan 17, 2025
1 parent a8ecf06 commit 5109ae1
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions AquaMai.Mods/Fix/DisableReboot.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
using System.Linq;
using System.Reflection;
using AquaMai.Config.Attributes;
using AquaMai.Core.Attributes;
using HarmonyLib;
using Manager.Operation;
using MelonLoader;

namespace AquaMai.Mods.Fix;

[ConfigSection(exampleHidden: true, defaultOn: true)]
public class DisableReboot
{
private static bool forceOfflineTimerExists = false;

public static void OnBeforePatch()
{
forceOfflineTimerExists = typeof(MaintenanceTimer).GetProperty(
"ForceOfflineRemainingMinutes",
BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic) != null;
}

// IsAutoRebootNeeded
[HarmonyPrefix]
[HarmonyPatch(typeof(MaintenanceTimer), "IsAutoRebootNeeded")]
Expand Down Expand Up @@ -84,4 +97,13 @@ public static bool IsClosed(ref bool __result)
__result = false;
return false;
}

[EnableIf(nameof(forceOfflineTimerExists))]
[HarmonyPrefix]
[HarmonyPatch(typeof(MaintenanceTimer), "ForceOfflineRemainingMinutes", MethodType.Getter)]
public static bool ForceOfflineRemainingMinutes(ref int __result)
{
__result = 600;
return false;
}
}

0 comments on commit 5109ae1

Please sign in to comment.