Skip to content

Commit

Permalink
Fixes some small bugs with translation potion base effect.
Browse files Browse the repository at this point in the history
There was an issue that it tried to translate extra effects and ignored main one.

Relates to #290
  • Loading branch information
BONNe committed Jan 8, 2022
1 parent fc1d4fc commit b9e57fd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
19 changes: 10 additions & 9 deletions src/main/java/world/bentobox/challenges/utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
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;
Expand Down Expand Up @@ -629,27 +630,27 @@ public static String prettifyObject(Enchantment enchantment, User user)


/**
* 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;
}


Expand Down Expand Up @@ -681,7 +682,7 @@ public static String prettifyObject(ItemStack item, @Nullable PotionMeta potionM
if (type.isEmpty())
{
// Check potion types translation.
type = prettifyObject(potionData.getType().getEffectType(), user);
type = prettifyObject(potionData.getType(), user);
}

String upgraded = user.getTranslationOrNothing(metaReference + "upgraded");
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/locales/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit b9e57fd

Please sign in to comment.