From a43c965e5b98b83a93c27c218d978129891912cd Mon Sep 17 00:00:00 2001 From: Christopher Martin Date: Tue, 18 Oct 2016 16:29:42 -0700 Subject: [PATCH] Various Fixes (#626) * Various Fixes --- .../projectkorra/GeneralMethods.java | 22 ++++++++++++++++++- .../projectkorra/projectkorra/PKListener.java | 9 ++++---- .../projectkorra/airbending/AirFlight.java | 1 + .../projectkorra/earthbending/EarthGrab.java | 2 +- .../projectkorra/util/logging/LogFilter.java | 4 ++++ .../projectkorra/waterbending/SurgeWave.java | 14 +++++++----- .../projectkorra/waterbending/Torrent.java | 2 +- 7 files changed, 42 insertions(+), 12 deletions(-) diff --git a/src/com/projectkorra/projectkorra/GeneralMethods.java b/src/com/projectkorra/projectkorra/GeneralMethods.java index 7afb35cd..26f3f049 100644 --- a/src/com/projectkorra/projectkorra/GeneralMethods.java +++ b/src/com/projectkorra/projectkorra/GeneralMethods.java @@ -1136,7 +1136,7 @@ public class GeneralMethods { } public static boolean isAdjacentToThreeOrMoreSources(Block block) { - if (TempBlock.isTempBlock(block)) { + if (TempBlock.isTempBlock(block) || block.equals(null)) { return false; } int sources = 0; @@ -1828,6 +1828,26 @@ public class GeneralMethods { } return; } + + // Attempt to stop velocity from going over the packet cap. + if(velocity.getX() > 4){ + velocity.setX(4); + } else if(velocity.getX() < -4){ + velocity.setX(-4); + } + + if(velocity.getY() > 4){ + velocity.setY(4); + } else if(velocity.getY() < -4){ + velocity.setY(-4); + } + + if(velocity.getZ() > 4){ + velocity.setZ(4); + } else if(velocity.getZ() < -4){ + velocity.setZ(-4); + } + entity.setVelocity(velocity); } diff --git a/src/com/projectkorra/projectkorra/PKListener.java b/src/com/projectkorra/projectkorra/PKListener.java index eb105842..9ec61e3f 100644 --- a/src/com/projectkorra/projectkorra/PKListener.java +++ b/src/com/projectkorra/projectkorra/PKListener.java @@ -984,7 +984,7 @@ public class PKListener implements Listener { event.setCancelled(true); } - if (bPlayer.getBoundAbilityName().equalsIgnoreCase("HealingWaters")) { + if (bPlayer.getBoundAbilityName().equalsIgnoreCase("HealingWaters") && event.getHand().equals(EquipmentSlot.HAND)) { HealingWaters instance = CoreAbility.getAbility(player, HealingWaters.class); if(instance != null && instance.charged) { instance.click(); @@ -1069,9 +1069,10 @@ public class PKListener implements Listener { double distance1 = 0; double distance2 = 0; Location loc = Bloodbending.getBloodbendingLocation(player); - if (event.getPlayer().getWorld().equals(loc.getWorld())) - distance1 = event.getFrom().distance(loc); - distance2 = event.getTo().distance(loc); + if (event.getPlayer().getWorld().equals(loc.getWorld())) { + distance1 = event.getFrom().distance(loc); + distance2 = event.getTo().distance(loc); + } if (distance2 > distance1) { player.setVelocity(new Vector(0, 0, 0)); } diff --git a/src/com/projectkorra/projectkorra/airbending/AirFlight.java b/src/com/projectkorra/projectkorra/airbending/AirFlight.java index 54fc9966..8c33999a 100644 --- a/src/com/projectkorra/projectkorra/airbending/AirFlight.java +++ b/src/com/projectkorra/projectkorra/airbending/AirFlight.java @@ -81,6 +81,7 @@ public class AirFlight extends FlightAbility { if (!HOVERING.containsKey(playername)) { HOVERING.put(playername, new PlayerFlyData(player.getAllowFlight(), player.isFlying())); player.setVelocity(new Vector(0, 0, 0)); + player.setAllowFlight(true); player.setFlying(true); } } else { diff --git a/src/com/projectkorra/projectkorra/earthbending/EarthGrab.java b/src/com/projectkorra/projectkorra/earthbending/EarthGrab.java index b90bda2d..0a16be01 100644 --- a/src/com/projectkorra/projectkorra/earthbending/EarthGrab.java +++ b/src/com/projectkorra/projectkorra/earthbending/EarthGrab.java @@ -56,7 +56,7 @@ public class EarthGrab extends EarthAbility { } else { Location targetLocation = GeneralMethods.getTargetedLocation(player, 1); Block block = GeneralMethods.getTopBlock(targetLocation, 1, 1); - if(isEarthbendable(block) && block.getWorld().equals(player.getLocation()) && block.getLocation().distance(player.getLocation()) <= 1.3) { + if(isEarthbendable(block) && block.getWorld().equals(player.getWorld()) && block.getLocation().distance(player.getLocation()) <= 1.6) { earthGrabSelf(); remove(); } diff --git a/src/com/projectkorra/projectkorra/util/logging/LogFilter.java b/src/com/projectkorra/projectkorra/util/logging/LogFilter.java index 01ddadf8..3002f961 100644 --- a/src/com/projectkorra/projectkorra/util/logging/LogFilter.java +++ b/src/com/projectkorra/projectkorra/util/logging/LogFilter.java @@ -58,6 +58,10 @@ public class LogFilter implements Filter { // Logged records contains record return false; } + + if(Bukkit.getServer().getPluginManager().isPluginEnabled(ProjectKorra.plugin.getName())) { + return false; + } final String toRecord = recordString; Bukkit.getScheduler().runTaskLater(ProjectKorra.plugin, new Runnable() { diff --git a/src/com/projectkorra/projectkorra/waterbending/SurgeWave.java b/src/com/projectkorra/projectkorra/waterbending/SurgeWave.java index 97579a2d..6004738b 100644 --- a/src/com/projectkorra/projectkorra/waterbending/SurgeWave.java +++ b/src/com/projectkorra/projectkorra/waterbending/SurgeWave.java @@ -348,8 +348,10 @@ public class SurgeWave extends WaterAbility { super.remove(); thaw(); returnWater(); - for (Block block : waveBlocks.keySet()) { - finalRemoveWater(block); + if (waveBlocks != null) { + for (Block block : waveBlocks.keySet()) { + finalRemoveWater(block); + } } } @@ -360,9 +362,11 @@ public class SurgeWave extends WaterAbility { } private void thaw() { - for (Block block : frozenBlocks.keySet()) { - TempBlock.revertBlock(block, frozenBlocks.get(block)); - frozenBlocks.remove(block); + if (frozenBlocks != null) { + for (Block block : frozenBlocks.keySet()) { + TempBlock.revertBlock(block, frozenBlocks.get(block)); + frozenBlocks.remove(block); + } } } diff --git a/src/com/projectkorra/projectkorra/waterbending/Torrent.java b/src/com/projectkorra/projectkorra/waterbending/Torrent.java index 07d181c4..935a6a87 100644 --- a/src/com/projectkorra/projectkorra/waterbending/Torrent.java +++ b/src/com/projectkorra/projectkorra/waterbending/Torrent.java @@ -222,7 +222,7 @@ public class Torrent extends WaterAbility { double dy = 0; double dz = Math.sin(phi) * radius; loc.add(dx, dy, dz); - if(GeneralMethods.isAdjacentToThreeOrMoreSources(loc.getBlock())) { + if(isWater(loc.getBlock()) && GeneralMethods.isAdjacentToThreeOrMoreSources(loc.getBlock())) { ParticleEffect.WATER_BUBBLE.display((float) Math.random(), (float) Math.random(), (float) Math.random(), 0f, 5, loc.getBlock().getLocation().clone().add(.5,.5,.5), 255.0); } loc.subtract(dx, dy, dz);