From 74e4c3bd64671179abdac6b1dd993f74cfe1b6a5 Mon Sep 17 00:00:00 2001 From: Jerozgen Date: Mon, 28 Oct 2024 05:38:33 +0300 Subject: [PATCH] Fix potential NullPointerException --- gradle.properties | 2 +- .../jerozgen/languagereload/mixin/SearchManagerMixin.java | 5 ++++- .../languagereload/mixin/TranslatableTextContentMixin.java | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index 60090c7..1f7760b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ loader_version=0.16.7 fabric_version=0.107.0+1.21.3 # Mod Properties -mod_version=1.7+1.21.3 +mod_version=1.7.1+1.21.3 maven_group=jerozgen archives_base_name=language-reload diff --git a/src/main/java/jerozgen/languagereload/mixin/SearchManagerMixin.java b/src/main/java/jerozgen/languagereload/mixin/SearchManagerMixin.java index 5c87d0f..30593e2 100644 --- a/src/main/java/jerozgen/languagereload/mixin/SearchManagerMixin.java +++ b/src/main/java/jerozgen/languagereload/mixin/SearchManagerMixin.java @@ -29,7 +29,10 @@ private static List addFallbackTranslationsToSearchTooltips(ItemStack inst if (Config.getInstance() == null) return original; if (!Config.getInstance().multilingualItemSearch) return original; - var translationStorage = ((ILanguage) Language.getInstance()).languagereload_getTranslationStorage(); + var language = Language.getInstance(); + if (language == null) return original; + + var translationStorage = ((ILanguage) language).languagereload_getTranslationStorage(); if (translationStorage == null) return original; var result = new ArrayList<>(original); diff --git a/src/main/java/jerozgen/languagereload/mixin/TranslatableTextContentMixin.java b/src/main/java/jerozgen/languagereload/mixin/TranslatableTextContentMixin.java index e2585ef..e546c73 100644 --- a/src/main/java/jerozgen/languagereload/mixin/TranslatableTextContentMixin.java +++ b/src/main/java/jerozgen/languagereload/mixin/TranslatableTextContentMixin.java @@ -45,6 +45,8 @@ List getOverriddenTranslations() { if (!Config.getInstance().multilingualItemSearch) return null; var language = Language.getInstance(); + if (language == null) return null; + var translationStorage = ((ILanguage) language).languagereload_getTranslationStorage(); if (translationStorage == null) return null;