Fixes bending with weapons (#678)

This commit is contained in:
Christopher Martin 2017-01-05 17:57:39 -08:00 committed by GitHub
parent 4ac9b8fb6e
commit 7a67becb58
2 changed files with 263 additions and 278 deletions

View file

@ -256,6 +256,24 @@ public class BendingPlayer {
return true;
}
public boolean canCurrentlyBendWithWeapons() {
if (getBoundAbility() != null && player.getInventory().getItemInMainHand() != null) {
boolean hasWeapon = GeneralMethods.isWeapon(player.getInventory().getItemInMainHand().getType());
boolean noWeaponElement = GeneralMethods.getElementsWithNoWeaponBending().contains(getBoundAbility().getElement());
if (hasWeapon) {
if(noWeaponElement) {
return false;
} else {
return true;
}
}
return true;
}
return false;
}
/**
* Checks to see if {@link BendingPlayer} can be slowed.
*

View file

@ -71,6 +71,7 @@ import org.bukkit.util.Vector;
import com.projectkorra.projectkorra.ability.Ability;
import com.projectkorra.projectkorra.ability.AddonAbility;
import com.projectkorra.projectkorra.ability.AirAbility;
import com.projectkorra.projectkorra.ability.AvatarAbility;
import com.projectkorra.projectkorra.ability.ChiAbility;
import com.projectkorra.projectkorra.ability.CoreAbility;
import com.projectkorra.projectkorra.ability.EarthAbility;
@ -896,10 +897,7 @@ public class PKListener implements Listener {
if (sourceBPlayer.canBendPassive(Element.CHI)) {
if (e.getCause() == DamageCause.ENTITY_ATTACK && e.getDamage() == 1) {
if (sourceBPlayer.getBoundAbility() instanceof ChiAbility) {
if (sourceBPlayer.getBoundAbility() != null && sourcePlayer.getInventory().getItemInMainHand() != null && GeneralMethods.isWeapon(sourcePlayer.getInventory().getItemInMainHand().getType())
&& !plugin.getConfig().getBoolean("Properties.Chi.CanBendWithWeapons")) {
return;
}
if (sourceBPlayer.canCurrentlyBendWithWeapons()) {
if (sourceBPlayer.isElementToggled(Element.CHI) == true) {
if (boundAbil.equalsIgnoreCase("Paralyze")) {
new Paralyze(sourcePlayer, targetPlayer);
@ -907,11 +905,9 @@ public class PKListener implements Listener {
new QuickStrike(sourcePlayer, targetPlayer);
} else if (boundAbil.equalsIgnoreCase("SwiftKick")) {
new SwiftKick(sourcePlayer, targetPlayer);
}
else if (boundAbil.equalsIgnoreCase("RapidPunch")) {
} else if (boundAbil.equalsIgnoreCase("RapidPunch")) {
new RapidPunch(sourcePlayer, targetPlayer);
}
else {
} else {
if (ChiPassive.willChiBlock(sourcePlayer, targetPlayer)) {
ChiPassive.blockChi(targetPlayer);
}
@ -920,20 +916,6 @@ public class PKListener implements Listener {
}
}
}
if (sourceBPlayer.canBendPassive(Element.CHI)) {
if (sourcePlayer.getInventory().getItemInMainHand() != null && GeneralMethods.isWeapon(sourcePlayer.getInventory().getItemInMainHand().getType())
&& !ProjectKorra.plugin.getConfig().getBoolean("Properties.Chi.CanBendWithWeapons")) {
return;
}
if (e.getCause() == DamageCause.ENTITY_ATTACK
&& sourceBPlayer.isElementToggled(Element.CHI) == true) {
if (boundAbil.equalsIgnoreCase("Paralyze") && e.getDamage() == 1) {
if (sourcePlayer.getWorld().equals(targetPlayer.getWorld())
&& Math.abs(sourcePlayer.getLocation().distance(targetPlayer.getLocation())) < 3) {
new Paralyze(sourcePlayer, targetPlayer);
}
}
}
}
}
}
@ -1025,7 +1007,7 @@ public class PKListener implements Listener {
}.runTaskLater(plugin, 5);
if (event.getHand() == EquipmentSlot.HAND) {
if (bPlayer.getBoundAbility() != null && player.getInventory().getItemInMainHand() != null && !GeneralMethods.isWeapon(player.getInventory().getItemInMainHand().getType()) && GeneralMethods.getElementsWithNoWeaponBending().contains(bPlayer.getBoundAbility().getElement())) {
if (bPlayer.canCurrentlyBendWithWeapons()) {
if (event.getClickedBlock() != null) {
ComboManager.addComboAbility(player, ClickType.RIGHT_CLICK_BLOCK);
} else {
@ -1053,7 +1035,7 @@ public class PKListener implements Listener {
Player player = event.getPlayer();
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
if (bPlayer.getBoundAbility() != null && player.getInventory().getItemInMainHand() != null && !GeneralMethods.isWeapon(player.getInventory().getItemInMainHand().getType()) && GeneralMethods.getElementsWithNoWeaponBending().contains(bPlayer.getBoundAbility().getElement())) {
if (bPlayer.canCurrentlyBendWithWeapons()) {
ComboManager.addComboAbility(player, ClickType.RIGHT_CLICK_ENTITY);
}
@ -1263,7 +1245,7 @@ public class PKListener implements Listener {
return;
}
if (bPlayer.getBoundAbility() != null && player.getInventory().getItemInMainHand() != null && !GeneralMethods.isWeapon(player.getInventory().getItemInMainHand().getType()) && GeneralMethods.getElementsWithNoWeaponBending().contains(bPlayer.getBoundAbility().getElement())) {
if (bPlayer.canCurrentlyBendWithWeapons()) {
if (player.isSneaking()) {
ComboManager.addComboAbility(player, ClickType.SHIFT_UP);
} else {
@ -1308,10 +1290,7 @@ public class PKListener implements Listener {
return;
}
if (coreAbil instanceof AirAbility && bPlayer.isElementToggled(Element.AIR) == true) {
if (player.getInventory().getItemInMainHand() != null && GeneralMethods.isWeapon(player.getInventory().getItemInMainHand().getType())
&& !plugin.getConfig().getBoolean("Properties.Air.CanBendWithWeapons")) {
return;
}
if (bPlayer.canCurrentlyBendWithWeapons()) {
if (abil.equalsIgnoreCase("Tornado")) {
new Tornado(player);
} else if (abil.equalsIgnoreCase("AirBlast")) {
@ -1333,12 +1312,10 @@ public class PKListener implements Listener {
new AirFlight(player);
}
}
}
if (coreAbil instanceof WaterAbility && bPlayer.isElementToggled(Element.WATER) == true) {
if (player.getInventory().getItemInMainHand() != null && GeneralMethods.isWeapon(player.getInventory().getItemInMainHand().getType())
&& !plugin.getConfig().getBoolean("Properties.Water.CanBendWithWeapons")) {
return;
}
if (bPlayer.canCurrentlyBendWithWeapons()) {
if (abil.equalsIgnoreCase("Bloodbending")) {
new Bloodbending(player);
} else if (abil.equalsIgnoreCase("IceBlast")) {
@ -1367,12 +1344,10 @@ public class PKListener implements Listener {
new HealingWaters(player);
}
}
}
if (coreAbil instanceof EarthAbility && bPlayer.isElementToggled(Element.EARTH) == true) {
if (player.getInventory().getItemInMainHand() != null && GeneralMethods.isWeapon(player.getInventory().getItemInMainHand().getType())
&& !plugin.getConfig().getBoolean("Properties.Earth.CanBendWithWeapons")) {
return;
}
if (bPlayer.canCurrentlyBendWithWeapons()) {
if (abil.equalsIgnoreCase("EarthBlast")) {
new EarthBlast(player);
} else if (abil.equalsIgnoreCase("EarthArmor")) {
@ -1408,12 +1383,10 @@ public class PKListener implements Listener {
new EarthSmash(player, ClickType.SHIFT_DOWN);
}
}
}
if (coreAbil instanceof FireAbility && bPlayer.isElementToggled(Element.FIRE) == true) {
if (player.getInventory().getItemInMainHand() != null && GeneralMethods.isWeapon(player.getInventory().getItemInMainHand().getType())
&& !plugin.getConfig().getBoolean("Properties.Fire.CanBendWithWeapons")) {
return;
}
if (bPlayer.canCurrentlyBendWithWeapons()) {
if (abil.equalsIgnoreCase("Blaze")) {
new BlazeRing(player);
} else if (abil.equalsIgnoreCase("FireBlast")) {
@ -1432,6 +1405,7 @@ public class PKListener implements Listener {
}
}
}
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlayerSlotChange(PlayerItemHeldEvent event) {
@ -1467,7 +1441,7 @@ public class PKListener implements Listener {
Entity target = GeneralMethods.getTargetedEntity(player, 3);
if(bPlayer.getBoundAbility() != null && player.getInventory().getItemInMainHand() != null && !GeneralMethods.isWeapon(player.getInventory().getItemInMainHand().getType()) && GeneralMethods.getElementsWithNoWeaponBending().contains(bPlayer.getBoundAbility().getElement())) {
if(bPlayer.canCurrentlyBendWithWeapons()) {
if (target != null && !(target.equals(player)) && target instanceof LivingEntity) {
ComboManager.addComboAbility(player, ClickType.LEFT_CLICK_ENTITY);
@ -1506,10 +1480,7 @@ public class PKListener implements Listener {
}
if (coreAbil instanceof AirAbility && bPlayer.isElementToggled(Element.AIR) == true) {
if (bPlayer.getBoundAbility() != null && player.getInventory().getItemInMainHand() != null && GeneralMethods.isWeapon(player.getInventory().getItemInMainHand().getType())
&& !plugin.getConfig().getBoolean("Properties.Air.CanBendWithWeapons")) {
return;
}
if (bPlayer.canCurrentlyBendWithWeapons()) {
if (abil.equalsIgnoreCase("AirBlast")) {
new AirBlast(player);
} else if (abil.equalsIgnoreCase("AirSuction")) {
@ -1537,12 +1508,10 @@ public class PKListener implements Listener {
}
}
}
}
if (coreAbil instanceof WaterAbility && bPlayer.isElementToggled(Element.WATER) == true) {
if (bPlayer.getBoundAbility() != null && player.getInventory().getItemInMainHand() != null && GeneralMethods.isWeapon(player.getInventory().getItemInMainHand().getType())
&& !plugin.getConfig().getBoolean("Properties.Water.CanBendWithWeapons")) {
return;
}
if (bPlayer.canCurrentlyBendWithWeapons()) {
if (abil.equalsIgnoreCase("Bloodbending")) {
Bloodbending.launch(player);
} else if (abil.equalsIgnoreCase("IceBlast")) {
@ -1570,12 +1539,10 @@ public class PKListener implements Listener {
new Torrent(player);
}
}
}
if (coreAbil instanceof EarthAbility && bPlayer.isElementToggled(Element.EARTH) == true) {
if (bPlayer.getBoundAbility() != null && player.getInventory().getItemInMainHand() != null && GeneralMethods.isWeapon(player.getInventory().getItemInMainHand().getType())
&& !plugin.getConfig().getBoolean("Properties.Earth.CanBendWithWeapons")) {
return;
}
if (bPlayer.canCurrentlyBendWithWeapons()) {
if (abil.equalsIgnoreCase("Catapult")) {
new Catapult(player);
} else if (abil.equalsIgnoreCase("EarthBlast")) {
@ -1599,8 +1566,9 @@ public class PKListener implements Listener {
MetalClips clips = CoreAbility.getAbility(player, MetalClips.class);
if (clips == null) {
new MetalClips(player, 0);
} else if (clips.getMetalClipsCount() < (player.hasPermission("bending.ability.MetalClips.4clips")
? 4 : 3)) {
} else if (clips
.getMetalClipsCount() < (player.hasPermission("bending.ability.MetalClips.4clips") ? 4
: 3)) {
clips.shootMetal();
} else if (clips.getMetalClipsCount() == 4 && clips.isCanUse4Clips()) {
clips.crush();
@ -1618,12 +1586,10 @@ public class PKListener implements Listener {
new SandSpout(player);
}
}
}
if (coreAbil instanceof FireAbility && bPlayer.isElementToggled(Element.FIRE) == true) {
if (bPlayer.getBoundAbility() != null && player.getInventory().getItemInMainHand() != null && GeneralMethods.isWeapon(player.getInventory().getItemInMainHand().getType())
&& !plugin.getConfig().getBoolean("Properties.Fire.CanBendWithWeapons")) {
return;
}
if (bPlayer.canCurrentlyBendWithWeapons()) {
if (abil.equalsIgnoreCase("Blaze")) {
new Blaze(player);
} else if (abil.equalsIgnoreCase("FireBlast")) {
@ -1649,12 +1615,10 @@ public class PKListener implements Listener {
Combustion.explode(player);
}
}
}
if (coreAbil instanceof ChiAbility && bPlayer.isElementToggled(Element.CHI) == true) {
if (bPlayer.getBoundAbility() != null && player.getInventory().getItemInMainHand() != null && GeneralMethods.isWeapon(player.getInventory().getItemInMainHand().getType())
&& !plugin.getConfig().getBoolean("Properties.Chi.CanBendWithWeapons")) {
return;
}
if (bPlayer.canCurrentlyBendWithWeapons()) {
if (abil.equalsIgnoreCase("HighJump")) {
new HighJump(player);
} else if (abil.equalsIgnoreCase("Smokescreen")) {
@ -1665,11 +1629,14 @@ public class PKListener implements Listener {
new AcrobatStance(player);
}
}
}
if (coreAbil instanceof AvatarAbility) {
if (abil.equalsIgnoreCase("AvatarState")) {
new AvatarState(player);
}
}
}
if (MultiAbilityManager.hasMultiAbilityBound(player)) {
abil = MultiAbilityManager.getBoundMultiAbility(player);