File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -60,7 +60,14 @@ export function getJavaVersion(minecraftVersion: string): JavaVersion {
60
60
return JAVA_21 ;
61
61
}
62
62
63
- const JAVA_PACKAGE_REGEX = / ^ [ a - z ] [ a - z 0 - 9 _ ] * ( \. [ a - z 0 - 9 _ ] + ) + [ 0 - 9 a - z _ ] $ / ;
63
+ const JAVA_PACKAGE_REGEX = / ^ [ a - z _ ] [ a - z 0 - 9 _ ] * ( \. [ a - z _ ] [ a - z 0 - 9 _ ] * ) * $ / ;
64
+ const JAVA_RESERVED_WORDS = `
65
+ abstract continue for new switch assert default goto package synchronized
66
+ boolean do if private this break double implements protected throw byte else
67
+ import public throws case enum instanceof return transient catch extends int
68
+ short try char final interface static void class finally long strictfp
69
+ volatile const float native super while _ true false null
70
+ ` . trim ( ) . split ( / \s + / ) ;
64
71
const RESERVED_PACKAGE_PREFIXES = [ "net.minecraft." , "com.mojang." , "net.fabricmc." , "java." ] ;
65
72
66
73
export function computePackageNameErrors ( packageName : string ) : string [ ] {
@@ -70,6 +77,11 @@ export function computePackageNameErrors(packageName: string): string[] {
70
77
errorList . push ( "Package name is not a valid Java package name!" ) ;
71
78
}
72
79
80
+ const reservedWordsFound = packageName . split ( '.' ) . filter ( c => JAVA_RESERVED_WORDS . includes ( c ) ) ;
81
+ if ( reservedWordsFound . length != 0 ) {
82
+ errorList . push ( `Package name contains illegal component: '${ reservedWordsFound [ 0 ] } '` ) ;
83
+ }
84
+
73
85
for ( let prefix of RESERVED_PACKAGE_PREFIXES ) {
74
86
if ( packageName . toLowerCase ( ) . startsWith ( prefix ) ) {
75
87
errorList . push ( `Package name starts with '${ prefix } ', which is reserved!` ) ;
You can’t perform that action at this time.
0 commit comments