From cdd0e8155d3cb9a00827f5016199d941aec1caac Mon Sep 17 00:00:00 2001 From: StavWasPlayZ Date: Mon, 28 Aug 2023 00:07:14 +0300 Subject: [PATCH] More null safety --- .../partial/InstrumentThemeLoader.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/cstav/genshinstrument/client/gui/screen/instrument/partial/InstrumentThemeLoader.java b/src/main/java/com/cstav/genshinstrument/client/gui/screen/instrument/partial/InstrumentThemeLoader.java index 9bae9c8f..bfc17eec 100644 --- a/src/main/java/com/cstav/genshinstrument/client/gui/screen/instrument/partial/InstrumentThemeLoader.java +++ b/src/main/java/com/cstav/genshinstrument/client/gui/screen/instrument/partial/InstrumentThemeLoader.java @@ -259,13 +259,25 @@ public void setNoteRingTheme(Color noteRingTheme) { } - protected T getTheme(final Supplier theme) { - if (theme.get() == null) { + protected Color getTheme(final Supplier theme) { + return getTheme(theme, Color.BLACK); + } + + protected T getTheme(final Supplier theme, final T def) { + T _theme = theme.get(); + + if (_theme == null) { LOGGER.warn("Requested theme not found, performing reload!"); performReload(Minecraft.getInstance().getResourceManager()); + + _theme = theme.get(); + if (_theme == null) { + LOGGER.error("Failed to load instrument resources!"); + return def; + } } - return theme.get(); + return _theme; } } \ No newline at end of file