diff --git a/src/com/projectkorra/projectkorra/GeneralMethods.java b/src/com/projectkorra/projectkorra/GeneralMethods.java index 21d4e4a5..990ed418 100644 --- a/src/com/projectkorra/projectkorra/GeneralMethods.java +++ b/src/com/projectkorra/projectkorra/GeneralMethods.java @@ -1994,22 +1994,27 @@ public class GeneralMethods { final ClassLoader loader = ProjectKorra.class.getClassLoader(); try { for (final ClassPath.ClassInfo info : ClassPath.from(loader).getTopLevelClasses()) { - if (info.getName().startsWith("com.projectkorra.")) { - final Class clazz = info.load(); - for (final Field field : clazz.getDeclaredFields()) { - final String simpleName = clazz.getSimpleName(); - field.setAccessible(true); - try { - final Object obj = field.get(null); - if (obj instanceof Collection) { - writeToDebug(simpleName + ": " + field.getName() + " size=" + ((Collection) obj).size()); - } else if (obj instanceof Map) { - writeToDebug(simpleName + ": " + field.getName() + " size=" + ((Map) obj).size()); - } - } catch (final Exception e) { + if (info.getName().startsWith("com.projectkorra.") && !info.getName().contains("hooks")) { + try { + final Class clazz = info.load(); + for (final Field field : clazz.getDeclaredFields()) { + final String simpleName = clazz.getSimpleName(); + field.setAccessible(true); + try { + final Object obj = field.get(null); + if (obj instanceof Collection) { + writeToDebug(simpleName + ": " + field.getName() + " size=" + ((Collection) obj).size()); + } else if (obj instanceof Map) { + writeToDebug(simpleName + ": " + field.getName() + " size=" + ((Map) obj).size()); + } + } catch (final Exception e) { + } } + } catch (Exception e) { + continue; } + } } } catch (final IOException e) { diff --git a/src/com/projectkorra/projectkorra/PKListener.java b/src/com/projectkorra/projectkorra/PKListener.java index da7a34a5..b041bd22 100644 --- a/src/com/projectkorra/projectkorra/PKListener.java +++ b/src/com/projectkorra/projectkorra/PKListener.java @@ -61,6 +61,7 @@ import org.bukkit.event.inventory.InventoryPickupItemEvent; import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.PlayerBucketEmptyEvent; import org.bukkit.event.player.PlayerChangedWorldEvent; +import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerGameModeChangeEvent; import org.bukkit.event.player.PlayerInteractAtEntityEvent; import org.bukkit.event.player.PlayerInteractEvent; @@ -197,6 +198,7 @@ public class PKListener implements Listener { private static final HashMap BENDING_PLAYER_DEATH = new HashMap<>(); // Player killed by Bending. private static final List RIGHT_CLICK_INTERACT = new ArrayList(); // Player right click block. private static final ArrayList TOGGLED_OUT = new ArrayList<>(); // Stands for toggled = false while logging out. + private static final List PLAYER_DROPPED_ITEM = new ArrayList<>(); // Player dropped an item. private static final Map JUMPS = new HashMap<>(); private static MCTiming TimingPhysicsWaterManipulationCheck, TimingPhysicsEarthPassiveCheck, TimingPhysicsIlluminationTorchCheck, TimingPhysicsEarthAbilityCheck, TimingPhysicsAirTempBlockBelowFallingBlockCheck; @@ -1062,6 +1064,24 @@ public class PKListener implements Listener { } } + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onPlayerItemDrop(PlayerDropItemEvent event) { + Player player = event.getPlayer(); + BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player); + + if (event.isCancelled()) + return; + + if (bPlayer == null) + return; + + if (bPlayer.getBoundAbility() == null) + return; + + if (!PLAYER_DROPPED_ITEM.contains(player)) + PLAYER_DROPPED_ITEM.add(player); + } + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onPlayerInteraction(final PlayerInteractEvent event) { final Player player = event.getPlayer(); @@ -1588,6 +1608,11 @@ public class PKListener implements Listener { @EventHandler(priority = EventPriority.NORMAL) public void onPlayerSwing(final PlayerInteractEvent event) { final Player player = event.getPlayer(); + + if (PLAYER_DROPPED_ITEM.contains(player)) { + PLAYER_DROPPED_ITEM.remove(player); + return; + } if (event.getHand() != EquipmentSlot.HAND) { return; } diff --git a/src/com/projectkorra/projectkorra/airbending/AirBlast.java b/src/com/projectkorra/projectkorra/airbending/AirBlast.java index a2aee29f..d6beae7e 100644 --- a/src/com/projectkorra/projectkorra/airbending/AirBlast.java +++ b/src/com/projectkorra/projectkorra/airbending/AirBlast.java @@ -330,10 +330,12 @@ public class AirBlast extends AirAbility { if (bf == face) { if (!door.isOpen()) { + this.remove(); return; } } else if (bf.getOppositeFace() == face) { if (door.isOpen()) { + this.remove(); return; } } @@ -350,10 +352,12 @@ public class AirBlast extends AirAbility { if (this.origin.getY() < block.getY()) { if (!tDoor.isOpen()) { + this.remove(); return; } } else { if (tDoor.isOpen()) { + this.remove(); return; } } diff --git a/src/com/projectkorra/projectkorra/airbending/Suffocate.java b/src/com/projectkorra/projectkorra/airbending/Suffocate.java index a42abeae..ad494bd2 100644 --- a/src/com/projectkorra/projectkorra/airbending/Suffocate.java +++ b/src/com/projectkorra/projectkorra/airbending/Suffocate.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.List; import org.bukkit.Location; +import org.bukkit.entity.ArmorStand; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -149,7 +150,7 @@ public class Suffocate extends AirAbility { public void progress() { for (int i = 0; i < this.targets.size(); i++) { final LivingEntity target = this.targets.get(i); - if (target.isDead() || !target.getWorld().equals(this.player.getWorld()) || target.getLocation().distanceSquared(this.player.getEyeLocation()) > this.range * this.range || GeneralMethods.isRegionProtectedFromBuild(this, target.getLocation())) { + if (target.isDead() || !target.getWorld().equals(this.player.getWorld()) || target.getLocation().distanceSquared(this.player.getEyeLocation()) > this.range * this.range || GeneralMethods.isRegionProtectedFromBuild(this, target.getLocation()) || target instanceof ArmorStand) { this.breakSuffocateLocal(target); i--; } else if (target instanceof Player) { @@ -190,8 +191,7 @@ public class Suffocate extends AirAbility { return; } else if (!this.started) { this.started = true; - for (final LivingEntity targ : this.targets) { - final LivingEntity target = targ; + for (final LivingEntity target : this.targets) { final BukkitRunnable br1 = new BukkitRunnable() { @Override public void run() { @@ -220,7 +220,10 @@ public class Suffocate extends AirAbility { } } - this.animate(); + for (final LivingEntity target : this.targets) { + this.animate(target); + } + if (!this.player.isSneaking()) { this.remove(); return; @@ -290,7 +293,7 @@ public class Suffocate extends AirAbility { * specific time (dt) the ability will create a different set of * SuffocationSpirals. */ - public void animate() { + public void animate(final LivingEntity target) { final int steps = 8 * this.particleCount; final long curTime = System.currentTimeMillis(); final long dt = curTime - this.getStartTime() - this.chargeTime; @@ -299,28 +302,25 @@ public class Suffocate extends AirAbility { final long t2 = (long) (2500 * this.animationSpeed); final long t3 = (long) (5000 * this.animationSpeed); final long t4 = (long) (6000 * this.animationSpeed); - for (final LivingEntity lent : this.targets) { - final LivingEntity target = lent; - if (dt < t1) { - new SuffocateSpiral(target, steps, this.radius, delay, 0, 0.25 - (0.25 * dt / t1), 0, SpiralType.HORIZONTAL1); - new SuffocateSpiral(target, steps, this.radius, delay, 0, 0.25 - (0.25 * dt / t1), 0, SpiralType.HORIZONTAL2); - } else if (dt < t2) { - new SuffocateSpiral(target, steps, this.radius, delay, 0, 0, 0, SpiralType.HORIZONTAL1); - new SuffocateSpiral(target, steps * 2, this.radius, delay, 0, 0, 0, SpiralType.VERTICAL1); - new SuffocateSpiral(target, steps * 2, this.radius, delay, 0, 0, 0, SpiralType.VERTICAL2); - } else if (dt < t3) { - new SuffocateSpiral(target, steps, this.radius, delay, 0, 0, 0, SpiralType.HORIZONTAL1); - new SuffocateSpiral(target, steps, this.radius, delay, 0, 0, 0, SpiralType.VERTICAL1); - new SuffocateSpiral(target, steps, this.radius, delay, 0, 0, 0, SpiralType.VERTICAL2); - } else if (dt < t4) { - new SuffocateSpiral(target, steps, this.radius - Math.min(this.radius * 3 / 4, (this.radius * 3.0 / 4 * ((double) (dt - t3) / (double) (t4 - t3)))), delay, 0, 0, 0, SpiralType.HORIZONTAL1); - new SuffocateSpiral(target, steps, this.radius - Math.min(this.radius * 3 / 4, (this.radius * 3.0 / 4 * ((double) (dt - t3) / (double) (t4 - t3)))), delay, 0, 0, 0, SpiralType.VERTICAL1); - new SuffocateSpiral(target, steps, this.radius - Math.min(this.radius * 3 / 4, (this.radius * 3.0 / 4 * ((double) (dt - t3) / (double) (t4 - t3)))), delay, 0, 0, 0, SpiralType.VERTICAL2); - } else { - new SuffocateSpiral(target, steps, this.radius - (this.radius * 3.0 / 4.0), delay, 0, 0, 0, SpiralType.HORIZONTAL1); - new SuffocateSpiral(target, steps, this.radius - (this.radius * 3.0 / 4.0), delay, 0, 0, 0, SpiralType.VERTICAL1); - new SuffocateSpiral(target, steps, this.radius - (this.radius * 3.0 / 4.0), delay, 0, 0, 0, SpiralType.VERTICAL2); - } + if (dt < t1) { + new SuffocateSpiral(target, steps, this.radius, delay, 0, 0.25 - (0.25 * dt / t1), 0, SpiralType.HORIZONTAL1); + new SuffocateSpiral(target, steps, this.radius, delay, 0, 0.25 - (0.25 * dt / t1), 0, SpiralType.HORIZONTAL2); + } else if (dt < t2) { + new SuffocateSpiral(target, steps, this.radius, delay, 0, 0, 0, SpiralType.HORIZONTAL1); + new SuffocateSpiral(target, steps * 2, this.radius, delay, 0, 0, 0, SpiralType.VERTICAL1); + new SuffocateSpiral(target, steps * 2, this.radius, delay, 0, 0, 0, SpiralType.VERTICAL2); + } else if (dt < t3) { + new SuffocateSpiral(target, steps, this.radius, delay, 0, 0, 0, SpiralType.HORIZONTAL1); + new SuffocateSpiral(target, steps, this.radius, delay, 0, 0, 0, SpiralType.VERTICAL1); + new SuffocateSpiral(target, steps, this.radius, delay, 0, 0, 0, SpiralType.VERTICAL2); + } else if (dt < t4) { + new SuffocateSpiral(target, steps, this.radius - Math.min(this.radius * 3 / 4, (this.radius * 3.0 / 4 * ((double) (dt - t3) / (double) (t4 - t3)))), delay, 0, 0, 0, SpiralType.HORIZONTAL1); + new SuffocateSpiral(target, steps, this.radius - Math.min(this.radius * 3 / 4, (this.radius * 3.0 / 4 * ((double) (dt - t3) / (double) (t4 - t3)))), delay, 0, 0, 0, SpiralType.VERTICAL1); + new SuffocateSpiral(target, steps, this.radius - Math.min(this.radius * 3 / 4, (this.radius * 3.0 / 4 * ((double) (dt - t3) / (double) (t4 - t3)))), delay, 0, 0, 0, SpiralType.VERTICAL2); + } else { + new SuffocateSpiral(target, steps, this.radius - (this.radius * 3.0 / 4.0), delay, 0, 0, 0, SpiralType.HORIZONTAL1); + new SuffocateSpiral(target, steps, this.radius - (this.radius * 3.0 / 4.0), delay, 0, 0, 0, SpiralType.VERTICAL1); + new SuffocateSpiral(target, steps, this.radius - (this.radius * 3.0 / 4.0), delay, 0, 0, 0, SpiralType.VERTICAL2); } } diff --git a/src/com/projectkorra/projectkorra/hooks/PlaceholderAPIHook.java b/src/com/projectkorra/projectkorra/hooks/PlaceholderAPIHook.java index 485334e2..8291d20c 100644 --- a/src/com/projectkorra/projectkorra/hooks/PlaceholderAPIHook.java +++ b/src/com/projectkorra/projectkorra/hooks/PlaceholderAPIHook.java @@ -9,8 +9,6 @@ import com.projectkorra.projectkorra.BendingPlayer; import com.projectkorra.projectkorra.Element; import com.projectkorra.projectkorra.ProjectKorra; import com.projectkorra.projectkorra.ability.CoreAbility; -import com.projectkorra.projectkorra.configuration.ConfigManager; - import me.clip.placeholderapi.expansion.PlaceholderExpansion; public class PlaceholderAPIHook extends PlaceholderExpansion { diff --git a/src/com/projectkorra/projectkorra/hooks/WorldGuardFlag.java b/src/com/projectkorra/projectkorra/hooks/WorldGuardFlag.java index 9291790a..71602fcb 100644 --- a/src/com/projectkorra/projectkorra/hooks/WorldGuardFlag.java +++ b/src/com/projectkorra/projectkorra/hooks/WorldGuardFlag.java @@ -3,7 +3,6 @@ package com.projectkorra.projectkorra.hooks; import com.sk89q.worldguard.WorldGuard; import com.sk89q.worldguard.protection.flags.StateFlag; import com.sk89q.worldguard.protection.flags.registry.FlagRegistry; - import com.projectkorra.projectkorra.ProjectKorra; public class WorldGuardFlag { diff --git a/src/com/projectkorra/projectkorra/waterbending/multiabilities/WaterArmsSpear.java b/src/com/projectkorra/projectkorra/waterbending/multiabilities/WaterArmsSpear.java index 861510cb..d2ef225e 100644 --- a/src/com/projectkorra/projectkorra/waterbending/multiabilities/WaterArmsSpear.java +++ b/src/com/projectkorra/projectkorra/waterbending/multiabilities/WaterArmsSpear.java @@ -178,7 +178,7 @@ public class WaterArmsSpear extends WaterAbility { return; } - new TempBlock(this.location.getBlock(), Material.WATER, GeneralMethods.getWaterData(0)); + new TempBlock(this.location.getBlock(), Material.WATER); getIceBlocks().put(this.location.getBlock(), System.currentTimeMillis() + 600L); final Vector direction = GeneralMethods.getDirection(this.initLocation, GeneralMethods.getTargetedLocation(this.player, this.spearRange, getTransparentMaterials())).normalize(); @@ -256,7 +256,7 @@ public class WaterArmsSpear extends WaterAbility { private boolean canPlaceBlock(final Block block) { if (!isTransparent(this.player, block) && !((isWater(block) || this.isIcebendable(block)) && (TempBlock.isTempBlock(block) && !getIceBlocks().containsKey(block)))) { return false; - } else if (GeneralMethods.isRegionProtectedFromBuild(this, block.getLocation())) { + } else if (GeneralMethods.isRegionProtectedFromBuild(this, block.getLocation()) || GeneralMethods.isSolid(block)) { return false; } else if (WaterArms.isUnbreakable(block) && !isWater(block)) { return false;