/// <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; } else { Info = new PluginInfo { Metadata = metadata, Instance = this, Dependencies = MetadataHelper.GetDependencies(GetType()), Processes = MetadataHelper.GetAttributes <BepInProcess>(GetType()), Location = GetType().Assembly.Location }; } Logger = Logging.Logger.CreateLogSource(metadata.Name); Config = new ConfigFile(Utility.CombinePaths(Paths.ConfigPath, metadata.GUID + ".cfg"), false, metadata); }
/// <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."); } Info = new PluginInfo { Metadata = metadata, Instance = this, Dependencies = MetadataHelper.GetDependencies(GetType()), Processes = MetadataHelper.GetAttributes <BepInProcess>(GetType()), Location = GetType().Assembly.Location }; Logger = Logging.Logger.CreateLogSource(metadata.Name); if (this.GetType().GetCustomAttributes(typeof(BepInConfigType), true).FirstOrDefault() is BepInConfigType configTypeAttribute) { Config = (ConfigFile)Activator.CreateInstance(configTypeAttribute.ConfigFileType, new object[] { Utility.CombinePaths(Paths.ConfigPath, metadata.GUID + ".cfg"), false, metadata }); } else { Config = new ConfigFile(Utility.CombinePaths(Paths.ConfigPath, metadata.GUID + ".cfg"), false, metadata); } }
protected BaseUnityPlugin() { var metadata = MetadataHelper.GetMetadata(this); Logger = Logging.Logger.CreateLogSource(metadata.Name); Config = new ConfigFile(Utility.CombinePaths(Paths.ConfigPath, metadata.GUID + ".cfg"), false); }
protected BaseUnityPlugin() { var metadata = MetadataHelper.GetMetadata(this); if (Chainloader.PluginInfos.TryGetValue(metadata.GUID, out var info)) { Info = info; } else { Info = new PluginInfo { Metadata = metadata, Instance = this, Dependencies = MetadataHelper.GetDependencies(GetType()), Processes = MetadataHelper.GetAttributes <BepInProcess>(GetType()), Location = GetType().Assembly.Location }; } Logger = Logging.Logger.CreateLogSource(metadata.Name); Config = new ConfigFile(Utility.CombinePaths(Paths.ConfigPath, metadata.GUID + ".cfg"), false); }
public ConfigWrapper(string key, BaseUnityPlugin plugin, IConfigConverter <T> converter, T @default = default(T)) : this(key, converter.ConvertFromString, converter.ConvertToString, @default) { Section = MetadataHelper.GetMetadata(plugin).GUID; }
public ConfigWrapper(string key, BaseUnityPlugin plugin, Func <string, T> strToObj, Func <T, string> objToStr, T @default = default(T)) : this(key, strToObj, objToStr, @default) { Section = MetadataHelper.GetMetadata(plugin).GUID; }
public ConfigWrapper(string key, BaseUnityPlugin plugin, T @default = default(T)) : this(key, @default) { Section = MetadataHelper.GetMetadata(plugin).GUID; }
protected BaseUnityPlugin() { var metadata = MetadataHelper.GetMetadata(this); Logger = Logging.Logger.CreateLogSource(metadata.Name); }
public static bool HasEntry(this BaseUnityPlugin plugin, string key) { return(HasEntry(key, MetadataHelper.GetMetadata(plugin).GUID)); }
public static void SetEntry(this BaseUnityPlugin plugin, string key, string value) { SetEntry(key, value, MetadataHelper.GetMetadata(plugin).GUID); }
public static string GetEntry(this BaseUnityPlugin plugin, string key, string defaultValue = "") { return(GetEntry(key, defaultValue, MetadataHelper.GetMetadata(plugin).GUID)); }