Skip to content

Commit

Permalink
Merge pull request #46 from Ynverxe/fix/component-renderer-translator…
Browse files Browse the repository at this point in the history
…-npe

fix: Avoid NPE when no translation is provided
  • Loading branch information
FixedDev authored Aug 10, 2024
2 parents d74a021 + 97fb1a7 commit b30844b
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ public ComponentRendererTranslator(TranslationProvider translationProvider) {
renderer = new TranslatableComponentRenderer<Namespace>() {
@Override
protected @Nullable MessageFormat translate(@NotNull String key, @NotNull Namespace context) {
return new MessageFormat(provider.getTranslation(context, key));
String translationFound = provider.getTranslation(context, key);

if (translationFound == null) {
return null;
}

return new MessageFormat(translationFound);
}
};
}
Expand Down

0 comments on commit b30844b

Please sign in to comment.