From b9e57fdebba29c10aa97e05459cc09ea1a93966d Mon Sep 17 00:00:00 2001 From: BONNe Date: Sat, 8 Jan 2022 13:23:48 +0200 Subject: [PATCH] Fixes some small bugs with translation potion base effect. There was an issue that it tried to translate extra effects and ignored main one. Relates to #290 --- .../bentobox/challenges/utils/Utils.java | 19 ++++++++++--------- src/main/resources/locales/en-US.yml | 2 +- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/main/java/world/bentobox/challenges/utils/Utils.java b/src/main/java/world/bentobox/challenges/utils/Utils.java index 0f06b6a..88ac9e1 100644 --- a/src/main/java/world/bentobox/challenges/utils/Utils.java +++ b/src/main/java/world/bentobox/challenges/utils/Utils.java @@ -17,6 +17,7 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.*; import org.bukkit.potion.PotionData; import org.bukkit.potion.PotionEffectType; +import org.bukkit.potion.PotionType; import org.eclipse.jdt.annotation.Nullable; import world.bentobox.bentobox.BentoBox; @@ -629,27 +630,27 @@ public class Utils /** - * Prettify effect string. + * Prettify type string. * - * @param effect the enchantment + * @param type the potion type * @param user the user * @return the string */ - public static String prettifyObject(PotionEffectType effect, User user) + public static String prettifyObject(PotionType type, User user) { - if (effect == null) + if (type == null) { return ""; } - String type = user.getTranslationOrNothing(Constants.ITEM_STACKS + "potion-effect." + effect.getName().toLowerCase()); + String text = user.getTranslationOrNothing(Constants.ITEM_STACKS + "potion-type." + type.name().toLowerCase()); - if (type.isEmpty()) + if (text.isEmpty()) { - type = LangUtilsHook.getPotionEffectName(effect, user); + text = LangUtilsHook.getPotionBaseEffectName(type, user); } - return type; + return text; } @@ -681,7 +682,7 @@ public class Utils if (type.isEmpty()) { // Check potion types translation. - type = prettifyObject(potionData.getType().getEffectType(), user); + type = prettifyObject(potionData.getType(), user); } String upgraded = user.getTranslationOrNothing(metaReference + "upgraded"); diff --git a/src/main/resources/locales/en-US.yml b/src/main/resources/locales/en-US.yml index 256c648..bc03183 100755 --- a/src/main/resources/locales/en-US.yml +++ b/src/main/resources/locales/en-US.yml @@ -1230,7 +1230,7 @@ challenges: # menting: "Mending" # unbreaking: "Unbreaking" # # Custom Potion Translation. -# potion-effect: +# potion-type: # water_breathing: "Water Breathing" # # You can also create specific item translations # # Like translate all potions.