Skip to content

Commit

Permalink
Remove watermark
Browse files Browse the repository at this point in the history
  • Loading branch information
sailro committed Feb 7, 2025
1 parent 9a71aa9 commit 15eefde
Showing 1 changed file with 29 additions and 7 deletions.
36 changes: 29 additions & 7 deletions BepInExPlugin/AkiEftTrainerPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,43 @@ public void Awake()
Loader.Load();
Loaded = true;

WhitelistThisPlugin();
HandleSptAkiBetaReleases();
}

private static void WhitelistThisPlugin()
[UsedImplicitly]
public void OnGUI()
{
if (_commitHash == null)
return;

var hash = _commitHash.GetValue(null) as string;
if (hash == string.Empty)
{
// Stop monitoring
_commitHash = null;
return;
}

// Suppress this dumb watermark
_commitHash.SetValue(null, string.Empty);
}

private static FieldInfo _commitHash;
private static void HandleSptAkiBetaReleases()
{
// Whitelist this plugin for spt-aki beta releases
var type = Type.GetType("SPT.Custom.Utils.MenuNotificationManager, spt-custom", throwOnError: false);
if (type == null)
var menuNotificationManager = Type.GetType("SPT.Custom.Utils.MenuNotificationManager, spt-custom", throwOnError: false);
if (menuNotificationManager == null)
return;

var field = type.GetField("whitelistedPlugins", BindingFlags.NonPublic | BindingFlags.Static);
if (field == null)
var hashField = menuNotificationManager.GetField("whitelistedPlugins", BindingFlags.NonPublic | BindingFlags.Static);
if (hashField == null)
return;

var hashset = field.GetValue(null) as HashSet<string>;
var hashset = hashField.GetValue(null) as HashSet<string>;
hashset?.Add(PluginId);

_commitHash = menuNotificationManager.GetField("commitHash", BindingFlags.Public | BindingFlags.Static);

}
}

0 comments on commit 15eefde

Please sign in to comment.