From e9e336f9ffa06fcf564216fd9504bc50a5ea0968 Mon Sep 17 00:00:00 2001 From: FUTURE-SL Date: Thu, 13 Nov 2025 21:52:51 +0300 Subject: [PATCH] Optimizing interactions with CurrentItem --- .../Features/DamageHandlers/CustomDamageHandler.cs | 12 +++++++++--- EXILED/Exiled.API/Features/Player.cs | 6 ++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/EXILED/Exiled.API/Features/DamageHandlers/CustomDamageHandler.cs b/EXILED/Exiled.API/Features/DamageHandlers/CustomDamageHandler.cs index 67b464474f..fde6e9e00a 100644 --- a/EXILED/Exiled.API/Features/DamageHandlers/CustomDamageHandler.cs +++ b/EXILED/Exiled.API/Features/DamageHandlers/CustomDamageHandler.cs @@ -39,11 +39,17 @@ public CustomDamageHandler(Player target, BaseHandler baseHandler) if (Attacker is not null) { if (baseHandler is BaseScpDamageHandler) + { CustomBase = new ScpDamageHandler(target, baseHandler); - else if (Attacker.CurrentItem is not null && Attacker.CurrentItem.Type.IsWeapon() && baseHandler is BaseFirearmHandler) - CustomBase = new FirearmDamageHandler(Attacker.CurrentItem, target, baseHandler); + } else - CustomBase = new DamageHandler(target, Attacker); + { + Item item = Attacker.CurrentItem; + if (item is not null && item.Type.IsWeapon() && baseHandler is BaseFirearmHandler) + CustomBase = new FirearmDamageHandler(item, target, baseHandler); + else + CustomBase = new DamageHandler(target, Attacker); + } } else { diff --git a/EXILED/Exiled.API/Features/Player.cs b/EXILED/Exiled.API/Features/Player.cs index ea317a5d5d..606e6e80e3 100644 --- a/EXILED/Exiled.API/Features/Player.cs +++ b/EXILED/Exiled.API/Features/Player.cs @@ -2014,10 +2014,12 @@ public void DropItem(Item item, bool isThrown = false) /// Dropped item's . public Pickup DropHeldItem() { - if (CurrentItem is null) + Item item = CurrentItem; + + if (item is null) return null; - return DropItem(CurrentItem); + return DropItem(item); } ///