From 23318883ed6f42830ae8b01504e164a4060d1fb9 Mon Sep 17 00:00:00 2001 From: Bolton Date: Sun, 2 Jun 2024 19:41:20 +0200 Subject: [PATCH] refactor: use get effect instead of creating a new instance --- Exiled.API/Extensions/EffectTypeExtension.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Exiled.API/Extensions/EffectTypeExtension.cs b/Exiled.API/Extensions/EffectTypeExtension.cs index 78d595dc27..ba2e92685e 100644 --- a/Exiled.API/Extensions/EffectTypeExtension.cs +++ b/Exiled.API/Extensions/EffectTypeExtension.cs @@ -15,6 +15,7 @@ namespace Exiled.API.Extensions using CustomPlayerEffects; using CustomRendering; using Enums; + using Exiled.API.Features; using InventorySystem.Items.MarshmallowMan; using InventorySystem.Items.Usables.Scp244.Hypothermia; using PlayerRoles.FirstPersonControl; @@ -154,7 +155,7 @@ or EffectType.Corroding or EffectType.Decontaminating or EffectType.Hemorrhage o /// The . /// Whether or not the effect is a negative effect. /// - public static bool IsNegative(this EffectType effect) => IsHarmful(effect) || (EffectTypeToType.TryGetValue(effect, out Type type) && type.IsSubclassOf(typeof(StatusEffectBase)) && ((StatusEffectBase)Activator.CreateInstance(type)).Classification == StatusEffectBase.EffectClassification.Negative); + public static bool IsNegative(this EffectType effect) => IsHarmful(effect) || Server.Host.GetEffect(effect).Classification == StatusEffectBase.EffectClassification.Negative; /// /// Returns whether or not the provided is a positive effect. @@ -162,7 +163,7 @@ or EffectType.Corroding or EffectType.Decontaminating or EffectType.Hemorrhage o /// The . /// Whether or not the effect is a positive effect. /// - public static bool IsPositive(this EffectType effect) => EffectTypeToType.TryGetValue(effect, out Type type) && type.IsSubclassOf(typeof(StatusEffectBase)) && ((StatusEffectBase)Activator.CreateInstance(type)).Classification == StatusEffectBase.EffectClassification.Positive; + public static bool IsPositive(this EffectType effect) => Server.Host.GetEffect(effect).Classification == StatusEffectBase.EffectClassification.Positive; /// /// Returns whether or not the provided affects the player's movement speed.