Skip to content

Commit

Permalink
remove hat when 268
Browse files Browse the repository at this point in the history
  • Loading branch information
moddedmcplayer committed Oct 18, 2022
1 parent 6131524 commit ecfba32
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions hats/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<RoleType> RolesToHideHatFrom { get; set; } = new List<RoleType>()
Expand Down
13 changes: 13 additions & 0 deletions hats/EventHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,18 @@ public void OnLeave(LeftEventArgs ev)
if(ev.Player.GameObject.TryGetComponent<HatComponent>(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<HatComponent>(out _))
{
ev.Player.RemoveHat();
ev.Player.ShowHint("Removed hat since you used 268.");
}
}
}
}
6 changes: 4 additions & 2 deletions hats/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class Plugin : Plugin<Config>
{
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;
Expand All @@ -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();
}
Expand All @@ -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;
Expand Down

0 comments on commit ecfba32

Please sign in to comment.