From 6419ba620122c5ff42dd58ea30fb1371159b4ea5 Mon Sep 17 00:00:00 2001 From: StrangeOne101 Date: Sun, 12 Jun 2016 16:44:37 +1200 Subject: [PATCH] PhaseChange now melts WaterArms Spear Ice --- .../waterbending/PhaseChangeMelt.java | 3 ++ .../projectkorra/waterbending/WaterArms.java | 11 +++++++ .../waterbending/WaterArmsSpear.java | 31 +++++++++++++++---- 3 files changed, 39 insertions(+), 6 deletions(-) diff --git a/src/com/projectkorra/projectkorra/waterbending/PhaseChangeMelt.java b/src/com/projectkorra/projectkorra/waterbending/PhaseChangeMelt.java index a29cb176..6be6b23d 100644 --- a/src/com/projectkorra/projectkorra/waterbending/PhaseChangeMelt.java +++ b/src/com/projectkorra/projectkorra/waterbending/PhaseChangeMelt.java @@ -81,6 +81,9 @@ public class PhaseChangeMelt extends IceAbility { } else if (!Torrent.canThaw(block)) { Torrent.thaw(block); return; + } else if (WaterArmsSpear.canThaw(block)) { + WaterArmsSpear.thaw(block); + return; } WaterSpoutWave.thaw(block); diff --git a/src/com/projectkorra/projectkorra/waterbending/WaterArms.java b/src/com/projectkorra/projectkorra/waterbending/WaterArms.java index 04ab1d6c..2017e17c 100644 --- a/src/com/projectkorra/projectkorra/waterbending/WaterArms.java +++ b/src/com/projectkorra/projectkorra/waterbending/WaterArms.java @@ -341,6 +341,16 @@ public class WaterArms extends WaterAbility { BLOCK_REVERT_TIMES.remove(block); } } + + for (Block block : WaterArmsSpear.getIceBlocks().keySet()) { + long time = WaterArmsSpear.getIceBlocks().get(block); + if (System.currentTimeMillis() > time || ignoreTime) { + if (TempBlock.isTempBlock(block)) { + TempBlock.revertBlock(block, Material.AIR); + } + WaterArmsSpear.getIceBlocks().remove(block); + } + } } private void checkIfZapped() { @@ -407,6 +417,7 @@ public class WaterArms extends WaterAbility { public static void removeAllCleanup() { progressRevert(true); BLOCK_REVERT_TIMES.clear(); + WaterArmsSpear.getIceBlocks().clear(); WaterArmsWhip.removeAllCleanup(); } diff --git a/src/com/projectkorra/projectkorra/waterbending/WaterArmsSpear.java b/src/com/projectkorra/projectkorra/waterbending/WaterArmsSpear.java index 558efd1a..1b977ca8 100644 --- a/src/com/projectkorra/projectkorra/waterbending/WaterArmsSpear.java +++ b/src/com/projectkorra/projectkorra/waterbending/WaterArmsSpear.java @@ -18,9 +18,12 @@ import org.bukkit.util.Vector; import java.util.ArrayList; import java.util.List; +import java.util.concurrent.ConcurrentHashMap; public class WaterArmsSpear extends WaterAbility { + private static final ConcurrentHashMap ICE_BLOCKS = new ConcurrentHashMap(); + private boolean hitEntity; private boolean canFreeze; private boolean usageCooldownEnabled; @@ -182,7 +185,7 @@ public class WaterArmsSpear extends WaterAbility { } new TempBlock(location.getBlock(), Material.STATIONARY_WATER, (byte) 8); - WaterArms.getBlockRevertTimes().put(location.getBlock(), System.currentTimeMillis() + 600L); + getIceBlocks().put(location.getBlock(), System.currentTimeMillis() + 600L); Vector direction = GeneralMethods.getDirection(initLocation, GeneralMethods.getTargetedLocation(player, spearRange, new Integer[] { 8, 9, 79, 174 })).normalize(); location = location.add(direction.clone().multiply(1)); @@ -201,29 +204,41 @@ public class WaterArmsSpear extends WaterAbility { Block block = spearLocations.get(i).getBlock(); if (canPlaceBlock(block)) { playIcebendingSound(block.getLocation()); - if (WaterArms.getBlockRevertTimes().containsKey(block)) { - WaterArms.getBlockRevertTimes().remove(block); + if (getIceBlocks().containsKey(block)) { + getIceBlocks().remove(block); } + new TempBlock(block, Material.ICE, (byte) 0); - WaterArms.getBlockRevertTimes().put(block, System.currentTimeMillis() + spearDuration + (long) (Math.random() * 500)); + getIceBlocks().put(block, System.currentTimeMillis() + spearDuration + (long) (Math.random() * 500)); } } } } + + public static boolean canThaw(Block block) { + return getIceBlocks().containsKey(block) && block.getType() == Material.ICE; + } + + public static void thaw(Block block) { + if (canThaw(block)) { + getIceBlocks().remove(block); + block.setType(Material.AIR); + } + } private void createIceBall() { for (Block block : GeneralMethods.getBlocksAroundPoint(location, spearSphere)) { if (isTransparent(player, block) && block.getType() != Material.ICE && !WaterArms.isUnbreakable(block)) { playIcebendingSound(block.getLocation()); new TempBlock(block, Material.ICE, (byte) 0); - WaterArms.getBlockRevertTimes().put(block, System.currentTimeMillis() + spearDuration + (long) (Math.random() * 500)); + getIceBlocks().put(block, System.currentTimeMillis() + spearDuration + (long) (Math.random() * 500)); } } } private boolean canPlaceBlock(Block block) { if (!isTransparent(player, block) - && !((isWater(block) || isIcebendable(block)) && (TempBlock.isTempBlock(block) && !WaterArms.getBlockRevertTimes().containsKey(block)))) { + && !((isWater(block) || isIcebendable(block)) && (TempBlock.isTempBlock(block) && !getIceBlocks().containsKey(block)))) { return false; } else if (GeneralMethods.isRegionProtectedFromBuild(this, block.getLocation())) { return false; @@ -450,5 +465,9 @@ public class WaterArmsSpear extends WaterAbility { public void setLocation(Location location) { this.location = location; } + + public static ConcurrentHashMap getIceBlocks() { + return ICE_BLOCKS; + } }