Add cleaner page for when there is only 1 team

This commit is contained in:
Shaun Bennett 2014-11-13 19:33:39 -06:00
parent ea8b8dca15
commit 6038c72e86
1 changed files with 36 additions and 4 deletions

View File

@ -44,10 +44,37 @@ public class SpectatorPage extends ShopPageBase<CompassAddon, SpectatorShop>
@Override
protected void BuildPage()
{
int currentRow = 0;
int playerCount = _arcadeManager.GetGame().GetPlayers(true).size();
List<GameTeam> teamList = _arcadeManager.GetGame().GetTeamList();
if (teamList.size() == 1 && playerCount < 28)
buildSingleTeam(teamList.get(0), playerCount);
else
buildMultipleTeams(teamList, playerCount);
}
private void buildSingleTeam(GameTeam team, int playerCount)
{
setItem(13, getTeamItem(team, playerCount));
int slot = 19;
for (Player other : team.GetPlayers(true))
{
addPlayerItem(slot, team, other);
if ((slot + 2) % 9 == 0)
slot += 3;
else
slot++;
}
}
private void buildMultipleTeams(List<GameTeam> teamList, int playerCount)
{
int currentRow = 0;
for (GameTeam team : teamList)
{
ArrayList<Player> teamPlayers = team.GetPlayers(true);
@ -74,9 +101,7 @@ public class SpectatorPage extends ShopPageBase<CompassAddon, SpectatorShop>
if (slot >= getSize())
continue;
ItemStack playerItem = getPlayerItem(team, teamPlayers.get(playerIndex));
ShopItem shopItem = new ShopItem(playerItem, other.getName(), other.getName(), 1, false, false);
AddButton(slot, shopItem, new SpectatorButton(_arcadeManager, Player, other));
addPlayerItem(slot, team, other);
}
}
@ -88,6 +113,13 @@ public class SpectatorPage extends ShopPageBase<CompassAddon, SpectatorShop>
}
}
private void addPlayerItem(int slot, GameTeam team, Player other)
{
ItemStack playerItem = getPlayerItem(team, other);
ShopItem shopItem = new ShopItem(playerItem, other.getName(), other.getName(), 1, false, false);
AddButton(slot, shopItem, new SpectatorButton(_arcadeManager, Player, other));
}
private ItemStack getTeamItem(GameTeam team, int playerCount)
{
ItemStack item = new ItemStack(Material.WOOL, 1, (short)0, UtilColor.chatColorToWoolData(team.GetColor()));