From 653ca4b3227ed038b3def72f0df45483c4233b1e Mon Sep 17 00:00:00 2001 From: KennyTV Date: Wed, 6 May 2020 09:30:16 +0200 Subject: [PATCH] Fix toggleglide listener swimming check --- .../protocol1_15to1_14_4/EntityToggleGlideListener.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/listeners/protocol1_15to1_14_4/EntityToggleGlideListener.java b/bukkit/src/main/java/us/myles/ViaVersion/bukkit/listeners/protocol1_15to1_14_4/EntityToggleGlideListener.java index f2171ef35..bb290ee50 100644 --- a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/listeners/protocol1_15to1_14_4/EntityToggleGlideListener.java +++ b/bukkit/src/main/java/us/myles/ViaVersion/bukkit/listeners/protocol1_15to1_14_4/EntityToggleGlideListener.java @@ -18,8 +18,15 @@ import java.util.Arrays; public class EntityToggleGlideListener extends ViaBukkitListener { + private boolean swimmingMethodExists; + public EntityToggleGlideListener(ViaVersionPlugin plugin) { super(plugin, Protocol1_15To1_14_4.class); + try { + Player.class.getMethod("isSwimming"); + swimmingMethodExists = true; + } catch (NoSuchMethodException ignored) { + } } @EventHandler(priority = EventPriority.MONITOR) @@ -47,7 +54,7 @@ public class EntityToggleGlideListener extends ViaBukkitListener { if (player.isSprinting()) { bitmask |= 0x08; } - if (player.isSwimming()) { + if (swimmingMethodExists && player.isSwimming()) { bitmask |= 0x10; } if (player.hasPotionEffect(PotionEffectType.INVISIBILITY)) {