Skip to content

Commit

Permalink
feat: priority order for plugin version
Browse files Browse the repository at this point in the history
  • Loading branch information
KillStr3aK committed Oct 10, 2024
1 parent 748c9cd commit 0b2d9a1
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion managed/CounterStrikeSharp.API/Core/Plugin/PluginContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,26 @@ public void Load(bool hotReload = false)

if (Plugin == null) throw new Exception("Unable to create plugin instance");

/* Version Priority order:
* ModuleVersion override
* Assembly.GetName().Version
* "<unknown>"
*/
if (Plugin is BasePlugin basePlugin)
{
// if no override we look for assembly version
if (basePlugin._version == "<unknown>")
{
Version? assemblyVersion = defaultAssembly.GetName().Version;

// if its set, we use that, otherwise it remains "<unknown>"
if (assemblyVersion != null)
{
basePlugin._version = assemblyVersion.ToString();
}
}
}

State = PluginState.Loading;

Plugin.ModulePath = _path;
Expand Down Expand Up @@ -241,4 +261,4 @@ public void Unload(bool hotReload = false)
_logger.LogInformation("Finished unloading plugin {Name}", cachedName);
}
}
}
}

0 comments on commit 0b2d9a1

Please sign in to comment.