Fix Flight Merge Conflict

This commit is contained in:
MistPhizzle 2014-12-29 15:32:53 -05:00
commit 6bbb6f3b55
13 changed files with 201 additions and 2 deletions

View file

@ -77,6 +77,7 @@ public class AbilityModuleManager {
if (a == StockAbilities.AirBlast) shiftabilities.add(a.name());
if (a == StockAbilities.AirBurst) shiftabilities.add(a.name());
if (a == StockAbilities.AirShield) shiftabilities.add(a.name());
if (a == StockAbilities.Flight) shiftabilities.add(a.name());
}
}
else if (StockAbilities.isWaterbending(a)) {

View file

@ -18,10 +18,10 @@ public enum StockAbilities {
AvatarState,
// Project Korra
Extraction, MetalClips, Smokescreen, Combustion, LavaFlow, Suffocate, IceBlast, WarriorStance, AcrobatStance, EarthSmash;
Extraction, MetalClips, Smokescreen, Combustion, LavaFlow, Suffocate, IceBlast, WarriorStance, AcrobatStance, EarthSmash, Flight;
private enum AirbendingAbilities {
AirBlast, AirBubble, AirShield, AirSuction, AirSwipe, Tornado, AirScooter, AirSpout, AirBurst, Suffocate;
AirBlast, AirBubble, AirShield, AirSuction, AirSwipe, Tornado, AirScooter, AirSpout, AirBurst, Suffocate, Flight;
}
private enum WaterbendingAbilities {

View file

@ -100,6 +100,9 @@ public class BendingManager implements Runnable {
}
}
for (Player player: world.getPlayers()) {
if(!player.hasPermission("bending.message.nightmessage")) return;
if (Methods.isBender(player.getName(), Element.Water)) {
if (Methods.hasRPG()) {
if (RPGMethods.isLunarEclipse(world)) {
@ -118,6 +121,7 @@ public class BendingManager implements Runnable {
}
}
if (Methods.isBender(player.getName(), Element.Fire)) {
if(player.hasPermission("bending.message.daymessage")) return;
player.sendMessage(Methods.getFireColor() + defaultsunsetmessage);
}
}

View file

@ -213,6 +213,10 @@ public class ConfigManager {
config.addDefault("Abilities.Air.AirSwipe.ChargeFactor", 3);
config.addDefault("Abilities.Air.AirSwipe.MaxChargeTime", 3000);
config.addDefault("Abilities.Air.Flight.Enabled", true);
config.addDefault("Abilities.Air.Flight.Description", "Jump in the air, crouch (default: shift) and hold with this ability bound and you will glide around in the direction you look. While flying, click to Hover. Click again to disable Hovering.");
config.addDefault("Abilities.Air.Flight.HoverEnabled", true);
config.addDefault("Abilities.Air.Suffocate.Enabled", true);
config.addDefault("Abilities.Air.Suffocate.Description", "This ability is one of the most dangerous abilities an Airbender possesses. To use, simply look at an entity and hold shift. The entity will begin taking damage as you extract the air from their lungs. Any bender caught in this sphere will only be able to use basic moves, such as AirSwipe, WaterManipulation, FireBlast, or EarthBlast. An entity can be knocked out of the sphere by certain bending arts, and your attention will be disrupted if you are hit by bending.");
config.addDefault("Abilities.Air.Suffocate.CanBeUsedOnUndeadMobs", true);

View file

@ -2456,4 +2456,32 @@ public class Methods {
}
}
public static boolean canFly(Player player, boolean first, boolean hovering) {
BendingPlayer bender = getBendingPlayer(player.getName());
if(!player.isOnline()) return false;
if(!player.isSneaking()) {
if(first) {
}else if(hovering) {
}else{
return false;
}
}
if(bender.isChiBlocked()) return false;
if(!player.isOnline()) return false;
if(bender.isPermaRemoved()) return false;
if(!bender.getElements().contains(Element.Air)) return false;
if(!canBend(player.getName(), "Flight")) return false;
if(!getBoundAbility(player).equalsIgnoreCase("Flight")) return false;
if(isRegionProtectedFromBuild(player, "Flight", player.getLocation())) return false;
if(player.getLocation().subtract(0, 1, 0).getBlock().getType() != Material.AIR) return false;
return true;
}
}

View file

@ -49,6 +49,7 @@ import org.bukkit.event.player.PlayerAnimationEvent;
import org.bukkit.event.player.PlayerFishEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerToggleFlightEvent;
@ -356,6 +357,15 @@ public class PKListener implements Listener {
MetalClips.instances.get(p).remove();
}
}
com.projectkorra.ProjectKorra.airbending.Flight.remove(event.getPlayer());
}
@EventHandler
public void playerIsKicked(PlayerKickEvent event) {
if(event.isCancelled()) return;
com.projectkorra.ProjectKorra.airbending.Flight.remove(event.getPlayer());
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
@ -420,6 +430,10 @@ public class PKListener implements Listener {
if(abil.equalsIgnoreCase("Suffocate")) {
new Suffocate(player);
}
if(abil.equalsIgnoreCase("Flight")) {
if(player.isSneaking()) return;
new com.projectkorra.ProjectKorra.airbending.Flight(player);
}
}
@ -592,6 +606,12 @@ public class PKListener implements Listener {
player.setVelocity(new Vector(0, 0, 0));
}
}
if(com.projectkorra.ProjectKorra.airbending.Flight.instances.containsKey(event.getPlayer().getName())) {
if(com.projectkorra.ProjectKorra.airbending.Flight.isHovering(event.getPlayer())) {
event.setTo(new Location(event.getFrom().getWorld(), event.getFrom().getX(), event.getFrom().getY(), event.getFrom().getZ(), event.getTo().getYaw(), event.getTo().getPitch()));
}
}
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
@ -769,6 +789,17 @@ public class PKListener implements Listener {
if (abil.equalsIgnoreCase("AirSwipe")) {
new AirSwipe(player);
}
if(abil.equalsIgnoreCase("Flight")) {
if(!ProjectKorra.plugin.getConfig().getBoolean("Abilities.Air.Flight.HoverEnabled")) return;
if(com.projectkorra.ProjectKorra.airbending.Flight.instances.containsKey(event.getPlayer().getName())) {
if(com.projectkorra.ProjectKorra.airbending.Flight.isHovering(event.getPlayer())) {
com.projectkorra.ProjectKorra.airbending.Flight.setHovering(event.getPlayer(), false);
}else{
com.projectkorra.ProjectKorra.airbending.Flight.setHovering(event.getPlayer(), true);
}
}
}
}
if (Methods.isWaterAbility(abil)) {
if (Methods.isWeapon(player.getItemInHand().getType()) && !plugin.getConfig().getBoolean("Properties.Water.CanBendWithWeapons")) {

View file

@ -214,6 +214,9 @@ public class AirSuction {
private void advanceLocation() {
Methods.playAirbendingParticles(location, 10);
if (Methods.rand.nextInt(4) == 0) {
Methods.playAirbendingSound(location);
}
// location.getWorld().playEffect(location, Effect.SMOKE, 4,
// (int) AirBlast.defaultrange);
location = location.add(direction.clone().multiply(speedfactor));

View file

@ -214,6 +214,9 @@ public class AirSwipe {
}
} else {
Methods.playAirbendingParticles(location, 10);
if (Methods.rand.nextInt(4) == 0) {
Methods.playAirbendingSound(location);
}
affectPeople(location, direction);
}
}

View file

@ -26,6 +26,7 @@ public class AirbendingManager implements Runnable {
Tornado.progressAll();
AirShield.progressAll();
AirCombo.progressAll();
Flight.progressAll();
}
}

View file

@ -0,0 +1,113 @@
package com.projectkorra.ProjectKorra.airbending;
import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import com.projectkorra.ProjectKorra.Methods;
public class Flight {
public static ConcurrentHashMap<String, Flight> instances = new ConcurrentHashMap<String, Flight>();
private static ConcurrentHashMap<String, Integer> hits = new ConcurrentHashMap<String, Integer>();
private static ConcurrentHashMap<String, Boolean> hovering = new ConcurrentHashMap<String, Boolean>();
private Player p;
public Flight(Player player) {
if(!Methods.canFly(player, true, false)) return;
player.setAllowFlight(true);
player.setVelocity(player.getEyeLocation().getDirection().normalize());
instances.put(player.getName(), this);
p = player;
}
private void progress() {
if(!Methods.canFly(p, false, isHovering(p))) {
remove(p);
return;
}
p.setAllowFlight(true);
p.setVelocity(p.getEyeLocation().getDirection().normalize());
}
public static void addHit(Player player) {
if(instances.containsKey(player)) {
if(hits.containsKey(player.getName())) {
if(hits.get(player.getName()) >= 4) {
hits.remove(player.getName());
remove(player);
}
}else{
hits.put(player.getName(), 1);
}
}
}
public static boolean isHovering(Player player) {
String playername = player.getName();
if(hovering.containsKey(playername) && hovering.get(playername)) return true;
if(hovering.containsKey(playername) && hovering.get(playername)) return false; //Shouldn't happen
return false;
}
public static void setHovering(Player player, boolean bool) {
String playername = player.getName();
if(bool) {
if(!hovering.containsKey(playername)) {
hovering.put(playername, true);
player.setFlying(true);
player.setVelocity(new Vector(0, 0 ,0));
}
}else{
if(hovering.containsKey(playername)) {
hovering.remove(playername);
player.setFlying(false);
}
}
}
public static void progressAll() {
for(String names : instances.keySet()) {
instances.get(names).progress();
}
}
@SuppressWarnings("deprecation")
public static void remove(Player player) {
if(instances.containsKey(player.getName())) {
instances.remove(player.getName());
if(hits.containsKey(player.getName())) {
hits.remove(player.getName());
}
if(hovering.containsKey(player.getName())) {
hovering.remove(player.getName());
}
if((!(player.getGameMode().getValue() == 1))) {
if(!(player.getGameMode().getValue() == 1)) {
player.setAllowFlight(false);
}
}
if((!(player.getGameMode().getValue() == 3))) {
if(!(player.getGameMode().getValue() == 1)) {
player.setAllowFlight(false);
}
}
}
}
public static void removeAll() {
instances.clear();
hits.clear();
hovering.clear();
}
}

View file

@ -113,6 +113,12 @@ public class Cook {
case POTATO_ITEM:
cooked = new ItemStack(Material.BAKED_POTATO, 1);
break;
case MUTTON:
cooked = new ItemStack(Material.COOKED_MUTTON);
break;
case RABBIT:
cooked = new ItemStack(Material.COOKED_RABBIT);
break;
default:
break; //Shouldn't happen
}

View file

@ -153,6 +153,10 @@ Abilities:
Cooldown: 1500
ChargeFactor: 3
MaxChargeTime: 3000
Flight:
Enabled: true
Description: "Jump in the air, crouch (default: shift) and hold with this ability bound and you will glide around in the direction you look. While flying, click to Hover. Click again to disable Hovering."
HoverEnabled: true
Suffocate:
Enabled: true
Description: "This ability is one of the most dangerous abilities an Airbender possesses. To use, simply look at an entity and hold shift. The entity will begin taking damage as you extract the air from their lungs. Any bender caught in this sphere will only be able to use basic moves, such as AirSwipe, WaterManipulation, FireBlast, or EarthBlast. An entity can be knocked out of the sphere by certain bending arts, and your attention will be disrupted if you are hit by bending."

View file

@ -22,6 +22,7 @@ permissions:
bending.admin.choose: true
bending.ability.AvatarState: true
bending.ability.Bloodbending: true
bending.ability.Flight: true
bending.command.import: true
bending.command.toggle.all: true
bending.command.give: true