From ecfba32d366b9e137f179e142817263910efc8a9 Mon Sep 17 00:00:00 2001 From: moddedmcplayer <76910334+moddedmcplayer@users.noreply.github.com> Date: Tue, 18 Oct 2022 19:03:19 +0200 Subject: [PATCH] remove hat when 268 --- hats/Config.cs | 1 + hats/EventHandler.cs | 13 +++++++++++++ hats/Plugin.cs | 6 ++++-- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/hats/Config.cs b/hats/Config.cs index bc08885..1175170 100644 --- a/hats/Config.cs +++ b/hats/Config.cs @@ -14,6 +14,7 @@ public class Config : IConfig public bool ShowHatToOwnerIfRoleHideHatAndHideHatToOwnerFalse { get; set; } = true; public bool AllowGetHatToRemoveHat { get; set; } = true; public bool TrimHatNamesInGetHat { get; set; } = true; + public bool RemoveHatWhenUsing268 { get; set; } = true; public string CommandPrefix { get; set; } = "hatplugin"; public List RolesToHideHatFrom { get; set; } = new List() diff --git a/hats/EventHandler.cs b/hats/EventHandler.cs index 25d8814..790cc55 100644 --- a/hats/EventHandler.cs +++ b/hats/EventHandler.cs @@ -36,5 +36,18 @@ public void OnLeave(LeftEventArgs ev) if(ev.Player.GameObject.TryGetComponent(out _)) ev.Player.RemoveHat(); } + + public void UsedItem(UsedItemEventArgs ev) + { + if(!cfg.RemoveHatWhenUsing268) + return; + if (ev.Item.Type != ItemType.SCP268) + return; + if (ev.Player.GameObject.TryGetComponent(out _)) + { + ev.Player.RemoveHat(); + ev.Player.ShowHint("Removed hat since you used 268."); + } + } } } \ No newline at end of file diff --git a/hats/Plugin.cs b/hats/Plugin.cs index 51c1d60..0bcca29 100644 --- a/hats/Plugin.cs +++ b/hats/Plugin.cs @@ -11,7 +11,7 @@ public class Plugin : Plugin { public override string Author { get; } = "Rowpann SCP"; public override string Name { get; } = "hats"; - public override Version Version { get; } = new Version(1, 4, 2); + public override Version Version { get; } = new Version(1, 4, 3); public override Version RequiredExiledVersion { get; } = new Version(5, 2, 0); public static Plugin Singleton; @@ -27,6 +27,7 @@ public override void OnEnabled() Server.WaitingForPlayers += Handler.WaitingForPlayers; Player.Left += Handler.OnLeave; Player.Died += Handler.Died; + Player.UsedItem += Handler.UsedItem; base.OnEnabled(); } @@ -36,7 +37,8 @@ public override void OnDisabled() Server.WaitingForPlayers -= Handler.WaitingForPlayers; Player.Left -= Handler.OnLeave; Player.Died -= Handler.Died; - + Player.UsedItem -= Handler.UsedItem; + Singleton = null; Handler = null; hats = null;