From 496b519a95d604fbf361dd14a6185e8a883e1540 Mon Sep 17 00:00:00 2001 From: Luke Bemish Date: Tue, 19 Nov 2024 07:31:22 -0600 Subject: [PATCH] Change mod ID regex to allow '.' in mod IDs (#203) Also add mod ID format to the contract of getModId() --- .../net/neoforged/fml/loading/moddiscovery/ModInfo.java | 2 +- .../net/neoforged/neoforgespi/language/IModInfo.java | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/loader/src/main/java/net/neoforged/fml/loading/moddiscovery/ModInfo.java b/loader/src/main/java/net/neoforged/fml/loading/moddiscovery/ModInfo.java index e9fd89c67..ed4c8f212 100644 --- a/loader/src/main/java/net/neoforged/fml/loading/moddiscovery/ModInfo.java +++ b/loader/src/main/java/net/neoforged/fml/loading/moddiscovery/ModInfo.java @@ -29,7 +29,7 @@ public class ModInfo implements IModInfo, IConfigurable { private static final Logger LOGGER = LogUtils.getLogger(); private static final DefaultArtifactVersion DEFAULT_VERSION = new DefaultArtifactVersion("1"); - private static final Pattern VALID_MODID = Pattern.compile("^[a-z][a-z0-9_]{1,63}$"); + private static final Pattern VALID_MODID = Pattern.compile("^(?=.{2,64}$)[a-z][a-z0-9_]*(\\.[a-z][a-z0-9_]*)*$"); private static final Pattern VALID_NAMESPACE = Pattern.compile("^[a-z][a-z0-9_.-]{1,63}$"); private static final Pattern VALID_VERSION = Pattern.compile("^\\d+.*"); diff --git a/loader/src/main/java/net/neoforged/neoforgespi/language/IModInfo.java b/loader/src/main/java/net/neoforged/neoforgespi/language/IModInfo.java index b2a678e3d..9e646b8b7 100644 --- a/loader/src/main/java/net/neoforged/neoforgespi/language/IModInfo.java +++ b/loader/src/main/java/net/neoforged/neoforgespi/language/IModInfo.java @@ -27,6 +27,15 @@ public interface IModInfo { */ IModLanguageLoader getLoader(); + /** + * {@return the mod id} + * Mod IDs must satisfy the following requirements: + * + */ String getModId(); String getDisplayName();