Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions EXILED/Exiled.Events/EventArgs/Player/BanningEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace Exiled.Events.EventArgs.Player
using System.Reflection;

using API.Features;
using CommandSystem;

/// <summary>
/// Contains all information before banning a player from the server.
Expand All @@ -23,12 +24,13 @@ public class BanningEventArgs : KickingEventArgs
/// </summary>
/// <param name="target">The ban target.</param>
/// <param name="issuer">The ban issuer.</param>
/// <param name="commandSender">The ban command sender.</param>
/// <param name="duration">The ban seconds duration.</param>
/// <param name="reason">The ban reason.</param>
/// <param name="fullMessage">The ban full message.</param>
/// <param name="isAllowed">Indicates whether the event can be executed or not.</param>
public BanningEventArgs(Player target, Player issuer, long duration, string reason, string fullMessage, bool isAllowed = true)
: base(target, issuer, reason, fullMessage, isAllowed)
public BanningEventArgs(Player target, Player issuer, ICommandSender commandSender, long duration, string reason, string fullMessage, bool isAllowed = true)
: base(target, issuer, commandSender, reason, fullMessage, isAllowed)
{
Duration = duration;
}
Expand Down
13 changes: 11 additions & 2 deletions EXILED/Exiled.Events/EventArgs/Player/KickingEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Exiled.Events.EventArgs.Player
using System.Reflection;

using API.Features;

using CommandSystem;
using Interfaces;

/// <summary>
Expand All @@ -32,6 +32,9 @@ public class KickingEventArgs : IPlayerEvent, IDeniableEvent
/// <param name="issuer">
/// <inheritdoc cref="Player" />
/// </param>
/// <param name="commandSender">
/// <inheritdoc cref="ICommandSender" />
/// </param>
/// <param name="reason">
/// <inheritdoc cref="Reason" />
/// </param>
Expand All @@ -41,10 +44,11 @@ public class KickingEventArgs : IPlayerEvent, IDeniableEvent
/// <param name="isAllowed">
/// <inheritdoc cref="IsAllowed" />
/// </param>
public KickingEventArgs(Player target, Player issuer, string reason, string fullMessage, bool isAllowed = true)
public KickingEventArgs(Player target, Player issuer, ICommandSender commandSender, string reason, string fullMessage, bool isAllowed = true)
{
Target = target;
Player = issuer ?? Server.Host;
CommandSender = commandSender;
Reason = reason;
startkickmessage = fullMessage;
IsAllowed = isAllowed;
Expand Down Expand Up @@ -114,6 +118,11 @@ public Player Player
}
}

/// <summary>
/// Gets the command sender.
/// </summary>
public ICommandSender CommandSender { get; }

/// <summary>
/// Logs the kick, anti-backdoor protection from malicious plugins.
/// </summary>
Expand Down
10 changes: 10 additions & 0 deletions EXILED/Exiled.Events/Patches/Events/Player/Banning.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,24 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
index,
new[]
{
// target
new(OpCodes.Ldarg_0),
new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(Footprint) })),

// issuer
new(OpCodes.Ldarg_1),
new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ICommandSender) })),

// commandSender
new(OpCodes.Ldarg_1),

// duration
new(OpCodes.Ldarg_3),

// reason
new(OpCodes.Ldarg_2),

// fullMessage
new(OpCodes.Ldstr, "You have been banned. "),
new(OpCodes.Ldarg_2),
new(OpCodes.Call, Method(typeof(string), nameof(string.IsNullOrEmpty))),
Expand All @@ -67,8 +75,10 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
new(OpCodes.Call, Method(typeof(string), nameof(string.Concat), new[] { typeof(string), typeof(string) })),
new CodeInstruction(OpCodes.Call, Method(typeof(string), nameof(string.Concat), new[] { typeof(string), typeof(string) })).WithLabels(empty),

// isAllowed = true
new(OpCodes.Ldc_I4_1),

// ev = new BanningEventArgs(target, issuer, commandSender, duration, reason, fullMessage, true)
new(OpCodes.Newobj, GetDeclaredConstructors(typeof(BanningEventArgs))[0]),
new(OpCodes.Dup),
new(OpCodes.Dup),
Expand Down
5 changes: 4 additions & 1 deletion EXILED/Exiled.Events/Patches/Events/Player/Kicking.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
new(OpCodes.Ldarg_1),
new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ICommandSender) })),

// commandSender
new(OpCodes.Ldarg_1),

// reason
new(OpCodes.Ldarg_2),

Expand All @@ -58,7 +61,7 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
// true
new(OpCodes.Ldc_I4_1),

// KickingEventArgs ev = new(Player, Player, string, string, bool)
// KickingEventArgs ev = new(Player, Player, ICommandSender, string, string, bool)
new(OpCodes.Newobj, GetDeclaredConstructors(typeof(KickingEventArgs))[0]),
new(OpCodes.Dup),
new(OpCodes.Dup),
Expand Down