diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAlg.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAlg.java index b23ff2ec7..29abf4352 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAlg.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAlg.java @@ -414,7 +414,7 @@ public class UtilAlg isInPyramid(player.getLocation().getDirection(), UtilAlg.getTrajectory(player.getEyeLocation(), target.getLocation()), angleLimit); } - public static Location getLocationAwayFromPlayers(ArrayList locs, ArrayList players) + public static Location getLocationAwayFromPlayers(List locs, ArrayList players) { Location bestLoc = null; double bestDist = 0; @@ -486,7 +486,7 @@ public class UtilAlg return bestLoc; } - public static Location getLocationNearPlayers(ArrayList locs, ArrayList players, ArrayList dontOverlap) + public static Location getLocationNearPlayers(List locs, ArrayList players, ArrayList dontOverlap) { Location bestLoc = null; double bestDist = 0; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java index 1b8526825..4c2f8309d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java @@ -180,6 +180,7 @@ public abstract class Game extends ListenerComponent implements Lifetimed private final GameTeamModule _teamModule; protected ArrayList _teamList = new ArrayList(); protected TeamSelector _teamSelector = new EvenTeamSelector(); + public boolean TeamMode = false; // Player Preferences protected NautHashMap _playerKit = new NautHashMap(); @@ -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 initialSpawns = this.GetTeamList().get(0).GetSpawns(); - ArrayList 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 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() { } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/GameTeam.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/GameTeam.java index 402eff52e..768644b1f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/GameTeam.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/GameTeam.java @@ -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 _players = new HashMap<>(); + private final Map _players = new HashMap<>(); - private ArrayList _spawns; + private List _spawns; private Creature _teamEntity = null; - private HashSet _kitRestrict = new HashSet<>(); + private final Set _kitRestrict = new HashSet<>(); private boolean _visible = true; - private boolean _displayTag; - //Records order players go out in - private ArrayList _places = new ArrayList<>(); + private List _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 spawns, boolean tags) + public GameTeam(Game host, String name, ChatColor color, List spawns, boolean tags) { Host = host; @@ -93,7 +89,7 @@ public class GameTeam _displayTag = tags; } - public GameTeam(Game host, String name, ChatColor color, ArrayList spawns) + public GameTeam(Game host, String name, ChatColor color, List spawns) { this(host, name, color, spawns, false); } @@ -113,7 +109,7 @@ public class GameTeam return _color; } - public ArrayList GetSpawns() + public List GetSpawns() { return _spawns; } @@ -287,7 +283,7 @@ public class GameTeam } } - public HashSet GetRestrictedKits() + public Set GetRestrictedKits() { return _kitRestrict; } @@ -396,7 +392,7 @@ public class GameTeam return _teamEntity; } - public void SetSpawns(ArrayList spawns) + public void SetSpawns(List spawns) { _spawns = spawns; } @@ -440,7 +436,7 @@ public class GameTeam _places.remove(player); } - public ArrayList GetPlacements(boolean includeAlivePlayers) + public List GetPlacements(boolean includeAlivePlayers) { if (includeAlivePlayers) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/SoloGame.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/SoloGame.java index 6a8873016..ad369ca98 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/SoloGame.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/SoloGame.java @@ -49,7 +49,7 @@ public abstract class SoloGame extends Game if (GetPlayers(true).size() <= 1) { - ArrayList places = _players.GetPlacements(true); + List places = _players.GetPlacements(true); //Announce AnnounceEnd(places); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/modes/TeamBuild.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/modes/TeamBuild.java index 962e5eadd..5a58362ca 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/modes/TeamBuild.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/modes/TeamBuild.java @@ -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<>(); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/deathtag/DeathTag.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/deathtag/DeathTag.java index 757a660e9..6c5d8e8d8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/deathtag/DeathTag.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/deathtag/DeathTag.java @@ -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; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/QuiverTeamBase.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/QuiverTeamBase.java index 592a69701..b95bf0156 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/QuiverTeamBase.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/QuiverTeamBase.java @@ -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; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/SoloSkyfall.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/SoloSkyfall.java index 9d26f1c34..cc84cba74 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/SoloSkyfall.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/SoloSkyfall.java @@ -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 places = GetTeamList().get(0).GetPlacements(true); + List places = GetTeamList().get(0).GetPlacements(true); //Announce AnnounceEnd(places); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/TeamSkyfall.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/TeamSkyfall.java index 44778d0b1..8324eb051 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/TeamSkyfall.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skyfall/TeamSkyfall.java @@ -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 diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/SoloSkywars.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/SoloSkywars.java index 99fd8e040..b4e91ec80 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/SoloSkywars.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/SoloSkywars.java @@ -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 places = GetTeamList().get(0).GetPlacements(true); + List places = GetTeamList().get(0).GetPlacements(true); //Announce AnnounceEnd(places); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/TeamSkywars.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/TeamSkywars.java index 70892561d..555aa16bc 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/TeamSkywars.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/TeamSkywars.java @@ -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); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SoloSuperSmash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SoloSuperSmash.java index e542c7549..4bac8efd5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SoloSuperSmash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SoloSuperSmash.java @@ -132,7 +132,7 @@ public class SoloSuperSmash extends SuperSmash if (GetPlayers(true).size() <= 1) { - ArrayList places = GetTeamList().get(0).GetPlacements(true); + List places = GetTeamList().get(0).GetPlacements(true); //Announce AnnounceEnd(places); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/TeamSuperSmash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/TeamSuperSmash.java index 194867709..0069b7b3c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/TeamSuperSmash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/TeamSuperSmash.java @@ -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() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/SpeedBuilders.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/SpeedBuilders.java index b8e6eca16..148fa72c1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/SpeedBuilders.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/speedbuilders/SpeedBuilders.java @@ -1761,7 +1761,7 @@ public class SpeedBuilders extends SoloGame if (playersTeam.GetPlayers(true).size() <= 1) { - ArrayList places = playersTeam.GetPlacements(true); + List places = playersTeam.GetPlacements(true); //Announce AnnounceEnd(places); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGamesNewTeams.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGamesNewTeams.java index 943d1c2a2..257e2e93d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGamesNewTeams.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGamesNewTeams.java @@ -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); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java index 0774a6f59..14487f056 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java @@ -1645,7 +1645,7 @@ public abstract class UHC extends Game { if (GetPlayers(true).size() <= 1) { - ArrayList places = GetTeamList().get(0).GetPlacements(true); + List places = GetTeamList().get(0).GetPlacements(true); // Announce AnnounceEnd(places); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHCTeams.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHCTeams.java index 590426532..af6cfb9be 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHCTeams.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHCTeams.java @@ -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); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/valentines/Valentines.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/valentines/Valentines.java index a47e8cfa7..9d7e71ab8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/valentines/Valentines.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/valentines/Valentines.java @@ -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 places = _players.GetPlacements(true); + List places = _players.GetPlacements(true); System.out.println("EndCheck:760"); //Announce diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/zombiesurvival/ZombieSurvival.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/zombiesurvival/ZombieSurvival.java index c274096a1..803d6a733 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/zombiesurvival/ZombieSurvival.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/zombiesurvival/ZombieSurvival.java @@ -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 places = _survivors.GetPlacements(true); + List places = _survivors.GetPlacements(true); if (places.size() >= 1) AddGems(places.get(0), 15, "1st Place", false, false); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/team/GameTeamModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/team/GameTeamModule.java index 490a937f7..b7aa6b168 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/team/GameTeamModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/team/GameTeamModule.java @@ -249,4 +249,9 @@ public class GameTeamModule extends Module { return _preferences; } + + public int getPlayersPerTeam() + { + return _target; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/team/NamedTeamsModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/team/NamedTeamsModule.java new file mode 100644 index 000000000..b8bab4e82 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/team/NamedTeamsModule.java @@ -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 spawns = getGame().GetTeamList().get(0).GetSpawns(); + getGame().GetTeamList().clear(); + + if (_teamPerSpawn) + { + Bukkit.broadcastMessage("Creating teams by spawns " + spawns.size()); + + for (Location location : spawns) + { + List 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 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]; + } + } +}