Skip to content

Commit

Permalink
Implements more patches for RemovingHandcuffs event and adding Remove…
Browse files Browse the repository at this point in the history
…dHandcuffs event (#3)

* Update labeler.yml

* RemovingHandcuffs event

* Update UncuffReason.cs

* New event

* docs
  • Loading branch information
Misaka-ZeroTwo authored Aug 9, 2024
1 parent 09de18b commit a1ae554
Show file tree
Hide file tree
Showing 5 changed files with 321 additions and 4 deletions.
30 changes: 30 additions & 0 deletions EXILED/Exiled.API/Enums/UncuffReason.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// -----------------------------------------------------------------------
// <copyright file="UncuffReason.cs" company="Exiled Team">
// Copyright (c) Exiled Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
// </copyright>
// -----------------------------------------------------------------------

namespace Exiled.API.Enums
{
/// <summary>
/// Reasons that player gets uncuffed.
/// </summary>
public enum UncuffReason
{
/// <summary>
/// Uncuffed by a player.
/// </summary>
Player,

/// <summary>
/// Uncuffed due to the distance between cuffer and target.
/// </summary>
OutOfRange,

/// <summary>
/// Uncuffed due to the cuffer no longer alive.
/// </summary>
CufferDied,
}
}
47 changes: 47 additions & 0 deletions EXILED/Exiled.Events/EventArgs/Player/RemovedHandcuffsEventArgs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// -----------------------------------------------------------------------
// <copyright file="RemovedHandcuffsEventArgs.cs" company="Exiled Team">
// Copyright (c) Exiled Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
// </copyright>
// -----------------------------------------------------------------------

namespace Exiled.Events.EventArgs.Player
{
using API.Enums;
using API.Features;
using Exiled.Events.EventArgs.Interfaces;

/// <summary>
/// Contains all information after freeing a handcuffed player.
/// </summary>
public class RemovedHandcuffsEventArgs : IPlayerEvent
{
/// <summary>
/// Initializes a new instance of the <see cref="RemovedHandcuffsEventArgs" /> class.
/// </summary>
/// <param name="cuffer">The cuffer player.</param>
/// <param name="target">The target player was uncuffed.</param>
/// <param name="uncuffReason">The reason for removing the handcuffs.</param>
public RemovedHandcuffsEventArgs(Player cuffer, Player target, UncuffReason uncuffReason)
{
Player = cuffer;
Target = target;
UncuffReason = uncuffReason;
}

/// <summary>
/// Gets the target player to be cuffed.
/// </summary>
public Player Target { get; }

/// <summary>
/// Gets the cuffer player.
/// </summary>
public Player Player { get; }

/// <summary>
/// Gets the reason for removing handcuffs.
/// </summary>
public UncuffReason UncuffReason { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace Exiled.Events.EventArgs.Player
{
using API.Enums;
using API.Features;
using Exiled.Events.EventArgs.Interfaces;

Expand All @@ -20,11 +21,13 @@ public class RemovingHandcuffsEventArgs : IPlayerEvent, IDeniableEvent
/// </summary>
/// <param name="cuffer">The cuffer player.</param>
/// <param name="target">The target player to be uncuffed.</param>
/// <param name="uncuffReason">The reason of removing handcuffs.</param>
/// <param name="isAllowed">Indicates whether the event can be executed or not.</param>
public RemovingHandcuffsEventArgs(Player cuffer, Player target, bool isAllowed = true)
public RemovingHandcuffsEventArgs(Player cuffer, Player target, UncuffReason uncuffReason, bool isAllowed = true)
{
Player = cuffer;
Target = target;
UncuffReason = uncuffReason;
IsAllowed = isAllowed;
}

Expand All @@ -34,13 +37,19 @@ public RemovingHandcuffsEventArgs(Player cuffer, Player target, bool isAllowed =
public Player Target { get; }

/// <summary>
/// Gets or sets a value indicating whether or not the player can be handcuffed.
/// Gets or sets a value indicating whether or not the player can be handcuffed. Denying the event will only have an effect when <see cref="UncuffReason" /> is <see cref="UncuffReason.Player" /> until next major update.
/// </summary>
/// TODO: Update docs and patches
public bool IsAllowed { get; set; }

/// <summary>
/// Gets the cuffer player.
/// </summary>
public Player Player { get; }

/// <summary>
/// Gets the reason of removing handcuffs.
/// </summary>
public UncuffReason UncuffReason { get; }
}
}
11 changes: 11 additions & 0 deletions EXILED/Exiled.Events/Handlers/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,11 @@ public class Player
/// </summary>
public static Event<RemovingHandcuffsEventArgs> RemovingHandcuffs { get; set; } = new();

/// <summary>
/// Invoked after freeing a handcuffed <see cref="API.Features.Player"/>.
/// </summary>
public static Event<RemovedHandcuffsEventArgs> RemovedHandcuffs { get; set; } = new();

/// <summary>
/// Invoked before a <see cref="API.Features.Player"/> escapes.
/// </summary>
Expand Down Expand Up @@ -704,6 +709,12 @@ public class Player
/// <param name="ev">The <see cref="RemovingHandcuffsEventArgs"/> instance.</param>
public static void OnRemovingHandcuffs(RemovingHandcuffsEventArgs ev) => RemovingHandcuffs.InvokeSafely(ev);

/// <summary>
/// Called after freeing a handcuffed <see cref="API.Features.Player"/>.
/// </summary>
/// <param name="ev">The <see cref="RemovedHandcuffsEventArgs"/> instance.</param>
public static void OnRemovedHandcuffs(RemovedHandcuffsEventArgs ev) => RemovedHandcuffs.InvokeSafely(ev);

/// <summary>
/// Called before a <see cref="API.Features.Player"/> escapes.
/// </summary>
Expand Down
Loading

0 comments on commit a1ae554

Please sign in to comment.