Fixed AirFlight Fix (#544)

ty chaos for pointing it out
ty toby for being toby
This commit is contained in:
Sobki 2016-08-16 05:04:19 +10:00 committed by OmniCypher
parent 2851a82ee4
commit 4cccc6e527
2 changed files with 17 additions and 11 deletions

View file

@ -1,8 +1,7 @@
package com.projectkorra.projectkorra.airbending; package com.projectkorra.projectkorra.airbending;
import com.projectkorra.projectkorra.ability.FlightAbility; import java.util.Map;
import com.projectkorra.projectkorra.object.PlayerFlyData; import java.util.concurrent.ConcurrentHashMap;
import com.projectkorra.projectkorra.util.Flight;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
@ -10,24 +9,28 @@ import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import java.util.concurrent.ConcurrentHashMap; import com.projectkorra.projectkorra.ability.FlightAbility;
import com.projectkorra.projectkorra.ability.CoreAbility;
import com.projectkorra.projectkorra.object.PlayerFlyData;
import com.projectkorra.projectkorra.util.Flight;
public class AirFlight extends FlightAbility { public class AirFlight extends FlightAbility {
private static final ConcurrentHashMap<String, Integer> HITS = new ConcurrentHashMap<>(); private static final Map<String, Integer> HITS = new ConcurrentHashMap<>();
private static final ConcurrentHashMap<String, PlayerFlyData> HOVERING = new ConcurrentHashMap<>(); private static final Map<String, PlayerFlyData> HOVERING = new ConcurrentHashMap<>();
private boolean firstProgressIteration; private boolean firstProgressIteration;
private int maxHitsBeforeRemoval; private int maxHitsBeforeRemoval;
private double speed; private double speed;
private Flight flight; private Flight flight;
static int hoverY; private double hoverY;
public AirFlight(Player player) { public AirFlight(Player player) {
super(player); super(player);
this.maxHitsBeforeRemoval = getConfig().getInt("Abilities.Air.Flight.MaxHits"); this.maxHitsBeforeRemoval = getConfig().getInt("Abilities.Air.Flight.MaxHits");
this.speed = getConfig().getDouble("Abilities.Air.Flight.Speed"); this.speed = getConfig().getDouble("Abilities.Air.Flight.Speed");
this.firstProgressIteration = true; this.firstProgressIteration = true;
hoverY = player.getLocation().getBlockY();
start(); start();
} }
@ -65,6 +68,9 @@ public class AirFlight extends FlightAbility {
} }
public static void setHovering(Player player, boolean bool) { public static void setHovering(Player player, boolean bool) {
AirFlight flight = CoreAbility.getAbility(player, AirFlight.class);
flight.hoverY = player.getLocation().getBlockY();
String playername = player.getName(); String playername = player.getName();
if (bool) { if (bool) {
@ -72,7 +78,6 @@ public class AirFlight extends FlightAbility {
HOVERING.put(playername, new PlayerFlyData(player.getAllowFlight(), player.isFlying())); HOVERING.put(playername, new PlayerFlyData(player.getAllowFlight(), player.isFlying()));
player.setVelocity(new Vector(0, 0, 0)); player.setVelocity(new Vector(0, 0, 0));
player.setFlying(true); player.setFlying(true);
hoverY = Integer.valueOf((int) player.getLocation().getY());
} }
} else { } else {
if (HOVERING.containsKey(playername)) { if (HOVERING.containsKey(playername)) {
@ -109,10 +114,10 @@ public class AirFlight extends FlightAbility {
Vector vec = player.getVelocity().clone(); Vector vec = player.getVelocity().clone();
vec.setY(0); vec.setY(0);
player.setVelocity(vec); player.setVelocity(vec);
if (!Integer.valueOf((int) player.getLocation().getY()).equals(hoverY)) { if (player.getLocation().getBlockY() != hoverY) {
Location loc = new Location(player.getWorld(), Location loc = new Location(player.getWorld(),
player.getLocation().getX(), player.getLocation().getX(),
hoverY + 0.5, hoverY + 0.5,
player.getLocation().getZ(), player.getLocation().getZ(),
player.getLocation().getYaw(), player.getLocation().getYaw(),
player.getLocation().getPitch()); player.getLocation().getPitch());
@ -161,4 +166,4 @@ public class AirFlight extends FlightAbility {
return true; return true;
} }
} }

View file

@ -35,6 +35,7 @@ public class SwiftKick extends ChiAbility {
return; return;
} }
if (player.getLocation().subtract(0, 0.5, 0).getBlock().getType() != Material.AIR) { if (player.getLocation().subtract(0, 0.5, 0).getBlock().getType() != Material.AIR) {
remove();
return; return;
} }
DamageHandler.damageEntity(target, damage, this); DamageHandler.damageEntity(target, damage, this);