Change AirFlight to use setFlying. Change remove command. (#502)

This commit is contained in:
jedk1 2016-06-16 00:40:54 +01:00 committed by OmniCypher
parent 91bb27882e
commit 913780cb85
3 changed files with 81 additions and 43 deletions

View file

@ -1,6 +1,7 @@
package com.projectkorra.projectkorra.airbending;
import com.projectkorra.projectkorra.ability.FlightAbility;
import com.projectkorra.projectkorra.object.PlayerFlyData;
import com.projectkorra.projectkorra.util.Flight;
import org.bukkit.GameMode;
@ -14,7 +15,7 @@ import java.util.concurrent.ConcurrentHashMap;
public class AirFlight extends FlightAbility {
private static final ConcurrentHashMap<String, Integer> HITS = new ConcurrentHashMap<>();
private static final ConcurrentHashMap<String, Boolean> HOVERING = new ConcurrentHashMap<>();
private static final ConcurrentHashMap<String, PlayerFlyData> HOVERING = new ConcurrentHashMap<>();
private boolean firstProgressIteration;
private int maxHitsBeforeRemoval;
@ -67,11 +68,15 @@ public class AirFlight extends FlightAbility {
if (bool) {
if (!HOVERING.containsKey(playername)) {
HOVERING.put(playername, true);
HOVERING.put(playername, new PlayerFlyData(player.getAllowFlight(), player.isFlying()));
player.setVelocity(new Vector(0, 0, 0));
player.setFlying(true);
}
} else {
if (HOVERING.containsKey(playername)) {
PlayerFlyData pfd = HOVERING.get(playername);
player.setAllowFlight(pfd.canFly());
player.setFlying(pfd.isFlying());
HOVERING.remove(playername);
}
}

View file

@ -54,6 +54,7 @@ public class RemoveCommand extends PKCommand {
Player player = Bukkit.getPlayer(args.get(0));
if (player == null) {
if (args.size() == 1) {
Element e = Element.fromString(args.get(0));
BendingPlayer senderBPlayer = BendingPlayer.getBendingPlayer(sender.getName());
@ -97,6 +98,10 @@ public class RemoveCommand extends PKCommand {
}
sender.sendMessage(ChatColor.RED + playerOffline);
return;
} else {
help(sender, false);
return;
}
}
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);

View file

@ -0,0 +1,28 @@
package com.projectkorra.projectkorra.object;
public class PlayerFlyData {
private boolean canFly;
private boolean isFlying;
public PlayerFlyData(boolean canFly, boolean isFlying) {
this.canFly = canFly;
this.isFlying = isFlying;
}
/**
* Does the player have access to fly mode?
* @return
*/
public boolean canFly() {
return canFly;
}
/**
* Was the player flying?
* @return
*/
public boolean isFlying() {
return isFlying;
}
}