Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix NPE on pgm reload due to text translation changes #1109

Merged
merged 1 commit into from
Nov 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions core/src/main/java/tc/oc/pgm/PGMPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
10 changes: 5 additions & 5 deletions util/src/main/java/tc/oc/pgm/util/text/TextTranslations.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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<String> SOURCE_NAMES =
ImmutableList.of(
"command",
Expand Down Expand Up @@ -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);
}

Expand All @@ -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);
}

Expand All @@ -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()));
Expand Down