File tree Expand file tree Collapse file tree
java/org/jackhuang/hmcl/util/versioning
test/java/org/jackhuang/hmcl/util/versioning
HMCL/src/main/java/org/jackhuang/hmcl/util/i18n/translator Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -155,7 +155,32 @@ public static String translateGameVersion(GameVersionNumber gameVersion) {
155155 case "23w13a_or_b" -> "二三週一三暨" ;
156156 case "24w14potato" -> "二四週一四芋" ;
157157 case "25w14craftmine" -> "二五週一四礦" ;
158- default -> version ;
158+ default -> {
159+ if (version .length () >= 6 && version .charAt (2 ) == 'w' ) {
160+ Matcher matcher = Pattern .compile ("(?<year>[0-9]{2})w(?<week>[0-9]{2})(?<suffix>.+)" ).matcher (version );
161+ if (matcher .matches ()) {
162+ int year = Integer .parseInt (matcher .group ("year" ));
163+ int week = Integer .parseInt (matcher .group ("week" ));
164+ String suffix = matcher .group ("suffix" );
165+ char suffixFirstChar = suffix .charAt (0 );
166+
167+ StringBuilder builder = new StringBuilder ();
168+ appendDigitByDigit (builder , String .valueOf (year ));
169+ builder .append ('週' );
170+ appendDigitByDigit (builder , String .valueOf (week ));
171+
172+ if (suffix .length () == 1
173+ && suffixFirstChar >= 'a' && (suffixFirstChar - 'a' ) < TIAN_GAN .length )
174+ builder .append (TIAN_GAN [suffixFirstChar - 'a' ]);
175+ else
176+ builder .append (suffix );
177+
178+ yield builder .toString ();
179+ }
180+ }
181+
182+ yield version ;
183+ }
159184 };
160185 } else {
161186 return gameVersion .toString ();
Original file line number Diff line number Diff line change @@ -627,6 +627,10 @@ static LegacySnapshot parse(String value) {
627627 throw new IllegalArgumentException (value );
628628 }
629629
630+ if (year >= Release .MINIMUM_YEAR_MAJOR_VERSION ) {
631+ throw new IllegalArgumentException (value );
632+ }
633+
630634 char suffix = value .charAt (5 );
631635 if (suffix < 'a' || suffix > 'z' )
632636 throw new IllegalArgumentException (value );
Original file line number Diff line number Diff line change 91291226.1-rc-1
91391326.1-rc-2
91491426.1
915+ 26.1.1-rc-1
916+ 26.1.1
917+ 26w14a
Original file line number Diff line number Diff line change @@ -376,10 +376,11 @@ public void testCompareMix() {
376376 "1.21.11-pre1_unobfuscated" ,
377377 "1.21.11-pre2" ,
378378 "1.21.11-pre2_unobfuscated" ,
379- "99w99a" ,
380379 "26.1-snapshot-1" ,
381380 "26.1-snapshot-2" ,
382381 "26.1" ,
382+ "26.1.1" ,
383+ "26w14a" ,
383384 "26.2-snapshot-1" ,
384385 "26.2-snapshot-2" ,
385386 "26.2" ,
You can’t perform that action at this time.
0 commit comments