From 35e0d44b0b93b1d643c949bd2b42ab9cadeb12ca Mon Sep 17 00:00:00 2001 From: LinoxGH <54643600+LinoxGH@users.noreply.github.com> Date: Sat, 12 Sep 2020 17:21:03 +0300 Subject: [PATCH] Some refactoring and added a material check. --- .../listeners/BeeWingListener.java | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeWingListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeWingListener.java index 2a6afb61f..be374d3dd 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeWingListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BeeWingListener.java @@ -1,9 +1,5 @@ package io.github.thebusybiscuit.slimefun4.implementation.listeners; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; -import me.mrCookieSlime.Slimefun.api.Slimefun; import org.bukkit.HeightMap; import org.bukkit.Location; import org.bukkit.entity.Entity; @@ -16,11 +12,17 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; +import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; +import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; +import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import me.mrCookieSlime.Slimefun.api.Slimefun; + /** * This {@link Listener} is responsible for the slow falling effect given to the player - * When Nearing the ground when using the Bee Wings. + * when nearing the ground while using the Bee Wings. * * @author beSnow + * */ public class BeeWingListener implements Listener { @@ -31,11 +33,16 @@ public class BeeWingListener implements Listener { @EventHandler(priority = EventPriority.LOWEST) public void onApproachGround(PlayerMoveEvent e) { Player player = e.getPlayer(); + if (!player.isGliding()) return; if (player.isOnGround()) return; - ItemStack helmet = player.getInventory().getChestplate(); - if (!SlimefunUtils.isItemSimilar(helmet, SlimefunItems.BEE_WINGS, true) && !Slimefun.hasUnlocked(player, helmet, true)) + + ItemStack chestplate = player.getInventory().getChestplate(); + if (chestplate.getType() != Material.ELYTRA) return; + + if (!SlimefunUtils.isItemSimilar(chestplate, SlimefunItems.BEE_WINGS, true) && !Slimefun.hasUnlocked(player, chestplate, true)) { return; + } double playerDistanceToHighestBlock = (player.getLocation().getY() - player.getWorld().getHighestBlockYAt(player.getLocation(), HeightMap.WORLD_SURFACE)); @@ -62,4 +69,4 @@ public class BeeWingListener implements Listener { } return distance; } -} \ No newline at end of file +}