Skip to content

Commit

Permalink
100% fixes all the problems
Browse files Browse the repository at this point in the history
  • Loading branch information
DentyTxR committed Jul 14, 2023
1 parent 24cc0d4 commit 034dd3f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 20 deletions.
34 changes: 15 additions & 19 deletions CuffUtilsNwAPI/EventHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,47 @@
using PluginAPI.Core;
using PluginAPI.Core.Attributes;
using PluginAPI.Enums;
using PluginAPI.Events;

namespace CuffUtilsNwAPI
{
public class EventHandler
{
private readonly Config _config = CuffUtils.Singleton.Config;

[PluginEvent(ServerEventType.PlayerHandcuff)]
public void PlayerCuffingEvent(Player player, Player target, bool state)
[PluginEvent]
public void PlayerCuffingEvent(PlayerHandcuffEvent ev)
{
if (_config.EnableCuffRemoveOnDistance)
{
DistanceComponent distanceComponent = target.GameObject.AddComponent<DistanceComponent>();
distanceComponent.Target = target;
DistanceComponent distanceComponent = ev.Target.GameObject.AddComponent<DistanceComponent>();
distanceComponent.Target = ev.Target;
}
}

[PluginEvent(ServerEventType.PlayerRemoveHandcuffs)]
public void PlayerUncuffingEvent(Player player, Player target, bool state)
[PluginEvent]
public void PlayerUncuffingEvent(PlayerRemoveHandcuffsEvent ev)
{
}

[PluginEvent(ServerEventType.PlayerDamage)]
public bool PlayerDamagingEvent(Player player, Player attacker, DamageHandlerBase damageHandler)
[PluginEvent]
public bool PlayerDamagingEvent(PlayerDamageEvent ev)
{
if (player == null)
return false;

if (attacker == null)
return true;

if (player.IsDisarmed)
if (ev.Target.IsDisarmed)
{
if (_config.WhitelistCuffDamageRole.Contains(attacker.Role))
if (_config.WhitelistCuffDamageRole.Contains(ev.Player.Role))
{
Log.Debug($"Attacker role is whitelisted {attacker.Role}");
Log.Debug($"Attacker role is whitelisted {ev.Player.Role}");
return true;
} else if (_config.BlacklistDetainDamageRole.Contains(attacker.Role))
} else if (_config.BlacklistDetainDamageRole.Contains(ev.Player.Role))
{
Log.Debug($"Attacker role is blacklisted {attacker.Role}");
Log.Debug($"Attacker role is blacklisted {ev.Player.Role}");
return false;
}

if (_config.DetainPlayerTakeDmg == false)
player.DamageManager.CanReceiveDamageFromPlayers = false;
ev.Target.DamageManager.CanReceiveDamageFromPlayers = false;
}
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion CuffUtilsNwAPI/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace CuffUtilsNwAPI
public class CuffUtils
{
public const string PluginName = "CuffUtils";
public const string PluginVersion = "1.2.0"; //Maj/Min/Build
public const string PluginVersion = "1.2.1"; //Maj/Min/Build
public const string PluginDesc = "Multi-purpose plugin that creates many features around cuffing events to help moderation/gameplay changes";

public static CuffUtils Singleton;
Expand Down

0 comments on commit 034dd3f

Please sign in to comment.