Merge pull request #4 from jacklin213/master

Fixed NPE's in Method and small edits to other classes
This commit is contained in:
MistPhizzle 2014-07-18 12:28:43 -04:00
commit 19cfe223b1
3 changed files with 10 additions and 6 deletions

View file

@ -502,6 +502,7 @@ public class Methods {
public static boolean canBend(String player, String ability) { public static boolean canBend(String player, String ability) {
BendingPlayer bPlayer = getBendingPlayer(player); BendingPlayer bPlayer = getBendingPlayer(player);
Player p = Bukkit.getPlayer(player); Player p = Bukkit.getPlayer(player);
if (bPlayer == null) return false;
if (!bPlayer.isToggled) return false; if (!bPlayer.isToggled) return false;
if (p == null) return false; if (p == null) return false;
if (!p.hasPermission("bending.ability." + ability)) return false; if (!p.hasPermission("bending.ability." + ability)) return false;
@ -539,6 +540,8 @@ public class Methods {
public static boolean canBendPassive(String player, Element element) { public static boolean canBendPassive(String player, Element element) {
BendingPlayer bPlayer = getBendingPlayer(player); BendingPlayer bPlayer = getBendingPlayer(player);
Player p = Bukkit.getPlayer(player); Player p = Bukkit.getPlayer(player);
if (bPlayer == null) return false;
if (p == null) return false;
if (!p.hasPermission("bending." + element.toString().toLowerCase() + ".passive")) return false; if (!p.hasPermission("bending." + element.toString().toLowerCase() + ".passive")) return false;
if (!bPlayer.isToggled) return false; if (!bPlayer.isToggled) return false;
if (!bPlayer.hasElement(element)) return false; if (!bPlayer.hasElement(element)) return false;
@ -610,7 +613,8 @@ public class Methods {
public static String getBoundAbility(Player player) { public static String getBoundAbility(Player player) {
BendingPlayer bPlayer = getBendingPlayer(player.getName()); BendingPlayer bPlayer = getBendingPlayer(player.getName());
if (bPlayer == null) return null;
int slot = player.getInventory().getHeldItemSlot() + 1; int slot = player.getInventory().getHeldItemSlot() + 1;
return bPlayer.abilities.get(slot); return bPlayer.abilities.get(slot);
} }

View file

@ -274,10 +274,6 @@ public class PKListener implements Listener {
if (!player.isSneaking() && Methods.canBend(player.getName(), abil)) { if (!player.isSneaking() && Methods.canBend(player.getName(), abil)) {
if (abil.equalsIgnoreCase("AirShield")) {
new AirShield(player);
}
if (Methods.isAirAbility(abil)) { if (Methods.isAirAbility(abil)) {
if (Methods.isWeapon(player.getItemInHand().getType()) && !plugin.getConfig().getBoolean("Properties.Air.CanBendWithWeapons")) { if (Methods.isWeapon(player.getItemInHand().getType()) && !plugin.getConfig().getBoolean("Properties.Air.CanBendWithWeapons")) {
return; return;
@ -297,6 +293,10 @@ public class PKListener implements Listener {
if (abil.equalsIgnoreCase("AirSwipe")) { if (abil.equalsIgnoreCase("AirSwipe")) {
AirSwipe.charge(player); AirSwipe.charge(player);
} }
if (abil.equalsIgnoreCase("AirShield")) {
new AirShield(player);
}
} }
if (Methods.isWaterAbility(abil)) { if (Methods.isWaterAbility(abil)) {

View file

@ -117,7 +117,7 @@ public class IceSpike {
public IceSpike(Player player, Location origin, int damage, public IceSpike(Player player, Location origin, int damage,
Vector throwing, long aoecooldown) { Vector throwing, long aoecooldown) {
this.cooldown = aoecooldown; cooldown = aoecooldown;
this.player = player; this.player = player;
this.origin = origin; this.origin = origin;
location = origin.clone(); location = origin.clone();