mirror of
https://github.com/BepInEx/BepInEx.git
synced 2026-10-20 01:46:13 +00:00
Add better error message for missing BepInPlugin attribute instead of a nullref
This commit is contained in:
1 parent
7649fd0fee
commit
7aa1fe32de
1 file changed
+9
-5
@@ -1,4 +1,5 @@
|
||||
using BepInEx.Bootstrap;
|
||||
using System;
|
||||
using BepInEx.Bootstrap;
|
||||
using BepInEx.Configuration;
|
||||
using BepInEx.Logging;
|
||||
using UnityEngine;
|
||||
@@ -25,12 +26,15 @@ namespace BepInEx
|
||||
/// </summary>
|
||||
public ConfigFile Config { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Create a new instance of a plugin and all of its tied in objects.
|
||||
/// </summary>
|
||||
protected BaseUnityPlugin()
|
||||
/// <summary>
|
||||
/// Create a new instance of a plugin and all of its tied in objects.
|
||||
/// </summary>
|
||||
/// <exception cref="InvalidOperationException">BepInPlugin attribute is missing.</exception>
|
||||
protected BaseUnityPlugin()
|
||||
{
|
||||
var metadata = MetadataHelper.GetMetadata(this);
|
||||
if(metadata == null)
|
||||
throw new InvalidOperationException("Can't create an instance of " + GetType().FullName + " because it inherits from BaseUnityPlugin and the BepInPlugin attribute is missing.");
|
||||
|
||||
if (Chainloader.PluginInfos.TryGetValue(metadata.GUID, out var info))
|
||||
Info = info;
|
||||
|
||||
Reference in new issue
Block a user