public void InitPlugin( Guid key )
{
if ( PluginStates.ContainsKey( key ) )
return;
String pluginPath = _pluginPaths[ key ];
ApplicationLog.BaseLog.Info( "Initializing plugin at {0} - {1}'", pluginPath, key );
try
{
IPlugin plugin = Plugins[ key ];
if ( plugin.Name == "Dedicated Server Essentials" )
{
FieldInfo memberInfo = plugin.GetType().GetField( "StableBuild", BindingFlags.Static | BindingFlags.Public );
if (memberInfo != null)
{
bool pluginStable = (bool)memberInfo.GetValue(null);
if (!pluginStable && IsStable)
{
ApplicationLog.Error("WARNING: This version of Essentials is NOT compatible with \"stable\" branch!");
ApplicationLog.Error("Aborting plugin initialization!");
if (SystemInformation.UserInteractive)
{
MessageBox.Show("WARNING: This version of Essentials is NOT compatible with \"stable\" branch!\r\n" +
"Essentials will not load!",
"FATAL ERROR", MessageBoxButtons.OK);
}
return;
}
else if (pluginStable && !IsStable)
{
ApplicationLog.Error("WARNING: This version of Essentials is NOT compatible with \"dev\" branch!");
ApplicationLog.Error("Aborting plugin initialization!");
if (SystemInformation.UserInteractive)
{
MessageBox.Show("WARNING: This version of Essentials is NOT compatible with \"dev\" branch!\r\n" +
"Essentials will not load!",
"FATAL ERROR", MessageBoxButtons.OK);
}
return;
}
}
}
FieldInfo logField = plugin.GetType( ).GetField( "Log" );
if ( logField != null )
{
logField.SetValue( plugin, ApplicationLog.PluginLog, BindingFlags.Static, null, CultureInfo.CurrentCulture );
}
MethodInfo initMethod = plugin.GetType( ).GetMethod( "InitWithPath" );
if ( initMethod != null )
{
initMethod.Invoke( plugin, new object[ ] { pluginPath } );
}
if ( initMethod == null )
{
initMethod = plugin.GetType( ).GetMethod( "Init" );
initMethod.Invoke( plugin, new object[ ] { } );
}
PluginStates.Add( key, true );
}
catch ( Exception ex )
{
ApplicationLog.BaseLog.Error( ex );
}
}