diff --git a/plugin/src/main/java/de/epiceric/shopchest/language/item/LocalizedItemNameManager.java b/plugin/src/main/java/de/epiceric/shopchest/language/item/LocalizedItemNameManager.java index 8ae77c7..d158c5d 100644 --- a/plugin/src/main/java/de/epiceric/shopchest/language/item/LocalizedItemNameManager.java +++ b/plugin/src/main/java/de/epiceric/shopchest/language/item/LocalizedItemNameManager.java @@ -2,6 +2,7 @@ package de.epiceric.shopchest.language.item; import java.util.Map; import java.util.Objects; +import java.util.logging.Level; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.BookMeta; @@ -10,8 +11,12 @@ import org.bukkit.inventory.meta.SkullMeta; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import de.epiceric.shopchest.ShopChest; + public class LocalizedItemNameManager implements ItemNameManager { + private final static String ERROR_ITEM_NAME = "ERROR"; + private final Map itemTranslations; public LocalizedItemNameManager(@NotNull Map itemTranslations) { @@ -58,13 +63,19 @@ public class LocalizedItemNameManager implements ItemNameManager { @NotNull private String getDefaultName(@NotNull ItemStack stack) { - return getCached(stack.getTranslationKey()); + try { + return getCached(stack.getTranslationKey()); + } catch (Exception e) { + ShopChest.getInstance().getLogger().log(Level.SEVERE, e.getMessage()); + return ERROR_ITEM_NAME; + } } @NotNull private String getCached(@NotNull String key) { final String cachedTranslation = itemTranslations.get(key); if (cachedTranslation == null) { + // Keep this behavior to ensure quick fixes throw new RuntimeException("Could not get the translation for '" + key + "'. Report it to github"); } return cachedTranslation;