From dad1f1cb38c88370c4014da8845ade34b6edd43a Mon Sep 17 00:00:00 2001 From: Pablete1234 Date: Mon, 28 Nov 2022 18:45:34 +0100 Subject: [PATCH] Fix NPE on pgm reload due to text translation changes Signed-off-by: Pablete1234 --- core/src/main/java/tc/oc/pgm/PGMPlugin.java | 3 +-- .../java/tc/oc/pgm/util/text/TextTranslations.java | 10 +++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/tc/oc/pgm/PGMPlugin.java b/core/src/main/java/tc/oc/pgm/PGMPlugin.java index 52fe2f39b5..7cd7beaed8 100644 --- a/core/src/main/java/tc/oc/pgm/PGMPlugin.java +++ b/core/src/main/java/tc/oc/pgm/PGMPlugin.java @@ -253,8 +253,7 @@ public void reloadConfig() { if (!startup) { getGameLogger() - .log( - Level.INFO, ChatColor.GREEN + TextTranslations.translate("admin.reloadConfig", null)); + .log(Level.INFO, ChatColor.GREEN + TextTranslations.translate("admin.reloadConfig")); } final Logger logger = getLogger(); diff --git a/util/src/main/java/tc/oc/pgm/util/text/TextTranslations.java b/util/src/main/java/tc/oc/pgm/util/text/TextTranslations.java index 9869ae1ea6..dafa45e8f9 100644 --- a/util/src/main/java/tc/oc/pgm/util/text/TextTranslations.java +++ b/util/src/main/java/tc/oc/pgm/util/text/TextTranslations.java @@ -1,7 +1,6 @@ package tc.oc.pgm.util.text; import static net.kyori.adventure.key.Key.key; -import static net.kyori.adventure.text.Component.score; import static net.kyori.adventure.text.Component.text; import static net.kyori.adventure.text.Component.translatable; import static tc.oc.pgm.util.Assert.assertTrue; @@ -66,7 +65,7 @@ public Locale load(@NotNull String str) { // A control to ensure that .properties are loaded in UTF-8 format private static final UTF8Control SOURCE_CONTROL = new UTF8Control(); - // An list of all .properties files to load + // A list of all .properties files to load private static final List SOURCE_NAMES = ImmutableList.of( "command", @@ -367,7 +366,7 @@ public static String translateLegacy(Component text, @NotNull Pointered viewer) * @see #translate(Component, Pointered) for the newer text system. */ @Deprecated - public static String translate(String key, Object... args) { + public static String translate(String key, @NotNull Object... args) { return translate(key, Audience.empty(), args); } @@ -381,7 +380,8 @@ public static String translate(String key, Object... args) { * @see #translate(Component, Pointered) for the newer text system. */ @Deprecated - public static String translate(String key, @Nullable CommandSender viewer, Object... args) { + public static String translate( + String key, @Nullable CommandSender viewer, @NotNull Object... args) { return translate(key, getPointered(viewer), args); } @@ -395,7 +395,7 @@ public static String translate(String key, @Nullable CommandSender viewer, Objec * @see #translate(Component, Pointered) for the newer text system. */ @Deprecated - public static String translate(String key, @NotNull Pointered viewer, Object... args) { + public static String translate(String key, @NotNull Pointered viewer, @NotNull Object... args) { final Component text = translatable( key, Stream.of(args).map(TextTranslations::toComponent).collect(Collectors.toList()));