11package net .onelitefeather .antiredstoneclockremastered .injection ;
22
3+ import com .github .zafarkhaja .semver .Version ;
34import com .google .inject .AbstractModule ;
45import com .google .inject .Inject ;
56import com .google .inject .Provides ;
2021import java .nio .file .Path ;
2122import java .util .HashSet ;
2223import java .util .Locale ;
24+ import java .util .Optional ;
2325import java .util .ResourceBundle ;
2426
2527public final class TranslationModule extends AbstractModule {
@@ -31,11 +33,11 @@ public final class TranslationModule extends AbstractModule {
3133 protected void configure () {
3234 }
3335
36+ @ SuppressWarnings ("removal" )
3437 @ Provides
3538 @ Singleton
3639 public TranslationService provideTranslationService () {
37- ServerBuildInfo buildInfo = ServerBuildInfo .buildInfo ();
38- if (buildInfo .minecraftVersionId ().startsWith ("1.20" )) {
40+ if (isLegacyVersion ()) {
3941 LOGGER .info ("Using legacy translation service" );
4042 return new LegacyTranslationService ();
4143 } else {
@@ -44,6 +46,19 @@ public TranslationService provideTranslationService() {
4446 }
4547 }
4648
49+ private boolean isLegacyVersion () {
50+ ServerBuildInfo buildInfo = ServerBuildInfo .buildInfo ();
51+ Optional <Version > optionalVersion = Version .tryParse (buildInfo .minecraftVersionId ());
52+ if (optionalVersion .isEmpty ()) {
53+ return true ;
54+ }
55+ Version version = optionalVersion .get ();
56+ if (version .isHigherThanOrEquivalentTo (Version .of (1 , 21 , 4 ))) {
57+ return false ;
58+ }
59+ return version .isLowerThanOrEquivalentTo (Version .of (1 , 21 , 3 ));
60+ }
61+
4762 @ Inject
4863 public void bootstrap (AntiRedstoneClockRemastered plugin , TranslationService translationService ) {
4964 // Setup translations
0 commit comments