Remove double plants entire from spawn locations

This commit is contained in:
Thanos Paravantis 2016-06-28 12:15:49 +03:00
parent cf434b92de
commit c5367d4510
2 changed files with 26 additions and 12 deletions

View File

@ -482,12 +482,19 @@ public class BawkBawkBattles extends TeamGame implements IThrown
private void removeSolidBlock(Location location)
{
Block block = location.getBlock();
Block upper = block.getRelative(BlockFace.UP);
if (!block.isEmpty() && _challenge.getData().isModifiedBlock(block))
{
_challenge.resetBlock(block);
_challenge.getData().removeModifiedBlock(block);
}
if (!upper.isEmpty() && _challenge.getData().isModifiedBlock(upper))
{
_challenge.resetBlock(upper);
_challenge.getData().removeModifiedBlock(upper);
}
}
private void teamTeleport(boolean firstRun)

View File

@ -37,6 +37,7 @@ import nautilus.game.arcade.game.games.mineware.challenge.other.ZombieWrapper;
public class ChallengeZombieInfection extends Challenge
{
private ZombieWrapper _zombie;
private Set<Player> _infected = new HashSet<>();
// The default zombie speed.
@ -133,6 +134,12 @@ public class ChallengeZombieInfection extends Challenge
_infected.clear();
}
@Override
protected boolean shouldDie(Player player)
{
return _infected.contains(player);
}
@EventHandler
public void onUpdateZombie(UpdateEvent event)
{
@ -200,7 +207,7 @@ public class ChallengeZombieInfection extends Challenge
if (event.getType() != UpdateType.FASTER)
return;
if (_infected.size() >= Math.floor(getPlayersAlive().size() / 2))
if (_infected.size() >= Settings.getMaxCompletedCount())
{
for (Player player : getPlayersAlive())
{
@ -231,12 +238,7 @@ public class ChallengeZombieInfection extends Challenge
if (!isChallengeValid())
return;
Player player = event.getPlayer();
if (_infected.contains(player))
{
_infected.remove(player);
}
_infected.remove(event.getPlayer());
}
private void spawnZombie()
@ -270,6 +272,12 @@ public class ChallengeZombieInfection extends Challenge
private void selectTarget()
{
Player target = UtilPlayer.getClosest(_zombie.getLocation(), (Entity) null);
while (_infected.contains(target))
{
target = UtilMath.randomElement(getPlayersAlive());
}
_zombie.setTarget(target);
_zombie.move(target);
}
@ -310,7 +318,7 @@ public class ChallengeZombieInfection extends Challenge
Host.WorldData.World.strikeLightningEffect(player.getLocation());
Host.getArcadeManager().GetDisguise().disguise(new DisguiseZombie(player));
if (_infected.size() < Math.floor(getPlayersAlive().size() / 2))
if (_infected.size() < Settings.getMaxCompletedCount()) // Check if the challenge is still running after the player is infected.
{
UtilPlayer.message(player, F.main("Game", "You have been infected, you now have to infect the rest."));
}
@ -319,15 +327,14 @@ public class ChallengeZombieInfection extends Challenge
private void damage(Player player)
{
if (player.getHealth() <= 5.0)
player.damage(5.0);
if (player.isDead())
{
System.out.println("Infected");
infect(player);
}
else
{
player.damage(5.0);
if (!player.hasPotionEffect(PotionEffectType.SLOW) && !player.hasPotionEffect(PotionEffectType.CONFUSION))
{
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 20, 1));