Skip to content

Commit ed2f69c

Browse files
fix: Make GetEffectType not brick server when no key is found (#678)
* Thing * Update EXILED/Exiled.API/Extensions/EffectTypeExtension.cs --------- Co-authored-by: Yamato <[email protected]>
1 parent 204b1cd commit ed2f69c

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

EXILED/Exiled.API/Extensions/EffectTypeExtension.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ namespace Exiled.API.Extensions
1515
using CustomPlayerEffects;
1616
using CustomRendering;
1717
using Enums;
18+
using Exiled.API.Features;
1819
using InventorySystem.Items.MarshmallowMan;
1920
using InventorySystem.Items.Usables.Scp244.Hypothermia;
2021
using PlayerRoles.FirstPersonControl;
@@ -131,7 +132,15 @@ public static bool TryGetType(this EffectType effect, out Type type)
131132
/// <param name="statusEffectBase">The <see cref="StatusEffectBase"/> enum.</param>
132133
/// <returns>The <see cref="EffectType"/>.</returns>
133134
public static EffectType GetEffectType(this StatusEffectBase statusEffectBase)
134-
=> TypeToEffectType.TryGetValue(statusEffectBase.GetType(), out EffectType effect) ? effect : throw new InvalidOperationException("Invalid effect status base provided");
135+
{
136+
if (!TypeToEffectType.TryGetValue(statusEffectBase.GetType(), out EffectType type))
137+
{
138+
Log.Warn($"Missing EffectType for Type {statusEffectBase.GetType()}!!! This issue likely originates from a new update or a CustomEffect on your Server");
139+
return EffectType.None;
140+
}
141+
142+
return type;
143+
}
135144

136145
/// <summary>
137146
/// Gets the <see cref="EffectType"/> of the specified <see cref="StatusEffectBase"/>.

0 commit comments

Comments
 (0)