Name the guardian, 10 seconds to view builds

This commit is contained in:
Shaun Bennett 2016-01-21 22:42:25 -05:00
parent d37b8b40fc
commit c38596a09f

View File

@ -46,6 +46,7 @@ import net.minecraft.server.v1_8_R3.PacketPlayOutGameStateChange;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Effect;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
@ -84,6 +85,8 @@ import org.bukkit.util.Vector;
public class SpeedBuilder extends SoloGame
{
private static final String GUARDIAN_NAME = "Gwen the Guardian";
//Build Size and some other values used commonly
public int BuildSize = 7;
public int BuildSizeDiv2 = BuildSize / 2;
@ -120,6 +123,8 @@ public class SpeedBuilder extends SoloGame
private ArrayList<RecreationData> _toEliminate = new ArrayList<RecreationData>();
private long _lastElimination;
private boolean _eliminating;
// Track the time we switch to review so we can give players 8 seconds to look around
private long _reviewStartTime;
private NautHashMap<Player, Long> _perfectBuild = new NautHashMap<Player, Long>();
@ -305,8 +310,10 @@ public class SpeedBuilder extends SoloGame
_judgeEntity.setSmall(true);
_judgeDisguise = new DisguiseGuardian(_judgeEntity);
_judgeDisguise.setElder(true);
_judgeDisguise.setCustomNameVisible(true);
_judgeDisguise.setName(GUARDIAN_NAME);
Manager.GetDisguise().disguise(_judgeDisguise);
}
@ -642,13 +649,13 @@ public class SpeedBuilder extends SoloGame
double distFromOther = UtilMath.offsetSquared(player.getLocation(), loc.clone().add(0.5, 0, 0.5));
if (dist > distFromOther || player.getLocation().getY() < recreation.OriginalBuildLocation.getY() - 2)
if (player.getGameMode() != GameMode.SPECTATOR && (dist > distFromOther || player.getLocation().getY() < recreation.OriginalBuildLocation.getY() - 2))
{
player.teleport(recreation.PlayerSpawn);
UtilPlayer.message(player, F.main("Build", "You cannot leave your area!"));
UtilTextMiddle.display("", C.cRed + "You cannot leave your area!", 0, 30, 10, player);
break;
}
}
@ -734,6 +741,15 @@ public class SpeedBuilder extends SoloGame
//Sometimes doesn't show in the update method
UtilTextMiddle.display("", C.cRed + "TIME'S UP!", 0, 30, 10);
Manager.runSyncLater(new Runnable()
{
@Override
public void run()
{
UtilTextMiddle.display("", C.cAqua + GUARDIAN_NAME + " is judging", 0, 30, 10);
}
}, 40L);
for (Player player : UtilServer.getPlayers())
{
@ -776,10 +792,18 @@ public class SpeedBuilder extends SoloGame
_toEliminate.add(lowest);
_lastElimination = System.currentTimeMillis();
_reviewStartTime = System.currentTimeMillis();
pasteBuildInCenter(_currentBuild);
setSpeedBuilderState(SpeedBuilderState.REVIEWING);
for (Player player : GetTeamList().get(0).GetPlayers(true))
{
player.setGameMode(GameMode.SPECTATOR);
// player.setAllowFlight(true);
// player.setFlying(true);
}
}
}
else if (_state == SpeedBuilderState.REVIEWING)
@ -792,6 +816,13 @@ public class SpeedBuilder extends SoloGame
clearCenterArea(true);
_currentBuild = UtilAlg.Random(_buildData);
for (Player player : GetTeamList().get(0).GetPlayers(true))
{
player.setGameMode(GameMode.SURVIVAL);
// player.setAllowFlight(false);
// player.setFlying(false);
}
for (RecreationData recreation : _buildRecreations.values())
{
@ -856,7 +887,7 @@ public class SpeedBuilder extends SoloGame
}
else
{
if (UtilTime.elapsed(_lastElimination, 2000))
if (UtilTime.elapsed(_reviewStartTime, 10000) && UtilTime.elapsed(_lastElimination, 2000))
{
//Eliminate in order This also means that the empty builds are eliminated first
final RecreationData eliminating = _toEliminate.get(0);