Skip to content

Commit

Permalink
fix: use the correct allowed char ranges for fabric mod ids (#1104)
Browse files Browse the repository at this point in the history
### Motivation
The current fabric platform generator is generating invalid mod ids due
to a too permissive mod id description in the fabric wiki.

### Modification
Ensure that the mod id is matching the actual mod id pattern
`[a-z][a-z0-9-_]{1,63}` of fabric (taken from the
[MetadataVerifier](https://github.com/FabricMC/fabric-loader/blob/2a378f1c563b6ec96ae6620a278ecd23fa09da0f/src/main/java/net/fabricmc/loader/impl/metadata/MetadataVerifier.java#L36))

### Result
Mod ids for fabric are now generated correctly and no longer cause a
startup crash.

##### Other context
Fixes #1102
  • Loading branch information
derklaro authored Jan 30, 2023
1 parent 21b3e8d commit d937454
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,19 @@

final class FabricPluginInfoGenerator extends NightConfigInfoGenerator {

// https://fabricmc.net/wiki/documentation:fabric_mod_json#mandatory_fields
// [a-z][a-z0-9-_]{1,63}
private static final PluginIdGenerator MOD_ID_GENERATOR = PluginIdGenerator.withBoundedLength(1, 63)
.registerRange(
0,
1,
'a',
CharRange.range('a', 'z'))
.registerRange(
1,
'_',
CharRange.range('_'),
CharRange.range('-'),
CharRange.range('a', 'z'),
CharRange.range('A', 'Z'),
CharRange.range('0', '9'));

public FabricPluginInfoGenerator() {
Expand Down

0 comments on commit d937454

Please sign in to comment.