Add support for NamedTeams like Skywars, Skyfall etc..
This commit is contained in:
parent
108f2d7f16
commit
beaf47f783
@ -414,7 +414,7 @@ public class UtilAlg
|
||||
isInPyramid(player.getLocation().getDirection(), UtilAlg.getTrajectory(player.getEyeLocation(), target.getLocation()), angleLimit);
|
||||
}
|
||||
|
||||
public static Location getLocationAwayFromPlayers(ArrayList<Location> locs, ArrayList<Player> players)
|
||||
public static Location getLocationAwayFromPlayers(List<Location> locs, ArrayList<Player> players)
|
||||
{
|
||||
Location bestLoc = null;
|
||||
double bestDist = 0;
|
||||
@ -486,7 +486,7 @@ public class UtilAlg
|
||||
return bestLoc;
|
||||
}
|
||||
|
||||
public static Location getLocationNearPlayers(ArrayList<Location> locs, ArrayList<Player> players, ArrayList<Player> dontOverlap)
|
||||
public static Location getLocationNearPlayers(List<Location> locs, ArrayList<Player> players, ArrayList<Player> dontOverlap)
|
||||
{
|
||||
Location bestLoc = null;
|
||||
double bestDist = 0;
|
||||
|
@ -180,6 +180,7 @@ public abstract class Game extends ListenerComponent implements Lifetimed
|
||||
private final GameTeamModule _teamModule;
|
||||
protected ArrayList<GameTeam> _teamList = new ArrayList<GameTeam>();
|
||||
protected TeamSelector _teamSelector = new EvenTeamSelector();
|
||||
public boolean TeamMode = false;
|
||||
|
||||
// Player Preferences
|
||||
protected NautHashMap<Player, Kit> _playerKit = new NautHashMap<Player, Kit>();
|
||||
@ -1499,7 +1500,7 @@ public abstract class Game extends ListenerComponent implements Lifetimed
|
||||
winnerText = team.GetColor() + team.GetName();
|
||||
subColor = team.GetColor();
|
||||
|
||||
UtilPlayer.message(player, team.GetColor() + C.Bold + team.GetName() + " won the game!");
|
||||
UtilPlayer.message(player, subColor + C.Bold + team.GetName() + " won the game!");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2157,96 +2158,6 @@ public abstract class Game extends ListenerComponent implements Lifetimed
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void CustomTeamGeneration(GameStateChangeEvent event)
|
||||
{
|
||||
if (!TeamMode)
|
||||
return;
|
||||
|
||||
if (event.GetState() != GameState.Recruit)
|
||||
return;
|
||||
|
||||
ArrayList<Location> initialSpawns = this.GetTeamList().get(0).GetSpawns();
|
||||
ArrayList<Location> spawns = this.GetTeamList().get(0).GetSpawns();
|
||||
this.GetTeamList().clear();
|
||||
|
||||
TeamColors color = TeamColors.DARK_AQUA;
|
||||
|
||||
if (TeamPerSpawn)
|
||||
{
|
||||
|
||||
int i = 0;
|
||||
|
||||
for (Location location : initialSpawns)
|
||||
{
|
||||
i++;
|
||||
spawns = new ArrayList<>();
|
||||
|
||||
spawns.add(location);
|
||||
|
||||
addRelativeSpawns(spawns, location);
|
||||
|
||||
//Got Spawns
|
||||
color = getNextColor(color);
|
||||
int e = 0;
|
||||
for (GameTeam teams : GetTeamList())
|
||||
{
|
||||
if (teams.GetColor() == color.getColor())
|
||||
{
|
||||
e++;
|
||||
if (getColorName(color.getColor()).length <= e)
|
||||
{
|
||||
e = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GameTeam team = new GameTeam(this, getColorName(color.getColor())[e],
|
||||
color.getColor(), spawns, true);
|
||||
team.SetVisible(true);
|
||||
GetTeamList().add(team);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
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++)
|
||||
{
|
||||
//Got Spawns
|
||||
color = getNextColor(color);
|
||||
int e = 0;
|
||||
for (GameTeam teams : GetTeamList())
|
||||
{
|
||||
if (teams.GetColor() == color.getColor())
|
||||
{
|
||||
e++;
|
||||
if (getColorName(color.getColor()).length <= e)
|
||||
{
|
||||
e = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
GameTeam team = new GameTeam(this, getColorName(color.getColor())[e],
|
||||
color.getColor(), spawns, true);
|
||||
team.SetVisible(true);
|
||||
GetTeamList().add(team);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onJoin(PlayerJoinEvent event)
|
||||
{
|
||||
@ -2272,106 +2183,6 @@ public abstract class Game extends ListenerComponent implements Lifetimed
|
||||
_playerInTime.put(player, System.currentTimeMillis());
|
||||
}
|
||||
|
||||
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++)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private enum TeamColors
|
||||
{
|
||||
|
||||
YELLOW(ChatColor.YELLOW, new String[]{"Banana", "Sunshine", "Custard", "Sponge", "Star", "Giraffe", "Lego", "Light"}),
|
||||
GREEN(ChatColor.GREEN, new String[]{"Creepers", "Alien", "Seaweed", "Emerald", "Grinch", "Shrub", "Snake", "Leaf"}),
|
||||
AQUA(ChatColor.AQUA, new String[]{"Diamond", "Ice", "Pool", "Kraken", "Aquatic", "Ocean"}),
|
||||
RED(ChatColor.RED, new String[]{"Heart", "Tomato", "Ruby", "Jam", "Rose", "Apple", "TNT"}),
|
||||
GOLD(ChatColor.GOLD, new String[]{"Mango", "Foxes", "Sunset", "Nuggets", "Lion", "Desert", "Gapple"}),
|
||||
LIGHT_PURPLE(ChatColor.LIGHT_PURPLE, new String[]{"Dream", "Cupcake", "Cake", "Candy", "Unicorn"}),
|
||||
DARK_BLUE(ChatColor.DARK_BLUE, new String[]{"Squid", "Lapis", "Sharks", "Galaxy", "Empoleon"}),
|
||||
DARK_RED(ChatColor.DARK_RED, new String[]{"Rose", "Apple", "Twizzler", "Rocket", "Blood"}),
|
||||
WHITE(ChatColor.WHITE, new String[]{"Ghosts", "Spookies", "Popcorn", "Seagull", "Rice", "Snowman", "Artic"}),
|
||||
BLUE(ChatColor.BLUE, new String[]{"Sky", "Whale", "Lake", "Birds", "Bluebird", "Piplup"}),
|
||||
DARK_GREEN(ChatColor.DARK_GREEN, new String[]{"Forest", "Zombies", "Cactus", "Slime", "Toxic", "Poison"}),
|
||||
DARK_PURPLE(ChatColor.DARK_PURPLE, new String[]{"Amethyst", "Slugs", "Grape", "Witch", "Magic", "Zula"}),
|
||||
DARK_AQUA(ChatColor.DARK_AQUA, new String[]{"Snorlax", "Aquatic", "Clam", "Fish"});
|
||||
|
||||
private ChatColor color;
|
||||
private String[] names;
|
||||
|
||||
private TeamColors(ChatColor color, String[] names)
|
||||
{
|
||||
this.color = color;
|
||||
this.names = names;
|
||||
}
|
||||
|
||||
public ChatColor getColor()
|
||||
{
|
||||
return color;
|
||||
}
|
||||
|
||||
public String[] getNames()
|
||||
{
|
||||
return names;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private String[] getColorName(ChatColor color)
|
||||
{
|
||||
for (TeamColors colors : TeamColors.values())
|
||||
{
|
||||
if (colors.getColor() == color)
|
||||
{
|
||||
return colors.getNames();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private TeamColors getNextColor(TeamColors color)
|
||||
{
|
||||
for (TeamColors colors : TeamColors.values())
|
||||
{
|
||||
if (colors.ordinal() == color.ordinal() + 1)
|
||||
{
|
||||
return colors;
|
||||
}
|
||||
}
|
||||
return TeamColors.YELLOW;
|
||||
}
|
||||
|
||||
public void addTutorials()
|
||||
{
|
||||
}
|
||||
|
@ -3,6 +3,9 @@ package nautilus.game.arcade.game;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
@ -22,6 +25,7 @@ import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.game.kit.KitAvailability;
|
||||
import mineplex.core.visibility.VisibilityManager;
|
||||
|
||||
import nautilus.game.arcade.gametutorial.GameTutorial;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
|
||||
@ -29,32 +33,25 @@ public class GameTeam
|
||||
{
|
||||
private static final AtomicLong TEAM_ID = new AtomicLong();
|
||||
|
||||
private Game Host;
|
||||
private final Game Host;
|
||||
|
||||
private double _respawnTime = 0;
|
||||
|
||||
public enum PlayerState
|
||||
{
|
||||
IN("In", ChatColor.GREEN),
|
||||
OUT("Out", ChatColor.RED);
|
||||
IN("In"),
|
||||
OUT("Out");
|
||||
|
||||
private String name;
|
||||
private ChatColor color;
|
||||
private final String _name;
|
||||
|
||||
PlayerState(String name, ChatColor color)
|
||||
PlayerState(String name)
|
||||
{
|
||||
this.name = name;
|
||||
this.color = color;
|
||||
_name = name;
|
||||
}
|
||||
|
||||
public String GetName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public ChatColor GetColor()
|
||||
{
|
||||
return color;
|
||||
return _name;
|
||||
}
|
||||
}
|
||||
|
||||
@ -63,26 +60,25 @@ public class GameTeam
|
||||
private String _name;
|
||||
private String _displayName;
|
||||
private ChatColor _color;
|
||||
private boolean _displayTag;
|
||||
|
||||
private GameTutorial _tutorial;
|
||||
|
||||
private HashMap<Player, PlayerState> _players = new HashMap<>();
|
||||
private final Map<Player, PlayerState> _players = new HashMap<>();
|
||||
|
||||
private ArrayList<Location> _spawns;
|
||||
private List<Location> _spawns;
|
||||
|
||||
private Creature _teamEntity = null;
|
||||
|
||||
private HashSet<Kit> _kitRestrict = new HashSet<>();
|
||||
private final Set<Kit> _kitRestrict = new HashSet<>();
|
||||
|
||||
private boolean _visible = true;
|
||||
|
||||
private boolean _displayTag;
|
||||
|
||||
//Records order players go out in
|
||||
private ArrayList<Player> _places = new ArrayList<>();
|
||||
private List<Player> _places = new ArrayList<>();
|
||||
private long _teamCreatedTime = System.currentTimeMillis(); // Used just for SpectatorPage so that teams remain ordered
|
||||
|
||||
public GameTeam(Game host, String name, ChatColor color, ArrayList<Location> spawns, boolean tags)
|
||||
public GameTeam(Game host, String name, ChatColor color, List<Location> spawns, boolean tags)
|
||||
{
|
||||
Host = host;
|
||||
|
||||
@ -93,7 +89,7 @@ public class GameTeam
|
||||
_displayTag = tags;
|
||||
}
|
||||
|
||||
public GameTeam(Game host, String name, ChatColor color, ArrayList<Location> spawns)
|
||||
public GameTeam(Game host, String name, ChatColor color, List<Location> spawns)
|
||||
{
|
||||
this(host, name, color, spawns, false);
|
||||
}
|
||||
@ -113,7 +109,7 @@ public class GameTeam
|
||||
return _color;
|
||||
}
|
||||
|
||||
public ArrayList<Location> GetSpawns()
|
||||
public List<Location> GetSpawns()
|
||||
{
|
||||
return _spawns;
|
||||
}
|
||||
@ -287,7 +283,7 @@ public class GameTeam
|
||||
}
|
||||
}
|
||||
|
||||
public HashSet<Kit> GetRestrictedKits()
|
||||
public Set<Kit> GetRestrictedKits()
|
||||
{
|
||||
return _kitRestrict;
|
||||
}
|
||||
@ -396,7 +392,7 @@ public class GameTeam
|
||||
return _teamEntity;
|
||||
}
|
||||
|
||||
public void SetSpawns(ArrayList<Location> spawns)
|
||||
public void SetSpawns(List<Location> spawns)
|
||||
{
|
||||
_spawns = spawns;
|
||||
}
|
||||
@ -440,7 +436,7 @@ public class GameTeam
|
||||
_places.remove(player);
|
||||
}
|
||||
|
||||
public ArrayList<Player> GetPlacements(boolean includeAlivePlayers)
|
||||
public List<Player> GetPlacements(boolean includeAlivePlayers)
|
||||
{
|
||||
if (includeAlivePlayers)
|
||||
{
|
||||
|
@ -49,7 +49,7 @@ public abstract class SoloGame extends Game
|
||||
|
||||
if (GetPlayers(true).size() <= 1)
|
||||
{
|
||||
ArrayList<Player> places = _players.GetPlacements(true);
|
||||
List<Player> places = _players.GetPlacements(true);
|
||||
|
||||
//Announce
|
||||
AnnounceEnd(places);
|
||||
|
@ -20,7 +20,9 @@ import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.games.build.Build;
|
||||
import nautilus.game.arcade.game.games.build.BuildData;
|
||||
import nautilus.game.arcade.game.games.build.BuildQuality;
|
||||
import nautilus.game.arcade.game.team.NamedTeamsModule;
|
||||
import nautilus.game.arcade.game.team.TeamRequestsModule;
|
||||
import nautilus.game.arcade.game.team.selectors.FillToSelector;
|
||||
|
||||
/**
|
||||
* TeamBuild gamemode for Master builders
|
||||
@ -35,12 +37,15 @@ public class TeamBuild extends Build
|
||||
public TeamBuild(ArcadeManager manager)
|
||||
{
|
||||
super(manager, GameType.Brawl);
|
||||
|
||||
TeamMode = true;
|
||||
|
||||
new TeamRequestsModule().register(this);
|
||||
_teamSelector = new FillToSelector(this, 2);
|
||||
|
||||
TeamPerSpawn = true;
|
||||
new NamedTeamsModule()
|
||||
.setTeamPerSpawn(true)
|
||||
.register(this);
|
||||
|
||||
new TeamRequestsModule()
|
||||
.register(this);
|
||||
|
||||
_winners = new ArrayList<>();
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.MapUtil;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.core.visibility.VisibilityManager;
|
||||
|
@ -60,7 +60,6 @@ public class QuiverTeamBase extends TeamGame
|
||||
{
|
||||
super(manager, GameType.QuiverPayload, kits, new String[] {});
|
||||
|
||||
this.PlayersPerTeam = 5;
|
||||
this.DeathOut = false;
|
||||
this.DamageSelf = false;
|
||||
this.DamageTeamSelf = false;
|
||||
|
@ -1,6 +1,5 @@
|
||||
package nautilus.game.arcade.game.games.skyfall;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@ -19,7 +18,6 @@ import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.GameType;
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.Game.GameState;
|
||||
|
||||
/**
|
||||
* SoloSkyfall
|
||||
@ -114,7 +112,7 @@ public class SoloSkyfall extends Skyfall
|
||||
|
||||
if (GetPlayers(true).size() <= 1)
|
||||
{
|
||||
ArrayList<Player> places = GetTeamList().get(0).GetPlacements(true);
|
||||
List<Player> places = GetTeamList().get(0).GetPlacements(true);
|
||||
|
||||
//Announce
|
||||
AnnounceEnd(places);
|
||||
|
@ -17,7 +17,9 @@ import mineplex.core.updater.event.UpdateEvent;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.GameType;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.team.NamedTeamsModule;
|
||||
import nautilus.game.arcade.game.team.TeamRequestsModule;
|
||||
import nautilus.game.arcade.game.team.selectors.FillToSelector;
|
||||
|
||||
/**
|
||||
* TeamSkyfall
|
||||
@ -31,20 +33,24 @@ public class TeamSkyfall extends Skyfall
|
||||
public TeamSkyfall(ArcadeManager manager)
|
||||
{
|
||||
super(manager, GameType.SkyfallTeams);
|
||||
|
||||
PlayersPerTeam = 2;
|
||||
|
||||
SpawnNearAllies = true;
|
||||
|
||||
DamageTeamSelf = false;
|
||||
|
||||
DontAllowOverfill = true;
|
||||
TeamMode = true;
|
||||
ShowTeammateMessage = true;
|
||||
|
||||
HideTeamSheep = true;
|
||||
|
||||
registerModule(new TeamRequestsModule());
|
||||
_teamSelector = new FillToSelector(this, 2);
|
||||
|
||||
new NamedTeamsModule()
|
||||
.setTeamPerSpawn(true)
|
||||
.register(this);
|
||||
|
||||
new TeamRequestsModule()
|
||||
.register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,6 +1,5 @@
|
||||
package nautilus.game.arcade.game.games.skywars;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@ -128,7 +127,7 @@ public class SoloSkywars extends Skywars
|
||||
|
||||
if (GetPlayers(true).size() <= 1)
|
||||
{
|
||||
ArrayList<Player> places = GetTeamList().get(0).GetPlacements(true);
|
||||
List<Player> places = GetTeamList().get(0).GetPlacements(true);
|
||||
|
||||
//Announce
|
||||
AnnounceEnd(places);
|
||||
|
@ -14,7 +14,9 @@ import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.GameType;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.games.skywars.trackers.TNTStatTracker;
|
||||
import nautilus.game.arcade.game.team.NamedTeamsModule;
|
||||
import nautilus.game.arcade.game.team.TeamRequestsModule;
|
||||
import nautilus.game.arcade.game.team.selectors.FillToSelector;
|
||||
import nautilus.game.arcade.stats.DeathBomberStatTracker;
|
||||
import nautilus.game.arcade.stats.WinWithoutOpeningChestStatTracker;
|
||||
import nautilus.game.arcade.stats.WinWithoutWearingArmorStatTracker;
|
||||
@ -63,10 +65,14 @@ public class TeamSkywars extends Skywars
|
||||
|
||||
DontAllowOverfill = true;
|
||||
|
||||
TeamMode = true;
|
||||
TeamPerSpawn = true;
|
||||
ShowTeammateMessage = true;
|
||||
|
||||
_teamSelector = new FillToSelector(this, 2);
|
||||
|
||||
new NamedTeamsModule()
|
||||
.setTeamPerSpawn(true)
|
||||
.register(this);
|
||||
|
||||
new TeamRequestsModule()
|
||||
.register(this);
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ public class SoloSuperSmash extends SuperSmash
|
||||
|
||||
if (GetPlayers(true).size() <= 1)
|
||||
{
|
||||
ArrayList<Player> places = GetTeamList().get(0).GetPlacements(true);
|
||||
List<Player> places = GetTeamList().get(0).GetPlacements(true);
|
||||
|
||||
//Announce
|
||||
AnnounceEnd(places);
|
||||
|
@ -17,7 +17,9 @@ import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.GameType;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.modules.TeamArmorModule;
|
||||
import nautilus.game.arcade.game.team.NamedTeamsModule;
|
||||
import nautilus.game.arcade.game.team.TeamRequestsModule;
|
||||
import nautilus.game.arcade.game.team.selectors.FillToSelector;
|
||||
import nautilus.game.arcade.managers.chat.ChatStatData;
|
||||
import nautilus.game.arcade.stats.FreeKitWinStatTracker;
|
||||
import nautilus.game.arcade.stats.KillFastStatTracker;
|
||||
@ -32,22 +34,40 @@ public class TeamSuperSmash extends SuperSmash
|
||||
{
|
||||
super(manager, GameType.SmashTeams, new String[] { "Each player has 3 respawns", "Attack to restore hunger!", "Last team alive wins!" });
|
||||
|
||||
PlayersPerTeam = 2;
|
||||
|
||||
SpawnNearAllies = true;
|
||||
DamageTeamSelf = false;
|
||||
|
||||
DontAllowOverfill = true;
|
||||
|
||||
TeamMode = true;
|
||||
ShowTeammateMessage = true;
|
||||
|
||||
new TeamRequestsModule().register(this);
|
||||
_teamSelector = new FillToSelector(this, 2);
|
||||
|
||||
registerStatTrackers(new WinWithoutDyingStatTracker(this, "MLGPro"), new FreeKitWinStatTracker(this), new OneVThreeStatTracker(this), new KillFastStatTracker(this, 3, 10, "TripleKill"),
|
||||
new RecoveryMasterStatTracker(this));
|
||||
new NamedTeamsModule()
|
||||
.register(this);
|
||||
|
||||
registerChatStats(Kills, Deaths, KDRatio, BlankLine, Assists, DamageTaken, DamageDealt, BlankLine, new ChatStatData("kit", "Kit", true));
|
||||
new TeamRequestsModule().
|
||||
register(this);
|
||||
|
||||
registerStatTrackers(
|
||||
new WinWithoutDyingStatTracker(this, "MLGPro"),
|
||||
new FreeKitWinStatTracker(this),
|
||||
new OneVThreeStatTracker(this),
|
||||
new KillFastStatTracker(this, 3, 10, "TripleKill"),
|
||||
new RecoveryMasterStatTracker(this)
|
||||
);
|
||||
|
||||
registerChatStats(
|
||||
Kills,
|
||||
Deaths,
|
||||
KDRatio,
|
||||
BlankLine,
|
||||
Assists,
|
||||
DamageTaken,
|
||||
DamageDealt,
|
||||
BlankLine,
|
||||
new ChatStatData("kit", "Kit", true)
|
||||
);
|
||||
|
||||
new TeamArmorModule()
|
||||
.giveHotbarItem()
|
||||
|
@ -1761,7 +1761,7 @@ public class SpeedBuilders extends SoloGame
|
||||
|
||||
if (playersTeam.GetPlayers(true).size() <= 1)
|
||||
{
|
||||
ArrayList<Player> places = playersTeam.GetPlacements(true);
|
||||
List<Player> places = playersTeam.GetPlacements(true);
|
||||
|
||||
//Announce
|
||||
AnnounceEnd(places);
|
||||
|
@ -8,7 +8,9 @@ import org.bukkit.entity.Player;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.GameType;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.team.NamedTeamsModule;
|
||||
import nautilus.game.arcade.game.team.TeamRequestsModule;
|
||||
import nautilus.game.arcade.game.team.selectors.FillToSelector;
|
||||
|
||||
public class SurvivalGamesNewTeams extends SurvivalGamesNew
|
||||
{
|
||||
@ -25,8 +27,6 @@ public class SurvivalGamesNewTeams extends SurvivalGamesNew
|
||||
{
|
||||
super(manager, GameType.SurvivalGamesTeams, DESCRIPTION);
|
||||
|
||||
PlayersPerTeam = 2;
|
||||
TeamMode = true;
|
||||
ShowTeammateMessage = true;
|
||||
|
||||
SpawnNearAllies = true;
|
||||
@ -36,6 +36,12 @@ public class SurvivalGamesNewTeams extends SurvivalGamesNew
|
||||
|
||||
DontAllowOverfill = true;
|
||||
|
||||
_teamSelector = new FillToSelector(this, 2);
|
||||
|
||||
new NamedTeamsModule()
|
||||
.setTeamPerSpawn(true)
|
||||
.register(this);
|
||||
|
||||
new TeamRequestsModule()
|
||||
.register(this);
|
||||
}
|
||||
|
@ -1645,7 +1645,7 @@ public abstract class UHC extends Game
|
||||
{
|
||||
if (GetPlayers(true).size() <= 1)
|
||||
{
|
||||
ArrayList<Player> places = GetTeamList().get(0).GetPlacements(true);
|
||||
List<Player> places = GetTeamList().get(0).GetPlacements(true);
|
||||
|
||||
// Announce
|
||||
AnnounceEnd(places);
|
||||
|
@ -34,6 +34,7 @@ public class UHCTeams extends UHC
|
||||
DamageTeamSelf = false;
|
||||
DontAllowOverfill = true;
|
||||
ShowTeammateMessage = true;
|
||||
TeamMode = true;
|
||||
|
||||
// Load the Team Module
|
||||
new TeamRequestsModule().register(this);
|
||||
|
@ -57,6 +57,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class Valentines extends SoloGame
|
||||
{
|
||||
@ -749,7 +750,7 @@ public class Valentines extends SoloGame
|
||||
|
||||
if (GetPlayers(true).size() == 1)
|
||||
{
|
||||
ArrayList<Player> places = _players.GetPlacements(true);
|
||||
List<Player> places = _players.GetPlacements(true);
|
||||
|
||||
System.out.println("EndCheck:760");
|
||||
//Announce
|
||||
|
@ -3,6 +3,7 @@ package nautilus.game.arcade.game.games.zombiesurvival;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.EntityCreature;
|
||||
import net.minecraft.server.v1_8_R3.NavigationAbstract;
|
||||
@ -331,7 +332,7 @@ public class ZombieSurvival extends SoloGame
|
||||
|
||||
if (_survivors.GetPlayers(true).size() <= 1)
|
||||
{
|
||||
ArrayList<Player> places = _survivors.GetPlacements(true);
|
||||
List<Player> places = _survivors.GetPlacements(true);
|
||||
|
||||
if (places.size() >= 1)
|
||||
AddGems(places.get(0), 15, "1st Place", false, false);
|
||||
|
@ -249,4 +249,9 @@ public class GameTeamModule extends Module
|
||||
{
|
||||
return _preferences;
|
||||
}
|
||||
|
||||
public int getPlayersPerTeam()
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,146 @@
|
||||
package nautilus.game.arcade.game.team;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.game.Game.GameState;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.modules.Module;
|
||||
|
||||
public class NamedTeamsModule extends Module
|
||||
{
|
||||
|
||||
private boolean _teamPerSpawn;
|
||||
|
||||
private TeamColors _currentColor = TeamColors.first();
|
||||
private int _nameIndex;
|
||||
|
||||
@Override
|
||||
protected void setup()
|
||||
{
|
||||
getGame().TeamMode = true;
|
||||
}
|
||||
|
||||
public NamedTeamsModule setTeamPerSpawn(boolean teamPerSpawn)
|
||||
{
|
||||
_teamPerSpawn = teamPerSpawn;
|
||||
return this;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void generateCustomTeams(GameStateChangeEvent event)
|
||||
{
|
||||
if (event.GetState() != GameState.Recruit)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
List<Location> spawns = getGame().GetTeamList().get(0).GetSpawns();
|
||||
getGame().GetTeamList().clear();
|
||||
|
||||
if (_teamPerSpawn)
|
||||
{
|
||||
Bukkit.broadcastMessage("Creating teams by spawns " + spawns.size());
|
||||
|
||||
for (Location location : spawns)
|
||||
{
|
||||
List<Location> newSpawns = new ArrayList<>();
|
||||
|
||||
// Add nearby non block spawns
|
||||
for (Block block : UtilBlock.getInBoundingBox(location.clone().subtract(2, 0, 2), location.clone().add(2, 0, 2), false))
|
||||
{
|
||||
if (UtilBlock.airFoliage(block) && UtilBlock.airFoliage(block.getRelative(BlockFace.UP)))
|
||||
{
|
||||
newSpawns.add(block.getLocation().add(0.5, 0, 0.5));
|
||||
}
|
||||
}
|
||||
|
||||
// Give them a good old shuffle
|
||||
Collections.shuffle(newSpawns);
|
||||
|
||||
createTeam(newSpawns);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int playersPerTeam = getGame().getTeamModule().getPlayersPerTeam();
|
||||
int teams = getGame().getArcadeManager().GetPlayerFull() / playersPerTeam;
|
||||
|
||||
Bukkit.broadcastMessage("Creating teams by target " + teams);
|
||||
|
||||
for (int i = 0; i < teams; i++)
|
||||
{
|
||||
createTeam(spawns);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void createTeam(List<Location> spawns)
|
||||
{
|
||||
// Create the team
|
||||
GameTeam team = new GameTeam(getGame(), _currentColor._names[_nameIndex], _currentColor._color, spawns, true);
|
||||
getGame().AddTeam(team);
|
||||
|
||||
_currentColor = _currentColor.next();
|
||||
|
||||
// If there is no next colour reset and increment name index
|
||||
if (_currentColor == null)
|
||||
{
|
||||
_currentColor = TeamColors.first();
|
||||
_nameIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
enum TeamColors
|
||||
{
|
||||
|
||||
YELLOW(ChatColor.YELLOW, new String[]{"Banana", "Mopple", "Custard", "Sponge", "Star", "Giraffe", "Lego", "Light"}),
|
||||
GREEN(ChatColor.GREEN, new String[]{"Creepers", "Alien", "Seaweed", "Emerald", "Grinch", "Shrub", "Snake", "Leaf"}),
|
||||
AQUA(ChatColor.AQUA, new String[]{"Diamond", "Ice", "Pool", "Kraken", "Aquatic", "Ocean"}),
|
||||
RED(ChatColor.RED, new String[]{"Heart", "Tomato", "Ruby", "Jam", "Rose", "Apple", "TNT"}),
|
||||
GOLD(ChatColor.GOLD, new String[]{"Mango", "Foxes", "Sunset", "Nuggets", "Lion", "Desert", "Gapple"}),
|
||||
LIGHT_PURPLE(ChatColor.LIGHT_PURPLE, new String[]{"Dream", "Cupcake", "Cake", "Candy", "Unicorn"}),
|
||||
DARK_BLUE(ChatColor.DARK_BLUE, new String[]{"Squid", "Lapis", "Sharks", "Galaxy", "Empoleon"}),
|
||||
DARK_RED(ChatColor.DARK_RED, new String[]{"Rose", "Apple", "Twizzler", "Rocket", "Blood"}),
|
||||
WHITE(ChatColor.WHITE, new String[]{"Ghosts", "Spookies", "Popcorn", "Seagull", "Rice", "Snowman", "Artic"}),
|
||||
BLUE(ChatColor.BLUE, new String[]{"Sky", "Whale", "Lake", "Birds", "Bluebird", "Piplup"}),
|
||||
DARK_GREEN(ChatColor.DARK_GREEN, new String[]{"Forest", "Zombies", "Cactus", "Slime", "Toxic", "Poison"}),
|
||||
DARK_PURPLE(ChatColor.DARK_PURPLE, new String[]{"Amethyst", "Slugs", "Grape", "Witch", "Magic", "Zula"}),
|
||||
DARK_AQUA(ChatColor.DARK_AQUA, new String[]{"Snorlax", "Aquatic", "Clam", "Fish"});
|
||||
|
||||
static TeamColors first()
|
||||
{
|
||||
return TeamColors.values()[0];
|
||||
}
|
||||
|
||||
private final ChatColor _color;
|
||||
private final String[] _names;
|
||||
|
||||
TeamColors(ChatColor color, String[] names)
|
||||
{
|
||||
_color = color;
|
||||
_names = names;
|
||||
}
|
||||
|
||||
TeamColors next()
|
||||
{
|
||||
if (ordinal() == values().length - 1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return values()[ordinal() + 1];
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user