From 3dbe83734af4afbc02ab0b7b41593f5fd73aa65e Mon Sep 17 00:00:00 2001 From: xNexusACS <83370388+xNexusACS@users.noreply.github.com> Date: Mon, 28 Oct 2024 21:29:59 +0100 Subject: [PATCH] Ban event improvements & Port TPS Fix to Dev --- .../EventArgs/Player/BannedEventArgs.cs | 5 +++ Exiled.Events/Patches/Events/Player/Banned.cs | 4 +- .../Patches/Fixes/VoiceChatTpsFix.cs | 41 +++++++++++++++++++ 3 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 Exiled.Events/Patches/Fixes/VoiceChatTpsFix.cs diff --git a/Exiled.Events/EventArgs/Player/BannedEventArgs.cs b/Exiled.Events/EventArgs/Player/BannedEventArgs.cs index 0d55acc865..458e118228 100644 --- a/Exiled.Events/EventArgs/Player/BannedEventArgs.cs +++ b/Exiled.Events/EventArgs/Player/BannedEventArgs.cs @@ -57,5 +57,10 @@ public BannedEventArgs(Player target, Player issuer, BanDetails details, BanHand /// Gets a value indicating whether the ban is forced or not. /// public bool IsForced { get; } + + /// + /// Gets a value indicating whether the ban is an offline ban or not. + /// + public bool IsOffline => Details.OriginalName == "Unknown - offline ban"; } } \ No newline at end of file diff --git a/Exiled.Events/Patches/Events/Player/Banned.cs b/Exiled.Events/Patches/Events/Player/Banned.cs index c2934279f2..ba1a9667aa 100644 --- a/Exiled.Events/Patches/Events/Player/Banned.cs +++ b/Exiled.Events/Patches/Events/Player/Banned.cs @@ -75,8 +75,8 @@ private static IEnumerable Transpiler(IEnumerable.Pool.Return(newInstructions); } diff --git a/Exiled.Events/Patches/Fixes/VoiceChatTpsFix.cs b/Exiled.Events/Patches/Fixes/VoiceChatTpsFix.cs new file mode 100644 index 0000000000..3905946b47 --- /dev/null +++ b/Exiled.Events/Patches/Fixes/VoiceChatTpsFix.cs @@ -0,0 +1,41 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) Exiled Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.Patches.Fixes +{ + using System.Collections.Generic; + using System.Reflection.Emit; + + using API.Features.Core.Generic.Pools; + + using HarmonyLib; + + using VoiceChat.Networking; + + /// + /// Fixes method. + /// + [HarmonyPatch(typeof(VoiceTransceiver), nameof(VoiceTransceiver.ServerReceiveMessage))] + internal static class VoiceChatTpsFix + { + private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator) + { + List newInstructions = ListPool.Pool.Get(instructions); + + const int offset = -1; + int index = newInstructions.FindIndex(instruction => instruction.opcode == OpCodes.Newarr) + offset; + + // new array length 480 + newInstructions[index].operand = 480; + + foreach (CodeInstruction instruction in newInstructions) + yield return instruction; + + ListPool.Pool.Return(newInstructions); + } + } +} \ No newline at end of file