Skip to content

Commit

Permalink
Updated wPotionEffectToPotionEffect method for Minecraft 1.20.6
Browse files Browse the repository at this point in the history
  • Loading branch information
fulminazzo committed Dec 23, 2024
1 parent 564d5a0 commit da2ed9a
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -542,8 +542,16 @@ private static <T> void playInternalSound(final @NotNull Player player, final @N
* @return the potion effect
*/
public static @NotNull org.bukkit.potion.PotionEffect wPotionEffectToPotionEffect(final @NotNull PotionEffect potionEffect) {
final String effect = potionEffect.getName();
final PotionEffectType type = EnumUtils.valueOf(PotionEffectType.class, effect, "getByName");
String effect = potionEffect.getName();
PotionEffectType type;
try {
type = EnumUtils.valueOf(PotionEffectType.class, effect, "getByName");
} catch (IllegalArgumentException e) {
// For Minecraft 1.20.6 and above
effect = effect.replace(" ", "_").toLowerCase();
if (effect.equalsIgnoreCase("bad_luck")) effect = "unluck";
type = EnumUtils.valueOf(PotionEffectType.class, effect, "getByName");
}
try {
return new org.bukkit.potion.PotionEffect(type, potionEffect.getDurationInTicks(), potionEffect.getAmplifier(),
potionEffect.isShowingParticles(), potionEffect.isShowingParticles(),
Expand Down

0 comments on commit da2ed9a

Please sign in to comment.