Move spawn related methods to challenge classes
This commit is contained in:
parent
6fdbda0ed0
commit
e2663d6448
@ -76,9 +76,8 @@ import nautilus.game.arcade.game.GameTeam;
|
|||||||
import nautilus.game.arcade.game.TeamGame;
|
import nautilus.game.arcade.game.TeamGame;
|
||||||
import nautilus.game.arcade.game.games.mineware.challenge.Challenge;
|
import nautilus.game.arcade.game.games.mineware.challenge.Challenge;
|
||||||
import nautilus.game.arcade.game.games.mineware.challenge.ChallengeData;
|
import nautilus.game.arcade.game.games.mineware.challenge.ChallengeData;
|
||||||
import nautilus.game.arcade.game.games.mineware.challenge.ChallengeSettings;
|
|
||||||
import nautilus.game.arcade.game.games.mineware.challenge.ChallengeList;
|
import nautilus.game.arcade.game.games.mineware.challenge.ChallengeList;
|
||||||
import nautilus.game.arcade.game.games.mineware.challenge.TeamChallenge;
|
import nautilus.game.arcade.game.games.mineware.challenge.ChallengeSettings;
|
||||||
import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeAnvilDance;
|
import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeAnvilDance;
|
||||||
import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeArrowRampage;
|
import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeArrowRampage;
|
||||||
import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeBlockLobbers;
|
import nautilus.game.arcade.game.games.mineware.challenge.type.ChallengeBlockLobbers;
|
||||||
@ -398,6 +397,10 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Spawns
|
||||||
|
*/
|
||||||
|
|
||||||
private ArrayList<Location> setupChallengeSpawnLocations()
|
private ArrayList<Location> setupChallengeSpawnLocations()
|
||||||
{
|
{
|
||||||
ArrayList<Location> selected = _challenge.createSpawns();
|
ArrayList<Location> selected = _challenge.createSpawns();
|
||||||
@ -434,10 +437,6 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Spawns
|
|
||||||
*/
|
|
||||||
|
|
||||||
private void teleportSpectatorsToSpawn()
|
private void teleportSpectatorsToSpawn()
|
||||||
{
|
{
|
||||||
for (Player player : GetPlayers(false))
|
for (Player player : GetPlayers(false))
|
||||||
@ -451,15 +450,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
|||||||
|
|
||||||
private void teleportPlayersToSpawns(boolean firstRun)
|
private void teleportPlayersToSpawns(boolean firstRun)
|
||||||
{
|
{
|
||||||
if (_challenge instanceof TeamChallenge)
|
_challenge.spawn(firstRun);
|
||||||
{
|
|
||||||
teamTeleport(firstRun);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
playerTeleport(firstRun);
|
|
||||||
}
|
|
||||||
|
|
||||||
removeSolidBlockForPlayers();
|
removeSolidBlockForPlayers();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -489,46 +480,6 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void teamTeleport(boolean firstRun)
|
|
||||||
{
|
|
||||||
TeamChallenge teamChallenge = (TeamChallenge) _challenge;
|
|
||||||
|
|
||||||
if (teamChallenge.shouldTeamSpawn())
|
|
||||||
{
|
|
||||||
teamChallenge.spawn(firstRun);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
playerTeleport(firstRun);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void playerTeleport(boolean firstRun)
|
|
||||||
{
|
|
||||||
if (firstRun)
|
|
||||||
{
|
|
||||||
ArrayList<Player> players = GetPlayers(false);
|
|
||||||
|
|
||||||
for (int i = 0; i < players.size(); i++)
|
|
||||||
{
|
|
||||||
Player player = players.get(i);
|
|
||||||
|
|
||||||
new BukkitRunnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
_playerTeam.SpawnTeleport(player);
|
|
||||||
}
|
|
||||||
}.runTaskLater(Manager.getPlugin(), i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_playerTeam.SpawnTeleport(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Start
|
* Start
|
||||||
*/
|
*/
|
||||||
@ -948,7 +899,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
|||||||
{
|
{
|
||||||
for (Player player : UtilServer.getPlayers())
|
for (Player player : UtilServer.getPlayers())
|
||||||
{
|
{
|
||||||
UtilTextTop.displayTextBar(player, _challenge.getTimeLeftPercent(), C.cYellow + C.Bold + _challenge.getName());
|
UtilTextTop.displayTextBar(player, _challenge.getTimeLeftPercent(), C.cYellowB + _challenge.getName());
|
||||||
player.setLevel(_challenge.getRemainingPlaces());
|
player.setLevel(_challenge.getRemainingPlaces());
|
||||||
player.setExp(_challenge.getTimeLeftPercent());
|
player.setExp(_challenge.getTimeLeftPercent());
|
||||||
}
|
}
|
||||||
|
@ -121,6 +121,32 @@ public abstract class Challenge implements Listener
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void spawn(boolean firstRun)
|
||||||
|
{
|
||||||
|
if (firstRun)
|
||||||
|
{
|
||||||
|
ArrayList<Player> players = Host.GetPlayers(false);
|
||||||
|
|
||||||
|
for (int i = 0; i < players.size(); i++)
|
||||||
|
{
|
||||||
|
Player player = players.get(i);
|
||||||
|
|
||||||
|
new BukkitRunnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
Host.getPlayerTeam().SpawnTeleport(player);
|
||||||
|
}
|
||||||
|
}.runTaskLater(Host.Manager.getPlugin(), i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Host.getPlayerTeam().SpawnTeleport(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void start()
|
public void start()
|
||||||
{
|
{
|
||||||
Settings.setStartTime(System.currentTimeMillis());
|
Settings.setStartTime(System.currentTimeMillis());
|
||||||
|
@ -54,64 +54,72 @@ public abstract class TeamChallenge extends Challenge
|
|||||||
* Called automatically only when _teamSpawn is true.
|
* Called automatically only when _teamSpawn is true.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
|
@Override
|
||||||
public void spawn(boolean firstRun)
|
public void spawn(boolean firstRun)
|
||||||
{
|
{
|
||||||
autoSelectTeams();
|
if (_teamSpawn)
|
||||||
|
|
||||||
List<Player> firstTeam = _firstTeam.getPlayers();
|
|
||||||
List<Player> secondTeam = _secondTeam.getPlayers();
|
|
||||||
|
|
||||||
int firstTeamIndex = 0;
|
|
||||||
int secondTeamIndex = 0;
|
|
||||||
|
|
||||||
int players = Host.getPlayersWithRemainingLives();
|
|
||||||
int teleported = 0;
|
|
||||||
|
|
||||||
List<Location> randomSpawns = Data.getDefinedSpawns();
|
|
||||||
Collections.shuffle(randomSpawns);
|
|
||||||
|
|
||||||
while (teleported < players)
|
|
||||||
{
|
{
|
||||||
System.out.println("Selecting spawns");
|
autoSelectTeams();
|
||||||
|
|
||||||
for (Location spawn : randomSpawns)
|
List<Player> firstTeam = _firstTeam.getPlayers();
|
||||||
|
List<Player> secondTeam = _secondTeam.getPlayers();
|
||||||
|
|
||||||
|
int firstTeamIndex = 0;
|
||||||
|
int secondTeamIndex = 0;
|
||||||
|
|
||||||
|
int players = Host.getPlayersWithRemainingLives();
|
||||||
|
int teleported = 0;
|
||||||
|
|
||||||
|
List<Location> randomSpawns = Data.getDefinedSpawns();
|
||||||
|
Collections.shuffle(randomSpawns);
|
||||||
|
|
||||||
|
while (teleported < players)
|
||||||
{
|
{
|
||||||
Block block = spawn.getBlock().getRelative(BlockFace.DOWN);
|
System.out.println("Selecting spawns");
|
||||||
|
|
||||||
if (block.getData() == _firstTeamSpawnBlockData && firstTeamIndex < firstTeam.size())
|
for (Location spawn : randomSpawns)
|
||||||
{
|
{
|
||||||
Player player = firstTeam.get(firstTeamIndex);
|
Block block = spawn.getBlock().getRelative(BlockFace.DOWN);
|
||||||
|
|
||||||
if (firstRun)
|
if (block.getData() == _firstTeamSpawnBlockData && firstTeamIndex < firstTeam.size())
|
||||||
{
|
{
|
||||||
teleportWithDelay(player, spawn, teleported);
|
Player player = firstTeam.get(firstTeamIndex);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
player.teleport(spawn);
|
|
||||||
}
|
|
||||||
|
|
||||||
firstTeamIndex++;
|
if (firstRun)
|
||||||
teleported++;
|
{
|
||||||
}
|
teleportWithDelay(player, spawn, teleported);
|
||||||
else if (block.getData() == _secondTeamSpawnBlockData && secondTeamIndex < secondTeam.size())
|
}
|
||||||
{
|
else
|
||||||
Player player = secondTeam.get(secondTeamIndex);
|
{
|
||||||
|
player.teleport(spawn);
|
||||||
|
}
|
||||||
|
|
||||||
if (firstRun)
|
firstTeamIndex++;
|
||||||
{
|
teleported++;
|
||||||
teleportWithDelay(player, spawn, teleported);
|
|
||||||
}
|
}
|
||||||
else
|
else if (block.getData() == _secondTeamSpawnBlockData && secondTeamIndex < secondTeam.size())
|
||||||
{
|
{
|
||||||
player.teleport(spawn);
|
Player player = secondTeam.get(secondTeamIndex);
|
||||||
}
|
|
||||||
|
|
||||||
secondTeamIndex++;
|
if (firstRun)
|
||||||
teleported++;
|
{
|
||||||
|
teleportWithDelay(player, spawn, teleported);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
player.teleport(spawn);
|
||||||
|
}
|
||||||
|
|
||||||
|
secondTeamIndex++;
|
||||||
|
teleported++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
super.spawn(firstRun);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void teleportWithDelay(Player player, final Location spawn, int teleported)
|
private void teleportWithDelay(Player player, final Location spawn, int teleported)
|
||||||
|
Loading…
Reference in New Issue
Block a user