From 76cf0ebb01d6822f41378413c2cdff93f58c254b Mon Sep 17 00:00:00 2001 From: GJ Date: Wed, 1 May 2013 08:58:17 -0400 Subject: [PATCH] Only play ability effects if there's room above the player. --- .../util/skills/ParticleEffectUtils.java | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/util/skills/ParticleEffectUtils.java b/src/main/java/com/gmail/nossr50/util/skills/ParticleEffectUtils.java index d377b47ff..8c72ffcbb 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/ParticleEffectUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/ParticleEffectUtils.java @@ -7,6 +7,7 @@ import org.bukkit.FireworkEffect.Type; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; +import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.EntityType; import org.bukkit.entity.Firework; @@ -63,7 +64,9 @@ public final class ParticleEffectUtils { return; } - fireworkParticleShower(player, Color.GREEN); + if (hasHeadRoom(player)) { + fireworkParticleShower(player, Color.GREEN); + } } public static void playAbilityDisabledEffect(Player player) { @@ -71,7 +74,9 @@ public final class ParticleEffectUtils { return; } - fireworkParticleShower(player, Color.RED); + if (hasHeadRoom(player)) { + fireworkParticleShower(player, Color.RED); + } } public static void runescapeModeCelebration(Player player, SkillType skill) { @@ -91,4 +96,18 @@ public final class ParticleEffectUtils { fireworkMeta.setPower(0); firework.setFireworkMeta(fireworkMeta); } + + private static boolean hasHeadRoom(Player player) { + boolean hasHeadRoom = true; + Block headBlock = player.getEyeLocation().getBlock(); + + for (int i = 0; i < 3; i++) { + if (!headBlock.getRelative(BlockFace.UP, i).isEmpty()) { + hasHeadRoom = false; + break; + } + } + + return hasHeadRoom; + } }