diff --git a/src/com/projectkorra/projectkorra/GeneralMethods.java b/src/com/projectkorra/projectkorra/GeneralMethods.java index 6e1da99e..b1949a13 100644 --- a/src/com/projectkorra/projectkorra/GeneralMethods.java +++ b/src/com/projectkorra/projectkorra/GeneralMethods.java @@ -1024,7 +1024,7 @@ public class GeneralMethods { return blockHolder; } } - return null; + return blockHolder; } public static boolean hasItems() { diff --git a/src/com/projectkorra/projectkorra/ability/WaterAbility.java b/src/com/projectkorra/projectkorra/ability/WaterAbility.java index 0da987a8..e7cd0d7e 100644 --- a/src/com/projectkorra/projectkorra/ability/WaterAbility.java +++ b/src/com/projectkorra/projectkorra/ability/WaterAbility.java @@ -6,6 +6,7 @@ import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.util.BlockSource; import com.projectkorra.projectkorra.util.TempBlock; import com.projectkorra.projectkorra.waterbending.PhaseChangeFreeze; +import com.projectkorra.projectkorra.waterbending.PhaseChangeMelt; import com.projectkorra.projectkorra.waterbending.SurgeWall; import com.projectkorra.projectkorra.waterbending.SurgeWave; import com.projectkorra.projectkorra.waterbending.WaterArms; @@ -322,6 +323,7 @@ public abstract class WaterAbility extends ElementalAbility { public static void stopBending() { PhaseChangeFreeze.removeAllCleanup(); + PhaseChangeMelt.removeAllCleanup(); SurgeWall.removeAllCleanup(); SurgeWave.removeAllCleanup(); WaterArms.removeAllCleanup(); diff --git a/src/com/projectkorra/projectkorra/command/BindCommand.java b/src/com/projectkorra/projectkorra/command/BindCommand.java index e7c56fcc..4740d747 100644 --- a/src/com/projectkorra/projectkorra/command/BindCommand.java +++ b/src/com/projectkorra/projectkorra/command/BindCommand.java @@ -2,6 +2,7 @@ package com.projectkorra.projectkorra.command; import com.projectkorra.projectkorra.BendingPlayer; import com.projectkorra.projectkorra.Element; +import com.projectkorra.projectkorra.Element.SubElement; import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.ability.CoreAbility; import com.projectkorra.projectkorra.configuration.ConfigManager; @@ -25,6 +26,7 @@ public class BindCommand extends PKCommand { private String loadingInfo; private String toggledElementOff; private String noElement; + private String noSubElement; public BindCommand() { super("bind", "/bending bind [Slot]", ConfigManager.languageConfig.get().getString("Commands.Bind.Description"), new String[]{ "bind", "b" }); @@ -34,6 +36,7 @@ public class BindCommand extends PKCommand { this.loadingInfo = ConfigManager.languageConfig.get().getString("Commands.Bind.LoadingInfo"); this.toggledElementOff = ConfigManager.languageConfig.get().getString("Commands.Bind.ToggledElementOff"); this.noElement = ConfigManager.languageConfig.get().getString("Commands.Bind.NoElement"); + this.noSubElement = ConfigManager.languageConfig.get().getString("Commands.Bind.NoSubElement"); } @Override @@ -74,7 +77,11 @@ public class BindCommand extends PKCommand { return; } else if (coreAbil == null || !bPlayer.canBind(coreAbil)) { if (coreAbil != null && coreAbil.getElement() != Element.AVATAR && !bPlayer.hasElement(coreAbil.getElement())) { - sender.sendMessage(ChatColor.RED + this.noElement.replace("{element}", coreAbil.getElement().getName() + coreAbil.getElement().getType().getBender())); + if (coreAbil.getElement() instanceof SubElement) { + sender.sendMessage(ChatColor.RED + this.noSubElement.replace("{subelement}", coreAbil.getElement().getName() + coreAbil.getElement().getType().getBending())); + } else { + sender.sendMessage(ChatColor.RED + this.noElement.replace("{element}", coreAbil.getElement().getName() + coreAbil.getElement().getType().getBender())); + } } else { sender.sendMessage(ChatColor.RED + super.noPermissionMessage); } diff --git a/src/com/projectkorra/projectkorra/configuration/ConfigManager.java b/src/com/projectkorra/projectkorra/configuration/ConfigManager.java index 03b1ffb9..91ef7e50 100644 --- a/src/com/projectkorra/projectkorra/configuration/ConfigManager.java +++ b/src/com/projectkorra/projectkorra/configuration/ConfigManager.java @@ -199,6 +199,7 @@ public class ConfigManager { config.addDefault("Commands.Bind.ElementToggledOff", "You have that ability's element toggled off currently."); config.addDefault("Commands.Bind.SuccessfullyBound", "Succesfully bound {ability} to slot {slot}."); config.addDefault("Commands.Bind.NoElement", "You are not a {element}!"); + config.addDefault("Commands.Bind.NoSubElement", "You don't have access to {subelement}!"); config.addDefault("Commands.Add.Description", "This command will allow the user to add an element to the targeted , or themselves if the target is not specified. This command is typically reserved for server administrators."); config.addDefault("Commands.Add.SuccessfullyAddedCFW", "You are now also a {element}."); diff --git a/src/com/projectkorra/projectkorra/earthbending/LavaFlow.java b/src/com/projectkorra/projectkorra/earthbending/LavaFlow.java index 61f72fd9..318834c7 100644 --- a/src/com/projectkorra/projectkorra/earthbending/LavaFlow.java +++ b/src/com/projectkorra/projectkorra/earthbending/LavaFlow.java @@ -232,12 +232,12 @@ public class LavaFlow extends LavaAbility { Block lower = block.getRelative(BlockFace.DOWN); if (isPlant(lower)) { Block lower2 = lower.getRelative(BlockFace.DOWN); - if (!(isEarth(lower2) || isSand(lower2) || isMetal(lower2))) { + if (!isEarth(lower2) && !isSand(lower2) && !isMetal(lower2)) { continue; } createLava(lower2); } else { - if (!(isEarth(lower) || isSand(lower) || isMetal(lower))) { + if (!isEarth(lower) && !isSand(lower) && !isMetal(lower)) { continue; } createLava(lower); @@ -339,7 +339,6 @@ public class LavaFlow extends LavaAbility { if (!isEarth(lower2) && !isSand(lower2) && !isMetal(lower2)) { continue; } - tempBlock.breakNaturally(); createLava(lower2); } else { if (!isEarth(lower) && !isSand(lower) && !isMetal(lower)) { @@ -387,19 +386,16 @@ public class LavaFlow extends LavaAbility { if (isPlant(block.getRelative(BlockFace.UP))) { Block above = block.getRelative(BlockFace.UP); Block above2 = above.getRelative(BlockFace.UP); - if (isPlant(above2) && above2.getType() == Material.DOUBLE_PLANT) { + if (isPlant(above) && above.getType() == Material.DOUBLE_PLANT) { TempBlock tb = new TempBlock(above, Material.AIR, (byte) 0); TEMP_AIR_BLOCKS.put(above, tb); affectedBlocks.add(tb); - TempBlock tb2 = new TempBlock(above2, Material.AIR, (byte) 0); - TEMP_AIR_BLOCKS.put(above2, tb2); - affectedBlocks.add(tb2); } else if (!isPlant(above2)) { TempBlock tb = new TempBlock(above, Material.AIR, (byte) 0); TEMP_AIR_BLOCKS.put(above, tb); affectedBlocks.add(tb); } else return; - } + } TempBlock tblock = new TempBlock(block, Material.STATIONARY_LAVA, (byte) 0); TEMP_LAVA_BLOCKS.put(block, tblock); affectedBlocks.add(tblock); @@ -458,10 +454,17 @@ public class LavaFlow extends LavaAbility { super.remove(); for (int i = affectedBlocks.size() - 1; i > -1; i--) { final TempBlock tblock = affectedBlocks.get(i); + final boolean isTempAir = TEMP_AIR_BLOCKS.values().contains(tblock); new BukkitRunnable() { + @SuppressWarnings("deprecation") @Override public void run() { tblock.revertBlock(); + if (isTempAir && tblock.getState().getType() == Material.DOUBLE_PLANT) { + tblock.getBlock().getRelative(BlockFace.UP).setType(Material.DOUBLE_PLANT); + tblock.getBlock().getRelative(BlockFace.UP).setData((byte) (tblock.getState().getRawData() + 8)); + } + } }.runTaskLater(ProjectKorra.plugin, (long) (i / shiftRemoveSpeed)); @@ -540,7 +543,7 @@ public class LavaFlow extends LavaAbility { Block block = loc.getBlock(); for (int x = -1; x <= 1; x++) { - for (int y = -1; y <= 1; y++) { + for (int y = -2; y <= 1; y++) { for (int z = -1; z <= 1; z++) { if (!(x == 0 && y == 0 && z == 0)) { list.add(block.getLocation().add(x, y, z).getBlock()); diff --git a/src/com/projectkorra/projectkorra/waterbending/PhaseChangeMelt.java b/src/com/projectkorra/projectkorra/waterbending/PhaseChangeMelt.java index 0d09b483..0c47ad6f 100644 --- a/src/com/projectkorra/projectkorra/waterbending/PhaseChangeMelt.java +++ b/src/com/projectkorra/projectkorra/waterbending/PhaseChangeMelt.java @@ -1,6 +1,7 @@ package com.projectkorra.projectkorra.waterbending; import com.projectkorra.projectkorra.GeneralMethods; +import com.projectkorra.projectkorra.ProjectKorra; import com.projectkorra.projectkorra.ability.IceAbility; import com.projectkorra.projectkorra.avatar.AvatarState; import com.projectkorra.projectkorra.util.TempBlock; @@ -10,11 +11,15 @@ import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.entity.Player; +import org.bukkit.scheduler.BukkitRunnable; import java.util.HashSet; +import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; public class PhaseChangeMelt extends IceAbility { + private static final List MELTED_BLOCKS = new CopyOnWriteArrayList(); private static final byte FULL = 0x0; private int seaLevel; @@ -72,7 +77,7 @@ public class PhaseChangeMelt extends IceAbility { } @SuppressWarnings("deprecation") - public static void melt(Player player, Block block) { + public static void melt(Player player, final Block block) { if (GeneralMethods.isRegionProtectedFromBuild(player, "PhaseChange", block.getLocation())) { return; } else if (!SurgeWave.canThaw(block)) { @@ -96,8 +101,17 @@ public class PhaseChangeMelt extends IceAbility { } else if (PhaseChangeFreeze.getFrozenBlocks().containsKey(block)) { PhaseChangeFreeze.thaw(block); } else { + MELTED_BLOCKS.add(block); block.setType(Material.WATER); block.setData(FULL); + + new BukkitRunnable() { + @Override + public void run() { + MELTED_BLOCKS.remove(block); + block.setType(Material.ICE); + } + }.runTaskLater(ProjectKorra.plugin, 5 * 20 * 60); } } } @@ -110,6 +124,13 @@ public class PhaseChangeMelt extends IceAbility { block.getWorld().playEffect(block.getLocation(), Effect.SMOKE, 1); } } + + public static void removeAllCleanup() { + for (Block b : MELTED_BLOCKS) { + b.setType(Material.ICE); + MELTED_BLOCKS.remove(b); + } + } @Override public String getName() { @@ -176,4 +197,8 @@ public class PhaseChangeMelt extends IceAbility { this.location = location; } + public static List getMeltedBlocks() { + return MELTED_BLOCKS; + } + } diff --git a/src/com/projectkorra/projectkorra/waterbending/PlantRegrowth.java b/src/com/projectkorra/projectkorra/waterbending/PlantRegrowth.java index 4ed428f8..2ebb719a 100644 --- a/src/com/projectkorra/projectkorra/waterbending/PlantRegrowth.java +++ b/src/com/projectkorra/projectkorra/waterbending/PlantRegrowth.java @@ -27,9 +27,17 @@ public class PlantRegrowth extends PlantAbility { this.type = block.getType(); this.data = block.getData(); - if (block.getType() == Material.DOUBLE_PLANT && block.getRelative(BlockFace.DOWN).getType() == Material.DOUBLE_PLANT) { - this.block = block.getRelative(BlockFace.DOWN); - this.data = (byte) (block.getData() - 8); + if (block.getType() == Material.DOUBLE_PLANT) { + if (block.getRelative(BlockFace.DOWN).getType() == Material.DOUBLE_PLANT) { + this.block = block.getRelative(BlockFace.DOWN); + this.data = block.getRelative(BlockFace.DOWN).getData(); + + block.getRelative(BlockFace.DOWN).setType(Material.AIR); + block.setType(Material.AIR); + } else { + block.setType(Material.AIR); + block.getRelative(BlockFace.UP).setType(Material.AIR); + } } time = System.currentTimeMillis() + regrowTime / 2 + (long) (Math.random() * (double) regrowTime) / 2; @@ -46,7 +54,7 @@ public class PlantRegrowth extends PlantAbility { block.setData(data); if (type == Material.DOUBLE_PLANT) { block.getRelative(BlockFace.UP).setType(Material.DOUBLE_PLANT); - block.getRelative(BlockFace.UP).setData((byte) (data + 8)); + block.getRelative(BlockFace.UP).setData((byte) 10); } } else {