mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2025-08-05 03:55:21 +00:00
Fixes bending with weapons (#678)
This commit is contained in:
parent
4ac9b8fb6e
commit
7a67becb58
2 changed files with 263 additions and 278 deletions
|
@ -256,6 +256,24 @@ public class BendingPlayer {
|
||||||
return true;
|
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.
|
* Checks to see if {@link BendingPlayer} can be slowed.
|
||||||
*
|
*
|
||||||
|
|
|
@ -71,6 +71,7 @@ import org.bukkit.util.Vector;
|
||||||
import com.projectkorra.projectkorra.ability.Ability;
|
import com.projectkorra.projectkorra.ability.Ability;
|
||||||
import com.projectkorra.projectkorra.ability.AddonAbility;
|
import com.projectkorra.projectkorra.ability.AddonAbility;
|
||||||
import com.projectkorra.projectkorra.ability.AirAbility;
|
import com.projectkorra.projectkorra.ability.AirAbility;
|
||||||
|
import com.projectkorra.projectkorra.ability.AvatarAbility;
|
||||||
import com.projectkorra.projectkorra.ability.ChiAbility;
|
import com.projectkorra.projectkorra.ability.ChiAbility;
|
||||||
import com.projectkorra.projectkorra.ability.CoreAbility;
|
import com.projectkorra.projectkorra.ability.CoreAbility;
|
||||||
import com.projectkorra.projectkorra.ability.EarthAbility;
|
import com.projectkorra.projectkorra.ability.EarthAbility;
|
||||||
|
@ -896,10 +897,7 @@ public class PKListener implements Listener {
|
||||||
if (sourceBPlayer.canBendPassive(Element.CHI)) {
|
if (sourceBPlayer.canBendPassive(Element.CHI)) {
|
||||||
if (e.getCause() == DamageCause.ENTITY_ATTACK && e.getDamage() == 1) {
|
if (e.getCause() == DamageCause.ENTITY_ATTACK && e.getDamage() == 1) {
|
||||||
if (sourceBPlayer.getBoundAbility() instanceof ChiAbility) {
|
if (sourceBPlayer.getBoundAbility() instanceof ChiAbility) {
|
||||||
if (sourceBPlayer.getBoundAbility() != null && sourcePlayer.getInventory().getItemInMainHand() != null && GeneralMethods.isWeapon(sourcePlayer.getInventory().getItemInMainHand().getType())
|
if (sourceBPlayer.canCurrentlyBendWithWeapons()) {
|
||||||
&& !plugin.getConfig().getBoolean("Properties.Chi.CanBendWithWeapons")) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (sourceBPlayer.isElementToggled(Element.CHI) == true) {
|
if (sourceBPlayer.isElementToggled(Element.CHI) == true) {
|
||||||
if (boundAbil.equalsIgnoreCase("Paralyze")) {
|
if (boundAbil.equalsIgnoreCase("Paralyze")) {
|
||||||
new Paralyze(sourcePlayer, targetPlayer);
|
new Paralyze(sourcePlayer, targetPlayer);
|
||||||
|
@ -907,11 +905,9 @@ public class PKListener implements Listener {
|
||||||
new QuickStrike(sourcePlayer, targetPlayer);
|
new QuickStrike(sourcePlayer, targetPlayer);
|
||||||
} else if (boundAbil.equalsIgnoreCase("SwiftKick")) {
|
} else if (boundAbil.equalsIgnoreCase("SwiftKick")) {
|
||||||
new SwiftKick(sourcePlayer, targetPlayer);
|
new SwiftKick(sourcePlayer, targetPlayer);
|
||||||
}
|
} else if (boundAbil.equalsIgnoreCase("RapidPunch")) {
|
||||||
else if (boundAbil.equalsIgnoreCase("RapidPunch")) {
|
|
||||||
new RapidPunch(sourcePlayer, targetPlayer);
|
new RapidPunch(sourcePlayer, targetPlayer);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (ChiPassive.willChiBlock(sourcePlayer, targetPlayer)) {
|
if (ChiPassive.willChiBlock(sourcePlayer, targetPlayer)) {
|
||||||
ChiPassive.blockChi(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);
|
}.runTaskLater(plugin, 5);
|
||||||
|
|
||||||
if (event.getHand() == EquipmentSlot.HAND) {
|
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) {
|
if (event.getClickedBlock() != null) {
|
||||||
ComboManager.addComboAbility(player, ClickType.RIGHT_CLICK_BLOCK);
|
ComboManager.addComboAbility(player, ClickType.RIGHT_CLICK_BLOCK);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1053,7 +1035,7 @@ public class PKListener implements Listener {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
|
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);
|
ComboManager.addComboAbility(player, ClickType.RIGHT_CLICK_ENTITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1263,7 +1245,7 @@ public class PKListener implements Listener {
|
||||||
return;
|
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()) {
|
if (player.isSneaking()) {
|
||||||
ComboManager.addComboAbility(player, ClickType.SHIFT_UP);
|
ComboManager.addComboAbility(player, ClickType.SHIFT_UP);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1308,10 +1290,7 @@ public class PKListener implements Listener {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (coreAbil instanceof AirAbility && bPlayer.isElementToggled(Element.AIR) == true) {
|
if (coreAbil instanceof AirAbility && bPlayer.isElementToggled(Element.AIR) == true) {
|
||||||
if (player.getInventory().getItemInMainHand() != null && GeneralMethods.isWeapon(player.getInventory().getItemInMainHand().getType())
|
if (bPlayer.canCurrentlyBendWithWeapons()) {
|
||||||
&& !plugin.getConfig().getBoolean("Properties.Air.CanBendWithWeapons")) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (abil.equalsIgnoreCase("Tornado")) {
|
if (abil.equalsIgnoreCase("Tornado")) {
|
||||||
new Tornado(player);
|
new Tornado(player);
|
||||||
} else if (abil.equalsIgnoreCase("AirBlast")) {
|
} else if (abil.equalsIgnoreCase("AirBlast")) {
|
||||||
|
@ -1333,12 +1312,10 @@ public class PKListener implements Listener {
|
||||||
new AirFlight(player);
|
new AirFlight(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (coreAbil instanceof WaterAbility && bPlayer.isElementToggled(Element.WATER) == true) {
|
if (coreAbil instanceof WaterAbility && bPlayer.isElementToggled(Element.WATER) == true) {
|
||||||
if (player.getInventory().getItemInMainHand() != null && GeneralMethods.isWeapon(player.getInventory().getItemInMainHand().getType())
|
if (bPlayer.canCurrentlyBendWithWeapons()) {
|
||||||
&& !plugin.getConfig().getBoolean("Properties.Water.CanBendWithWeapons")) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (abil.equalsIgnoreCase("Bloodbending")) {
|
if (abil.equalsIgnoreCase("Bloodbending")) {
|
||||||
new Bloodbending(player);
|
new Bloodbending(player);
|
||||||
} else if (abil.equalsIgnoreCase("IceBlast")) {
|
} else if (abil.equalsIgnoreCase("IceBlast")) {
|
||||||
|
@ -1367,12 +1344,10 @@ public class PKListener implements Listener {
|
||||||
new HealingWaters(player);
|
new HealingWaters(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (coreAbil instanceof EarthAbility && bPlayer.isElementToggled(Element.EARTH) == true) {
|
if (coreAbil instanceof EarthAbility && bPlayer.isElementToggled(Element.EARTH) == true) {
|
||||||
if (player.getInventory().getItemInMainHand() != null && GeneralMethods.isWeapon(player.getInventory().getItemInMainHand().getType())
|
if (bPlayer.canCurrentlyBendWithWeapons()) {
|
||||||
&& !plugin.getConfig().getBoolean("Properties.Earth.CanBendWithWeapons")) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (abil.equalsIgnoreCase("EarthBlast")) {
|
if (abil.equalsIgnoreCase("EarthBlast")) {
|
||||||
new EarthBlast(player);
|
new EarthBlast(player);
|
||||||
} else if (abil.equalsIgnoreCase("EarthArmor")) {
|
} else if (abil.equalsIgnoreCase("EarthArmor")) {
|
||||||
|
@ -1408,12 +1383,10 @@ public class PKListener implements Listener {
|
||||||
new EarthSmash(player, ClickType.SHIFT_DOWN);
|
new EarthSmash(player, ClickType.SHIFT_DOWN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (coreAbil instanceof FireAbility && bPlayer.isElementToggled(Element.FIRE) == true) {
|
if (coreAbil instanceof FireAbility && bPlayer.isElementToggled(Element.FIRE) == true) {
|
||||||
if (player.getInventory().getItemInMainHand() != null && GeneralMethods.isWeapon(player.getInventory().getItemInMainHand().getType())
|
if (bPlayer.canCurrentlyBendWithWeapons()) {
|
||||||
&& !plugin.getConfig().getBoolean("Properties.Fire.CanBendWithWeapons")) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (abil.equalsIgnoreCase("Blaze")) {
|
if (abil.equalsIgnoreCase("Blaze")) {
|
||||||
new BlazeRing(player);
|
new BlazeRing(player);
|
||||||
} else if (abil.equalsIgnoreCase("FireBlast")) {
|
} else if (abil.equalsIgnoreCase("FireBlast")) {
|
||||||
|
@ -1432,6 +1405,7 @@ public class PKListener implements Listener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||||
public void onPlayerSlotChange(PlayerItemHeldEvent event) {
|
public void onPlayerSlotChange(PlayerItemHeldEvent event) {
|
||||||
|
@ -1467,7 +1441,7 @@ public class PKListener implements Listener {
|
||||||
|
|
||||||
Entity target = GeneralMethods.getTargetedEntity(player, 3);
|
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) {
|
if (target != null && !(target.equals(player)) && target instanceof LivingEntity) {
|
||||||
ComboManager.addComboAbility(player, ClickType.LEFT_CLICK_ENTITY);
|
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 (coreAbil instanceof AirAbility && bPlayer.isElementToggled(Element.AIR) == true) {
|
||||||
if (bPlayer.getBoundAbility() != null && player.getInventory().getItemInMainHand() != null && GeneralMethods.isWeapon(player.getInventory().getItemInMainHand().getType())
|
if (bPlayer.canCurrentlyBendWithWeapons()) {
|
||||||
&& !plugin.getConfig().getBoolean("Properties.Air.CanBendWithWeapons")) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (abil.equalsIgnoreCase("AirBlast")) {
|
if (abil.equalsIgnoreCase("AirBlast")) {
|
||||||
new AirBlast(player);
|
new AirBlast(player);
|
||||||
} else if (abil.equalsIgnoreCase("AirSuction")) {
|
} else if (abil.equalsIgnoreCase("AirSuction")) {
|
||||||
|
@ -1537,12 +1508,10 @@ public class PKListener implements Listener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (coreAbil instanceof WaterAbility && bPlayer.isElementToggled(Element.WATER) == true) {
|
if (coreAbil instanceof WaterAbility && bPlayer.isElementToggled(Element.WATER) == true) {
|
||||||
if (bPlayer.getBoundAbility() != null && player.getInventory().getItemInMainHand() != null && GeneralMethods.isWeapon(player.getInventory().getItemInMainHand().getType())
|
if (bPlayer.canCurrentlyBendWithWeapons()) {
|
||||||
&& !plugin.getConfig().getBoolean("Properties.Water.CanBendWithWeapons")) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (abil.equalsIgnoreCase("Bloodbending")) {
|
if (abil.equalsIgnoreCase("Bloodbending")) {
|
||||||
Bloodbending.launch(player);
|
Bloodbending.launch(player);
|
||||||
} else if (abil.equalsIgnoreCase("IceBlast")) {
|
} else if (abil.equalsIgnoreCase("IceBlast")) {
|
||||||
|
@ -1570,12 +1539,10 @@ public class PKListener implements Listener {
|
||||||
new Torrent(player);
|
new Torrent(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (coreAbil instanceof EarthAbility && bPlayer.isElementToggled(Element.EARTH) == true) {
|
if (coreAbil instanceof EarthAbility && bPlayer.isElementToggled(Element.EARTH) == true) {
|
||||||
if (bPlayer.getBoundAbility() != null && player.getInventory().getItemInMainHand() != null && GeneralMethods.isWeapon(player.getInventory().getItemInMainHand().getType())
|
if (bPlayer.canCurrentlyBendWithWeapons()) {
|
||||||
&& !plugin.getConfig().getBoolean("Properties.Earth.CanBendWithWeapons")) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (abil.equalsIgnoreCase("Catapult")) {
|
if (abil.equalsIgnoreCase("Catapult")) {
|
||||||
new Catapult(player);
|
new Catapult(player);
|
||||||
} else if (abil.equalsIgnoreCase("EarthBlast")) {
|
} else if (abil.equalsIgnoreCase("EarthBlast")) {
|
||||||
|
@ -1599,8 +1566,9 @@ public class PKListener implements Listener {
|
||||||
MetalClips clips = CoreAbility.getAbility(player, MetalClips.class);
|
MetalClips clips = CoreAbility.getAbility(player, MetalClips.class);
|
||||||
if (clips == null) {
|
if (clips == null) {
|
||||||
new MetalClips(player, 0);
|
new MetalClips(player, 0);
|
||||||
} else if (clips.getMetalClipsCount() < (player.hasPermission("bending.ability.MetalClips.4clips")
|
} else if (clips
|
||||||
? 4 : 3)) {
|
.getMetalClipsCount() < (player.hasPermission("bending.ability.MetalClips.4clips") ? 4
|
||||||
|
: 3)) {
|
||||||
clips.shootMetal();
|
clips.shootMetal();
|
||||||
} else if (clips.getMetalClipsCount() == 4 && clips.isCanUse4Clips()) {
|
} else if (clips.getMetalClipsCount() == 4 && clips.isCanUse4Clips()) {
|
||||||
clips.crush();
|
clips.crush();
|
||||||
|
@ -1618,12 +1586,10 @@ public class PKListener implements Listener {
|
||||||
new SandSpout(player);
|
new SandSpout(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (coreAbil instanceof FireAbility && bPlayer.isElementToggled(Element.FIRE) == true) {
|
if (coreAbil instanceof FireAbility && bPlayer.isElementToggled(Element.FIRE) == true) {
|
||||||
if (bPlayer.getBoundAbility() != null && player.getInventory().getItemInMainHand() != null && GeneralMethods.isWeapon(player.getInventory().getItemInMainHand().getType())
|
if (bPlayer.canCurrentlyBendWithWeapons()) {
|
||||||
&& !plugin.getConfig().getBoolean("Properties.Fire.CanBendWithWeapons")) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (abil.equalsIgnoreCase("Blaze")) {
|
if (abil.equalsIgnoreCase("Blaze")) {
|
||||||
new Blaze(player);
|
new Blaze(player);
|
||||||
} else if (abil.equalsIgnoreCase("FireBlast")) {
|
} else if (abil.equalsIgnoreCase("FireBlast")) {
|
||||||
|
@ -1649,12 +1615,10 @@ public class PKListener implements Listener {
|
||||||
Combustion.explode(player);
|
Combustion.explode(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (coreAbil instanceof ChiAbility && bPlayer.isElementToggled(Element.CHI) == true) {
|
if (coreAbil instanceof ChiAbility && bPlayer.isElementToggled(Element.CHI) == true) {
|
||||||
if (bPlayer.getBoundAbility() != null && player.getInventory().getItemInMainHand() != null && GeneralMethods.isWeapon(player.getInventory().getItemInMainHand().getType())
|
if (bPlayer.canCurrentlyBendWithWeapons()) {
|
||||||
&& !plugin.getConfig().getBoolean("Properties.Chi.CanBendWithWeapons")) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (abil.equalsIgnoreCase("HighJump")) {
|
if (abil.equalsIgnoreCase("HighJump")) {
|
||||||
new HighJump(player);
|
new HighJump(player);
|
||||||
} else if (abil.equalsIgnoreCase("Smokescreen")) {
|
} else if (abil.equalsIgnoreCase("Smokescreen")) {
|
||||||
|
@ -1665,11 +1629,14 @@ public class PKListener implements Listener {
|
||||||
new AcrobatStance(player);
|
new AcrobatStance(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (coreAbil instanceof AvatarAbility) {
|
||||||
if (abil.equalsIgnoreCase("AvatarState")) {
|
if (abil.equalsIgnoreCase("AvatarState")) {
|
||||||
new AvatarState(player);
|
new AvatarState(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (MultiAbilityManager.hasMultiAbilityBound(player)) {
|
if (MultiAbilityManager.hasMultiAbilityBound(player)) {
|
||||||
abil = MultiAbilityManager.getBoundMultiAbility(player);
|
abil = MultiAbilityManager.getBoundMultiAbility(player);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue