Validate mod ids
This commit is contained in:
parent
7c840dce35
commit
276d0c49c1
1 changed files with 5 additions and 0 deletions
|
@ -29,6 +29,7 @@ import java.util.Map;
|
|||
import java.util.Optional;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* The container that wraps around mods in the system.
|
||||
|
@ -45,13 +46,17 @@ import java.util.function.Supplier;
|
|||
|
||||
public abstract class ModContainer
|
||||
{
|
||||
private static final Pattern VALID_MODIDS = Pattern.compile("^[a-z0-9_-]{3,64}$");
|
||||
protected final String modId;
|
||||
protected final IModInfo modInfo;
|
||||
protected ModLoadingStage modLoadingStage;
|
||||
protected final Map<ModLoadingStage, Consumer<LifecycleEventProvider.LifecycleEvent>> triggerMap;
|
||||
protected final Map<ExtensionPoint, Supplier<?>> extensionPoints = new IdentityHashMap<>();
|
||||
|
||||
public ModContainer(IModInfo info)
|
||||
{
|
||||
if (!VALID_MODIDS.matcher(info.getModId()).matches())
|
||||
throw new IllegalArgumentException("Invalid modid " + info.getModId() + "! Mod ids need to be lowercase alphanumeric characters or '-'/'_' and need to be between 3 and 64 chars long.");
|
||||
this.modId = info.getModId();
|
||||
this.modInfo = info;
|
||||
this.triggerMap = new HashMap<>();
|
||||
|
|
Loading…
Reference in a new issue