From fa9f45497805be1e4d4d1eb2c89de5408396cfac Mon Sep 17 00:00:00 2001 From: Vahagn Tovmasian Date: Sun, 19 Jul 2020 21:28:17 -0700 Subject: [PATCH] Fix Illumination, Tremorsense, and who (#1070) ## Fixes * Fixes Illumination torch duplication when breaking the block below the Illumination * Fixes Tremorsense activating on slabs * Fixes WhoCommand not displaying Blue Fire as a perk if the user has it --- src/com/projectkorra/projectkorra/PKListener.java | 12 ++++++++++-- .../projectkorra/command/WhoCommand.java | 3 +++ .../projectkorra/earthbending/Tremorsense.java | 5 +++++ .../projectkorra/firebending/Illumination.java | 2 +- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/com/projectkorra/projectkorra/PKListener.java b/src/com/projectkorra/projectkorra/PKListener.java index 1e3c6f33..0b978691 100644 --- a/src/com/projectkorra/projectkorra/PKListener.java +++ b/src/com/projectkorra/projectkorra/PKListener.java @@ -17,7 +17,6 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; -import org.bukkit.entity.Item; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -232,6 +231,15 @@ public class PKListener implements Listener { final String abil = bPlayer.getBoundAbilityName(); CoreAbility ability = null; + if (Illumination.isIlluminationTorch(block.getRelative(BlockFace.UP))) { + TempBlock torch = TempBlock.get(block.getRelative(BlockFace.UP)); + Player user = Illumination.getBlocks().get(torch); + Illumination illumination = CoreAbility.getAbility(user, Illumination.class); + if (illumination != null) { + illumination.remove(); + } + } + if (bPlayer.isElementToggled(Element.WATER) && bPlayer.isToggled()) { if (abil != null && abil.equalsIgnoreCase("Surge")) { ability = CoreAbility.getAbility(SurgeWall.class); @@ -398,7 +406,7 @@ public class PKListener implements Listener { } try (MCTiming timing = TimingPhysicsIlluminationTorchCheck.startTiming()) { - if (Illumination.isIlluminationTorch(block)) { + if (Illumination.isIlluminationTorch(block) || Illumination.isIlluminationTorch(block.getRelative(BlockFace.UP))) { event.setCancelled(true); return; } diff --git a/src/com/projectkorra/projectkorra/command/WhoCommand.java b/src/com/projectkorra/projectkorra/command/WhoCommand.java index bf49ff86..7cf2655d 100644 --- a/src/com/projectkorra/projectkorra/command/WhoCommand.java +++ b/src/com/projectkorra/projectkorra/command/WhoCommand.java @@ -281,6 +281,9 @@ public class WhoCommand extends PKCommand { if (bPlayer.canLightningbend()) { sender.sendMessage(Element.LIGHTNING.getColor() + " Can Lightningbend"); } + if (bPlayer.hasSubElement(Element.BLUE_FIRE)) { + sender.sendMessage(Element.BLUE_FIRE.getColor() + " Can use Blue Fire"); + } for (final SubElement se : Element.getAddonSubElements(Element.FIRE)) { if (bPlayer.canUseSubElement(se)) { sender.sendMessage(se.getColor() + " Can " + (!se.getType().equals(ElementType.NO_SUFFIX) ? "" : "use ") + se.getName() + se.getType().getBend()); diff --git a/src/com/projectkorra/projectkorra/earthbending/Tremorsense.java b/src/com/projectkorra/projectkorra/earthbending/Tremorsense.java index 5865ea91..c13b630d 100644 --- a/src/com/projectkorra/projectkorra/earthbending/Tremorsense.java +++ b/src/com/projectkorra/projectkorra/earthbending/Tremorsense.java @@ -9,6 +9,7 @@ import org.bukkit.Material; import org.bukkit.Server; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.Slab; import org.bukkit.entity.Player; import com.projectkorra.projectkorra.BendingPlayer; @@ -101,6 +102,10 @@ public class Tremorsense extends EarthAbility { final boolean isBendable = this.isEarthbendable(standBlock); + if (standBlock.getBlockData() instanceof Slab) { + return; + } + if (isBendable && this.block == null) { this.block = standBlock; this.player.sendBlockChange(this.block.getLocation(), Material.GLOWSTONE, (byte) 1); diff --git a/src/com/projectkorra/projectkorra/firebending/Illumination.java b/src/com/projectkorra/projectkorra/firebending/Illumination.java index c16cb502..2ea2a505 100644 --- a/src/com/projectkorra/projectkorra/firebending/Illumination.java +++ b/src/com/projectkorra/projectkorra/firebending/Illumination.java @@ -197,7 +197,7 @@ public class Illumination extends FireAbility { public static boolean isIlluminationTorch(final Block block) { final TempBlock tempBlock = TempBlock.get(block); - if (tempBlock == null || block.getType() != Material.TORCH || !BLOCKS.containsKey(tempBlock)) { + if (tempBlock == null || (block.getType() != Material.TORCH && block.getType() != Material.SOUL_TORCH) || !BLOCKS.containsKey(tempBlock)) { return false; }