diff --git a/.editorconfig b/.editorconfig
index 01e10b8..1691a66 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -95,3 +95,6 @@ dotnet_diagnostic.S1244.severity = none
# IDE0045: Convert to conditional expression
dotnet_diagnostic.IDE0045.severity = none
+
+# IDE0046: Convert to conditional expression
+dotnet_diagnostic.IDE0046.severity = none
diff --git a/MiraAPI/Colors/PaletteManager.cs b/MiraAPI/Colors/PaletteManager.cs
index 286cd25..9127bb6 100644
--- a/MiraAPI/Colors/PaletteManager.cs
+++ b/MiraAPI/Colors/PaletteManager.cs
@@ -45,6 +45,9 @@ public static class PaletteManager
/// true if the color is a variable color; false otherwise.
public static bool IsVariable(int colorId)
{
+ if (colorId < 0 || colorId >= Palette.ColorNames.Length)
+ return false;
+
return VariableColorNames.Contains(Palette.ColorNames[colorId]);
}
@@ -65,6 +68,9 @@ public static class PaletteManager
/// The main color associated with the provided ID.
public static Color GetMainColor(int colorId)
{
+ if (colorId < 0 || colorId >= Palette.ColorNames.Length)
+ return Color.white;
+
return !ColorIdToColorMap.TryGetValue(colorId, out var custom)
? Palette.PlayerColors[colorId]
: (custom is VariableColor variable
@@ -79,6 +85,9 @@ public static class PaletteManager
/// The shadow color associated with the provided ID.
public static Color GetShadowColor(int colorId)
{
+ if (colorId < 0 || colorId >= Palette.ColorNames.Length)
+ return Color.white;
+
return !ColorIdToColorMap.TryGetValue(colorId, out var custom)
? Palette.ShadowColors[colorId]
: (custom is VariableColor variable