changed skywars teams. forced at 16 teams.
This commit is contained in:
parent
558b71f866
commit
3335a7c288
@ -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,82 +40,66 @@ 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)
|
||||
|
||||
TeamColors color = TeamColors.DARK_AQUA;
|
||||
|
||||
//Create 1 Team for each Spawn
|
||||
int i = 0;
|
||||
for(Location location : initialSpawns)
|
||||
{
|
||||
for(int x = -1; x <= 1; x++)
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
private void addRelativeSpawns(ArrayList<Location> spawns, Location location)
|
||||
{
|
||||
//Gather Extra Spawns
|
||||
for(int x = -1; x <= 1; x++)
|
||||
{
|
||||
for(int z = -1; z <= 1; z++)
|
||||
{
|
||||
for(int z = -1; z <= 1; z++)
|
||||
if(x != 0 && z != 0)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TeamColors color = TeamColors.DARK_AQUA;
|
||||
|
||||
if(!this.ForceTeamSize)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(int i = 1; i <= Manager.GetPlayerFull() / this.PlayersPerTeam; i++)
|
||||
{
|
||||
System.out.println("Test");
|
||||
color = getNextColor(color);
|
||||
GameTeam team = new GameTeam(this, String.valueOf(i), color.getColor(), spawns);
|
||||
team.SetVisible(true);
|
||||
GetTeamList().add(team);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private BlockFace getBlockface(BlockFace face)
|
||||
{
|
||||
for(BlockFace faces : BlockFace.values()) {
|
||||
|
Loading…
Reference in New Issue
Block a user