Fix NPE on Volley Pig

This commit is contained in:
Thanos paravantis 2016-04-19 18:25:04 +03:00
parent 50175f9453
commit 11aef273ba
2 changed files with 36 additions and 7 deletions

View File

@ -88,7 +88,7 @@ public class ChallengeMiniOneInTheQuiver extends Challenge
}
else if ((absX <= getArenaSize() - 1 || absZ <= getArenaSize() - 1))
{
if (((absX == getArenaSize() - 2 || absZ == getArenaSize() - 2) || (absX == getArenaSize() - 4 || absZ == getArenaSize() - 4)) && UtilMath.r(7) == 0 && canPlaceBarrier(block.getRelative(BlockFace.UP)) && !Data.isSpawnLocation(block.getLocation()))
if (((absX == getArenaSize() - 2 || absZ == getArenaSize() - 2) || (absX == getArenaSize() - 4 || absZ == getArenaSize() - 4)) && UtilMath.r(8) == 0 && canPlaceBarrier(block.getRelative(BlockFace.UP)) && !Data.isSpawnLocation(block.getLocation()))
{
generateBarrier(block);
}

View File

@ -17,6 +17,7 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import org.bukkit.potion.PotionEffect;
@ -76,7 +77,9 @@ public class ChallengeVolleyPig extends Challenge
for (int z = -9; z <= 9; z++)
{
if (z == 0)
{
continue;
}
spawns.add(getCenter().add(x + 0.5, 1.1, z + 0.5));
}
@ -106,7 +109,6 @@ public class ChallengeVolleyPig extends Challenge
}
}
}
}
@Override
@ -116,8 +118,8 @@ public class ChallengeVolleyPig extends Challenge
spawnPig();
addPlayersOnTeam();
equipKnockbackStick();
equipTeamHelmets();
startMainTask();
}
@ -126,8 +128,11 @@ public class ChallengeVolleyPig extends Challenge
{
Host.DamagePvE = false;
if (_pig != null)
{
_pig.remove();
}
}
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.LOW)
@ -224,7 +229,22 @@ public class ChallengeVolleyPig extends Challenge
@SuppressWarnings("deprecation")
private void addPlayersOnTeam()
{
ItemStack stick = new ItemBuilder(Material.STICK).addEnchantment(Enchantment.KNOCKBACK, 1).build();
// int half = getPlayersAlive().size() / 2;
// int current = 0;
//
// for (Player player : getPlayersAlive())
// {
// if (current < half)
// {
// _blueTeam.add(player);
// }
// else
// {
// _redTeam.add(player);
// }
//
// current++;
// }
for (Player player : getPlayersAlive())
{
@ -242,8 +262,6 @@ public class ChallengeVolleyPig extends Challenge
_redTeam.add(player);
}
}
player.getInventory().setItem(Settings.getLockedSlot(), stick);
}
}
@ -267,6 +285,17 @@ public class ChallengeVolleyPig extends Challenge
{
player.getInventory().setHelmet(helmet);
}
}
private void equipKnockbackStick()
{
ItemStack stick = new ItemBuilder(Material.STICK)
.addEnchantment(Enchantment.KNOCKBACK, 1)
.addItemFlags(ItemFlag.HIDE_ENCHANTS)
.build();
setItem(Settings.getLockedSlot(), stick);
}
private void knockback(Player player)