Skip to content

Commit 94a9144

Browse files
authored
allow numbers in pack id (#350)
1 parent f9f6898 commit 94a9144

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/main/java/com/cleanroommc/groovyscript/sandbox/RunConfig.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,12 @@ public static JsonObject createDefaultJson() {
7474
private final String asmClass = null;
7575
private boolean debug;
7676

77-
7877
private final boolean invalidPackId;
7978
private boolean warnedAboutInvalidPackId;
8079
private int packmodeConfigState;
8180

8281
public static final String[] GROOVY_SUFFIXES = SandboxData.GROOVY_SUFFIXES;
82+
private static final Pattern ID_PATTERN = Pattern.compile("[a-z0-9_]+");
8383

8484
public static boolean isGroovyFile(String path) {
8585
return SandboxData.isGroovyFile(path);
@@ -88,8 +88,7 @@ public static boolean isGroovyFile(String path) {
8888
public RunConfig(JsonObject json) {
8989
String name = JsonHelper.getString(json, "", "packName", "name");
9090
String id = JsonHelper.getString(json, "", "packId", "id");
91-
Pattern idPattern = Pattern.compile("[a-z_]+");
92-
this.invalidPackId = id.isEmpty() || !idPattern.matcher(id).matches();
91+
this.invalidPackId = id.isEmpty() || !ID_PATTERN.matcher(id).matches();
9392
if (name.isEmpty() && !this.invalidPackId) {
9493
name = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, id).replace('_', ' ');
9594
}

0 commit comments

Comments
 (0)