diff --git a/osu.Game/Utils/ModUtils.cs b/osu.Game/Utils/ModUtils.cs
index 7485950f47..eb5deef6ea 100644
--- a/osu.Game/Utils/ModUtils.cs
+++ b/osu.Game/Utils/ModUtils.cs
@@ -8,6 +8,7 @@ using System.Diagnostics.CodeAnalysis;
using System.Linq;
using osu.Framework.Bindables;
using osu.Game.Online.API;
+using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods;
#nullable enable
@@ -185,5 +186,33 @@ namespace osu.Game.Utils
return setting;
}
}
+
+ ///
+ /// Verifies all proposed mods are valid for a given ruleset and returns instantiated s for further processing.
+ ///
+ /// The ruleset to verify mods against.
+ /// The proposed mods.
+ /// Mods instantiated from which were valid for the given .
+ /// Whether all were valid for the given .
+ public static bool InstantiateValidModsForRuleset(Ruleset ruleset, IEnumerable proposedMods, out List valid)
+ {
+ valid = new List();
+ bool proposedWereValid = true;
+
+ foreach (var apiMod in proposedMods)
+ {
+ try
+ {
+ // will throw if invalid
+ valid.Add(apiMod.ToMod(ruleset));
+ }
+ catch
+ {
+ proposedWereValid = false;
+ }
+ }
+
+ return proposedWereValid;
+ }
}
}