using System; using System.Linq; using System.Reflection; using System.Collections.Generic; using UnityEngine; using Oxide.Core; using Oxide.Core.Plugins; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Facepunch; using Rust; #region Changelogs and ToDo /********************************************************************** * * 1.0.0 : - Initial release version. * 1.0.1 : - Added More trees to the list * - Fix for messages on pickup * 1.0.2 : - hotfix * 1.0.3 : - Simplified Tree checks * - Optimised Permission checks * - Optimised Debug message system * - Optimised chat message system * 1.1.0 : - Reworked the Pickup rewards code block * 1.2.0 : - Blocked triggers if harvestable is not atleast Mature * - Added Profile use true/false and wil unsubscribe too their hooks if false (performance) * * Notes : - roadsigns do not trigger on OnDispenserGather only on OnEntityDeath * **********************************************************************/ #endregion namespace Oxide.Plugins { [Info("GatherBonus", "Krungh Crow", "1.2.0")] [Description("Get a random item doing gathering actions")] class GatherBonus : RustPlugin { #region Variables const string Bonus_Perm = "gatherbonus.bonus"; const string Harvest_Perm = "gatherbonus.harvest"; const string HarvestCorpse_Perm = "gatherbonus.corpse"; const string Pickup_Perm = "gatherbonus.pickup"; const string Chat_Perm = "gatherbonus.chat"; ulong chaticon = 0; string prefix; Item bonus; string _Node; string _Pickup; bool Debug = false; bool SendMsg; bool IsSeed = false; bool CanGive = false; bool IsNode; bool IsHarvested; bool IsCorpse; #endregion #region Configuration void Init() { if (!LoadConfigVariables()) { Puts("Config file issue detected. Please delete file, or check syntax and fix."); return; } permission.RegisterPermission(Chat_Perm, this); permission.RegisterPermission(Bonus_Perm, this); permission.RegisterPermission(Harvest_Perm, this); permission.RegisterPermission(HarvestCorpse_Perm, this); permission.RegisterPermission(Pickup_Perm, this); Debug = configData.PlugCFG.Debug; SendMsg = configData.PlugCFG.UseMsg; prefix = configData.PlugCFG.Prefix; if (Debug) Puts($"[Debug] trigger for Debug is true"); CheckSubscriptions(); } private ConfigData configData; class ConfigData { [JsonProperty(PropertyName = "Main config")] public SettingsPlugin PlugCFG = new SettingsPlugin(); [JsonProperty(PropertyName = "GatherBonus Profile")] public bool GatherUse = true; [JsonProperty(PropertyName = "Pickup Profile")] public bool PickupUse = true; [JsonProperty(PropertyName = "Harvest Profile")] public bool HarvestUse = true; [JsonProperty(PropertyName = "Drop Chance on GatherBonus (0.0-1.0)")] public DropRates DropRateBonus = new DropRates(); [JsonProperty(PropertyName = "Drop Chance on Pickup (0.0-1.0)")] public DropRatesPU DropRatePickup = new DropRatesPU(); [JsonProperty(PropertyName = "Drop Chance on Crops Harvest (0.0-1.0)")] public DropRatesHar DropRateHarvest = new DropRatesHar(); [JsonProperty(PropertyName = "Drop Chance on Animal Corpse Harvest (0.0-1.0)")] public DropRatesCorpse DropRateHarvestCorpse = new DropRatesCorpse(); [JsonProperty(PropertyName = "Reward Item setup")] public ItemList ItemCFG = new ItemList(); } class SettingsPlugin { [JsonProperty(PropertyName = "Debug")] public bool Debug = false; [JsonProperty(PropertyName = "Use Chat messages")] public bool UseMsg = true; [JsonProperty(PropertyName = "Chat Prefix")] public string Prefix = "[GBonus] : "; } class DropRates//Bonus { [JsonProperty(PropertyName = "Cactus")] public float Cactus = 1f; [JsonProperty(PropertyName = "Driftwood")] public float Driftwood = 1f; [JsonProperty(PropertyName = "Roadsigns")] public float Roadsigns = 1f; [JsonProperty(PropertyName = "Tree")] public float Tree = 1f; [JsonProperty(PropertyName = "Metal Node")] public float MetalNode = 1f; [JsonProperty(PropertyName = "Stone Node")] public float StoneNode = 1f; [JsonProperty(PropertyName = "Sulfur Node")] public float SulfurNode = 1f; } class DropRatesPU//Pickup { [JsonProperty(PropertyName = "Hemp")] public float Hemp = 1f; [JsonProperty(PropertyName = "Wood")] public float Wood = 1f; [JsonProperty(PropertyName = "Stone")] public float Stone = 1f; [JsonProperty(PropertyName = "Sulfur")] public float Sulfur = 1f; [JsonProperty(PropertyName = "metal")] public float Metal = 1f; [JsonProperty(PropertyName = "Mushroom")] public float Mushroom = 1f; [JsonProperty(PropertyName = "Bones")] public float Bones = 1f; [JsonProperty(PropertyName = "Corn")] public float Corn = 1f; [JsonProperty(PropertyName = "Pumpkin")] public float Pumpkin = 1f; [JsonProperty(PropertyName = "Potato")] public float Potato = 1f; [JsonProperty(PropertyName = "Berries")] public float Berries = 1f; } class DropRatesHar//Harvest crops { [JsonProperty(PropertyName = "Hemp")] public float Hemp = 1f; [JsonProperty(PropertyName = "Corn")] public float Corn = 1f; [JsonProperty(PropertyName = "Pumpkin")] public float Pumpkin = 1f; [JsonProperty(PropertyName = "Potato")] public float Potato = 1f; [JsonProperty(PropertyName = "Berries")] public float Berries = 1f; } class DropRatesCorpse//Harvest Animal Corpse { [JsonProperty(PropertyName = "Bear")] public float Bear = 1f; [JsonProperty(PropertyName = "Boar")] public float Boar= 1f; [JsonProperty(PropertyName = "Chicken")] public float Chicken = 1f; [JsonProperty(PropertyName = "Horse")] public float Horse = 1f; [JsonProperty(PropertyName = "Shark")] public float Shark = 1f; [JsonProperty(PropertyName = "Stag")] public float Stag = 1f; [JsonProperty(PropertyName = "Wolf")] public float Wolf = 1f; } class ItemList { [JsonProperty(PropertyName = "Items From Gathering (shortname)")] public List RewardItems = new List(); [JsonProperty(PropertyName = "Items From Pickup (shortname)")] public List RewardItemsPU = new List(); [JsonProperty(PropertyName = "Items From Harvesting Crops (shortname)")] public List RewardItemsHar = new List(); [JsonProperty(PropertyName = "Items From Harvesting Animal Corpses (shortname)")] public List RewardItemsHarCorpse = new List(); } private bool LoadConfigVariables() { try { configData = Config.ReadObject(); } catch { return false; } SaveConf(); return true; } protected override void LoadDefaultConfig() { Puts("Fresh install detected Creating a new config file."); configData = new ConfigData(); #region Default item lists configData.ItemCFG.RewardItems = new List { {"radiationresisttea"}, {"healingtea"}, {"maxhealthtea"}, {"oretea"}, {"tarp"}, {"scraptea"}, {"woodtea"}, {"apple"}, {"black.raspberries"}, {"fish.cooked"} }; configData.ItemCFG.RewardItemsPU = new List { {"fish.minnows"}, {"fun.guitar"}, {"antiradpills"}, {"bandage"}, {"hat.cap"}, {"beachtable"}, {"beachchair"}, {"beachparasol"}, {"beachtowel"}, {"cakefiveyear"} }; configData.ItemCFG.RewardItemsHar = new List { {"worm"}, {"fishtrap.small"}, {"grub"}, {"syringe.medical"}, {"hat.boonie"}, {"fishingrod.handmade"}, {"scarecrow"}, {"skull_fire_pit"}, {"spookyspeaker"}, {"hat.bunnyhat"} }; configData.ItemCFG.RewardItemsHarCorpse = new List { {"ammo.shotgun"}, {"ammo.shotgun.fire"}, {"ammo.shotgun.slug"}, {"ammo.handmade.shell"}, {"attire.hide.boots"}, {"attire.hide.helterneck"}, {"attire.hide.pants"}, {"attire.hide.poncho"}, {"attire.hide.skirt"}, {"attire.hide.vest"} }; #endregion SaveConf(); } void SaveConf() => Config.WriteObject(configData, true); #endregion #region LanguageAPI protected override void LoadDefaultMessages() { lang.RegisterMessages(new Dictionary { ["Info"] = "\nAvailable Commands\n/gatherbonus info : Shows info on version/author and commands", ["InvalidInput"] = "Please enter a valid command!", ["NoPermission"] = "You do not have permission to use that command!", ["ItemReward"] = "You found a {0} around a {1}", ["ItemRewardPickup"] = "You picked up {0} and found a {1}", ["ItemRewardHarvest"] = "{0} harvested and found a {1}", ["Version"] = "Version : V", }, this); } #endregion #region Commands [ChatCommand("gatherbonus")] private void cmdGatherBonus(BasePlayer player, string command, string[] args) { if(!HasPerm(player , Chat_Perm)) { Player.Message(player, string.Format(msg("NoPermission")), chaticon); Debugmsg($"{player} has no {Chat_Perm} permission for using Commands"); return; } if (args.Length == 0) { Player.Message(player, string.Format(msg("InvalidInput")), chaticon); } else { if (args[0].ToLower() == "info") { Player.Message(player, string.Format(msg("Version")) + this.Version.ToString() + " By : " + this.Author.ToString() + msg("Info") , chaticon); return; } else { Player.Message(player, string.Format(msg("InvalidInput")), chaticon); } } } #endregion #region Hooks #region On Gather and Bonus void OnEntityDeath(BaseEntity entity, HitInfo info)//bonus { if (info?.Initiator == null) return; BasePlayer player = info.InitiatorPlayer; if (player == null || !player.IsValid() || entity == null || !permission.UserHasPermission(player.UserIDString, Bonus_Perm)) return; if (!entity.PrefabName.ToString().Contains("roadsign")) return; CanGive = false; try { if (UnityEngine.Random.Range(0f, 1f) <= configData.DropRateBonus.Roadsigns) { _Node = "Roadsign"; CanGive = true; Debugmsg($"{_Node} was depleted"); } if (!CanGive) return; bonus = ItemManager.CreateByName("healingtea.advanced", 1); if (CanGive) { if (configData.ItemCFG.RewardItems.Count != 0) { string RandomItem = configData.ItemCFG.RewardItems[new System.Random().Next(configData.ItemCFG.RewardItems.Count())]; bonus = ItemManager.CreateByName($"{RandomItem}", 1, 0); } bonus.MarkDirty(); player.inventory.GiveItem(bonus, null); var _rewardedItem = (bonus.info.displayName.english); if (player.inventory.containerMain.IsFull()) { bonus.DropAndTossUpwards(player.transform.position); } if (SendMsg) Player.Message(player, "" + string.Format(msg($"ItemReward") + "", _rewardedItem, _Node), chaticon); Debugmsg($"{player} recieved a [{_rewardedItem}] from a {_Node}"); return; } return; } catch { } if (!CanGive) return; CanGive = false; } void OnDispenserGather(ResourceDispenser dispenser, BaseEntity entity, Item item)//bonus { BasePlayer player = entity.ToPlayer(); if (player == null || !player.IsValid()) return; var ent = dispenser.GetComponent(); CanGive = false; if (ent != null && (ent.name.ToString().Contains("cactus") && HasPerm(player, Bonus_Perm) && UnityEngine.Random.Range(0f, 1f) <= configData.DropRateBonus.Cactus)) { NextTick(() => { if (ent != null) return; _Node = "Cactus"; IsNode = true; CanGive = true; Debugmsg($"{_Node} was depleted"); }); } if (ent != null && (ent.name.ToString().Contains("driftwood") && HasPerm(player, Bonus_Perm) && UnityEngine.Random.Range(0f, 1f) <= configData.DropRateBonus.Driftwood)) { NextTick(() => { if (ent != null) return; _Node = "Driftwood"; IsNode = true; CanGive = true; Debugmsg($"{_Node} was depleted"); }); } if (ent != null && (ent.name.ToString().Contains("bear.corpse") && HasPerm(player, HarvestCorpse_Perm) && UnityEngine.Random.Range(0f, 1f) <= configData.DropRateHarvestCorpse.Bear)) { NextTick(() => { if (ent != null) return; _Node = "Bear Corpse"; IsCorpse = true; CanGive = true; Debugmsg($"{_Node} was depleted"); }); } if (ent != null && (ent.name.ToString().Contains("boar.corpse") && permission.UserHasPermission(player.UserIDString, HarvestCorpse_Perm) && UnityEngine.Random.Range(0f, 1f) <= configData.DropRateHarvestCorpse.Boar)) { NextTick(() => { if (ent != null) return; _Node = "Boar Corpse"; IsCorpse = true; CanGive = true; if (Debug) Puts($"[Debug] {_Node} was depleted"); }); } if (ent != null && (ent.name.ToString().Contains("chicken.corpse") && HasPerm(player, HarvestCorpse_Perm) && UnityEngine.Random.Range(0f, 1f) <= configData.DropRateHarvestCorpse.Chicken)) { NextTick(() => { if (ent != null) return; _Node = "Chicken Corpse"; IsCorpse = true; CanGive = true; Debugmsg($"{_Node} was depleted"); }); } if (ent != null && (ent.name.ToString().Contains("horse.corpse") && HasPerm(player, HarvestCorpse_Perm) && UnityEngine.Random.Range(0f, 1f) <= configData.DropRateHarvestCorpse.Horse)) { NextTick(() => { if (ent != null) return; _Node = "Horse Corpse"; IsCorpse = true; CanGive = true; Debugmsg($"{_Node} was depleted"); }); } if (ent != null && (ent.name.ToString().Contains("shark.corpse") && HasPerm(player, HarvestCorpse_Perm) && UnityEngine.Random.Range(0f, 1f) <= configData.DropRateHarvestCorpse.Shark)) { NextTick(() => { if (ent != null) return; _Node = "Shark Corpse"; IsCorpse = true; CanGive = true; Debugmsg($"{_Node} was depleted"); }); } if (ent != null && (ent.name.ToString().Contains("stag.corpse") && HasPerm(player, HarvestCorpse_Perm) && UnityEngine.Random.Range(0f, 1f) <= configData.DropRateHarvestCorpse.Stag)) { NextTick(() => { if (ent != null) return; _Node = "Stag Corpse"; IsCorpse = true; CanGive = true; Debugmsg($"{_Node} was depleted"); }); } if (ent != null && (ent.name.ToString().Contains("wolf.corpse") && HasPerm(player, HarvestCorpse_Perm) && UnityEngine.Random.Range(0f, 1f) <= configData.DropRateHarvestCorpse.Wolf)) { NextTick(() => { if (ent != null) return; _Node = "Wolf Corpse"; IsCorpse = true; CanGive = true; Debugmsg($"{_Node} was depleted"); }); } Debugmsg($"OnDispenserGather : Trigger on hit"); NextTick(() => { if (!CanGive) return; try { bonus = ItemManager.CreateByName("healingtea.advanced", 1); if (CanGive) { if (IsNode && configData.ItemCFG.RewardItems.Count != 0) { string RandomItem = configData.ItemCFG.RewardItems[new System.Random().Next(configData.ItemCFG.RewardItems.Count())]; bonus = ItemManager.CreateByName($"{RandomItem}", 1, 0); } if (IsCorpse && configData.ItemCFG.RewardItemsHarCorpse.Count != 0) { string RandomItem = configData.ItemCFG.RewardItemsHarCorpse[new System.Random().Next(configData.ItemCFG.RewardItemsHarCorpse.Count())]; bonus = ItemManager.CreateByName($"{RandomItem}", 1, 0); } bonus.MarkDirty(); player.inventory.GiveItem(bonus, null); var _rewardedItem = (bonus.info.displayName.english); if (player.inventory.containerMain.IsFull()) { bonus.DropAndTossUpwards(player.transform.position); } if (SendMsg) Player.Message(player, "" + string.Format(msg($"ItemReward") + "", _rewardedItem, _Node), chaticon); Debugmsg($"{player} recieved a [{_rewardedItem}] from a {_Node}"); CanGive = false; return; } return; } catch { } }); } object OnDispenserBonus(ResourceDispenser dispenser, BasePlayer player, Item item)//bonus { if (dispenser == null || player == null || item == null) return null; if (item.info.itemid == -1982036270) return null; if (CanGive == true) { Debugmsg($"BonusHit allready triggered"); return true; } if (!HasPerm(player, Bonus_Perm)) return null; if (dispenser.gatherType == ResourceDispenser.GatherType.Tree) { _Node = "Tree"; IsNode = true; CanGive = true; } if (dispenser.name.ToString().Contains("stone-ore") && UnityEngine.Random.Range(0f, 1f) <= configData.DropRateBonus.StoneNode) { _Node = "Stone Node"; IsNode = true; CanGive = true; } else if (dispenser.name.ToString().Contains("sulfur-ore") && UnityEngine.Random.Range(0f, 1f) <= configData.DropRateBonus.SulfurNode) { _Node = "Sulfur Node"; IsNode = true; CanGive = true; } if (dispenser.name.ToString().Contains("metal-ore") && UnityEngine.Random.Range(0f, 1f) <= configData.DropRateBonus.MetalNode) { _Node = "Metal Node"; IsNode = true; CanGive = true; } bonus = ItemManager.CreateByName("healingtea.advanced", 1); if(CanGive) { if (configData.ItemCFG.RewardItems.Count != 0) { string RandomItem = configData.ItemCFG.RewardItems[new System.Random().Next(configData.ItemCFG.RewardItems.Count())]; bonus = ItemManager.CreateByName($"{RandomItem}", 1, 0); } bonus.MarkDirty(); player.inventory.GiveItem(bonus, null); var _rewardedItem = (bonus.info.displayName.english); if (player.inventory.containerMain.IsFull()) { bonus.DropAndTossUpwards(player.transform.position); } if (SendMsg) Player.Message(player, "" + string.Format(msg($"ItemReward") + "", _rewardedItem, _Node), chaticon); Debugmsg($"{player} recieved a [{_rewardedItem}] from a {_Node}"); CanGive = false; return true; } return true; } #endregion #region On Pickup private void OnCollectiblePickup(CollectibleEntity item, BasePlayer player) { //Puts($"{item.ShortPrefabName.ToString()}"); if (item)// 1.2.0 test { Debugmsg($"OnCollectiblePickup pickup was {item}"); } if (item == null || player == null) return; if (!HasPerm(player, Pickup_Perm)) return; _Pickup = item.ShortPrefabName.ToString().ToLower(); if (_Pickup.Contains("hemp") && UnityEngine.Random.Range(0f, 1f) <= configData.DropRatePickup.Hemp) CanGive = true; if (_Pickup.Contains("wood") && UnityEngine.Random.Range(0f, 1f) <= configData.DropRatePickup.Wood) CanGive = true; if (_Pickup.Contains("stone") && UnityEngine.Random.Range(0f, 1f) <= configData.DropRatePickup.Stone) CanGive = true; if (_Pickup.Contains("sulfur") && UnityEngine.Random.Range(0f, 1f) <= configData.DropRatePickup.Sulfur) CanGive = true; if (_Pickup.Contains("metal") && UnityEngine.Random.Range(0f, 1f) <= configData.DropRatePickup.Metal) CanGive = true; if (_Pickup.Contains("mushroom") && UnityEngine.Random.Range(0f, 1f) <= configData.DropRatePickup.Mushroom) CanGive = true; if (_Pickup.Contains("bones") && UnityEngine.Random.Range(0f, 1f) <= configData.DropRatePickup.Bones) CanGive = true; if (_Pickup.Contains("corn") && UnityEngine.Random.Range(0f, 1f) <= configData.DropRatePickup.Corn) CanGive = true; if (_Pickup.Contains("pumpkin") && UnityEngine.Random.Range(0f, 1f) <= configData.DropRatePickup.Pumpkin) CanGive = true; if (_Pickup.Contains("potato") && UnityEngine.Random.Range(0f, 1f) <= configData.DropRatePickup.Potato) CanGive = true; if (_Pickup.Contains("berry") && UnityEngine.Random.Range(0f, 1f) <= configData.DropRatePickup.Berries) CanGive = true; if (CanGive) { bonus = ItemManager.CreateByName("healingtea.advanced", 1); if (configData.ItemCFG.RewardItemsPU.Count != 0) { string RandomItem = configData.ItemCFG.RewardItemsPU[new System.Random().Next(configData.ItemCFG.RewardItemsPU.Count())]; bonus = ItemManager.CreateByName($"{RandomItem}", 1, 0); } bonus.MarkDirty(); player.inventory.GiveItem(bonus, null); var _rewardedItem = (bonus.info.displayName.english); if (player.inventory.containerMain.IsFull()) { bonus.DropAndTossUpwards(player.transform.position); } if (SendMsg) Player.Message(player, "" + string.Format(msg($"ItemRewardPickup") +"", _Pickup, _rewardedItem), chaticon); Debugmsg($"{player} recieved a [{_rewardedItem}] from a {_Pickup}"); } if (!CanGive) Debugmsg($"Skipping pickup trigger"); CanGive = false; } #endregion #region On Harvest void OnGrowableGathered(GrowableEntity plant, Item item, BasePlayer player)//Harvest { if (plant == null || item == null || player == null) return; if (!HasPerm(player, Harvest_Perm)) return; if (plant) Debugmsg($"Gatherable plant was {plant} {plant.State}"); if ( plant && plant.State.ToString().Contains("Sapling")) return; CanGive = false; if (item.ToString().ToLower().Contains("cloth") && !CheckSeed(item) && UnityEngine.Random.Range(0f, 1f) <= configData.DropRateHarvest.Hemp) { Debugmsg($"{player} Harvested {item.amount} Hemp"); _Pickup = "Hemp"; CanGive = true; } if (item.info.shortname == "corn" && !CheckSeed(item) && UnityEngine.Random.Range(0f, 1f) <= configData.DropRateHarvest.Corn) { Debugmsg($"{player} Harvested {item.amount} Corn"); _Pickup = "Corn"; CanGive = true; } if (item.info.shortname == "pumpkin" && !CheckSeed(item) && UnityEngine.Random.Range(0f, 1f) <= configData.DropRateHarvest.Pumpkin) { Debugmsg($"{player} Harvested {item.amount} Pumpkins"); _Pickup = "Pumpkins"; CanGive = true; } if (item.info.shortname == "potato" && !CheckSeed(item) && UnityEngine.Random.Range(0f, 1f) <= configData.DropRateHarvest.Potato) { Debugmsg($"{player} Harvested {item.amount} Potatos"); _Pickup = "Potatos"; CanGive = true; } if (item.info.shortname == "black.berry" || item.info.shortname == "blue.berry" || item.info.shortname == "green.berry" || item.info.shortname == "red.berry" || item.info.shortname == "yellow.berry" || item.info.shortname == "white.berry" && !CheckSeed(item) && UnityEngine.Random.Range(0f, 1f) <= configData.DropRateHarvest.Berries) { _Pickup = item.info.displayName.english; CanGive = true; } if (!CheckSeed(item) && CanGive) { Debugmsg($"{player} has the {Bonus_Perm} Permission [pickup]"); bonus = ItemManager.CreateByName("healingtea.advanced", 1); if (configData.ItemCFG.RewardItemsHar.Count != 0) { string RandomItem = configData.ItemCFG.RewardItemsHar[new System.Random().Next(configData.ItemCFG.RewardItemsHar.Count())]; bonus = ItemManager.CreateByName($"{RandomItem}", 1, 0); } bonus.MarkDirty(); player.inventory.GiveItem(bonus, null); var _rewardedItem = (bonus.info.displayName.english); if (player.inventory.containerMain.IsFull()) { bonus.DropAndTossUpwards(player.transform.position); } if (!CheckSeed(item) && SendMsg) { Player.Message(player, "" + string.Format(msg($"ItemRewardHarvest") + "", _Pickup, _rewardedItem), chaticon); } Debugmsg($"Bonus item generated : [{_rewardedItem}]"); } if (!CheckSeed(item)) Debugmsg($"CanGive trigger = {CanGive}"); return; } #endregion #endregion #region Event Helpers private bool CheckSeed(Item item) { if (item.ToString().ToLower().Contains("seed") || item.ToString().ToLower().Contains("berry.seed")) { IsSeed = true; } else return false; return IsSeed; } bool HasPerm(BasePlayer player, string perm) { return permission.UserHasPermission(player.UserIDString, perm); } void CheckSubscriptions() { timer.Once(3f, () => { if (configData.HarvestUse == false) { Debugmsg($"Unsubscribed to OnGrowableGathered"); Unsubscribe(nameof(OnGrowableGathered)); } if (configData.GatherUse == false) { Debugmsg($"Unsubscribed to OnEntityDeath"); Unsubscribe(nameof(OnEntityDeath)); Debugmsg($"Unsubscribed to OnDispenserGather"); Unsubscribe(nameof(OnDispenserGather)); Debugmsg($"Unsubscribed to OnDispenserBonus"); Unsubscribe(nameof(OnDispenserBonus)); } if (configData.PickupUse == false) { Debugmsg($"Unsubscribed to OnCollectiblePickup"); Unsubscribe(nameof(OnCollectiblePickup)); } if (configData.PlugCFG.Debug == false) { Unsubscribe(nameof(Debugmsg)); } Puts("Checked Subscriptions"); }); } #endregion #region Message helper private string msg(string key, string id = null) => prefix + lang.GetMessage(key, this, id); void Debugmsg(string key) { if (Debug) Puts($"[Debug] {key}"); } #endregion }; }