Merge pull request #2444 from BentoBoxWorld/2240_Potions_for_Required_Items_causes_Challenges_to_Error

This commit is contained in:
tastybento 2024-07-26 07:46:42 -07:00 committed by GitHub
commit 11540c047f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -363,16 +363,23 @@ public class LangUtilsHook extends Hook {
* @param user The user's language will be used for translation.
* @return Return the translation result.
*/
@SuppressWarnings("deprecation")
public static String getPotionBaseEffectName(PotionType potionType, User user) {
if (hooked) {
return LanguageHelper.getPotionBaseEffectName(potionType, getUserLocale(user));
}
try {
List<PotionEffect> effects = potionType.getPotionEffects();
if (effects.isEmpty()) {
return "No Effects";
}
return effects.stream().map(effect -> Util.prettifyText(effect.getType().getKey().getKey()))
.collect(Collectors.joining(", "));
} catch (Exception e) {
// Older versions of Spigot pre-1.20.4 don't have getPotionEffects()
return Util.prettifyText(potionType.getEffectType().getKey().getKey());
}
}
/**