Skip to content

Commit

Permalink
Unique keys
Browse files Browse the repository at this point in the history
  • Loading branch information
Caraxi committed Oct 12, 2023
1 parent ec208dd commit 6169166
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions TweakSystem/SubTweakManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ public override void Setup() {
try {
var tweak = (T) Activator.CreateInstance(t);
if (tweak == null) continue;
if (SimpleTweaksPlugin.Plugin.GetTweakById(tweak.Key) != null) {
SimpleLog.Warning($"Skipped loading tweak with from '{t.Namespace}.{t.Name}'. Tweak with key '{tweak.Key}' already loaded.");
continue;
}

var blacklistKey = tweak.Key;
if (tweak.Version > 1) blacklistKey += $"::{tweak.Version}";
if (PluginConfig.BlacklistedTweaks.Contains(blacklistKey)) {
Expand Down
5 changes: 5 additions & 0 deletions TweakSystem/TweakProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ public virtual void LoadTweaks() {
SimpleLog.Debug($"Initalizing Tweak: {t.Name}");
try {
var tweak = (BaseTweak) Activator.CreateInstance(t)!;
if (SimpleTweaksPlugin.Plugin.GetTweakById(tweak.Key) != null) {
SimpleLog.Warning($"Skipped loading tweak from class '{t.Namespace}.{t.Name}'. Tweak with key '{tweak.Key}' already loaded.");
continue;
}

tweak.InterfaceSetup(SimpleTweaksPlugin.Plugin, Service.PluginInterface, SimpleTweaksPlugin.Plugin.PluginConfig, this);
if (tweak.CanLoad) {
var blacklistKey = tweak.Key;
Expand Down

0 comments on commit 6169166

Please sign in to comment.