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; + } }