changed skywars teams. forced at 16 teams.

This commit is contained in:
Cheese 2015-07-17 12:07:09 +10:00
parent 558b71f866
commit 3335a7c288
1 changed files with 49 additions and 72 deletions

View File

@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.List;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilTime.TimeUnit;
import mineplex.core.updater.UpdateType;
@ -22,11 +23,6 @@ import org.bukkit.event.EventHandler;
public class TeamSkywars extends Skywars
{
public boolean ForceTeamSize = true;
public int PlayersPerTeam = 2;
public int TeamCount = 0;
public TeamSkywars(ArcadeManager manager)
{
super(manager, GameType.SkywarsTeams,
@ -36,9 +32,6 @@ public class TeamSkywars extends Skywars
"Craft or loot gear for combat",
"Last team alive wins!"
});
this.PlayersPerTeam = 2;
}
@EventHandler
@ -47,78 +40,62 @@ public class TeamSkywars extends Skywars
if (event.GetState() != GameState.Recruit)
return;
ArrayList<Location> tempSpawns = this.GetTeamList().get(0).GetSpawns();
ArrayList<Location> initialSpawns = this.GetTeamList().get(0).GetSpawns();
this.GetTeamList().clear();
ArrayList<Location> spawns = new ArrayList<Location>();
for(Location location : tempSpawns)
{
for(int x = -1; x <= 1; x++)
{
for(int z = -1; z <= 1; z++)
{
if(x != 0 && z != 0)
{
Location spawnLocation = location.clone().add(x, 0, z);
if(spawnLocation.getWorld().getBlockAt(spawnLocation).getRelative(BlockFace.DOWN).getType() == Material.AIR)
{
boolean foundBlock = false;
Location tempLocation = spawnLocation.clone();
BlockFace currentBlockFace = BlockFace.NORTH;
while(!foundBlock)
{
for(BlockFace face : BlockFace.values())
{
if(spawnLocation.getWorld().getBlockAt(spawnLocation).getRelative(face).getType() != Material.AIR)
{
spawnLocation = tempLocation.getWorld().getBlockAt(tempLocation).getRelative(face).getLocation().add(0, 1, 0);
foundBlock = true;
}
}
if(!foundBlock)
{
tempLocation = spawnLocation.getWorld().getBlockAt(spawnLocation).getRelative(currentBlockFace).getLocation();
currentBlockFace = getBlockface(currentBlockFace);
if(currentBlockFace == BlockFace.SELF)
{
currentBlockFace = getBlockface(currentBlockFace);
tempLocation = spawnLocation.getWorld().getBlockAt(spawnLocation).getRelative(currentBlockFace).getLocation();
spawnLocation = tempLocation;
}
}
}
}
while(spawnLocation.getWorld().getBlockAt(spawnLocation).getType() != Material.AIR)
{
spawnLocation.add(0, 1, 0);
}
spawns.add(spawnLocation);
}
}
}
}
TeamColors color = TeamColors.DARK_AQUA;
if(!this.ForceTeamSize)
//Create 1 Team for each Spawn
int i = 0;
for(Location location : initialSpawns)
{
for(int i = 1; i <= this.TeamCount; i++)
{
color = getNextColor(color);
GameTeam team = new GameTeam(this, String.valueOf(i), color.getColor(), spawns);
team.SetVisible(true);
GetTeamList().add(team);
}
i++;
spawns.add(location);
addRelativeSpawns(spawns, location);
//Got Spawns
color = getNextColor(color);
GameTeam team = new GameTeam(this, String.valueOf(i), color.getColor(), spawns);
team.SetVisible(true);
GetTeamList().add(team);
}
else
}
private void addRelativeSpawns(ArrayList<Location> spawns, Location location)
{
//Gather Extra Spawns
for(int x = -1; x <= 1; x++)
{
for(int i = 1; i <= Manager.GetPlayerFull() / this.PlayersPerTeam; i++)
for(int z = -1; z <= 1; z++)
{
System.out.println("Test");
color = getNextColor(color);
GameTeam team = new GameTeam(this, String.valueOf(i), color.getColor(), spawns);
team.SetVisible(true);
GetTeamList().add(team);
if(x != 0 && z != 0)
{
Location newSpawn = location.clone().add(x, 0, z);
//Search Downward for Solid
while (UtilBlock.airFoliage(newSpawn.getBlock().getRelative(BlockFace.DOWN)) && newSpawn.getY() > location.getY()-5)
{
newSpawn.subtract(0, 1, 0);
}
//Move Up out of Solid
while (!UtilBlock.airFoliage(newSpawn.getBlock()) && newSpawn.getY() < location.getY()+5)
{
newSpawn.add(0, 1, 0);
}
//On Solid, with 2 Air Above
if (UtilBlock.airFoliage(newSpawn.getBlock()) &&
UtilBlock.airFoliage(newSpawn.getBlock().getRelative(BlockFace.UP)) &&
!UtilBlock.airFoliage(newSpawn.getBlock().getRelative(BlockFace.DOWN)))
{
spawns.add(newSpawn);
}
}
}
}
}