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
This commit is contained in:
BONNe 2022-01-08 13:23:48 +02:00
parent fc1d4fcf06
commit b9e57fdebb
2 changed files with 11 additions and 10 deletions

View File

@ -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");

View File

@ -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.