mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-22 02:35:21 +01:00
Add try/catch around potioneffects for older servers
This commit is contained in:
parent
a7c9ae6e36
commit
4bfd405c4e
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user