Fix minecart dance double life loss
This commit is contained in:
parent
ddad17855f
commit
aff4b6b270
@ -755,8 +755,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
||||
|
||||
if (lives > 0)
|
||||
{
|
||||
loseLife(player);
|
||||
taskFailedMessage(player, lives(player));
|
||||
_challenge.setLost(player);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -8,7 +8,6 @@ import org.bukkit.FireworkEffect.Type;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Minecart;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -20,6 +19,7 @@ import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilFirework;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
@ -28,7 +28,6 @@ import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
|
||||
import nautilus.game.arcade.game.games.mineware.challenge.Challenge;
|
||||
import nautilus.game.arcade.game.games.mineware.challenge.ChallengeType;
|
||||
import net.minecraft.server.v1_8_R3.BlockPosition;
|
||||
import net.minecraft.server.v1_8_R3.EntityPlayer;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutWorldEvent;
|
||||
|
||||
public class ChallengeMinecartDance extends Challenge
|
||||
@ -38,9 +37,9 @@ public class ChallengeMinecartDance extends Challenge
|
||||
WAITING, STARTED, ENDED
|
||||
}
|
||||
|
||||
private volatile MinecartDancePhase _phase = MinecartDancePhase.WAITING;
|
||||
private MinecartDancePhase _phase = MinecartDancePhase.WAITING;
|
||||
private long _timeSinceLastPhase;
|
||||
private boolean _isPlayingMusic = false;
|
||||
private boolean _isPlayingMusic;
|
||||
private int _availableMinecarts;
|
||||
private HashSet<Minecart> _minecarts = new HashSet<Minecart>();
|
||||
|
||||
@ -109,22 +108,18 @@ public class ChallengeMinecartDance extends Challenge
|
||||
@Override
|
||||
public void onStart()
|
||||
{
|
||||
Host.Manager.GetExplosion().SetLiquidDamage(false);
|
||||
_timeSinceLastPhase = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnd()
|
||||
{
|
||||
Host.Manager.GetExplosion().SetLiquidDamage(true);
|
||||
|
||||
if (_isPlayingMusic)
|
||||
{
|
||||
_isPlayingMusic = false;
|
||||
PacketPlayOutWorldEvent packet = new PacketPlayOutWorldEvent(1005, new BlockPosition(getCenter().getBlockX(), getCenter().getBlockY() + 5, getCenter().getBlockZ()), 0, false);
|
||||
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
{
|
||||
EntityPlayer entity = ((CraftPlayer) player).getHandle();
|
||||
entity.playerConnection.sendPacket(packet);
|
||||
}
|
||||
stopPlayingMusic();
|
||||
}
|
||||
|
||||
for (Minecart minecarts : _minecarts)
|
||||
@ -136,7 +131,43 @@ public class ChallengeMinecartDance extends Challenge
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onMinecartInteractionUpdate(UpdateEvent event)
|
||||
public void onUpdate(UpdateEvent event)
|
||||
{
|
||||
if (!isChallengeValid())
|
||||
return;
|
||||
|
||||
if (_phase == MinecartDancePhase.WAITING && event.getType() == UpdateType.SEC)
|
||||
{
|
||||
if (!_isPlayingMusic)
|
||||
{
|
||||
startPlayingMusic();
|
||||
}
|
||||
|
||||
spawnRedFireworks();
|
||||
}
|
||||
else if (_phase == MinecartDancePhase.STARTED)
|
||||
{
|
||||
spawnGreenFireworks();
|
||||
|
||||
if (_isPlayingMusic)
|
||||
{
|
||||
stopPlayingMusic();
|
||||
}
|
||||
|
||||
spawnMinecarts();
|
||||
|
||||
_phase = MinecartDancePhase.ENDED;
|
||||
|
||||
startTimerWhenReady();
|
||||
}
|
||||
else if (_phase == MinecartDancePhase.ENDED)
|
||||
{
|
||||
showMinecartsLeft();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInteractionUpdate(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.FASTEST)
|
||||
return;
|
||||
@ -160,47 +191,6 @@ public class ChallengeMinecartDance extends Challenge
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onMinecartUpdate(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.SEC)
|
||||
return;
|
||||
|
||||
if (!isChallengeValid())
|
||||
return;
|
||||
|
||||
if (_phase == MinecartDancePhase.WAITING)
|
||||
{
|
||||
if (!_isPlayingMusic)
|
||||
{
|
||||
_isPlayingMusic = true;
|
||||
startPlayingMusic();
|
||||
}
|
||||
|
||||
spawnRedFireworks();
|
||||
}
|
||||
else if (_phase == MinecartDancePhase.STARTED)
|
||||
{
|
||||
spawnGreenFireworks();
|
||||
|
||||
if (_isPlayingMusic)
|
||||
{
|
||||
_isPlayingMusic = false;
|
||||
stopPlayingMusic();
|
||||
}
|
||||
|
||||
spawnMinecarts();
|
||||
|
||||
_phase = MinecartDancePhase.ENDED;
|
||||
|
||||
startTimerWhenReady();
|
||||
}
|
||||
else
|
||||
{
|
||||
showMinecartsLeft();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onVehicleDamage(VehicleDamageEvent event)
|
||||
{
|
||||
@ -235,9 +225,13 @@ public class ChallengeMinecartDance extends Challenge
|
||||
for (Minecart minecart : _minecarts)
|
||||
{
|
||||
if (!minecart.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
@ -247,12 +241,9 @@ public class ChallengeMinecartDance extends Challenge
|
||||
{
|
||||
for (Player player : getPlayersIn(true))
|
||||
{
|
||||
if (player.isInsideVehicle())
|
||||
{
|
||||
setCompleted(player);
|
||||
}
|
||||
else
|
||||
if (!player.isInsideVehicle())
|
||||
{
|
||||
setLost(player);
|
||||
Host.WorldData.World.strikeLightningEffect(player.getLocation());
|
||||
}
|
||||
}
|
||||
@ -275,12 +266,13 @@ public class ChallengeMinecartDance extends Challenge
|
||||
|
||||
private void startPlayingMusic()
|
||||
{
|
||||
_isPlayingMusic = true;
|
||||
|
||||
PacketPlayOutWorldEvent packet = new PacketPlayOutWorldEvent(1005, new BlockPosition(getCenter().getBlockX(), getCenter().getBlockY() + 5, getCenter().getBlockZ()), 2259, false);
|
||||
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
{
|
||||
EntityPlayer entity = ((CraftPlayer) player).getHandle();
|
||||
entity.playerConnection.sendPacket(packet);
|
||||
UtilPlayer.sendPacket(player, packet);
|
||||
}
|
||||
}
|
||||
|
||||
@ -289,9 +281,13 @@ public class ChallengeMinecartDance extends Challenge
|
||||
if (_timeSinceLastPhase + 5500 < System.currentTimeMillis())
|
||||
{
|
||||
if (UtilMath.r(4) == 0)
|
||||
{
|
||||
_phase = MinecartDancePhase.STARTED;
|
||||
}
|
||||
else
|
||||
{
|
||||
spawnFireworkAtCorners(Color.RED);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -316,18 +312,19 @@ public class ChallengeMinecartDance extends Challenge
|
||||
|
||||
private void stopPlayingMusic()
|
||||
{
|
||||
_isPlayingMusic = false;
|
||||
|
||||
PacketPlayOutWorldEvent packet = new PacketPlayOutWorldEvent(1005, new BlockPosition(getCenter().getBlockX(), getCenter().getBlockY() + 5, getCenter().getBlockZ()), 0, false);
|
||||
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
{
|
||||
EntityPlayer entity = ((CraftPlayer) player).getHandle();
|
||||
entity.playerConnection.sendPacket(packet);
|
||||
UtilPlayer.sendPacket(player, packet);
|
||||
}
|
||||
}
|
||||
|
||||
private void spawnMinecarts()
|
||||
{
|
||||
for (int i = 0; i < getPlayersIn(true).size() / 2; i++)
|
||||
for (int i = 0; i < Math.round(getPlayersIn(true).size() / 2); i++)
|
||||
{
|
||||
Minecart minecart = Host.WorldData.World.spawn(getCenter().add(UtilMath.r(getArenaSize(7) * 2) - (getArenaSize(7)), 2, UtilMath.r(getArenaSize(7) * 2) - (getArenaSize(7))), Minecart.class);
|
||||
UtilEnt.ghost(minecart, true, false);
|
||||
@ -337,10 +334,14 @@ public class ChallengeMinecartDance extends Challenge
|
||||
|
||||
private void startTimerWhenReady()
|
||||
{
|
||||
if (getPlayersIn(false).size() >= 10)
|
||||
startTimer(Math.round(getPlayersIn(false).size() / 2));
|
||||
if (getPlayersIn(true).size() >= 10)
|
||||
{
|
||||
startTimer(Math.round(getPlayersIn(true).size() / 2));
|
||||
}
|
||||
else
|
||||
startTimer(Math.round(5));
|
||||
{
|
||||
startTimer(5);
|
||||
}
|
||||
}
|
||||
|
||||
private void showMinecartsLeft()
|
||||
@ -379,31 +380,12 @@ public class ChallengeMinecartDance extends Challenge
|
||||
{
|
||||
if (_phase == MinecartDancePhase.ENDED)
|
||||
{
|
||||
for (Player player : getPlayersIn(true))
|
||||
{
|
||||
if (!player.isInsideVehicle())
|
||||
{
|
||||
Host.WorldData.World.strikeLightningEffect(player.getLocation());
|
||||
setLost(player);
|
||||
// UtilPlayer.message(player, F.main("Minecart Dance", "You didn't make it inside a Minecart in time!"));
|
||||
}
|
||||
}
|
||||
playersLooseIfOutsideMinecart();
|
||||
|
||||
_timeSinceLastPhase = System.currentTimeMillis();
|
||||
_phase = MinecartDancePhase.WAITING;
|
||||
|
||||
for (Minecart minecarts : _minecarts)
|
||||
{
|
||||
if (!minecarts.isEmpty())
|
||||
{
|
||||
minecarts.eject();
|
||||
}
|
||||
|
||||
minecarts.remove();
|
||||
}
|
||||
|
||||
_minecarts.clear();
|
||||
|
||||
removeAndClearMinecarts();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user