Skip to content

Commit 2d9e121

Browse files
Add GetPluginErrors helper method & refactor plugin errors
1 parent fff9722 commit 2d9e121

3 files changed

Lines changed: 15 additions & 4 deletions

File tree

src/OxideMod.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ public bool PluginLoaded(Plugin plugin)
509509
{
510510
if (plugin.Loader != null)
511511
{
512-
plugin.Loader.PluginErrors[plugin.Name] = ex.Message;
512+
plugin.Loader.GetPluginErrors(plugin.Name).Add(ex.Message);
513513
}
514514

515515
LogException($"Could not initialize plugin '{plugin.Name} v{plugin.Version}'", ex);

src/Plugins/CSPlugin.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public override void HandleAddedToManager(PluginManager manager)
135135
Interface.Oxide.LogException($"Failed to initialize plugin '{Name} v{Version}'", ex);
136136
if (Loader != null)
137137
{
138-
Loader.PluginErrors[Name] = ex.Message;
138+
Loader.GetPluginErrors(Name).Add(ex.Message);
139139
}
140140
}
141141

src/Plugins/PluginLoader.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ public abstract class PluginLoader
2222
public Dictionary<string, Plugin> LoadedPlugins = new Dictionary<string, Plugin>();
2323

2424
/// <summary>
25-
/// Stores the last error a plugin had while loading
25+
/// Stores the errors a plugin had while loading
2626
/// </summary>
27-
public Dictionary<string, string> PluginErrors { get; } = new Dictionary<string, string>();
27+
public Dictionary<string, HashSet<string>> PluginErrors { get; } = new Dictionary<string, HashSet<string>>();
2828

2929
/// <summary>
3030
/// Stores the names of core plugins which should never be unloaded
@@ -141,5 +141,16 @@ public virtual void Reload(string directory, string name)
141141
public virtual void Unloading(Plugin plugin)
142142
{
143143
}
144+
145+
public HashSet<string> GetPluginErrors(string name)
146+
{
147+
if (!PluginErrors.TryGetValue(name, out HashSet<string>? errors))
148+
{
149+
errors = new HashSet<string>();
150+
PluginErrors[name] = errors;
151+
}
152+
153+
return errors;
154+
}
144155
}
145156
}

0 commit comments

Comments
 (0)