Skip to content

Commit 9ca4ff3

Browse files
committed
Call Init before auto patching Harmony patches
1 parent e80e08f commit 9ca4ff3

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

src/Plugins/CSPlugin.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,20 @@ public override void HandleAddedToManager(PluginManager manager)
125125
Subscribe(hookname);
126126
}
127127

128+
try
129+
{
130+
// Let the plugin know that it is loading
131+
OnCallHook("Init", null);
132+
}
133+
catch (Exception ex)
134+
{
135+
Interface.Oxide.LogException($"Failed to initialize plugin '{Name} v{Version}'", ex);
136+
if (Loader != null)
137+
{
138+
Loader.PluginErrors[Name] = ex.Message;
139+
}
140+
}
141+
128142
// Find all classes with the AutoPatch attribute and apply the patches
129143
foreach (Type nestedType in GetType().GetNestedTypes(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static))
130144
{
@@ -154,20 +168,6 @@ public override void HandleAddedToManager(PluginManager manager)
154168
Interface.Oxide.LogException($"[{Title}] Failed to automatically Harmony patch '{nestedType.Name}'", ex);
155169
}
156170
}
157-
158-
try
159-
{
160-
// Let the plugin know that it is loading
161-
OnCallHook("Init", null);
162-
}
163-
catch (Exception ex)
164-
{
165-
Interface.Oxide.LogException($"Failed to initialize plugin '{Name} v{Version}'", ex);
166-
if (Loader != null)
167-
{
168-
Loader.PluginErrors[Name] = ex.Message;
169-
}
170-
}
171171
}
172172

173173
/// <summary>

0 commit comments

Comments
 (0)