From da767bf13c089c78879dc566f54896fbb4de837d Mon Sep 17 00:00:00 2001 From: jedk1 Date: Mon, 21 Dec 2015 14:35:58 +0000 Subject: [PATCH 01/14] Fix ConcurrentModificationException in ChiCombo --- .../projectkorra/projectkorra/chiblocking/ChiCombo.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/com/projectkorra/projectkorra/chiblocking/ChiCombo.java b/src/com/projectkorra/projectkorra/chiblocking/ChiCombo.java index 6e6d74f8..7ed94810 100644 --- a/src/com/projectkorra/projectkorra/chiblocking/ChiCombo.java +++ b/src/com/projectkorra/projectkorra/chiblocking/ChiCombo.java @@ -90,13 +90,17 @@ public class ChiCombo { for (Entity e : paralyzedEntities.keySet()) { if (paralyzedEntities.get(e) <= System.currentTimeMillis()) { paralyzedEntities.remove(e); + List remove = new ArrayList(); for (ChiCombo c : instances) { if (e == null || c.target == null) { - instances.remove(c); + remove.add(instances.indexOf(c)); continue; } if (c.target.equals(e)) - instances.remove(c); + remove.add(instances.indexOf(c)); + } + for (int i : remove) { + instances.remove(i); } } } From 79d8a36d17bf5717fe05e8a8153a5029796225b1 Mon Sep 17 00:00:00 2001 From: jedk1 Date: Mon, 21 Dec 2015 17:39:29 +0000 Subject: [PATCH 02/14] Fix typo in AirBurst & FireBurst config --- .../projectkorra/configuration/ConfigManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/com/projectkorra/projectkorra/configuration/ConfigManager.java b/src/com/projectkorra/projectkorra/configuration/ConfigManager.java index 934431eb..70aaba95 100644 --- a/src/com/projectkorra/projectkorra/configuration/ConfigManager.java +++ b/src/com/projectkorra/projectkorra/configuration/ConfigManager.java @@ -219,7 +219,7 @@ public class ConfigManager { config.addDefault("Abilities.Air.AirBubble.Radius", 7); config.addDefault("Abilities.Air.AirBurst.Enabled", true); - config.addDefault("Abilities.Air.AirBurst.Description", "AirBurst is one of the most powerful abilities in the airbender's arsenal. " + "To use, press and hold sneak to charge your burst. " + "Once charged, you can either release sneak to launch a cone-shaped burst " + "of air in front of you, or click to release the burst in a sphere around you. " + "Additionally, having this ability selected when you land on the ground from a " + "large enough fall will create a burst of air around you."); + config.addDefault("Abilities.Air.AirBurst.Description", "AirBurst is one of the most powerful abilities in the airbender's arsenal. " + "To use, press and hold sneak to charge your burst. " + "Once charged, you can either release sneak to release the burst in a sphere around you " + "or click to launch a cone-shaped burst of air in front of you. " + "Additionally, having this ability selected when you land on the ground from a " + "large enough fall will create a burst of air around you."); config.addDefault("Abilities.Air.AirBurst.FallThreshold", 10); config.addDefault("Abilities.Air.AirBurst.PushFactor", 1.5); config.addDefault("Abilities.Air.AirBurst.ChargeTime", 1750); @@ -651,7 +651,7 @@ public class ConfigManager { config.addDefault("Abilities.Fire.FireBlast.Charged.FireTicks", 4); config.addDefault("Abilities.Fire.FireBurst.Enabled", true); - config.addDefault("Abilities.Fire.FireBurst.Description", "FireBurst is a very powerful firebending ability. " + "To use, press and hold sneak to charge your burst. " + "Once charged, you can either release sneak to launch a cone-shaped burst " + "of flames in front of you, or click to release the burst in a sphere around you. "); + config.addDefault("Abilities.Fire.FireBurst.Description", "FireBurst is a very powerful firebending ability. " + "To use, press and hold sneak to charge your burst. " + "Once charged, you can either release sneak to release the burst in a sphere around you or " + "click to launch a cone-shaped burst of flames in front of you."); config.addDefault("Abilities.Fire.FireBurst.Damage", 2); config.addDefault("Abilities.Fire.FireBurst.ChargeTime", 3500); config.addDefault("Abilities.Fire.FireBurst.Range", 15); From a91c165ce0b4ad764f7939f542ddd67c2f347b7b Mon Sep 17 00:00:00 2001 From: jedk1 Date: Mon, 21 Dec 2015 20:52:13 +0000 Subject: [PATCH 03/14] Fix NPE in AirScooter --- src/com/projectkorra/projectkorra/airbending/AirScooter.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/com/projectkorra/projectkorra/airbending/AirScooter.java b/src/com/projectkorra/projectkorra/airbending/AirScooter.java index 1b9faee4..5e0e0276 100644 --- a/src/com/projectkorra/projectkorra/airbending/AirScooter.java +++ b/src/com/projectkorra/projectkorra/airbending/AirScooter.java @@ -103,6 +103,10 @@ public class AirScooter implements ConfigLoadable { } public boolean progress() { + if (player.isDead() || !player.isOnline()) { + remove(); + return false; + } getFloor(); // Methods.verbose(player); if (floorblock == null) { From fa92bbe67e154c945b0e48bffccdc84e28ffb3fa Mon Sep 17 00:00:00 2001 From: jedk1 Date: Mon, 21 Dec 2015 23:52:26 +0000 Subject: [PATCH 04/14] Fix NPE in WaterWave --- .../projectkorra/projectkorra/waterbending/WaterWave.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/com/projectkorra/projectkorra/waterbending/WaterWave.java b/src/com/projectkorra/projectkorra/waterbending/WaterWave.java index d2bd5963..d49e4a54 100644 --- a/src/com/projectkorra/projectkorra/waterbending/WaterWave.java +++ b/src/com/projectkorra/projectkorra/waterbending/WaterWave.java @@ -276,9 +276,11 @@ public class WaterWave { public void remove() { instances.remove(this); - BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName()); - if (bPlayer != null) { - bPlayer.addCooldown("WaterWave", cooldown); + if (player != null && player.isOnline()) { + BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName()); + if (bPlayer != null) { + bPlayer.addCooldown("WaterWave", cooldown); + } } revertBlocks(); for (BukkitRunnable task : tasks) From 50934f980c3d31e111a29e22ee614019c3264bf9 Mon Sep 17 00:00:00 2001 From: OmniCypher Date: Fri, 25 Dec 2015 21:17:49 -0800 Subject: [PATCH 05/14] Various additions/fixes (read desc.) Fixes WaterArms Freeze going through ice Fixes cooldown typos Adds get/set cooldown in PlayerCooldownChangeEvent Adds Shift Modifier config option for Catapult Adds element toggle indicator to /b who Adds stock combos to autotab --- .../command/BendingTabComplete.java | 7 +++ .../projectkorra/command/WhoCommand.java | 31 ++++++++-- .../configuration/ConfigManager.java | 17 ++---- .../projectkorra/earthbending/Catapult.java | 8 ++- .../event/PlayerCooldownChangeEvent.java | 15 +++++ .../projectkorra/util/ActionBar.java | 61 +++++++++++++++++++ .../waterbending/WaterArmsFreeze.java | 2 +- 7 files changed, 119 insertions(+), 22 deletions(-) create mode 100644 src/com/projectkorra/projectkorra/util/ActionBar.java diff --git a/src/com/projectkorra/projectkorra/command/BendingTabComplete.java b/src/com/projectkorra/projectkorra/command/BendingTabComplete.java index 5a129cef..6e171c16 100644 --- a/src/com/projectkorra/projectkorra/command/BendingTabComplete.java +++ b/src/com/projectkorra/projectkorra/command/BendingTabComplete.java @@ -15,6 +15,8 @@ import com.projectkorra.projectkorra.Element; import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.ability.AbilityModuleManager; import com.projectkorra.projectkorra.ability.combo.ComboAbilityModule; +import com.projectkorra.projectkorra.ability.combo.ComboManager; +import com.projectkorra.projectkorra.ability.combo.ComboManager.ComboAbility; import com.projectkorra.projectkorra.ability.combo.ComboModuleManager; import com.projectkorra.projectkorra.object.Preset; @@ -113,6 +115,11 @@ public class BendingTabComplete implements TabCompleter { abils.add(abil); } } + for (ComboAbility abil : ComboManager.comboAbilityList.values()) { + if (GeneralMethods.canBind(sender.getName(), abil.getName()) && (abil.getName() != "IceBulletRightClick" && abil.getName() != "IceBulletLeftClick")) { + abils.add(abil.getName()); + } + } for (ComboAbilityModule abil : ComboModuleManager.combo) { if (GeneralMethods.canBind(sender.getName(), abil.getName())) { abils.add(abil.getName()); diff --git a/src/com/projectkorra/projectkorra/command/WhoCommand.java b/src/com/projectkorra/projectkorra/command/WhoCommand.java index f68019f5..be6f5c36 100644 --- a/src/com/projectkorra/projectkorra/command/WhoCommand.java +++ b/src/com/projectkorra/projectkorra/command/WhoCommand.java @@ -144,6 +144,7 @@ public class WhoCommand extends PKCommand { //Player player = Bukkit.getPlayer(playerName); @SuppressWarnings("deprecation") final OfflinePlayer player = Bukkit.getOfflinePlayer(playerName); + BendingPlayer bplayer = GeneralMethods.getBendingPlayer(player.getName()); if (player == null || !player.hasPlayedBefore()) { sender.sendMessage(ChatColor.RED + "Player not found!"); return; @@ -185,7 +186,11 @@ public class WhoCommand extends PKCommand { if (BendingPlayer.getPlayers().containsKey(player.getUniqueId())) { sender.sendMessage(player.getName() + (!player.isOnline() ? ChatColor.RESET + " (Offline)" : "") + " - "); if (GeneralMethods.isBender(playerName, Element.Air)) { - sender.sendMessage(AirMethods.getAirColor() + "- Airbender"); + if(bplayer.isElementToggled(Element.Air)) { + sender.sendMessage(AirMethods.getAirColor() + "- Airbender"); + } else { + sender.sendMessage(AirMethods.getAirColor() + "" + ChatColor.STRIKETHROUGH + "- Airbender"); + } if (player_ != null && AirMethods.canAirFlight((Player) player)) { sender.sendMessage(GeneralMethods.getSubBendingColor(Element.Air) + " Can Fly"); } @@ -194,7 +199,11 @@ public class WhoCommand extends PKCommand { } } if (GeneralMethods.isBender(playerName, Element.Water)) { - sender.sendMessage(WaterMethods.getWaterColor() + "- Waterbender"); + if(bplayer.isElementToggled(Element.Water)) { + sender.sendMessage(WaterMethods.getWaterColor() + "- Waterbender"); + } else { + sender.sendMessage(WaterMethods.getWaterColor() + "" + ChatColor.STRIKETHROUGH + "- Waterbender"); + } if (player_ != null && WaterMethods.canPlantbend((Player) player)) { sender.sendMessage(GeneralMethods.getSubBendingColor(Element.Water) + " Can Plantbend"); } @@ -213,7 +222,11 @@ public class WhoCommand extends PKCommand { } } if (GeneralMethods.isBender(playerName, Element.Earth)) { - sender.sendMessage(EarthMethods.getEarthColor() + "- Earthbender"); + if(bplayer.isElementToggled(Element.Earth)) { + sender.sendMessage(EarthMethods.getEarthColor() + "- Earthbender"); + } else { + sender.sendMessage(EarthMethods.getEarthColor() + "" + ChatColor.STRIKETHROUGH + "- Earthbender"); + } if (player_ != null && EarthMethods.canMetalbend((Player) player)) { sender.sendMessage(GeneralMethods.getSubBendingColor(Element.Earth) + " Can Metalbend"); } @@ -225,7 +238,11 @@ public class WhoCommand extends PKCommand { } } if (GeneralMethods.isBender(playerName, Element.Fire)) { - sender.sendMessage(FireMethods.getFireColor() + "- Firebender"); + if(bplayer.isElementToggled(Element.Fire)) { + sender.sendMessage(FireMethods.getFireColor() + "- Firebender"); + } else { + sender.sendMessage(FireMethods.getFireColor() + "" + ChatColor.STRIKETHROUGH + "- Firebender"); + } if (player_ != null && FireMethods.canCombustionbend((Player) player)) { sender.sendMessage(GeneralMethods.getSubBendingColor(Element.Fire) + " Can Combustionbend"); } @@ -234,7 +251,11 @@ public class WhoCommand extends PKCommand { } } if (GeneralMethods.isBender(playerName, Element.Chi)) { - sender.sendMessage(ChiMethods.getChiColor() + "- ChiBlocker"); + if(bplayer.isElementToggled(Element.Chi)) { + sender.sendMessage(ChiMethods.getChiColor() + "- Chiblocker"); + } else { + sender.sendMessage(ChiMethods.getChiColor() + "" + ChatColor.STRIKETHROUGH + "- Chiblocker"); + } } BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(playerName); UUID uuid = player.getUniqueId(); diff --git a/src/com/projectkorra/projectkorra/configuration/ConfigManager.java b/src/com/projectkorra/projectkorra/configuration/ConfigManager.java index f6c0ba5d..558ca01a 100644 --- a/src/com/projectkorra/projectkorra/configuration/ConfigManager.java +++ b/src/com/projectkorra/projectkorra/configuration/ConfigManager.java @@ -360,7 +360,7 @@ public class ConfigManager { config.addDefault("Abilities.Water.IceSpike.Projectile.Damage", 1); config.addDefault("Abilities.Water.IceSpike.SelectRange", 12); config.addDefault("Abilities.Water.IceSpike.AutoSourcing.Enabled", true); - config.addDefault("Abilities.Water.IceSpike.AutoSourcing.Cooldown", 1500); + config.addDefault("Abilities.Water.IceSpike.AutoSourcing.Cooldown", 2000); config.addDefault("Abilities.Water.IceSpike.AutoSourcing.SelectRange", 5); config.addDefault("Abilities.Water.IceSpike.DynamicSourcing.Enabled", true); @@ -392,7 +392,7 @@ public class ConfigManager { config.addDefault("Abilities.Water.PlantArmor.Cooldown", 10000); config.addDefault("Abilities.Water.PlantArmor.SelectRange", 12); config.addDefault("Abilities.Water.PlantArmor.AutoSourcing.Enabled", true); - config.addDefault("Abilities.Water.PlantArmor.AutoSourcing.Cooldown", 1500); + config.addDefault("Abilities.Water.PlantArmor.AutoSourcing.Cooldown", 10000); config.addDefault("Abilities.Water.PlantArmor.AutoSourcing.SelectRange", 5); config.addDefault("Abilities.Water.Surge.Enabled", true); @@ -476,7 +476,7 @@ public class ConfigManager { config.addDefault("Abilities.Water.WaterArms.Spear.NightAugments.Duration.Normal", 7000); config.addDefault("Abilities.Water.WaterArms.Spear.NightAugments.Duration.FullMoon", 12000); - config.addDefault("Abilities.Water.WaterArms.AutoSourcing.Enabled", true); + config.addDefault("Abilities.Water.WaterArms.AutoSourcing.Enabled", false); config.addDefault("Abilities.Water.WaterBubble.Enabled", true); config.addDefault("Abilities.Water.WaterBubble.Description", "To use, the bender must hold down sneak. All water around the user in a small bubble will vanish, replacing itself once the user either gets too far away or selects a different ability."); @@ -533,6 +533,7 @@ public class ConfigManager { config.addDefault("Abilities.Earth.Catapult.Length", 6); config.addDefault("Abilities.Earth.Catapult.Speed", 10); config.addDefault("Abilities.Earth.Catapult.Push", 4); + config.addDefault("Abilities.Earth.Catapult.ShiftModifier", 2); config.addDefault("Abilities.Earth.Catapult.Cooldown", 0); config.addDefault("Abilities.Earth.Collapse.Enabled", true); @@ -627,16 +628,6 @@ public class ConfigManager { config.addDefault("Abilities.Earth.EarthSmash.FlightTimer", 3000); config.addDefault("Abilities.Earth.EarthSmash.RemoveTimer", 30000); - // config.addDefault("Abilities.Earth.LavaSurge.Enabled", true); - // config.addDefault("Abilities.Earth.LavaSurge.Description", "LavaSurge is a fundamental move for any Lavabender out there. To use, simply sneak (Default: Shift) while looking at a source of Earth or Lava, then click in a direction. A surge of lava will swiftly travel towards the target you were pointing at, dealing moderate damage, a large knockback, and setting them on fire."); - // config.addDefault("Abilities.Earth.LavaSurge.Damage", 4); - // config.addDefault("Abilities.Earth.LavaSurge.Cooldown", 1000); - // config.addDefault("Abilities.Earth.LavaSurge.FractureRadius", 1); - // config.addDefault("Abilities.Earth.LavaSurge.PrepareRange", 7); - // config.addDefault("Abilities.Earth.LavaSurge.TravelRange", 15); - // config.addDefault("Abilities.Earth.LavaSurge.MaxLavaWaves", 10); - // config.addDefault("Abilities.Earth.LavaSurge.SourceCanBeEarth", true); - config.addDefault("Abilities.Earth.MetalClips.Enabled", true); config.addDefault("Abilities.Earth.MetalClips.Description", "MetalClips has the potential to be both an offensive and a utility ability. To start, you must carry smelted Iron Ingots in your inventory. To apply the clips onto an entity, simply click at them. If the entity is a Zombie, a Skeleton, or a Player, the clips will form armor around the entity, giving you some control over them. Each additional clip will give you more control. If you have permission to do so, you may crush the entity against a wall with a 4th clip, hurting them. Without explicit permissions, you will only be able to strap three clips on your target. If the entity is not one of the above, the clip will simply do damage and fall to the ground, to be collected. Another permission requiring action is throwing entities. To do so, click while controlling a metalclipped entity"); config.addDefault("Abilities.Earth.MetalClips.Damage", 2); diff --git a/src/com/projectkorra/projectkorra/earthbending/Catapult.java b/src/com/projectkorra/projectkorra/earthbending/Catapult.java index d946b98f..48fc97f1 100644 --- a/src/com/projectkorra/projectkorra/earthbending/Catapult.java +++ b/src/com/projectkorra/projectkorra/earthbending/Catapult.java @@ -21,12 +21,14 @@ public class Catapult implements ConfigLoadable { private static int LENGTH = ProjectKorra.plugin.getConfig().getInt("Abilities.Earth.Catapult.Length"); private static double SPEED = ProjectKorra.plugin.getConfig().getDouble("Abilities.Earth.Catapult.Speed"); private static double PUSH = ProjectKorra.plugin.getConfig().getDouble("Abilities.Earth.Catapult.Push"); - - private static long cooldown = ProjectKorra.plugin.getConfig().getLong("Abilities.Earth.Catapult.Cooldown"); + private static double SHIFT = ProjectKorra.plugin.getConfig().getDouble("Abilities.Earth.Catapult.ShiftModifier"); + private static long COOLDOWN = ProjectKorra.plugin.getConfig().getLong("Abilities.Earth.Catapult.Cooldown"); private int length = LENGTH; private double speed = SPEED; private double push = PUSH; + private double shift = SHIFT; + private long cooldown = COOLDOWN; private Player player; private Location origin; private Location location; @@ -67,7 +69,7 @@ public class Catapult implements ConfigLoadable { catapult = true; } if (player.isSneaking()) - distance = distance / 2; + distance = (int) (distance / shift); moving = true; instances.put(player, this); diff --git a/src/com/projectkorra/projectkorra/event/PlayerCooldownChangeEvent.java b/src/com/projectkorra/projectkorra/event/PlayerCooldownChangeEvent.java index 4cbd5171..3c4304ba 100644 --- a/src/com/projectkorra/projectkorra/event/PlayerCooldownChangeEvent.java +++ b/src/com/projectkorra/projectkorra/event/PlayerCooldownChangeEvent.java @@ -5,18 +5,25 @@ import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; +import com.projectkorra.projectkorra.BendingPlayer; +import com.projectkorra.projectkorra.GeneralMethods; + public final class PlayerCooldownChangeEvent extends Event implements Cancellable { private static final HandlerList handlers = new HandlerList(); private Player player; private String ability; private Result eventresult; private boolean cancelled; + private BendingPlayer bPlayer; + private long cooldown; public PlayerCooldownChangeEvent(Player player, String abilityname, Result result) { this.player = player; this.ability = abilityname; this.eventresult = result; this.cancelled = false; + this.bPlayer = GeneralMethods.getBendingPlayer(player.getName()); + this.cooldown = bPlayer.getCooldown(ability); } public Player getPlayer() { @@ -30,6 +37,10 @@ public final class PlayerCooldownChangeEvent extends Event implements Cancellabl public Result getResult() { return eventresult; } + + public long getCooldown() { + return cooldown; + } public boolean isCancelled() { return cancelled; @@ -38,6 +49,10 @@ public final class PlayerCooldownChangeEvent extends Event implements Cancellabl public void setCancelled(boolean cancel) { this.cancelled = cancel; } + + public void setCooldown(long cooldown) { + this.cooldown = cooldown; + } public HandlerList getHandlers() { return handlers; diff --git a/src/com/projectkorra/projectkorra/util/ActionBar.java b/src/com/projectkorra/projectkorra/util/ActionBar.java new file mode 100644 index 00000000..36cb16d7 --- /dev/null +++ b/src/com/projectkorra/projectkorra/util/ActionBar.java @@ -0,0 +1,61 @@ +package com.projectkorra.projectkorra.util; + +import org.bukkit.entity.Player; + +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.Method; + +import com.projectkorra.projectkorra.util.ReflectionHandler.PackageType; + +public class ActionBar { + + private static boolean initialised = false; + private static Constructor chatSer; + private static Constructor packetChat; + private static Method getHandle; + private static Field playerConnection; + private static Method sendPacket; + + static { + try { + chatSer = ReflectionHandler.getConstructor(PackageType.MINECRAFT_SERVER.getClass("ChatComponentText"), String.class); + packetChat = PackageType.MINECRAFT_SERVER.getClass("PacketPlayOutChat").getConstructor(PackageType.MINECRAFT_SERVER.getClass("IChatBaseComponent"), byte.class); + getHandle = ReflectionHandler.getMethod("CraftPlayer", PackageType.CRAFTBUKKIT_ENTITY, "getHandle"); + playerConnection = ReflectionHandler.getField("EntityPlayer", PackageType.MINECRAFT_SERVER, false, "playerConnection"); + sendPacket = ReflectionHandler.getMethod(playerConnection.getType(), "sendPacket", PackageType.MINECRAFT_SERVER.getClass("Packet")); + initialised = true; + } + catch (ReflectiveOperationException e) { + initialised = false; + } + } + + public static boolean isInitialised() { + return initialised; + } + + public static boolean sendActionBar(String message, Player... p) { + if (!initialised) { + return false; + } + try { + Object o = chatSer.newInstance(message); + Object packet = packetChat.newInstance(o, (byte) 2); + sendTo(packet, p); + } + catch (ReflectiveOperationException e) { + e.printStackTrace(); + initialised = false; + } + return initialised; + } + + private static void sendTo(Object packet, Player... pl) throws ReflectiveOperationException { + for (Player p : pl) { + Object entityplayer = getHandle.invoke(p); + Object PlayerConnection = playerConnection.get(entityplayer); + sendPacket.invoke(PlayerConnection, packet); + } + } +} diff --git a/src/com/projectkorra/projectkorra/waterbending/WaterArmsFreeze.java b/src/com/projectkorra/projectkorra/waterbending/WaterArmsFreeze.java index a1c50f62..f4a9788d 100644 --- a/src/com/projectkorra/projectkorra/waterbending/WaterArmsFreeze.java +++ b/src/com/projectkorra/projectkorra/waterbending/WaterArmsFreeze.java @@ -121,7 +121,7 @@ public class WaterArmsFreeze { } private boolean canPlaceBlock(Block block) { - if (!EarthMethods.isTransparentToEarthbending(player, block) && !((WaterMethods.isWater(block) || WaterMethods.isIcebendable(block)) && TempBlock.isTempBlock(block))) { + if (!EarthMethods.isTransparentToEarthbending(player, block) && !((WaterMethods.isWater(block)) && TempBlock.isTempBlock(block))) { return false; } if (GeneralMethods.isRegionProtectedFromBuild(player, "WaterArms", block.getLocation())) { From 3c9c0998ceef7188e70783d5ed2433abf82cd589 Mon Sep 17 00:00:00 2001 From: OmniCypher Date: Sat, 26 Dec 2015 11:50:47 -0800 Subject: [PATCH 06/14] Beta 7 --- src/plugin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugin.yml b/src/plugin.yml index 22cd542f..f1350c88 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: ProjectKorra author: ProjectKorra -version: 1.8.0 BETA 6 +version: 1.8.0 BETA 7 main: com.projectkorra.projectkorra.ProjectKorra softdepend: [PreciousStones, WorldGuard, WorldEdit, Factions, MassiveCore, GriefPrevention, Towny, NoCheatPlus, LWC] commands: From c03e4798083e2274fb04067aced4152abc7b8174 Mon Sep 17 00:00:00 2001 From: OmniCypher Date: Sat, 26 Dec 2015 12:29:38 -0800 Subject: [PATCH 07/14] Fixes nonbenders leaving blanks in /b who --- src/com/projectkorra/projectkorra/command/WhoCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/projectkorra/projectkorra/command/WhoCommand.java b/src/com/projectkorra/projectkorra/command/WhoCommand.java index be6f5c36..cabed443 100644 --- a/src/com/projectkorra/projectkorra/command/WhoCommand.java +++ b/src/com/projectkorra/projectkorra/command/WhoCommand.java @@ -76,7 +76,7 @@ public class WhoCommand extends PKCommand { List players = new ArrayList(); for (Player player : Bukkit.getOnlinePlayers()) { String playerName = player.getName(); - String result = ""; + String result = ChatColor.WHITE + playerName; BendingPlayer bp = GeneralMethods.getBendingPlayer(playerName); if (bp == null) { GeneralMethods.createBendingPlayer(player.getUniqueId(), player.getName()); From 22afc47f6169202b4ee776398f41fde82411bb54 Mon Sep 17 00:00:00 2001 From: jedk1 Date: Sat, 26 Dec 2015 22:40:15 +0000 Subject: [PATCH 08/14] Fix Cooldowns --- .../projectkorra/projectkorra/earthbending/Shockwave.java | 4 ++-- .../projectkorra/projectkorra/firebending/FireBurst.java | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/com/projectkorra/projectkorra/earthbending/Shockwave.java b/src/com/projectkorra/projectkorra/earthbending/Shockwave.java index 8d5778f3..ea9b2ace 100644 --- a/src/com/projectkorra/projectkorra/earthbending/Shockwave.java +++ b/src/com/projectkorra/projectkorra/earthbending/Shockwave.java @@ -94,9 +94,9 @@ public class Shockwave { for (double theta = 0; theta < 360; theta += dtheta) { double rtheta = Math.toRadians(theta); Vector vector = new Vector(Math.cos(rtheta), 0, Math.sin(rtheta)); - GeneralMethods.getBendingPlayer(player.getName()).addCooldown("Shockwave", cooldown); new Ripple(player, vector.normalize()); } + GeneralMethods.getBendingPlayer(player.getName()).addCooldown("Shockwave", cooldown); } public static void coneShockwave(Player player) { @@ -107,9 +107,9 @@ public class Shockwave { double rtheta = Math.toRadians(theta); Vector vector = new Vector(Math.cos(rtheta), 0, Math.sin(rtheta)); if (vector.angle(player.getEyeLocation().getDirection()) < angle) - GeneralMethods.getBendingPlayer(player.getName()).addCooldown("Shockwave", cooldown); new Ripple(player, vector.normalize()); } + GeneralMethods.getBendingPlayer(player.getName()).addCooldown("Shockwave", cooldown); instances.remove(player); } } diff --git a/src/com/projectkorra/projectkorra/firebending/FireBurst.java b/src/com/projectkorra/projectkorra/firebending/FireBurst.java index 85c80ff3..03edb86b 100644 --- a/src/com/projectkorra/projectkorra/firebending/FireBurst.java +++ b/src/com/projectkorra/projectkorra/firebending/FireBurst.java @@ -29,7 +29,7 @@ public class FireBurst implements ConfigLoadable { private int damage = config.get().getInt("Abilities.Fire.FireBurst.Damage"); private long chargetime = config.get().getLong("Abilities.Fire.FireBurst.ChargeTime"); private long range = config.get().getLong("Abilities.Fire.FireBurst.Range"); - private static long cooldown = config.get().getLong("Abilities.Air.Flight.Cooldown"); + private static long cooldown = config.get().getLong("Abilities.Fire.FireBurst.Cooldown"); private double deltheta = 10; private double delphi = 10; private boolean charged = false; @@ -91,12 +91,12 @@ public class FireBurst implements ConfigLoadable { if (direction.angle(vector) <= angle) { // Methods.verbose(direction.angle(vector)); // Methods.verbose(direction); - GeneralMethods.getBendingPlayer(player.getName()).addCooldown("FireBurst", cooldown); FireBlast fblast = new FireBlast(location, direction.normalize(), player, damage, safeblocks); fblast.setRange(this.range); } } } + GeneralMethods.getBendingPlayer(player.getName()).addCooldown("FireBurst", cooldown); } // Methods.verbose("--" + AirBlast.instances.size() + "--"); remove(); @@ -221,13 +221,13 @@ public class FireBurst implements ConfigLoadable { y = r * Math.sin(rphi) * Math.sin(rtheta); z = r * Math.cos(rtheta); Vector direction = new Vector(x, z, y); - GeneralMethods.getBendingPlayer(player.getName()).addCooldown("FireBurst", cooldown); FireBlast fblast = new FireBlast(location, direction.normalize(), player, damage, safeblocks); fblast.setRange(this.range); fblast.setShowParticles(false); blasts.add(fblast); } } + GeneralMethods.getBendingPlayer(player.getName()).addCooldown("FireBurst", cooldown); } // Methods.verbose("--" + AirBlast.instances.size() + "--"); remove(); From c7fbab8459bcf42b82d236a95cee5c3cab5bf74a Mon Sep 17 00:00:00 2001 From: jedk1 Date: Sat, 26 Dec 2015 23:56:50 +0000 Subject: [PATCH 09/14] Fix EarthSmash Config --- src/com/projectkorra/projectkorra/earthbending/EarthSmash.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/projectkorra/projectkorra/earthbending/EarthSmash.java b/src/com/projectkorra/projectkorra/earthbending/EarthSmash.java index 10b29aeb..f59b7cfc 100644 --- a/src/com/projectkorra/projectkorra/earthbending/EarthSmash.java +++ b/src/com/projectkorra/projectkorra/earthbending/EarthSmash.java @@ -32,7 +32,7 @@ public class EarthSmash { public static boolean ALLOW_GRAB = ProjectKorra.plugin.getConfig().getBoolean("Abilities.Earth.EarthSmash.AllowGrab"); public static boolean ALLOW_SHOOTING = ProjectKorra.plugin.getConfig().getBoolean("Abilities.Earth.EarthSmash.AllowShooting"); public static boolean ALLOW_FLIGHT = ProjectKorra.plugin.getConfig().getBoolean("Abilities.Earth.EarthSmash.AllowFlight"); - public static int GRAB_RANGE = ProjectKorra.plugin.getConfig().getInt("Properties.Earth.Range"); + public static int GRAB_RANGE = ProjectKorra.plugin.getConfig().getInt("Properties.Earth.SelectRange"); public static double TRAVEL_RANGE = ProjectKorra.plugin.getConfig().getDouble("Abilities.Earth.EarthSmash.ShotRange"); public static double SHOOTING_DAMAGE = ProjectKorra.plugin.getConfig().getDouble("Abilities.Earth.EarthSmash.Damage"); From d89e1777376904b9e328d5a3cba6b160d20cd537 Mon Sep 17 00:00:00 2001 From: OmniCypher Date: Sat, 26 Dec 2015 16:33:33 -0800 Subject: [PATCH 10/14] Various fixes (read desc.) Removes Auto/Dynamic capabilities from various moves (shouldnt have had them) Fixes metalbending Fixes Dynamic Toggles not working correctly --- .../configuration/ConfigManager.java | 8 --- .../projectkorra/earthbending/Collapse.java | 2 +- .../earthbending/CompactColumn.java | 2 +- .../projectkorra/earthbending/EarthArmor.java | 2 +- .../projectkorra/earthbending/EarthBlast.java | 4 +- .../earthbending/EarthColumn.java | 2 +- .../projectkorra/earthbending/EarthWall.java | 2 +- .../projectkorra/earthbending/LavaFlow.java | 2 +- .../projectkorra/earthbending/LavaSurge.java | 2 +- .../projectkorra/earthbending/LavaWall.java | 2 +- .../projectkorra/earthbending/LavaWave.java | 2 +- .../projectkorra/util/BlockSource.java | 69 +++++++++++-------- .../projectkorra/waterbending/IceSpike2.java | 18 +---- .../projectkorra/waterbending/WaterCombo.java | 18 +---- .../waterbending/WaterMethods.java | 2 +- .../projectkorra/waterbending/WaterWave.java | 3 +- 16 files changed, 59 insertions(+), 81 deletions(-) diff --git a/src/com/projectkorra/projectkorra/configuration/ConfigManager.java b/src/com/projectkorra/projectkorra/configuration/ConfigManager.java index 558ca01a..63f570d4 100644 --- a/src/com/projectkorra/projectkorra/configuration/ConfigManager.java +++ b/src/com/projectkorra/projectkorra/configuration/ConfigManager.java @@ -359,9 +359,6 @@ public class ConfigManager { config.addDefault("Abilities.Water.IceSpike.Projectile.Range", 20); config.addDefault("Abilities.Water.IceSpike.Projectile.Damage", 1); config.addDefault("Abilities.Water.IceSpike.SelectRange", 12); - config.addDefault("Abilities.Water.IceSpike.AutoSourcing.Enabled", true); - config.addDefault("Abilities.Water.IceSpike.AutoSourcing.Cooldown", 2000); - config.addDefault("Abilities.Water.IceSpike.AutoSourcing.SelectRange", 5); config.addDefault("Abilities.Water.IceSpike.DynamicSourcing.Enabled", true); config.addDefault("Abilities.Water.OctopusForm.Enabled", true); @@ -475,8 +472,6 @@ public class ConfigManager { config.addDefault("Abilities.Water.WaterArms.Spear.NightAugments.Sphere.FullMoon", 6); config.addDefault("Abilities.Water.WaterArms.Spear.NightAugments.Duration.Normal", 7000); config.addDefault("Abilities.Water.WaterArms.Spear.NightAugments.Duration.FullMoon", 12000); - - config.addDefault("Abilities.Water.WaterArms.AutoSourcing.Enabled", false); config.addDefault("Abilities.Water.WaterBubble.Enabled", true); config.addDefault("Abilities.Water.WaterBubble.Description", "To use, the bender must hold down sneak. All water around the user in a small bubble will vanish, replacing itself once the user either gets too far away or selects a different ability."); @@ -510,7 +505,6 @@ public class ConfigManager { config.addDefault("Abilities.Water.WaterSpout.Wave.AutoSourcing.Enabled", true); config.addDefault("Abilities.Water.WaterSpout.Wave.AutoSourcing.Cooldown", 1500); config.addDefault("Abilities.Water.WaterSpout.Wave.AutoSourcing.SelectRange", 5); - config.addDefault("Abilities.Water.WaterSpout.Wave.DynamicSourcing.Enabled", true); config.addDefault("Abilities.Water.WaterCombo.Enabled", true); config.addDefault("Abilities.Water.WaterCombo.IceWave.Damage", 4); @@ -522,8 +516,6 @@ public class ConfigManager { config.addDefault("Abilities.Water.WaterCombo.IceBullet.AnimationSpeed", 1); config.addDefault("Abilities.Water.WaterCombo.IceBullet.ShootTime", 10000); config.addDefault("Abilities.Water.WaterCombo.IceBullet.Cooldown", 10000); - config.addDefault("Abilities.Water.WaterCombo.IceBullet.AutoSourcing.Enabled", true); - config.addDefault("Abilities.Water.WaterCombo.IceBullet.DynamicSourcing.Enabled", true); config.addDefault("Abilities.Earth.Passive.Duration", 2500); config.addDefault("Properties.Earth.Passive.SandRunPower", 1); diff --git a/src/com/projectkorra/projectkorra/earthbending/Collapse.java b/src/com/projectkorra/projectkorra/earthbending/Collapse.java index eca17900..f9e53b9e 100644 --- a/src/com/projectkorra/projectkorra/earthbending/Collapse.java +++ b/src/com/projectkorra/projectkorra/earthbending/Collapse.java @@ -34,7 +34,7 @@ public class Collapse { return; this.player = player; - Block sblock = BlockSource.getEarthSourceBlock(player, selectRange, selectRange, ClickType.SHIFT_DOWN, false, false, dynamic, true, EarthMethods.canSandbend(player), false); + Block sblock = BlockSource.getEarthSourceBlock(player, selectRange, selectRange, ClickType.SHIFT_DOWN, false, dynamic, true, EarthMethods.canSandbend(player), EarthMethods.canMetalbend(player)); Location location; if (sblock == null) { location = player.getTargetBlock(EarthMethods.getTransparentEarthbending(), selectRange).getLocation(); diff --git a/src/com/projectkorra/projectkorra/earthbending/CompactColumn.java b/src/com/projectkorra/projectkorra/earthbending/CompactColumn.java index e8e9a55d..c7a22cb6 100644 --- a/src/com/projectkorra/projectkorra/earthbending/CompactColumn.java +++ b/src/com/projectkorra/projectkorra/earthbending/CompactColumn.java @@ -41,7 +41,7 @@ public class CompactColumn { if (bPlayer.isOnCooldown("Collapse")) return; - block = BlockSource.getEarthSourceBlock(player, selectRange, selectRange, ClickType.LEFT_CLICK, false, false, dynamic, true, EarthMethods.canSandbend(player), false); + block = BlockSource.getEarthSourceBlock(player, selectRange, selectRange, ClickType.LEFT_CLICK, false, dynamic, true, EarthMethods.canSandbend(player), EarthMethods.canMetalbend(player)); if (block == null) return; origin = block.getLocation(); diff --git a/src/com/projectkorra/projectkorra/earthbending/EarthArmor.java b/src/com/projectkorra/projectkorra/earthbending/EarthArmor.java index 6f0db17f..5c216166 100644 --- a/src/com/projectkorra/projectkorra/earthbending/EarthArmor.java +++ b/src/com/projectkorra/projectkorra/earthbending/EarthArmor.java @@ -59,7 +59,7 @@ public class EarthArmor { return; this.player = player; - headblock = BlockSource.getEarthSourceBlock(player, autoSelectRange, selectRange, ClickType.LEFT_CLICK, false, auto, false, true, EarthMethods.canSandbend(player), false); + headblock = BlockSource.getEarthSourceBlock(player, autoSelectRange, selectRange, ClickType.LEFT_CLICK, auto, false, true, EarthMethods.canSandbend(player), false); if (BlockSource.isAuto(headblock)) { bPlayer.addCooldown("EarthArmor", autocooldown); } else { diff --git a/src/com/projectkorra/projectkorra/earthbending/EarthBlast.java b/src/com/projectkorra/projectkorra/earthbending/EarthBlast.java index 2f8e0099..460cf6b2 100644 --- a/src/com/projectkorra/projectkorra/earthbending/EarthBlast.java +++ b/src/com/projectkorra/projectkorra/earthbending/EarthBlast.java @@ -83,8 +83,8 @@ public class EarthBlast { public boolean prepare() { cancelPrevious(); - Block block = BlockSource.getEarthSourceBlock(player, autoSelectRange, selectRange, ClickType.SHIFT_DOWN, dynamic, auto, - dynamic, true, EarthMethods.canSandbend(player), false); + Block block = BlockSource.getEarthSourceBlock(player, autoSelectRange, selectRange, ClickType.SHIFT_DOWN, auto, + dynamic, true, EarthMethods.canSandbend(player), EarthMethods.canMetalbend(player)); block(player); if (block != null) { if (block.getLocation().distance(player.getLocation()) > selectRange) { diff --git a/src/com/projectkorra/projectkorra/earthbending/EarthColumn.java b/src/com/projectkorra/projectkorra/earthbending/EarthColumn.java index a81e1446..ba76e08d 100644 --- a/src/com/projectkorra/projectkorra/earthbending/EarthColumn.java +++ b/src/com/projectkorra/projectkorra/earthbending/EarthColumn.java @@ -49,7 +49,7 @@ public class EarthColumn { if (AvatarState.isAvatarState(player)) { height = (int) (2. / 5. * (double) AvatarState.getValue(height)); } - block = BlockSource.getEarthSourceBlock(player, selectRange, selectRange, ClickType.LEFT_CLICK, false, false, dynamic, true, EarthMethods.canSandbend(player), false); + block = BlockSource.getEarthSourceBlock(player, selectRange, selectRange, ClickType.LEFT_CLICK, false, dynamic, true, EarthMethods.canSandbend(player), EarthMethods.canMetalbend(player)); if (block == null) return; origin = block.getLocation(); diff --git a/src/com/projectkorra/projectkorra/earthbending/EarthWall.java b/src/com/projectkorra/projectkorra/earthbending/EarthWall.java index edd4ab19..132e0888 100644 --- a/src/com/projectkorra/projectkorra/earthbending/EarthWall.java +++ b/src/com/projectkorra/projectkorra/earthbending/EarthWall.java @@ -45,7 +45,7 @@ public class EarthWall { Vector orth = new Vector(ox, oy, oz); orth = orth.normalize(); - Block sblock = BlockSource.getEarthSourceBlock(player, selectRange, selectRange, ClickType.SHIFT_DOWN, false, false, dynamic, true, EarthMethods.canSandbend(player), false); + Block sblock = BlockSource.getEarthSourceBlock(player, selectRange, selectRange, ClickType.SHIFT_DOWN, false, dynamic, true, EarthMethods.canSandbend(player), EarthMethods.canMetalbend(player)); if (sblock != null) { Location origin = sblock.getLocation(); World world = origin.getWorld(); diff --git a/src/com/projectkorra/projectkorra/earthbending/LavaFlow.java b/src/com/projectkorra/projectkorra/earthbending/LavaFlow.java index f7da6d84..5099c21c 100644 --- a/src/com/projectkorra/projectkorra/earthbending/LavaFlow.java +++ b/src/com/projectkorra/projectkorra/earthbending/LavaFlow.java @@ -168,7 +168,7 @@ public class LavaFlow { } instances.add(this); } else if (type == AbilityType.CLICK) { - Block sourceBlock = BlockSource.getEarthOrLavaSourceBlock(player, clickRange, clickRange, ClickType.SHIFT_DOWN, false, false, dynamic, true, EarthMethods.canSandbend(player)); + Block sourceBlock = BlockSource.getEarthOrLavaSourceBlock(player, clickRange, clickRange, ClickType.SHIFT_DOWN, false, dynamic, true, EarthMethods.canSandbend(player)); if (sourceBlock == null) { remove(); return; diff --git a/src/com/projectkorra/projectkorra/earthbending/LavaSurge.java b/src/com/projectkorra/projectkorra/earthbending/LavaSurge.java index 72ccc7bc..e2db54ba 100644 --- a/src/com/projectkorra/projectkorra/earthbending/LavaSurge.java +++ b/src/com/projectkorra/projectkorra/earthbending/LavaSurge.java @@ -102,7 +102,7 @@ public class LavaSurge { public boolean prepare() { - Block targetBlock = BlockSource.getEarthSourceBlock(player, selectRange, selectRange, ClickType.SHIFT_DOWN, false, false, dynamic, true, EarthMethods.canSandbend(player), false); + Block targetBlock = BlockSource.getEarthSourceBlock(player, selectRange, selectRange, ClickType.SHIFT_DOWN, false, dynamic, true, EarthMethods.canSandbend(player), EarthMethods.canMetalbend(player)); if(targetBlock == null || !(targetBlock.getRelative(BlockFace.UP).getType() == Material.AIR) && diff --git a/src/com/projectkorra/projectkorra/earthbending/LavaWall.java b/src/com/projectkorra/projectkorra/earthbending/LavaWall.java index 2692d288..246be03a 100644 --- a/src/com/projectkorra/projectkorra/earthbending/LavaWall.java +++ b/src/com/projectkorra/projectkorra/earthbending/LavaWall.java @@ -68,7 +68,7 @@ public class LavaWall { public boolean prepare() { cancelPrevious(); - Block block = BlockSource.getEarthOrLavaSourceBlock(player, selectRange, selectRange, ClickType.LEFT_CLICK, false, false, dynamic, true, EarthMethods.canSandbend(player)); + Block block = BlockSource.getEarthOrLavaSourceBlock(player, selectRange, selectRange, ClickType.LEFT_CLICK, false, dynamic, true, EarthMethods.canSandbend(player)); if (block != null) { sourceblock = block; focusBlock(); diff --git a/src/com/projectkorra/projectkorra/earthbending/LavaWave.java b/src/com/projectkorra/projectkorra/earthbending/LavaWave.java index 2d406d95..8bd96cac 100644 --- a/src/com/projectkorra/projectkorra/earthbending/LavaWave.java +++ b/src/com/projectkorra/projectkorra/earthbending/LavaWave.java @@ -67,7 +67,7 @@ public class LavaWave { public boolean prepare() { cancelPrevious(); // Block block = player.getTargetBlock(null, (int) range); - Block block = BlockSource.getEarthOrLavaSourceBlock(player, selectRange, selectRange, ClickType.SHIFT_DOWN, false, false, dynamic, true, EarthMethods.canSandbend(player)); + Block block = BlockSource.getEarthOrLavaSourceBlock(player, selectRange, selectRange, ClickType.SHIFT_DOWN, false, dynamic, true, EarthMethods.canSandbend(player)); if (block != null) { sourceblock = block; focusBlock(); diff --git a/src/com/projectkorra/projectkorra/util/BlockSource.java b/src/com/projectkorra/projectkorra/util/BlockSource.java index 3e185092..ae2dd96c 100644 --- a/src/com/projectkorra/projectkorra/util/BlockSource.java +++ b/src/com/projectkorra/projectkorra/util/BlockSource.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.entity.Player; @@ -147,7 +148,7 @@ public class BlockSource { public static Block getDynamicEarthSourceBlock(Player player, int autoRange, int selectRange, BlockSourceType sourceType, ClickType clickType, boolean auto, boolean dynamic, boolean earth, boolean sand, boolean metal) { update(player, selectRange, clickType); BlockSourceInformation info = getValidBlockSourceInformation(player, selectRange, sourceType, clickType); - if (info != null && dynamic) { + if (info != null) { Block tempBlock = info.getBlock(); if (EarthMethods.isEarthbendable(tempBlock.getType()) && earth) { return tempBlock; @@ -159,11 +160,10 @@ public class BlockSource { return tempBlock; } } - if (auto) { - return EarthMethods.getRandomEarthBlock(player, player.getLocation(), autoRange, earth, sand, metal); - } else { - return EarthMethods.getEarthSourceBlock(player, selectRange, earth, sand, metal); + if (info == null && dynamic) { + return null; } + return EarthMethods.getEarthSourceBlock(player, selectRange, earth, sand, metal); } /** @@ -189,11 +189,12 @@ public class BlockSource { return info.getBlock(); } } - if (auto) { - return WaterMethods.getRandomWaterBlock(player, player.getLocation(), autoRange, water, ice, plant); - } else { - return WaterMethods.getWaterSourceBlock(player, selectRange, water, ice, plant); + if (info == null && dynamic) { + Bukkit.broadcastMessage("2"); + return null; } + Bukkit.broadcastMessage("1"); + return WaterMethods.getWaterSourceBlock(player, selectRange, water, ice, plant); } /** @@ -212,13 +213,20 @@ public class BlockSource { * @return a valid Water bendable block, or null if none was found. */ public static Block getWaterSourceBlock(Player player, int autoRange, int selectRange, ClickType clickType, boolean auto, boolean dynamic, boolean bottles, boolean water, boolean ice, boolean plant) { - Block sourceBlock = BlockSource.getDynamicWaterSourceBlock(player, autoRange, selectRange, BlockSourceType.WATER, clickType, auto, dynamic, water, ice, plant); + Block sourceBlock = null; + if(dynamic) + sourceBlock = BlockSource.getDynamicWaterSourceBlock(player, autoRange, selectRange, BlockSourceType.WATER, clickType, auto, dynamic, water, ice, plant); + else + sourceBlock = WaterMethods.getWaterSourceBlock(player, selectRange, water, ice, plant); if (bottles && sourceBlock == null) { + if(bottles) { // Check the block in front of the player's eyes, it may have been created by a // WaterBottle. sourceBlock = WaterMethods.getWaterSourceBlock(player, selectRange, water, ice, plant); - if (sourceBlock == null || sourceBlock.getLocation().distance(player.getEyeLocation()) > 3) { - sourceBlock = null; + } + if (auto && (sourceBlock == null || sourceBlock.getLocation().distance(player.getEyeLocation()) > 3)) { + Bukkit.broadcastMessage("3"); + sourceBlock = WaterMethods.getRandomWaterBlock(player, player.getLocation(), autoRange, water, ice, plant); } } return sourceBlock; @@ -237,23 +245,28 @@ public class BlockSource { * block. * @return a valid Earth bendable block, or null if none was found. */ - public static Block getEarthSourceBlock(Player player, int autoRange, int selectRange, ClickType clickType, boolean nearby, boolean auto, boolean dynamic, boolean earth, boolean sand, boolean metal) { - Block sourceBlock = getDynamicEarthSourceBlock(player, autoRange, selectRange, BlockSourceType.EARTH, clickType, auto, dynamic, earth, sand, metal); - if (!auto && nearby && sourceBlock == null) { + public static Block getEarthSourceBlock(Player player, int autoRange, int selectRange, ClickType clickType, boolean auto, boolean dynamic, boolean earth, boolean sand, boolean metal) { + Block sourceBlock = null; + if(dynamic) + sourceBlock = getDynamicEarthSourceBlock(player, autoRange, selectRange, BlockSourceType.EARTH, clickType, auto, dynamic, earth, sand, metal); + else + sourceBlock = EarthMethods.getEarthSourceBlock(player, selectRange, earth, sand, metal); + if (sourceBlock == null) { BlockSourceInformation blockInfo = getBlockSourceInformation(player, BlockSourceType.EARTH, clickType); + if (dynamic) { + if (blockInfo == null) { + return null; + } + Block tempBlock = blockInfo.getBlock(); + if (tempBlock == null) { + return null; + } - if (blockInfo == null) { - return null; + Location loc = tempBlock.getLocation(); + sourceBlock = EarthMethods.getNearbyEarthBlock(loc, autoRange, autoRange, earth, sand, metal); } - Block tempBlock = blockInfo.getBlock(); - if (tempBlock == null) { - return null; - } - - Location loc = tempBlock.getLocation(); - sourceBlock = EarthMethods.getNearbyEarthBlock(loc, autoRange, autoRange, earth, sand, metal); - if (sourceBlock == null || !sourceBlock.getLocation().getWorld().equals(player.getWorld()) || Math.abs(sourceBlock.getLocation().distance(player.getEyeLocation())) > autoRange) { - return null; + if (auto && (sourceBlock == null || !sourceBlock.getLocation().getWorld().equals(player.getWorld()) || Math.abs(sourceBlock.getLocation().distance(player.getEyeLocation())) > selectRange)) { + return EarthMethods.getRandomEarthBlock(player, player.getLocation(), autoRange, earth, sand, metal); } } return sourceBlock; @@ -269,13 +282,13 @@ public class BlockSource { * either {@link ClickType}.SHIFT_DOWN or ClickType.LEFT_CLICK. * @return a valid Earth or Lava bendable block, or null if none was found. */ - public static Block getEarthOrLavaSourceBlock(Player player, int autoRange, int selectRange, ClickType clickType, boolean nearby, boolean auto, boolean dynamic, boolean earth, boolean sand) { + public static Block getEarthOrLavaSourceBlock(Player player, int autoRange, int selectRange, ClickType clickType, boolean auto, boolean dynamic, boolean earth, boolean sand) { /* * When Lava is selected as a source it automatically overrides the * previous Earth based source. Only one of these types can exist, so if * Lava exists then we know Earth is null. */ - Block earthBlock = getEarthSourceBlock(player, autoRange, selectRange, clickType, nearby, auto, dynamic, earth, sand, false); + Block earthBlock = getEarthSourceBlock(player, autoRange, selectRange, clickType, auto, dynamic, earth, sand, false); BlockSourceInformation lavaBlockInfo = getValidBlockSourceInformation(player, selectRange, BlockSourceType.LAVA, clickType); if (earthBlock != null) { return earthBlock; diff --git a/src/com/projectkorra/projectkorra/waterbending/IceSpike2.java b/src/com/projectkorra/projectkorra/waterbending/IceSpike2.java index 353622ab..bde822cb 100644 --- a/src/com/projectkorra/projectkorra/waterbending/IceSpike2.java +++ b/src/com/projectkorra/projectkorra/waterbending/IceSpike2.java @@ -34,9 +34,6 @@ public class IceSpike2 { static long slowCooldown = 5000; private static int selectRange = ProjectKorra.plugin.getConfig().getInt("Abilities.Water.IceSpike.Projectile.SelectRange"); - private static int autoSelectRange = ProjectKorra.plugin.getConfig().getInt("Abilities.Water.IceSpike.Projectile.AutoSourcing.SelectRange"); - private static boolean auto = ProjectKorra.plugin.getConfig().getBoolean("Abilities.Water.IceSpike.Projectile.AutoSourcing.Enabled"); - private static long autocooldown = ProjectKorra.plugin.getConfig().getLong("Abilities.Water.IceSpike.Projectile.AutoSourcing.Cooldown"); private static boolean dynamic = ProjectKorra.plugin.getConfig().getBoolean("Abilities.Water.IceSpike.Projectile.DynamicSourcing.Enabled"); private static final long interval = 20; @@ -58,8 +55,6 @@ public class IceSpike2 { private TempBlock source; private double defaultrange = RANGE; private double defaultdamage = DAMAGE; - - private boolean isAuto; public IceSpike2(Player player) { if (!WaterMethods.canIcebend(player)) @@ -67,12 +62,7 @@ public class IceSpike2 { block(player); this.player = player; - Block sourceblock = BlockSource.getWaterSourceBlock(player, autoSelectRange, selectRange, ClickType.SHIFT_DOWN, auto, dynamic, true, true, WaterMethods.canIcebend(player), WaterMethods.canPlantbend(player)); - if (BlockSource.isAuto(sourceblock)) { - isAuto = true; - } else { - isAuto = false; - } + Block sourceblock = BlockSource.getWaterSourceBlock(player, selectRange, selectRange, ClickType.SHIFT_DOWN, false, dynamic, true, true, WaterMethods.canIcebend(player), WaterMethods.canPlantbend(player)); if (sourceblock == null) { new SpikeField(player); } else { @@ -410,11 +400,7 @@ public class IceSpike2 { progressing = false; } BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName()); - if (isAuto) { - bPlayer.addCooldown("IceSpike", autocooldown); - } else { - bPlayer.addCooldown("IceSpike", GeneralMethods.getGlobalCooldown()); - } + bPlayer.addCooldown("IceSpike", GeneralMethods.getGlobalCooldown()); instances.remove(id); } diff --git a/src/com/projectkorra/projectkorra/waterbending/WaterCombo.java b/src/com/projectkorra/projectkorra/waterbending/WaterCombo.java index 6bb89933..768c34e2 100644 --- a/src/com/projectkorra/projectkorra/waterbending/WaterCombo.java +++ b/src/com/projectkorra/projectkorra/waterbending/WaterCombo.java @@ -57,10 +57,6 @@ public class WaterCombo { public static long ICE_BULLET_SHOOT_TIME = ProjectKorra.plugin.getConfig().getLong( "Abilities.Water.WaterCombo.IceBullet.ShootTime"); private static int icebullet_selectRange = ProjectKorra.plugin.getConfig().getInt("Abilities.Water.WaterCombo.IceBullet.SelectRange"); - private static int icebullet_autoSelectRange = ProjectKorra.plugin.getConfig().getInt("Abilities.Water.WaterCombo.IceBullet.AutoSourcing.SelectRange"); - private static boolean icebullet_auto = ProjectKorra.plugin.getConfig().getBoolean("Abilities.Water.WaterCombo.IceBullet.AutoSourcing.Enabled"); - private static long icebullet_autocooldown = ProjectKorra.plugin.getConfig().getLong("Abilities.Water.WaterCombo.IceBullet.AutoSourcing.Cooldown"); - private static boolean icebullet_dynamic = ProjectKorra.plugin.getConfig().getBoolean("Abilities.Water.IceBlast.DynamicSourcing.Enabled"); private boolean IceBulletisAuto; @@ -273,25 +269,17 @@ public class WaterCombo { remove(); return; } - Block waterBlock = BlockSource.getWaterSourceBlock(player, icebullet_autoSelectRange, icebullet_selectRange, ClickType.SHIFT_DOWN, icebullet_auto, icebullet_dynamic, true, true, WaterMethods.canIcebend(player), WaterMethods.canPlantbend(player)); + Block waterBlock = BlockSource.getWaterSourceBlock(player, icebullet_selectRange, icebullet_selectRange, ClickType.SHIFT_DOWN, false, false, true, true, WaterMethods.canIcebend(player), WaterMethods.canPlantbend(player)); if (waterBlock == null) { remove(); return; } - if (BlockSource.isAuto(waterBlock)) { - IceBulletisAuto = true; - } else { - IceBulletisAuto = false; - } + IceBulletisAuto = false; this.time = 0; origin = waterBlock.getLocation(); currentLoc = origin.clone(); state = AbilityState.ICE_BULLET_FORMING; - if (IceBulletisAuto) { - bplayer.addCooldown("IceBullet", icebullet_autocooldown); - } else { - bplayer.addCooldown("IceBullet", cooldown); - } + bplayer.addCooldown("IceBullet", cooldown); direction = new Vector(1, 0, 1); waterGrabber = new WaterSourceGrabber(player, origin.clone()); } else if (waterGrabber.getState() == WaterSourceGrabber.AnimationState.FAILED) { diff --git a/src/com/projectkorra/projectkorra/waterbending/WaterMethods.java b/src/com/projectkorra/projectkorra/waterbending/WaterMethods.java index 5a8be3be..875f2bc0 100644 --- a/src/com/projectkorra/projectkorra/waterbending/WaterMethods.java +++ b/src/com/projectkorra/projectkorra/waterbending/WaterMethods.java @@ -301,7 +301,7 @@ public class WaterMethods { } public static boolean isIcebendable(Block block) { - if (block.getType() == Material.ICE) + if (block.getType() == Material.ICE || block.getType() == Material.SNOW) return true; if (block.getType() == Material.PACKED_ICE && plugin.getConfig().getBoolean("Properties.Water.CanBendPackedIce")) return true; diff --git a/src/com/projectkorra/projectkorra/waterbending/WaterWave.java b/src/com/projectkorra/projectkorra/waterbending/WaterWave.java index 73526adc..f420530d 100644 --- a/src/com/projectkorra/projectkorra/waterbending/WaterWave.java +++ b/src/com/projectkorra/projectkorra/waterbending/WaterWave.java @@ -49,7 +49,6 @@ public class WaterWave { private static int autoSelectRange = ProjectKorra.plugin.getConfig().getInt("Abilities.Water.WaterSpout.Wave.AutoSourcing.SelectRange"); private static boolean auto = ProjectKorra.plugin.getConfig().getBoolean("Abilities.Water.WaterSpout.Wave.AutoSourcing.Enabled"); private static long autocooldown = ProjectKorra.plugin.getConfig().getLong("Abilities.Water.WaterSpout.Wave.AutoSourcing.Cooldown"); - private static boolean dynamic = ProjectKorra.plugin.getConfig().getBoolean("Abilities.Water.WaterSpout.Wave.DynamicSourcing.Enabled"); private boolean isAuto; @@ -112,7 +111,7 @@ public class WaterWave { if (origin == null) { removeType(player, AbilityType.CLICK); - Block block = BlockSource.getWaterSourceBlock(player, autoSelectRange, selectRange, ClickType.SHIFT_DOWN, auto, dynamic, true, true, WaterMethods.canIcebend(player), WaterMethods.canPlantbend(player)); + Block block = BlockSource.getWaterSourceBlock(player, autoSelectRange, selectRange, ClickType.SHIFT_DOWN, auto, false, true, true, WaterMethods.canIcebend(player), WaterMethods.canPlantbend(player)); if (block == null) { if(instances.contains(this)) { remove(); From 697825a7f3be18920743fe8a17b0bd58c122c379 Mon Sep 17 00:00:00 2001 From: jedk1 Date: Sun, 27 Dec 2015 15:20:34 +0000 Subject: [PATCH 11/14] Various Fixes Remove unused boolean in WaterCombo Fix Cooldown event not returning the correct cooldown --- src/com/projectkorra/projectkorra/BendingPlayer.java | 4 ++-- .../projectkorra/event/PlayerCooldownChangeEvent.java | 9 ++------- .../projectkorra/waterbending/WaterCombo.java | 4 ++-- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/com/projectkorra/projectkorra/BendingPlayer.java b/src/com/projectkorra/projectkorra/BendingPlayer.java index a0eb9dfc..fc6947bf 100644 --- a/src/com/projectkorra/projectkorra/BendingPlayer.java +++ b/src/com/projectkorra/projectkorra/BendingPlayer.java @@ -81,7 +81,7 @@ public class BendingPlayer { * @param cooldown The cooldown time */ public void addCooldown(String ability, long cooldown) { - PlayerCooldownChangeEvent event = new PlayerCooldownChangeEvent(Bukkit.getPlayer(uuid), ability, Result.ADDED); + PlayerCooldownChangeEvent event = new PlayerCooldownChangeEvent(Bukkit.getPlayer(uuid), ability, cooldown, Result.ADDED); Bukkit.getServer().getPluginManager().callEvent(event); if (!event.isCancelled()) { this.cooldowns.put(ability, cooldown + System.currentTimeMillis()); @@ -251,7 +251,7 @@ public class BendingPlayer { * @param ability The ability's cooldown to remove */ public void removeCooldown(String ability) { - PlayerCooldownChangeEvent event = new PlayerCooldownChangeEvent(Bukkit.getPlayer(uuid), ability, Result.REMOVED); + PlayerCooldownChangeEvent event = new PlayerCooldownChangeEvent(Bukkit.getPlayer(uuid), ability, 0, Result.REMOVED); Bukkit.getServer().getPluginManager().callEvent(event); if (!event.isCancelled()) { this.cooldowns.remove(ability); diff --git a/src/com/projectkorra/projectkorra/event/PlayerCooldownChangeEvent.java b/src/com/projectkorra/projectkorra/event/PlayerCooldownChangeEvent.java index 3c4304ba..9fae5317 100644 --- a/src/com/projectkorra/projectkorra/event/PlayerCooldownChangeEvent.java +++ b/src/com/projectkorra/projectkorra/event/PlayerCooldownChangeEvent.java @@ -5,25 +5,20 @@ import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; -import com.projectkorra.projectkorra.BendingPlayer; -import com.projectkorra.projectkorra.GeneralMethods; - public final class PlayerCooldownChangeEvent extends Event implements Cancellable { private static final HandlerList handlers = new HandlerList(); private Player player; private String ability; private Result eventresult; private boolean cancelled; - private BendingPlayer bPlayer; private long cooldown; - public PlayerCooldownChangeEvent(Player player, String abilityname, Result result) { + public PlayerCooldownChangeEvent(Player player, String abilityname, long cooldown, Result result) { this.player = player; this.ability = abilityname; this.eventresult = result; this.cancelled = false; - this.bPlayer = GeneralMethods.getBendingPlayer(player.getName()); - this.cooldown = bPlayer.getCooldown(ability); + this.cooldown = cooldown; } public Player getPlayer() { diff --git a/src/com/projectkorra/projectkorra/waterbending/WaterCombo.java b/src/com/projectkorra/projectkorra/waterbending/WaterCombo.java index 768c34e2..87a6d1e6 100644 --- a/src/com/projectkorra/projectkorra/waterbending/WaterCombo.java +++ b/src/com/projectkorra/projectkorra/waterbending/WaterCombo.java @@ -58,7 +58,7 @@ public class WaterCombo { "Abilities.Water.WaterCombo.IceBullet.ShootTime"); private static int icebullet_selectRange = ProjectKorra.plugin.getConfig().getInt("Abilities.Water.WaterCombo.IceBullet.SelectRange"); - private boolean IceBulletisAuto; + //private boolean IceBulletisAuto; public static ArrayList instances = new ArrayList(); public static ConcurrentHashMap frozenBlocks = new ConcurrentHashMap(); @@ -274,7 +274,7 @@ public class WaterCombo { remove(); return; } - IceBulletisAuto = false; + //IceBulletisAuto = false; this.time = 0; origin = waterBlock.getLocation(); currentLoc = origin.clone(); From fba3badaeca7fd8e66ba1f84a46debc65a9d974a Mon Sep 17 00:00:00 2001 From: jedk1 Date: Mon, 28 Dec 2015 00:07:08 +0000 Subject: [PATCH 12/14] Fix Bloodbending not working on snow etc. --- .../waterbending/Bloodbending.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/com/projectkorra/projectkorra/waterbending/Bloodbending.java b/src/com/projectkorra/projectkorra/waterbending/Bloodbending.java index 928f183a..ad6cf301 100644 --- a/src/com/projectkorra/projectkorra/waterbending/Bloodbending.java +++ b/src/com/projectkorra/projectkorra/waterbending/Bloodbending.java @@ -22,6 +22,7 @@ import org.bukkit.potion.PotionEffectType; import org.bukkit.util.Vector; import java.util.ArrayList; +import java.util.List; import java.util.concurrent.ConcurrentHashMap; public class Bloodbending { @@ -46,6 +47,14 @@ public class Bloodbending { private int range = RANGE; private long holdTime = HOLD_TIME; private long cooldown = COOLDOWN; + + private Integer[] transparent = {0, 6, 8, 9, 10, 11, 27, 28, 30, 31, 32, + 37, 38, 39, 40, 50, 51, 55, 59, 63, 64, + 65, 66, 68, 69, 70, 71, 72, 75, 76, 77, + 78, 83, 93, 94, 104, 105, 111, 115, 117, + 132, 141, 142, 143, 147, 148, 149, 150, + 157, 175, 176, 177, 183, 184, 185, 187, + 193, 194, 195, 196, 197}; public Bloodbending(Player player) { if (instances.containsKey(player)) { @@ -81,7 +90,13 @@ public class Bloodbending { } } } else { - Entity target = GeneralMethods.getTargetedEntity(player, range, new ArrayList()); + Location location = GeneralMethods.getTargetedLocation(player, 6, transparent); + List entities = GeneralMethods.getEntitiesAroundPoint(location, 1.5); + if (entities == null || entities.isEmpty()) { + return; + } + Entity target = entities.get(0); + //Entity target = GeneralMethods.getTargetedEntity(player, range, new ArrayList()); if (target == null) return; if (!(target instanceof LivingEntity) || GeneralMethods.isRegionProtectedFromBuild(player, "Bloodbending", target.getLocation())) @@ -225,7 +240,7 @@ public class Bloodbending { targetentities.remove(entity); continue; } - Location location = GeneralMethods.getTargetedLocation(player, 6, 0, 6, 8, 9, 10, 11, 27, 28, 30, 31, 32, 37, 38, 39, 40, 50, 51, 55, 59, 63, 64, 65, 66, 68, 69, 70, 71, 72, 75, 76, 77, 78, 83, 93, 94, 104, 105, 111, 115, 117, 132, 141, 142, 143, 147, 148, 149, 150, 157, 175, 176, 177, 183, 184, 185, 187, 193, 194, 195, 196, 197); + Location location = GeneralMethods.getTargetedLocation(player, 6, transparent); double distance = location.distance(newlocation); double dx, dy, dz; dx = location.getX() - newlocation.getX(); From 0861d768aec820fb8705c52464b5a3986efd44e7 Mon Sep 17 00:00:00 2001 From: jedk1 Date: Mon, 28 Dec 2015 17:39:07 +0000 Subject: [PATCH 13/14] Fix IceWave death message --- src/com/projectkorra/projectkorra/waterbending/WaterWave.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/com/projectkorra/projectkorra/waterbending/WaterWave.java b/src/com/projectkorra/projectkorra/waterbending/WaterWave.java index f420530d..bd3813c6 100644 --- a/src/com/projectkorra/projectkorra/waterbending/WaterWave.java +++ b/src/com/projectkorra/projectkorra/waterbending/WaterWave.java @@ -4,6 +4,7 @@ import com.projectkorra.projectkorra.BendingPlayer; import com.projectkorra.projectkorra.Element; import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.ProjectKorra; +import com.projectkorra.projectkorra.SubElement; import com.projectkorra.projectkorra.ability.AvatarState; import com.projectkorra.projectkorra.util.BlockSource; import com.projectkorra.projectkorra.util.ClickType; @@ -255,7 +256,7 @@ public class WaterWave { if (entity != this.player && entity instanceof LivingEntity && !affectedEntities.contains(entity)) { affectedEntities.add(entity); final double aug = WaterMethods.getWaterbendingNightAugment(player.getWorld()); - GeneralMethods.damageEntity(player, entity, aug * damage, Element.Water, "WaterWave"); + GeneralMethods.damageEntity(player, entity, aug * damage, Element.Water, SubElement.Icebending, "IceWave"); final Player fplayer = this.player; final Entity fent = entity; new BukkitRunnable() { From 6fbdb328eb23497a18215be47afd8fb2ad7ffd03 Mon Sep 17 00:00:00 2001 From: jedk1 Date: Mon, 28 Dec 2015 17:55:26 +0000 Subject: [PATCH 14/14] Remove debug messages --- .../projectkorra/util/BlockSource.java | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/com/projectkorra/projectkorra/util/BlockSource.java b/src/com/projectkorra/projectkorra/util/BlockSource.java index ae2dd96c..c310f6f3 100644 --- a/src/com/projectkorra/projectkorra/util/BlockSource.java +++ b/src/com/projectkorra/projectkorra/util/BlockSource.java @@ -1,18 +1,17 @@ package com.projectkorra.projectkorra.util; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.block.Block; -import org.bukkit.entity.Player; - import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.earthbending.EarthMethods; import com.projectkorra.projectkorra.waterbending.WaterMethods; +import org.bukkit.Location; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + /** * BlockSource is a class that handles water and earth bending sources. When a * Player left clicks or presses shift the update method is called which @@ -190,10 +189,8 @@ public class BlockSource { } } if (info == null && dynamic) { - Bukkit.broadcastMessage("2"); return null; } - Bukkit.broadcastMessage("1"); return WaterMethods.getWaterSourceBlock(player, selectRange, water, ice, plant); } @@ -225,7 +222,6 @@ public class BlockSource { sourceBlock = WaterMethods.getWaterSourceBlock(player, selectRange, water, ice, plant); } if (auto && (sourceBlock == null || sourceBlock.getLocation().distance(player.getEyeLocation()) > 3)) { - Bukkit.broadcastMessage("3"); sourceBlock = WaterMethods.getRandomWaterBlock(player, player.getLocation(), autoRange, water, ice, plant); } }