From 8bde492673e77e07d38fbeca98bf893cb37cbab5 Mon Sep 17 00:00:00 2001 From: sh4dow Date: Thu, 16 Aug 2018 19:53:16 +0200 Subject: [PATCH] prevent language file NPE please verify the code before merging; I never used scala before --- src/net/bdew/gendustry/misc/ResourceListener.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/net/bdew/gendustry/misc/ResourceListener.scala b/src/net/bdew/gendustry/misc/ResourceListener.scala index 15475ac..219b745 100644 --- a/src/net/bdew/gendustry/misc/ResourceListener.scala +++ b/src/net/bdew/gendustry/misc/ResourceListener.scala @@ -32,10 +32,10 @@ object ResourceListener extends IResourceManagerReloadListener { override def onResourceManagerReload(rm: IResourceManager): Unit = { val newLang = Client.minecraft.getLanguageManager.getCurrentLanguage - Gendustry.logInfo("Resource manager reload, new language: %s", newLang.getLanguageCode) + if(newLang!=null) Gendustry.logInfo("Resource manager reload, new language: %s", newLang.getLanguageCode) val configFiles = Gendustry.configDir.list().sorted configFiles.filter(_.endsWith(".en_US.lang")).foreach(loadLangFile) - if (newLang.getLanguageCode != "en_US") + if(newLang!=null) if (newLang.getLanguageCode != "en_US") configFiles.filter(_.endsWith("." + newLang.getLanguageCode + ".lang")).foreach(loadLangFile) } }