diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAction.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAction.java index 1b870ada9..09160ddc7 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAction.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilAction.java @@ -1,7 +1,10 @@ package mineplex.core.common.util; +import org.bukkit.Bukkit; +import org.bukkit.Material; import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; import org.bukkit.util.Vector; public class UtilAction @@ -37,6 +40,14 @@ public class UtilAction //Velocity ent.setFallDistance(0); - ent.setVelocity(vec); + + + //Debug + if (ent instanceof Player && UtilGear.isMat(((Player)ent).getItemInHand(), Material.SUGAR)) + { + Bukkit.broadcastMessage(F.main("Debug", "Velocity Sent: " + vec.length())); + } + + ent.setVelocity(vec); } } 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 fad8f1eef..d686faa2d 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 @@ -7,6 +7,7 @@ import java.util.TreeSet; + import org.bukkit.Location; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; @@ -260,4 +261,96 @@ public class UtilAlg return isInPyramid(player.getLocation().getDirection(), UtilAlg.getTrajectory(player.getEyeLocation(), target.getEyeLocation()), angleLimit) || isInPyramid(player.getLocation().getDirection(), UtilAlg.getTrajectory(player.getEyeLocation(), target.getLocation()), angleLimit); } + + public static Location getLocationAwayFromPlayers(ArrayList locs, ArrayList players) + { + Location bestLoc = null; + double bestDist = 0; + + for (Location loc : locs) + { + double closest = -1; + + for (Player player : players) + { + //Different Worlds + if (!player.getWorld().equals(loc.getWorld())) + continue; + + double dist = UtilMath.offsetSquared(player.getLocation(), loc); + + if (closest == -1 || dist < closest) + { + closest = dist; + } + } + + if (closest == -1) + continue; + + if (bestLoc == null || closest > bestDist) + { + bestLoc = loc; + bestDist = closest; + } + } + + return bestLoc; + } + + public static Location getLocationNearPlayers(ArrayList locs, ArrayList players, ArrayList dontOverlap) + { + Location bestLoc = null; + double bestDist = 0; + + for (Location loc : locs) + { + double closest = -1; + + boolean valid = true; + + //Dont spawn on other players + for (Player player : dontOverlap) + { + if (!player.getWorld().equals(loc.getWorld())) + continue; + + double dist = UtilMath.offsetSquared(player.getLocation(), loc); + + if (dist < 0.8) + { + valid = false; + break; + } + } + + if (!valid) + continue; + + //Find closest player + for (Player player : players) + { + if (!player.getWorld().equals(loc.getWorld())) + continue; + + double dist = UtilMath.offsetSquared(player.getLocation(), loc); + + if (closest == -1 || dist < closest) + { + closest = dist; + } + } + + if (closest == -1) + continue; + + if (bestLoc == null || closest < bestDist) + { + bestLoc = loc; + bestDist = closest; + } + } + + return bestLoc; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java index 07ffc1ccf..a4c8a7d62 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java @@ -62,6 +62,7 @@ public enum GameDisplay Build("Master Builders", Material.WOOD, (byte)0, GameCategory.CLASSICS, 50), Cards("Craft Against Humanity", Material.MAP, (byte)0, GameCategory.CLASSICS, 51), Skywars("Skywars", Material.FEATHER, (byte) 0, GameCategory.SURVIVAL, 52), + SkywarsTeams("Skywars Teams", Material.FEATHER, (byte)5, GameCategory.TEAM_VARIANT, 53), Event("Mineplex Event", Material.CAKE, (byte)0, GameCategory.EVENT, 999); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClientClass.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClientClass.java index ae8816f3a..e892c5f75 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClientClass.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClientClass.java @@ -341,7 +341,7 @@ public class ClientClass if (notify) { ListSkills(_client.GetPlayer()); - _client.GetPlayer().getWorld().playSound(_client.GetPlayer().getLocation(), Sound.LEVEL_UP, 1f, 1f); + _client.GetPlayer().playSound(_client.GetPlayer().getLocation(), Sound.LEVEL_UP, 1f, 1f); _client.GetPlayer().sendMessage(F.main("Class", "You equipped " + F.skill(customBuild.Name) + ".")); } diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/DamageManager.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/DamageManager.java index aab72ed1e..1d699e938 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/DamageManager.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/DamageManager.java @@ -41,6 +41,7 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.player.PlayerVelocityEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.util.Vector; @@ -251,34 +252,34 @@ public class DamageManager extends MiniPlugin { if (stack == null) continue; - + Map enchants = stack.getEnchantments(); for (Enchantment e : enchants.keySet()) { if (e.equals(Enchantment.PROTECTION_ENVIRONMENTAL)) event.AddMod("Ench Prot", damagee.getName(), 0.5 * (double)enchants.get(e), false); - + else if (e.equals(Enchantment.PROTECTION_FIRE) && event.GetCause() == DamageCause.FIRE && event.GetCause() == DamageCause.FIRE_TICK && event.GetCause() == DamageCause.LAVA) event.AddMod("Ench Prot", damagee.getName(), 0.5 * (double)enchants.get(e), false); - + else if (e.equals(Enchantment.PROTECTION_FALL) && event.GetCause() == DamageCause.FALL) event.AddMod("Ench Prot", damagee.getName(), 0.5 * (double)enchants.get(e), false); - + else if (e.equals(Enchantment.PROTECTION_EXPLOSIONS) && event.GetCause() == DamageCause.ENTITY_EXPLOSION) event.AddMod("Ench Prot", damagee.getName(), 0.5 * (double)enchants.get(e), false); - + else if (e.equals(Enchantment.PROTECTION_PROJECTILE) && event.GetCause() == DamageCause.PROJECTILE) event.AddMod("Ench Prot", damagee.getName(), 0.5 * (double)enchants.get(e), false); } } } - + //Offensive Player damager = event.GetDamagerPlayer(true); if (damager != null) @@ -390,11 +391,22 @@ public class DamageManager extends MiniPlugin trajectory.multiply(0.6 * knockback); trajectory.setY(Math.abs(trajectory.getY())); - //Apply - UtilAction.velocity(event.GetDamageeEntity(), - trajectory, 0.2 + trajectory.length() * 0.8, false, 0, Math.abs(0.2 * knockback), 0.4 + (0.04 * knockback), true); - } + //Debug + if (event.GetDamageeEntity() instanceof Player && UtilGear.isMat(((Player)event.GetDamageeEntity()).getItemInHand(), Material.SUGAR)) + { + Bukkit.broadcastMessage("--------- " + + UtilEnt.getName(event.GetDamageeEntity()) + " hurt by " + UtilEnt.getName(event.GetDamagerEntity(true)) + "-----------" ); + + Bukkit.broadcastMessage(F.main("Debug", "Damage: " + event.GetDamage())); + } + + //Apply + double vel = 0.2 + trajectory.length() * 0.8; + + UtilAction.velocity(event.GetDamageeEntity(), trajectory, vel, + false, 0, Math.abs(0.2 * knockback), 0.4 + (0.04 * knockback), true); + } } catch (IllegalAccessException e) { @@ -410,11 +422,20 @@ public class DamageManager extends MiniPlugin } } + @EventHandler + public void debugVel2(PlayerVelocityEvent event) + { + if (UtilGear.isMat(((Player)event.getPlayer()).getItemInHand(), Material.SUGAR)) + { + Bukkit.broadcastMessage(F.main("Debug", "Event: " + event.getVelocity().length())); + } + } + private void DisplayDamage(CustomDamageEvent event) { for (Player player : UtilServer.getPlayers()) { - if (!UtilGear.isMat(player.getItemInHand(), Material.BOOK)) + if (!UtilGear.isMat(player.getItemInHand(), Material.COMMAND)) continue; UtilPlayer.message(player, " "); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java index b2b8e3d40..355d0a853 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java @@ -38,10 +38,11 @@ import nautilus.game.arcade.game.games.quiver.QuiverTeams; import nautilus.game.arcade.game.games.runner.Runner; import nautilus.game.arcade.game.games.searchanddestroy.SearchAndDestroy; import nautilus.game.arcade.game.games.sheep.SheepGame; -import nautilus.game.arcade.game.games.skywars.Skywars; -import nautilus.game.arcade.game.games.smash.SuperSmash; +import nautilus.game.arcade.game.games.skywars.SoloSkywars; +import nautilus.game.arcade.game.games.skywars.TeamSkywars; +import nautilus.game.arcade.game.games.smash.SoloSuperSmash; import nautilus.game.arcade.game.games.smash.SuperSmashDominate; -import nautilus.game.arcade.game.games.smash.SuperSmashTeam; +import nautilus.game.arcade.game.games.smash.TeamSuperSmash; import nautilus.game.arcade.game.games.snake.Snake; import nautilus.game.arcade.game.games.sneakyassassins.SneakyAssassins; import nautilus.game.arcade.game.games.snowfight.SnowFight; @@ -49,8 +50,8 @@ import nautilus.game.arcade.game.games.spleef.Spleef; import nautilus.game.arcade.game.games.spleef.SpleefTeams; import nautilus.game.arcade.game.games.squidshooter.SquidShooter; import nautilus.game.arcade.game.games.stacker.Stacker; -import nautilus.game.arcade.game.games.survivalgames.SurvivalGames; -import nautilus.game.arcade.game.games.survivalgames.SurvivalGamesTeams; +import nautilus.game.arcade.game.games.survivalgames.SoloSurvivalGames; +import nautilus.game.arcade.game.games.survivalgames.TeamSurvivalGames; import nautilus.game.arcade.game.games.tug.Tug; import nautilus.game.arcade.game.games.turfforts.TurfForts; import nautilus.game.arcade.game.games.uhc.UHC; @@ -98,9 +99,9 @@ public enum GameType SearchAndDestroy(SearchAndDestroy.class, GameDisplay.SearchAndDestroy), Sheep(SheepGame.class, GameDisplay.Sheep), - Smash(SuperSmash.class, GameDisplay.Smash), + Smash(SoloSuperSmash.class, GameDisplay.Smash), SmashDomination(SuperSmashDominate.class, GameDisplay.SmashDomination), - SmashTeams(SuperSmashTeam.class, GameDisplay.SmashTeams), + SmashTeams(TeamSuperSmash.class, GameDisplay.SmashTeams, new GameType[]{GameType.Smash}, false), Snake(Snake.class, GameDisplay.Snake), SneakyAssassins(SneakyAssassins.class, GameDisplay.SneakyAssassins), SnowFight(SnowFight.class, GameDisplay.SnowFight), @@ -108,23 +109,35 @@ public enum GameType SpleefTeams(SpleefTeams.class, GameDisplay.SpleefTeams), SquidShooter(SquidShooter.class, GameDisplay.SquidShooter), Stacker(Stacker.class, GameDisplay.Stacker), - SurvivalGames(SurvivalGames.class, GameDisplay.SurvivalGames), - SurvivalGamesTeams(SurvivalGamesTeams.class, GameDisplay.SurvivalGamesTeams), + SurvivalGames(SoloSurvivalGames.class, GameDisplay.SurvivalGames), + SurvivalGamesTeams(TeamSurvivalGames.class, GameDisplay.SurvivalGamesTeams, new GameType[]{GameType.SurvivalGames}, false), Tug(Tug.class, GameDisplay.Tug), TurfWars(TurfForts.class, GameDisplay.TurfWars), UHC(UHC.class, GameDisplay.UHC), WitherAssault(WitherGame.class, GameDisplay.WitherAssault), Wizards(Wizards.class, GameDisplay.Wizards, "http://chivebox.com/file/c/ResWizards.zip", true), ZombieSurvival(ZombieSurvival.class, GameDisplay.ZombieSurvival), - Build(Build.class, GameDisplay.Build), Cards(Cards.class, GameDisplay.Cards), - Skywars(Skywars.class, GameDisplay.Skywars), + Skywars(SoloSkywars.class, GameDisplay.Skywars), + SkywarsTeams(TeamSkywars.class, GameDisplay.SkywarsTeams, new GameType[]{GameType.Skywars}, false), - Event(EventGame.class, GameDisplay.Event); + Event(EventGame.class, GameDisplay.Event, new GameType[]{ + GameType.BaconBrawl, GameType.Barbarians, GameType.Bridge, GameType.Build, GameType.Build, + GameType.Cards, GameType.CastleSiege, GameType.ChampionsDominate, GameType.ChampionsTDM, GameType.Christmas, + GameType.DeathTag, GameType.DragonEscape, GameType.DragonEscapeTeams, GameType.DragonRiders, GameType.Dragons, + GameType.Draw, GameType.Evolution, GameType.Gravity, GameType.Halloween, GameType.HideSeek, + GameType.HoleInTheWall, GameType.Horse, GameType.Micro, GameType.MilkCow, GameType.MineStrike, GameType.MineWare, + GameType.OldMineWare, GameType.Paintball, GameType.Quiver, GameType.QuiverTeams, GameType.Runner, GameType.SearchAndDestroy, + GameType.Sheep, GameType.Skywars, GameType.SkywarsTeams, GameType.Smash, GameType.SmashDomination, GameType.SmashTeams, + GameType.Snake, GameType.SneakyAssassins, GameType.SnowFight, GameType.Spleef, GameType.SpleefTeams, GameType.SquidShooter, + GameType.Stacker, GameType.SurvivalGames, GameType.SurvivalGamesTeams, GameType.Tug, GameType.TurfWars, GameType.UHC, + GameType.WitherAssault, GameType.Wizards, GameType.ZombieSurvival}, true); GameDisplay _display; boolean _enforceResourcePack; + GameType[] _mapSource; + boolean _ownMaps; String _resourcePack; Class _gameClass; @@ -133,17 +146,29 @@ public enum GameType GameType(Class gameClass, GameDisplay display) { - this(gameClass, display, null, false); + this(gameClass, display, null, false, null, true); } GameType(Class gameClass, GameDisplay display, String resourcePackUrl, boolean enforceResourcePack) + { + this(gameClass, display, resourcePackUrl, enforceResourcePack, null, true); + } + + GameType(Class gameClass, GameDisplay display, GameType[] mapSource, boolean ownMap) + { + this(gameClass, display, null, false, mapSource, ownMap); + } + + GameType(Class gameClass, GameDisplay display, String resourcePackUrl, boolean enforceResourcePack, GameType[] mapSource, boolean ownMaps) { _display = display; _gameClass = gameClass; _resourcePack = resourcePackUrl; _enforceResourcePack = enforceResourcePack; + _mapSource = mapSource; + _ownMaps = ownMaps; } - + public Class getGameClass() { return _gameClass; @@ -158,6 +183,16 @@ public enum GameType { return _resourcePack; } + + public GameType[] getMapSource() + { + return _mapSource; + } + + public boolean ownMaps() + { + return _ownMaps; + } public String GetName() { @@ -183,4 +218,5 @@ public enum GameType { return _display.getGameCategory(); } + } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/GameCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/GameCommand.java index 7cb8a6f80..76e4edb1c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/GameCommand.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/GameCommand.java @@ -25,7 +25,7 @@ public class GameCommand extends MultiCommandBase UtilPlayer.message(caller, F.main(Plugin.getName(), "Commands List:")); UtilPlayer.message(caller, F.help("/game start", "Start the current game", Rank.ADMIN)); UtilPlayer.message(caller, F.help("/game stop", "Stop the current game", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/game set (Map)", "Set the current game or next game", Rank.ADMIN)); + UtilPlayer.message(caller, F.help("/game set (MapSource) (Map)", "Set the current game or next game", Rank.ADMIN)); UtilPlayer.message(caller, F.main("Tip", "Use TAB for games/maps!")); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/SetCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/SetCommand.java index 0d7f183a7..d6958a663 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/SetCommand.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/SetCommand.java @@ -29,16 +29,31 @@ public class SetCommand extends CommandBase if (args == null || args.length == 0) { - caller.sendMessage(F.help("/game set (Map)", "Set the current game or next game", Rank.ADMIN)); + caller.sendMessage(F.help("/game set (MapSource) (Map)", "Set the current game or next game", Rank.ADMIN)); return; } String game = args[0].toLowerCase(); - if (args.length > 1) + if (args.length >= 2) { - Plugin.GetGameCreationManager().MapPref = args[1]; - UtilPlayer.message(caller, C.cAqua + C.Bold + "Map Preference: " + ChatColor.RESET + args[1]); + String map = ""; + String source = ""; + if(args.length == 3) + { + Plugin.GetGameCreationManager().MapSource = args[1]; + Plugin.GetGameCreationManager().MapPref = args[2]; + source = args[1]; + map = args[2]; + } + else + { + Plugin.GetGameCreationManager().MapSource = args[0]; + Plugin.GetGameCreationManager().MapPref = args[1]; + source = args[0]; + map = args[1]; + } + UtilPlayer.message(caller, C.cAqua + C.Bold + "Map Preference: " + ChatColor.RESET + source + ":" + map); } //Parse Game 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 abe4d740c..a59565071 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 @@ -86,7 +86,7 @@ public abstract class Game implements Listener protected String[] _gameDesc; //Map - private ArrayList _files; + private HashMap> _files; //State private GameState _gameState = GameState.Loading; @@ -193,8 +193,6 @@ public abstract class Game implements Listener public int HungerSet = -1; public int HealthSet = -1; - public int SpawnDistanceRequirement = 1; - public boolean PrepareFreeze = true; private double _itemMergeRadius = 0; @@ -211,6 +209,11 @@ public abstract class Game implements Listener public int TickPerTeleport = 1; + public int FillTeamsInOrderToCount = -1; + + public boolean SpawnNearAllies = false; + public boolean SpawnNearEnemies = false; + public boolean StrictAntiHack = false; public boolean DisableKillCommand = true; @@ -258,6 +261,9 @@ public abstract class Game implements Listener public boolean CanAddStats = true; public boolean CanGiveLoot = true; + public boolean HideTeamSheep = false; + public boolean ReplaceTeamsWithKits = false; + public boolean VersionRequire1_8 = false; public ArrayList GemBoosters = new ArrayList(); @@ -281,16 +287,28 @@ public abstract class Game implements Listener Scoreboard = new GameScoreboard(this); //Map Select - _files = Manager.LoadFiles(GetName()); + _files = new HashMap>(); + for(GameType type : GetWorldHostNames()) + { + _files.put(type, Manager.LoadFiles(type.GetName())); + } if (Manager.GetGameCreationManager().MapPref != null) { - ArrayList matches = new ArrayList(); - for (String cur : _files) + HashMap> matches = new HashMap>(); + for (GameType game : _files.keySet()) { - if (cur.toLowerCase().contains(Manager.GetGameCreationManager().MapPref.toLowerCase())) + ArrayList list = new ArrayList(); + for(String cur : _files.get(game)) { - matches.add(cur); - System.out.print("Map Preference: " + cur); + if (cur.toLowerCase().contains(Manager.GetGameCreationManager().MapPref.toLowerCase())) + { + if(game.toString().toLowerCase().contains(Manager.GetGameCreationManager().MapSource.toLowerCase())) + { + list.add(cur); + System.out.print("Map Preference: " + cur); + matches.put(game, list); + } + } } } @@ -298,6 +316,7 @@ public abstract class Game implements Listener _files = matches; Manager.GetGameCreationManager().MapPref = null; + Manager.GetGameCreationManager().MapSource = null; } WorldData = new WorldData(this); @@ -332,7 +351,7 @@ public abstract class Game implements Listener _kits = kits; } - public ArrayList GetFiles() + public HashMap> GetFiles() { return _files; } @@ -341,6 +360,60 @@ public abstract class Game implements Listener { return _gameType.GetName(); } + + public GameType[] GetWorldHostNames() + { + GameType[] mapSource = new GameType[]{GetType()}; + if(GetType().getMapSource() != null) + { + if(GetType().ownMaps()) + { + int i = 1; + mapSource = new GameType[GetType().getMapSource().length + 1]; + for(GameType type : GetType().getMapSource()) + { + mapSource[i] = type; + i++; + } + mapSource[0] = GetType(); + } + else + { + mapSource = GetType().getMapSource(); + } + } + return mapSource; + } + + public String GetGameNamebyMap(String game, String map) + { + for(GameType type : _files.keySet()) + { + if(type.GetName().toLowerCase().contains(game.toLowerCase())) + { + for(String string : _files.get(type)) + { + if(string.toLowerCase().contains(map.toLowerCase())) + { + return type.GetName(); + } + } + } + } + return null; + } + + public GameType GetGameByMapList(ArrayList maps) + { + for(GameType game : _files.keySet()) + { + if(maps.equals(_files.get(game))) + { + return game; + } + } + return null; + } public String GetMode() { @@ -465,9 +538,6 @@ public abstract class Game implements Listener //Add GetTeamList().add(team); - //Set Spawn Data - team.SetSpawnRequirement(this.SpawnDistanceRequirement); - System.out.println("Created Team: " + team.GetName()); } @@ -549,6 +619,17 @@ public abstract class Game implements Listener public GameTeam ChooseTeam(Player player) { + if (FillTeamsInOrderToCount != -1) + { + for (int i = 0; i < _teamList.size(); i++) + { + if (_teamList.get(i).GetSize() < FillTeamsInOrderToCount) + { + return _teamList.get(i); + } + } + } + GameTeam team = null; //Random Team @@ -1365,4 +1446,5 @@ public abstract class Game implements Listener //End SetState(GameState.End); } + } 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 c465dbf1d..d73da8f35 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 @@ -7,6 +7,7 @@ import java.util.Iterator; import mineplex.core.common.util.C; import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; @@ -60,19 +61,19 @@ public class GameTeam private HashMap _players = new HashMap(); private ArrayList _spawns; - + private Creature _teamEntity = null; private HashSet _kitRestrict = new HashSet(); - private int _spawnDistance = 0; - private boolean _visible = true; + private boolean _displayTag; + //Records order players go out in protected ArrayList _places = new ArrayList(); - public GameTeam(Game host, String name, ChatColor color, ArrayList spawns) + public GameTeam(Game host, String name, ChatColor color, ArrayList spawns, boolean tags) { Host = host; @@ -80,6 +81,12 @@ public class GameTeam _name = name; _color = color; _spawns = spawns; + _displayTag = tags; + } + + public GameTeam(Game host, String name, ChatColor color, ArrayList spawns) + { + this(host, name, color, spawns, false); } public String GetName() @@ -99,40 +106,48 @@ public class GameTeam public Location GetSpawn() { - // ArrayList valid = new ArrayList(); - - Location best = null; - double bestDist = 0; - - for (Location loc : _spawns) + //Keep allies together + if (!Host.IsLive() && Host.SpawnNearAllies) { - double closestPlayer = -1; - - for (Player player : Host.GetPlayers(true)) + //Find Location Nearest Ally + Location loc = UtilAlg.getLocationNearPlayers(_spawns, GetPlayers(true), Host.GetPlayers(true)); + if (loc != null) + return loc; + + //No allies existed spawned yet + + //Spawn near enemies (used for SG) + if (Host.SpawnNearEnemies) { - double playerDist = UtilMath.offsetSquared(player.getLocation(), loc); - - if (closestPlayer == -1 || playerDist < closestPlayer) - closestPlayer = playerDist; + loc = UtilAlg.getLocationNearPlayers(_spawns, Host.GetPlayers(true), Host.GetPlayers(true)); + if (loc != null) + return loc; } - - if (best == null || closestPlayer > bestDist) + //Spawn away from enemies + else { - best = loc; - bestDist = closestPlayer; - } - - // if (closestPlayer > _spawnDistance * _spawnDistance) - // { - // valid.add(loc); - // } + loc = UtilAlg.getLocationAwayFromPlayers(_spawns, Host.GetPlayers(true)); + if (loc != null) + return loc; + } + } + else + { + //Spawn near players + if (Host.SpawnNearEnemies) + { + Location loc = UtilAlg.getLocationAwayFromPlayers(_spawns, Host.GetPlayers(true)); + if (loc != null) + return loc; + } + //Spawn away from players + else + { + Location loc = UtilAlg.getLocationNearPlayers(_spawns, Host.GetPlayers(true), Host.GetPlayers(true)); + if (loc != null) + return loc; + } } - - // if (valid.size() > 0) - // valid.get(UtilMath.r(valid.size())); - - if (best != null) - return best; return _spawns.get(UtilMath.r(_spawns.size())); } @@ -333,11 +348,6 @@ public class GameTeam _spawns = spawns; } - public void SetSpawnRequirement(int value) - { - _spawnDistance = value; - } - public void SetVisible(boolean b) { _visible = b; @@ -347,6 +357,16 @@ public class GameTeam { return _visible; } + + public void setDisplayTag(boolean b) + { + _displayTag = b; + } + + public boolean GetDisplaytag() + { + return _displayTag; + } public void SetRespawnTime(double i) { @@ -390,6 +410,4 @@ public class GameTeam return _places; } - - } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/Evolution.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/Evolution.java index 3fb7a570f..338056822 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/Evolution.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/evolution/Evolution.java @@ -74,8 +74,6 @@ public class Evolution extends SoloGame this.DeathOut = false; this.PrepareFreeze = false; - - this.SpawnDistanceRequirement = 16; _scoreObj = Scoreboard.GetScoreboard().registerNewObjective("Evolutions", "dummy"); _scoreObj.setDisplaySlot(DisplaySlot.BELOW_NAME); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/Quiver.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/Quiver.java index bbd123b34..25b8b8fee 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/Quiver.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/Quiver.java @@ -72,7 +72,6 @@ public class Quiver extends SoloGame this.DamageSelf = false; this.DamageTeamSelf = true; this.PrepareFreeze = false; - this.SpawnDistanceRequirement = 16; this.BlockBreakAllow.add(102); this.BlockBreakAllow.add(20); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/QuiverTeams.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/QuiverTeams.java index c4aecbae2..2d871d801 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/QuiverTeams.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/QuiverTeams.java @@ -59,7 +59,6 @@ public class QuiverTeams extends TeamGame this.DamageSelf = false; this.DamageTeamSelf = false; this.PrepareFreeze = false; - this.SpawnDistanceRequirement = 24; this.BlockBreakAllow.add(102); this.BlockBreakAllow.add(20); this.BlockBreakAllow.add(18); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/Skywars.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/Skywars.java index c6a2003e9..deb1c5672 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/Skywars.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/Skywars.java @@ -92,7 +92,7 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; @SuppressWarnings("deprecation") -public class Skywars extends SoloGame +public abstract class Skywars extends Game { //./parse 19 30 56 @@ -128,23 +128,20 @@ public class Skywars extends SoloGame private ChestLoot _middleBlock = new ChestLoot(); @SuppressWarnings("unchecked") - public Skywars(ArcadeManager manager) + public Skywars(ArcadeManager manager, GameType type, String[] description) { - super(manager, GameType.Skywars, new Kit[] + super(manager, type, new Kit[] { new KitChicken(manager), new KitMiner(manager), new KitMadScientist(manager), new KitDestructor(manager), - }, new String[] - { - "Free for all battle in the sky!", - "Craft or loot gear for combat", - "Last player alive wins!" - }); + }, description); PrepareFreeze = true; + + HideTeamSheep = true; CompassEnabled = true; @@ -158,8 +155,8 @@ public class Skywars extends SoloGame WorldTimeSet = 0; WorldBoundaryKill = false; - - SpawnDistanceRequirement = 48; + + SpawnNearAllies = true; DamageSelf = true; DamageTeamSelf = true; @@ -1193,63 +1190,6 @@ public class Skywars extends SoloGame _oreHider.BlockBreak(event); } - @Override - @EventHandler - public void ScoreboardUpdate(UpdateEvent event) - { - if (event.getType() != UpdateType.FAST) - return; - - if (GetTeamList().isEmpty()) - return; - - Scoreboard.Reset(); - - GameTeam team = GetTeamList().get(0); - - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellow + C.Bold + "Players"); - if (team.GetPlayers(true).size() > 4) - { - Scoreboard.Write("" + team.GetPlayers(true).size()); - } - else - { - for (Player player : team.GetPlayers(true)) - { - Scoreboard.Write(C.cWhite + player.getName()); - } - } - - if (IsLive()) - { - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellow + C.Bold + "Time"); - Scoreboard.Write(UtilTime.convertString(System.currentTimeMillis() - GetStateTime(), 0, TimeUnit.FIT)); - - Scoreboard.WriteBlank(); - Scoreboard.Write((_tntGen.active() ? C.cGreen : C.cRed) + C.Bold + "TNT Spawn"); - Scoreboard.Write(_tntGen.getScoreboardInfo()); - - Scoreboard.WriteBlank(); - - if (UtilTime.elapsed(GetStateTime(), _crumbleTime)) - { - Scoreboard.Write(C.cRed + C.Bold + "Map Crumble"); - Scoreboard.Write("Active"); - } - else - { - Scoreboard.Write(C.cGreen + C.Bold + "Map Crumble"); - Scoreboard.Write(UtilTime.convertString(_crumbleTime - (System.currentTimeMillis() - GetStateTime()), 0, TimeUnit.FIT)); - } - } - - - - Scoreboard.Draw(); - } - @EventHandler public void tntDamageAttribute(ExplosionPrimeEvent event) { @@ -1367,4 +1307,15 @@ public class Skywars extends SoloGame else return 12; } + + public TNTGenerator getTnTGen() + { + return this._tntGen; + } + + public long getCrumbleTime() + { + return this._crumbleTime; + } + } 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 new file mode 100644 index 000000000..8da685ceb --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/SoloSkywars.java @@ -0,0 +1,173 @@ +package nautilus.game.arcade.game.games.skywars; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +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; + +public class SoloSkywars extends Skywars +{ + + private GameTeam _players; + + public SoloSkywars(ArcadeManager manager) + { + super(manager, GameType.Skywars, + new String[] + { + "Free for all battle in the sky!", + "Craft or loot gear for combat", + "Last player alive wins!" + }); + + this.DamageTeamSelf = true; + + } + + @EventHandler + public void CustomTeamGeneration(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Recruit) + return; + + _players = GetTeamList().get(0); + _players.SetColor(ChatColor.YELLOW); + _players.SetName("Players"); + _players.setDisplayName(C.cYellow + C.Bold + "Players"); + } + + @Override + @EventHandler + public void ScoreboardUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + if (GetTeamList().isEmpty()) + return; + + Scoreboard.Reset(); + + GameTeam team = GetTeamList().get(0); + + Scoreboard.WriteBlank(); + Scoreboard.Write(C.cYellow + C.Bold + "Players"); + if (team.GetPlayers(true).size() > 4) + { + Scoreboard.Write("" + team.GetPlayers(true).size()); + } + else + { + for (Player player : team.GetPlayers(true)) + { + Scoreboard.Write(C.cWhite + player.getName()); + } + } + + if (IsLive()) + { + Scoreboard.WriteBlank(); + Scoreboard.Write(C.cYellow + C.Bold + "Time"); + Scoreboard.Write(UtilTime.convertString(System.currentTimeMillis() - GetStateTime(), 0, TimeUnit.FIT)); + + Scoreboard.WriteBlank(); + Scoreboard.Write((this.getTnTGen().active() ? C.cGreen : C.cRed) + C.Bold + "TNT Spawn"); + Scoreboard.Write(this.getTnTGen().getScoreboardInfo()); + + Scoreboard.WriteBlank(); + + if (UtilTime.elapsed(GetStateTime(), this.getCrumbleTime())) + { + Scoreboard.Write(C.cRed + C.Bold + "Map Crumble"); + Scoreboard.Write("Active"); + } + else + { + Scoreboard.Write(C.cGreen + C.Bold + "Map Crumble"); + Scoreboard.Write(UtilTime.convertString(this.getCrumbleTime() - (System.currentTimeMillis() - GetStateTime()), 0, TimeUnit.FIT)); + } + } + + + + Scoreboard.Draw(); + } + + @Override + public void EndCheck() + { + if (!IsLive()) + return; + + if (GetPlayers(true).size() <= 1) + { + ArrayList places = GetTeamList().get(0).GetPlacements(true); + + //Announce + AnnounceEnd(places); + + //Gems + if (places.size() >= 1) + AddGems(places.get(0), 20, "1st Place", false, false); + + if (places.size() >= 2) + AddGems(places.get(1), 15, "2nd Place", false, false); + + if (places.size() >= 3) + AddGems(places.get(2), 10, "3rd Place", false, false); + + for (Player player : GetPlayers(false)) + if (player.isOnline()) + AddGems(player, 10, "Participation", false, false); + + //End + SetState(GameState.End); + } + } + + @Override + public List getWinners() + { + if (GetState().ordinal() >= GameState.End.ordinal()) + { + List places = GetTeamList().get(0).GetPlacements(true); + + if (places.isEmpty() || !places.get(0).isOnline()) + return Arrays.asList(); + else + return Arrays.asList(places.get(0)); + } + else + return null; + } + + @Override + public List getLosers() + { + List winners = getWinners(); + + if (winners == null) + return null; + + List losers = GetTeamList().get(0).GetPlayers(false); + + losers.removeAll(winners); + + return losers; + } + +} 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 new file mode 100644 index 000000000..53c7148cf --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/TeamSkywars.java @@ -0,0 +1,471 @@ +package nautilus.game.arcade.game.games.skywars; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +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; + +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerInteractEntityEvent; +import org.bukkit.event.player.PlayerQuitEvent; + +public class TeamSkywars extends Skywars +{ + + private NautHashMap _teamReqs = new NautHashMap(); + + public TeamSkywars(ArcadeManager manager) + { + super(manager, GameType.SkywarsTeams, + new String[] + { + "Free for all battle in the sky!", + "Craft or loot gear for combat", + "Last team alive wins!" + }); + + this.FillTeamsInOrderToCount = 2; + + this.SpawnNearAllies = true; + + this.DamageTeamSelf = false; + } + + @EventHandler + public void CustomTeamGeneration(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Recruit) + return; + + ArrayList initialSpawns = this.GetTeamList().get(0).GetSpawns(); + this.GetTeamList().clear(); + + ArrayList spawns = new ArrayList(); + + TeamColors color = TeamColors.DARK_AQUA; + + //Create 1 Team for each Spawn + int i = 0; + for(Location location : initialSpawns) + { + i++; + + 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); + } + } + + 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[]{"Bananna", "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; + } + + @Override + @EventHandler + public void ScoreboardUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + if (GetTeamList().isEmpty()) + return; + + Scoreboard.Reset(); + + Scoreboard.WriteBlank(); + Scoreboard.Write(C.cYellow + C.Bold + "Teams"); + + ArrayList alive = new ArrayList(); + for (GameTeam team : GetTeamList()) + { + if (team.IsTeamAlive()) + alive.add(team); + } + + if (GetPlayers(true).size() <= 4) + { + for (GameTeam team : GetTeamList()) + { + for (Player player : team.GetPlayers(true)) + { + Scoreboard.Write(team.GetColor() + player.getName()); + } + } + } + else if (alive.size() <= 4) + { + for (GameTeam team : alive) + { + Scoreboard.Write(C.cWhite + team.GetPlayers(true).size() + " " + team.GetColor() + team.GetName()); + } + } + else + { + Scoreboard.Write(C.cWhite + alive.size() + " Alive"); + } + + if (IsLive()) + { + Scoreboard.WriteBlank(); + Scoreboard.Write(C.cYellow + C.Bold + "Time"); + Scoreboard.Write(UtilTime.convertString(System.currentTimeMillis() - GetStateTime(), 0, TimeUnit.FIT)); + + Scoreboard.WriteBlank(); + Scoreboard.Write((this.getTnTGen().active() ? C.cGreen : C.cRed) + C.Bold + "TNT Spawn"); + Scoreboard.Write(this.getTnTGen().getScoreboardInfo()); + + Scoreboard.WriteBlank(); + + if (UtilTime.elapsed(GetStateTime(), this.getCrumbleTime())) + { + Scoreboard.Write(C.cRed + C.Bold + "Map Crumble"); + Scoreboard.Write("Active"); + } + else + { + Scoreboard.Write(C.cGreen + C.Bold + "Map Crumble"); + Scoreboard.Write(UtilTime.convertString(this.getCrumbleTime() - (System.currentTimeMillis() - GetStateTime()), 0, TimeUnit.FIT)); + } + } + + + + Scoreboard.Draw(); + } + + @Override + public void EndCheck() + { + if (!IsLive()) + return; + + ArrayList teamsAlive = new ArrayList(); + + for (GameTeam team : this.GetTeamList()) + if (team.GetPlayers(true).size() > 0) + teamsAlive.add(team); + + if (teamsAlive.size() <= 1) + { + //Announce + if (teamsAlive.size() > 0) + AnnounceEnd(teamsAlive.get(0)); + + for (GameTeam team : GetTeamList()) + { + if (WinnerTeam != null && team.equals(WinnerTeam)) + { + for (Player player : team.GetPlayers(false)) + AddGems(player, 10, "Winning Team", false, false); + } + + for (Player player : team.GetPlayers(false)) + if (player.isOnline()) + AddGems(player, 10, "Participation", false, false); + } + + //End + SetState(GameState.End); + } + } + + @Override + public List getWinners() + { + if (WinnerTeam == null) + return null; + + return WinnerTeam.GetPlayers(false); + } + + @Override + public List getLosers() + { + if (WinnerTeam == null) + return null; + + List players = new ArrayList<>(); + + for (GameTeam team : GetTeamList()) + { + if (team != WinnerTeam) + players.addAll(team.GetPlayers(false)); + } + + return players; + } + + @Override + public boolean CanJoinTeam(GameTeam team) + { + return team.GetSize() < 2; + } + + @EventHandler(priority = EventPriority.HIGH) + public void teamSelectInteract(PlayerInteractEntityEvent event) + { + if (GetState() != GameState.Recruit) + return; + + if (event.getRightClicked() == null) + return; + + if (!(event.getRightClicked() instanceof Player)) + return; + + Player player = event.getPlayer(); + + //Observer + if (Manager.IsObserver(player)) + { + UtilPlayer.message(player, F.main("Game", "Spectators cannot partake in games.")); + return; + } + + selectTeamMate(player, (Player)event.getRightClicked()); + } + + @EventHandler + public void teamSelectCommand(PlayerCommandPreprocessEvent event) + { + if (GetState() != GameState.Recruit) + return; + + if (!event.getMessage().toLowerCase().startsWith("/team ")) + return; + + event.setCancelled(true); + + Player target = UtilPlayer.searchOnline(event.getPlayer(), event.getMessage().split(" ")[1], true); + if (target == null) + return; + + //Observer + if (Manager.IsObserver(event.getPlayer())) + { + UtilPlayer.message(event.getPlayer(), F.main("Game", "Spectators cannot partake in games.")); + return; + } + + if (event.getPlayer().equals(target)) + return; + + selectTeamMate(event.getPlayer(), target); + } + + public void selectTeamMate(Player player, Player ally) + { + //Accept Invite + if (_teamReqs.containsKey(ally) && _teamReqs.get(ally).equals(player)) + { + //Remove Prefs + _teamReqs.remove(player); + _teamReqs.remove(ally); + + //Inform + UtilPlayer.message(player, F.main("Game", "You accepted " + ally.getName() + "'s Team Request!")); + UtilPlayer.message(ally, F.main("Game", player.getName() + " accepted your Team Request!")); + + //Leave Old Teams + if (GetTeam(player) != null) + GetTeam(player).DisbandTeam(); + + if (GetTeam(ally) != null) + GetTeam(ally).DisbandTeam(); + + //Get Team + GameTeam team = getEmptyTeam(); + if (team == null) + return; + + //Join Team + SetPlayerTeam(player, team, true); + SetPlayerTeam(ally, team, true); + } + //Send Invite + else + { + //Already on Team with Target + if (GetTeam(player) != null) + if (GetTeam(player).HasPlayer(ally)) + return; + + //Inform Player + UtilPlayer.message(player, F.main("Game", "You sent a Team Request to " + ally.getName() + "!")); + + //Inform Target + if (Recharge.Instance.use(player, "Team Req " + ally.getName(), 2000, false, false)) + { + UtilPlayer.message(ally, F.main("Game", player.getName() + " sent you a Team Request!")); + UtilPlayer.message(ally, F.main("Game", "Type " + F.elem("/team " + player.getName()) + " to accept!")); + } + + //Add Pref + _teamReqs.put(player, ally); + } + } + + @EventHandler + public void teamQuit(PlayerQuitEvent event) + { + if (GetState() != GameState.Recruit) + return; + + Player player = event.getPlayer(); + + if (GetTeam(player) != null) + GetTeam(player).DisbandTeam(); + + Iterator teamIter = _teamReqs.keySet().iterator(); + while (teamIter.hasNext()) + { + Player sender = teamIter.next(); + if (sender.equals(player) || _teamReqs.get(sender).equals(player)) + teamIter.remove(); + } + } + + public GameTeam getEmptyTeam() + { + for (GameTeam team : GetTeamList()) + { + if (team.GetPlayers(false).isEmpty()) + return team; + } + + return null; + } + +} 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 new file mode 100644 index 000000000..493fd7e24 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SoloSuperSmash.java @@ -0,0 +1,157 @@ +package nautilus.game.arcade.game.games.smash; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +import mineplex.core.common.util.C; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +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; + +public class SoloSuperSmash extends SuperSmash +{ + + private GameTeam _players; + + public SoloSuperSmash(ArcadeManager manager) + { + super(manager, GameType.Smash, new String[] + { + "Each player has 3 respawns", + "Attack to restore hunger!", + "Last player alive wins!" + }); + + this.DamageTeamSelf = true; + } + + @EventHandler + public void CustomTeamGeneration(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Recruit) + return; + + _players = GetTeamList().get(0); + _players.SetColor(ChatColor.YELLOW); + _players.SetName("Players"); + _players.setDisplayName(C.cYellow + C.Bold + "Players"); + } + + @Override + @EventHandler + public void ScoreboardUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + //Wipe Last + Scoreboard.Reset(); + + if (GetPlayers(true).size() > 14) + { + Scoreboard.WriteBlank(); + Scoreboard.Write(C.cGreen + "Players Alive"); + Scoreboard.Write(GetPlayers(true).size() + " "); + + Scoreboard.WriteBlank(); + Scoreboard.Write(C.cRed + "Players Dead"); + Scoreboard.Write((GetPlayers(false).size() - GetPlayers(true).size()) + " "); + } + else + { + Scoreboard.WriteBlank(); + + //Write New + for (Player player : GetPlayers(true)) + { + int lives = GetLives(player); + + String out; + if (lives >= 4) out = C.cGreen + player.getName(); + else if (lives == 3) out = C.cYellow + player.getName(); + else if (lives == 2) out = C.cGold + player.getName(); + else if (lives == 1) out = C.cRed + player.getName(); + else if (lives == 0) out = C.cRed + player.getName(); + else + continue; + + Scoreboard.WriteOrdered("Lives", out, lives, true); + } + } + + Scoreboard.Draw(); + } + + @Override + public void EndCheck() + { + if (!IsLive()) + return; + + if (GetPlayers(true).size() <= 1) + { + ArrayList places = GetTeamList().get(0).GetPlacements(true); + + //Announce + AnnounceEnd(places); + + //Gems + if (places.size() >= 1) + AddGems(places.get(0), 20, "1st Place", false, false); + + if (places.size() >= 2) + AddGems(places.get(1), 15, "2nd Place", false, false); + + if (places.size() >= 3) + AddGems(places.get(2), 10, "3rd Place", false, false); + + for (Player player : GetPlayers(false)) + if (player.isOnline()) + AddGems(player, 10, "Participation", false, false); + + //End + SetState(GameState.End); + } + } + + @Override + public List getWinners() + { + if (GetState().ordinal() >= GameState.End.ordinal()) + { + List places = GetTeamList().get(0).GetPlacements(true); + + if (places.isEmpty() || !places.get(0).isOnline()) + return Arrays.asList(); + else + return Arrays.asList(places.get(0)); + } + else + return null; + } + + @Override + public List getLosers() + { + List winners = getWinners(); + + if (winners == null) + return null; + + List losers = GetTeamList().get(0).GetPlayers(false); + + losers.removeAll(winners); + + return losers; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SuperSmash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SuperSmash.java index 8ea1c5c8a..a255d196c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SuperSmash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SuperSmash.java @@ -1,40 +1,16 @@ package nautilus.game.arcade.game.games.smash; +import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; -import org.bukkit.ChatColor; -import org.bukkit.FireworkEffect.Type; -import org.bukkit.Color; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.entity.EnderCrystal; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.block.BlockFadeEvent; -import org.bukkit.event.entity.EntityDamageEvent; -import org.bukkit.event.entity.EntityDeathEvent; -import org.bukkit.event.entity.EntityRegainHealthEvent; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; -import org.bukkit.event.entity.PlayerDeathEvent; -import org.bukkit.event.player.PlayerInteractEvent; - import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTextMiddle; -import mineplex.core.common.util.UtilTime; import mineplex.core.data.BlockData; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.recharge.Recharge; @@ -45,19 +21,57 @@ import nautilus.game.arcade.ArcadeFormat; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.GameTeam; -import nautilus.game.arcade.game.SoloGame; import nautilus.game.arcade.game.GameTeam.PlayerState; -import nautilus.game.arcade.game.games.smash.kits.*; +import nautilus.game.arcade.game.games.smash.kits.KitBlaze; +import nautilus.game.arcade.game.games.smash.kits.KitChicken; +import nautilus.game.arcade.game.games.smash.kits.KitCreeper; +import nautilus.game.arcade.game.games.smash.kits.KitEnderman; +import nautilus.game.arcade.game.games.smash.kits.KitGolem; +import nautilus.game.arcade.game.games.smash.kits.KitMagmaCube; +import nautilus.game.arcade.game.games.smash.kits.KitPig; +import nautilus.game.arcade.game.games.smash.kits.KitSheep; +import nautilus.game.arcade.game.games.smash.kits.KitSkeletalHorse; +import nautilus.game.arcade.game.games.smash.kits.KitSkeleton; +import nautilus.game.arcade.game.games.smash.kits.KitSkySquid; +import nautilus.game.arcade.game.games.smash.kits.KitSlime; +import nautilus.game.arcade.game.games.smash.kits.KitSnowman; +import nautilus.game.arcade.game.games.smash.kits.KitSpider; +import nautilus.game.arcade.game.games.smash.kits.KitWitch; +import nautilus.game.arcade.game.games.smash.kits.KitWitherSkeleton; +import nautilus.game.arcade.game.games.smash.kits.KitWolf; +import nautilus.game.arcade.game.games.smash.kits.KitZombie; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.SmashKit; -import nautilus.game.arcade.stats.KillFastStatTracker; import nautilus.game.arcade.stats.FreeKitWinStatTracker; +import nautilus.game.arcade.stats.KillFastStatTracker; import nautilus.game.arcade.stats.OneVThreeStatTracker; import nautilus.game.arcade.stats.RecoveryMasterStatTracker; import nautilus.game.arcade.stats.WinWithoutDyingStatTracker; -public class SuperSmash extends SoloGame +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Color; +import org.bukkit.FireworkEffect.Type; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.EnderCrystal; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.block.BlockFadeEvent; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.event.entity.EntityRegainHealthEvent; +import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.player.PlayerInteractEvent; + +public abstract class SuperSmash extends Game { private HashMap _lives = new HashMap(); @@ -68,9 +82,9 @@ public class SuperSmash extends SoloGame private HashSet _restoreBlock = new HashSet(); - public SuperSmash(ArcadeManager manager) + public SuperSmash(ArcadeManager manager, GameType type, String[] description) { - super(manager, GameType.Smash, + super(manager, type, new Kit[] { @@ -98,31 +112,25 @@ public class SuperSmash extends SoloGame new KitSheep(manager) - }, - - new String[] - { - "Each player has 3 respawns", - "Attack to restore hunger!", - "Last player alive wins!" - - }); + },description); this.DeathOut = false; - this.DamageTeamSelf = true; - this.CompassEnabled = true; this.DeathSpectateSecs = 4; - this.SpawnDistanceRequirement = 32; + this.SpawnNearAllies = true; this.WorldWaterDamage = 1000; - + + this.HideTeamSheep = true; + + this.ReplaceTeamsWithKits = true; + // Add stat table here // Example - //Manager.GetStatsManager().addTable("SuperSmashMobStats", "Kills", "Deaths", "Wins", "Losses"); + // Manager.GetStatsManager().addTable("SuperSmashMobStats", "Kills", "Deaths", "Wins", "Losses"); registerStatTrackers( new WinWithoutDyingStatTracker(this, "MLGPro"), @@ -154,7 +162,7 @@ public class SuperSmash extends SoloGame } } - private int GetLives(Player player) + public int GetLives(Player player) { if (!_lives.containsKey(player)) return 0; @@ -165,7 +173,7 @@ public class SuperSmash extends SoloGame return _lives.get(player); } - private boolean LoseLife(Player player) + public boolean LoseLife(Player player) { int lives = GetLives(player) - 1; @@ -188,51 +196,6 @@ public class SuperSmash extends SoloGame } } - @Override - @EventHandler - public void ScoreboardUpdate(UpdateEvent event) - { - if (event.getType() != UpdateType.FAST) - return; - - //Wipe Last - Scoreboard.Reset(); - - if (GetPlayers(true).size() > 14) - { - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cGreen + "Players Alive"); - Scoreboard.Write(GetPlayers(true).size() + " "); - - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cRed + "Players Dead"); - Scoreboard.Write((GetPlayers(false).size() - GetPlayers(true).size()) + " "); - } - else - { - Scoreboard.WriteBlank(); - - //Write New - for (Player player : GetPlayers(true)) - { - int lives = GetLives(player); - - String out; - if (lives >= 4) out = C.cGreen + player.getName(); - else if (lives == 3) out = C.cYellow + player.getName(); - else if (lives == 2) out = C.cGold + player.getName(); - else if (lives == 1) out = C.cRed + player.getName(); - else if (lives == 0) out = C.cRed + player.getName(); - else - continue; - - Scoreboard.WriteOrdered("Lives", out, lives, true); - } - } - - Scoreboard.Draw(); - } - @EventHandler public void powerupSpawn(UpdateEvent event) { @@ -535,4 +498,5 @@ public class SuperSmash extends SoloGame { return "Deathmatch"; } + } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SuperSmashTeam.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SuperSmashTeam.java deleted file mode 100644 index 4f4507bd3..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/SuperSmashTeam.java +++ /dev/null @@ -1,377 +0,0 @@ -package nautilus.game.arcade.game.games.smash; - -import java.util.HashMap; - -import org.bukkit.Sound; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.block.BlockFadeEvent; -import org.bukkit.event.entity.EntityDamageEvent; -import org.bukkit.event.entity.EntityDeathEvent; -import org.bukkit.event.entity.EntityRegainHealthEvent; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; -import org.bukkit.event.entity.PlayerDeathEvent; -import org.bukkit.event.player.PlayerInteractEvent; - -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilInv; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.recharge.Recharge; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.ArcadeFormat; -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.GameTeam.PlayerState; -import nautilus.game.arcade.game.TeamGame; -import nautilus.game.arcade.game.games.smash.kits.*; -import nautilus.game.arcade.kit.Kit; - -public class SuperSmashTeam extends TeamGame -{ - private HashMap _lives = new HashMap(); - - public SuperSmashTeam(ArcadeManager manager) - { - super(manager, GameType.SmashTeams, - - new Kit[] - { - - new KitSkeleton(manager), - new KitGolem(manager), - new KitSpider(manager), - new KitSlime(manager), - - new KitCreeper(manager), - new KitEnderman(manager), - new KitSnowman(manager), - new KitWolf(manager), - - - new KitBlaze(manager), - new KitWitch(manager), - new KitChicken(manager), - new KitSkeletalHorse(manager), - new KitPig(manager), - new KitSkySquid(manager), - new KitWitherSkeleton(manager), - new KitMagmaCube(manager), - - new KitSheep(manager) - - }, - - new String[] - { - "Each player has 3 respawns", - "Attack to restore hunger!", - "Last player alive wins!" - - }); - - this.DeathOut = false; - - this.DamageTeamSelf = false; - - this.CompassEnabled = true; - - this.SpawnDistanceRequirement = 16; - - this.TeamArmorHotbar = true; - } - - @EventHandler(priority = EventPriority.HIGH) - public void GameStateChange(GameStateChangeEvent event) - { - if (event.GetState() != GameState.Prepare) - return; - - for (Player player : GetPlayers(true)) - _lives.put(player, 4); - } - - @EventHandler - public void PlayerOut(PlayerDeathEvent event) - { - if (!LoseLife(event.getEntity())) - { - this.SetPlayerState(event.getEntity(), PlayerState.OUT); - } - } - - private int GetLives(Player player) - { - if (!_lives.containsKey(player)) - return 0; - - if (!IsAlive(player)) - return 0; - - return _lives.get(player); - } - - private boolean LoseLife(Player player) - { - int lives = GetLives(player) - 1; - - if (lives > 0) - { - UtilPlayer.message(player, C.cRed + C.Bold + "You have died!"); - UtilPlayer.message(player, C.cRed + C.Bold + "You have " + lives + " lives left!"); - player.playSound(player.getLocation(), Sound.NOTE_BASS_GUITAR, 2f, 0.5f); - - _lives.put(player, lives); - - return true; - } - else - { - UtilPlayer.message(player, C.cRed + C.Bold + "You are out of the game!"); - player.playSound(player.getLocation(), Sound.EXPLODE, 2f, 1f); - - return false; - } - } - - @Override - @EventHandler - public void ScoreboardUpdate(UpdateEvent event) - { - if (event.getType() != UpdateType.FAST) - return; - - //Wipe Last - Scoreboard.Reset(); - - if (GetPlayers(true).size() > 14) - { - for (GameTeam team : this.GetTeamList()) - { - Scoreboard.WriteBlank(); - Scoreboard.Write(team.GetFormattedName()); - - int lives = 0; - for (Player player : team.GetPlayers(true)) - lives += GetLives(player); - - Scoreboard.Write(team.GetColor() + "" + lives + " Lives"); - } - } - else - { - Scoreboard.WriteBlank(); - - //Write New - for (Player player : GetPlayers(true)) - { - int lives = GetLives(player); - - if (lives <= 0) - continue; - - Scoreboard.WriteOrdered("Lives", GetTeam(player).GetColor() + player.getName(), lives, true); - } - } - - Scoreboard.Draw(); - } - - @EventHandler(priority = EventPriority.LOWEST) - public void FallDamage(CustomDamageEvent event) - { - if (event.IsCancelled()) - return; - - if (event.GetCause() == DamageCause.FALL) - event.SetCancelled("No Fall Damage"); - } - - @EventHandler(priority = EventPriority.HIGH) - public void Knockback(CustomDamageEvent event) - { - if (event.IsCancelled()) - return; - - if (event.GetDamageePlayer() != null) - event.AddKnockback("Smash Knockback", 1 + 0.1 * (20 - event.GetDamageePlayer().getHealth())); - } - - @EventHandler(priority = EventPriority.HIGH) - public void ArenaWalls(CustomDamageEvent event) - { - if (event.IsCancelled()) - return; - - if (event.GetCause() == DamageCause.VOID || event.GetCause() == DamageCause.LAVA) - { - event.GetDamageeEntity().eject(); - event.GetDamageeEntity().leaveVehicle(); - - event.AddMod("Smash", "Super Smash Mobs", 5000, false); - } - } - - @EventHandler - public void HealthChange(EntityRegainHealthEvent event) - { - if (event.getRegainReason() == RegainReason.SATIATED) - event.setCancelled(true); - } - - @EventHandler(priority = EventPriority.MONITOR) - public void EntityDeath(EntityDeathEvent event) - { - event.getDrops().clear(); - } - - @Override - public void SetKit(Player player, Kit kit, boolean announce) - { - GameTeam team = GetTeam(player); - if (team != null) - { - if (!team.KitAllowed(kit)) - { - player.playSound(player.getLocation(), Sound.NOTE_BASS, 2f, 0.5f); - UtilPlayer.message(player, F.main("Kit", F.elem(team.GetFormattedName()) + " cannot use " + F.elem(kit.GetFormattedName() + " Kit") + ".")); - return; - } - } - - _playerKit.put(player, kit); - - if (announce) - { - player.playSound(player.getLocation(), Sound.ORB_PICKUP, 2f, 1f); - UtilPlayer.message(player, F.main("Kit", "You equipped " + F.elem(kit.GetFormattedName() + " Kit") + ".")); - kit.ApplyKit(player); - UtilInv.Update(player); - } - } - - @EventHandler(priority = EventPriority.LOWEST) - public void AbilityDescription(PlayerInteractEvent event) - { - if (event.isCancelled()) - return; - - Player player = event.getPlayer(); - - if (player.getItemInHand() == null) - return; - - if (player.getItemInHand().getItemMeta() == null) - return; - - if (player.getItemInHand().getItemMeta().getDisplayName() == null) - return; - - if (player.getItemInHand().getItemMeta().getLore() == null) - return; - - if (Manager.GetGame() == null || Manager.GetGame().GetState() != GameState.Recruit) - return; - - for (int i=player.getItemInHand().getItemMeta().getLore().size() ; i<=7 ; i++) - UtilPlayer.message(player, " "); - - UtilPlayer.message(player, ArcadeFormat.Line); - - UtilPlayer.message(player, "§aAbility - §f§l" + player.getItemInHand().getItemMeta().getDisplayName()); - - //Perk Descs - for (String line : player.getItemInHand().getItemMeta().getLore()) - { - UtilPlayer.message(player, line); - } - - UtilPlayer.message(player, ArcadeFormat.Line); - - player.playSound(player.getLocation(), Sound.NOTE_PLING, 1f, 2f); - - event.setCancelled(true); - } - - @Override - public double GetKillsGems(Player killer, Player killed, boolean assist) - { - return 4; - } - - @EventHandler - public void BlockFade(BlockFadeEvent event) - { - event.setCancelled(true); - } - - private int hungerTick = 0; - @EventHandler - public void Hunger(UpdateEvent event) - { - if (event.getType() != UpdateType.SEC) - return; - - if (!IsLive()) - return; - - hungerTick = (hungerTick + 1)%6; - - for (Player player : GetPlayers(true)) - { - player.setSaturation(3f); - player.setExhaustion(0f); - - if (player.getFoodLevel() <= 0) - { - Manager.GetDamage().NewDamageEvent(player, null, null, - DamageCause.STARVATION, 1, false, true, false, - "Starvation", GetName()); - - UtilPlayer.message(player, F.main("Game", "Attack other players to restore hunger!")); - } - - if (hungerTick == 0) - UtilPlayer.hunger(player, -1); - } - } - - @EventHandler(priority = EventPriority.MONITOR) - public void HungerRestore(CustomDamageEvent event) - { - - if (event.IsCancelled()) - return; - - if (event.GetDamagerPlayer(true) == null) - return; - - if (event.GetDamageePlayer() == null) - return; - - if (GetTeam(event.GetDamageePlayer()) == null) - return; - - Player damager = event.GetDamagerPlayer(true); - if (damager == null) - return; - - if (GetTeam(damager) == null) - return; - - if (GetTeam(damager).equals(GetTeam(event.GetDamageePlayer()))) - return; - - if (!Recharge.Instance.use(damager, "Hunger Restore", 250, false, false)) - return; - - int amount = Math.max(1, (int)(event.GetDamage()/2)); - UtilPlayer.hunger(damager, amount); - } -} 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 new file mode 100644 index 000000000..6aa1dbcef --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/TeamSuperSmash.java @@ -0,0 +1,416 @@ +package nautilus.game.arcade.game.games.smash; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.GameTeam; + +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerInteractEntityEvent; +import org.bukkit.event.player.PlayerQuitEvent; + +public class TeamSuperSmash extends SuperSmash +{ + + public boolean ForceTeamSize = true; + public int PlayersPerTeam = 2; + public int TeamCount = 0; + + private NautHashMap _teamReqs = new NautHashMap(); + + public TeamSuperSmash(ArcadeManager manager) + { + super(manager, GameType.SmashTeams, + new String[] + { + "Each player has 3 respawns", + "Attack to restore hunger!", + "Last team alive wins!" + }); + + this.PlayersPerTeam = 2; + this.FillTeamsInOrderToCount = 2; + + this.SpawnNearAllies = true; + this.DamageTeamSelf = false; + } + + @Override + @EventHandler + public void ScoreboardUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + ArrayList alive = new ArrayList(); + for (GameTeam team : GetTeamList()) + { + if (team.IsTeamAlive()) + alive.add(team); + } + + //Wipe Last + Scoreboard.Reset(); + Scoreboard.WriteBlank(); + + if (GetPlayers(true).size() < 16) + { + + for (GameTeam team : GetTeamList()) + { + for (Player player : team.GetPlayers(true)) + { + int lives = GetLives(player); + + Scoreboard.Write(C.cWhite + lives + " " + team.GetColor() + player.getName()); + } + } + } + else if (alive.size() < 16) + { + for (GameTeam team : alive) + { + int lives = 0; + + for (Player player : team.GetPlayers(true)) + { + lives += GetLives(player); + } + + Scoreboard.Write(C.cWhite + lives + " " + team.GetColor() + team.GetName()); + } + } + else + { + Scoreboard.Write(C.cYellow + C.Bold + "Teams Alive"); + Scoreboard.Write(C.cWhite + alive.size()); + } + + Scoreboard.Draw(); + } + + @EventHandler + public void CustomTeamGeneration(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Recruit) + return; + + ArrayList spawns = this.GetTeamList().get(0).GetSpawns(); + this.GetTeamList().clear(); + + 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++) + { + 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); + } + } + } + + private enum TeamColors + { + + YELLOW(ChatColor.YELLOW, new String[]{"Bananna", "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; + } + + @Override + public void EndCheck() + { + if (!IsLive()) + return; + + ArrayList teamsAlive = new ArrayList(); + + for (GameTeam team : this.GetTeamList()) + if (team.GetPlayers(true).size() > 0) + teamsAlive.add(team); + + if (teamsAlive.size() <= 1) + { + //Announce + if (teamsAlive.size() > 0) + AnnounceEnd(teamsAlive.get(0)); + + for (GameTeam team : GetTeamList()) + { + if (WinnerTeam != null && team.equals(WinnerTeam)) + { + for (Player player : team.GetPlayers(false)) + AddGems(player, 10, "Winning Team", false, false); + } + + for (Player player : team.GetPlayers(false)) + if (player.isOnline()) + AddGems(player, 10, "Participation", false, false); + } + + //End + SetState(GameState.End); + } + } + + @Override + public List getWinners() + { + if (WinnerTeam == null) + return null; + + return WinnerTeam.GetPlayers(false); + } + + @Override + public List getLosers() + { + if (WinnerTeam == null) + return null; + + List players = new ArrayList<>(); + + for (GameTeam team : GetTeamList()) + { + if (team != WinnerTeam) + players.addAll(team.GetPlayers(false)); + } + + return players; + } + + @Override + public boolean CanJoinTeam(GameTeam team) + { + return team.GetSize() < PlayersPerTeam; + } + + @EventHandler(priority = EventPriority.HIGH) + public void teamSelectInteract(PlayerInteractEntityEvent event) + { + if (GetState() != GameState.Recruit) + return; + + if (event.getRightClicked() == null) + return; + + if (!(event.getRightClicked() instanceof Player)) + return; + + Player player = event.getPlayer(); + + //Observer + if (Manager.IsObserver(player)) + { + UtilPlayer.message(player, F.main("Game", "Spectators cannot partake in games.")); + return; + } + + selectTeamMate(player, (Player)event.getRightClicked()); + } + + @EventHandler + public void teamSelectCommand(PlayerCommandPreprocessEvent event) + { + if (GetState() != GameState.Recruit) + return; + + if (!event.getMessage().toLowerCase().startsWith("/team ")) + return; + + event.setCancelled(true); + + Player target = UtilPlayer.searchOnline(event.getPlayer(), event.getMessage().split(" ")[1], true); + if (target == null) + return; + + //Observer + if (Manager.IsObserver(event.getPlayer())) + { + UtilPlayer.message(event.getPlayer(), F.main("Game", "Spectators cannot partake in games.")); + return; + } + + if (event.getPlayer().equals(target)) + return; + + selectTeamMate(event.getPlayer(), target); + } + + public void selectTeamMate(Player player, Player ally) + { + //Accept Invite + if (_teamReqs.containsKey(ally) && _teamReqs.get(ally).equals(player)) + { + //Remove Prefs + _teamReqs.remove(player); + _teamReqs.remove(ally); + + //Inform + UtilPlayer.message(player, F.main("Game", "You accepted " + ally.getName() + "'s Team Request!")); + UtilPlayer.message(ally, F.main("Game", player.getName() + " accepted your Team Request!")); + + //Leave Old Teams + if (GetTeam(player) != null) + GetTeam(player).DisbandTeam(); + + if (GetTeam(ally) != null) + GetTeam(ally).DisbandTeam(); + + //Get Team + GameTeam team = getEmptyTeam(); + if (team == null) + return; + + //Join Team + SetPlayerTeam(player, team, true); + SetPlayerTeam(ally, team, true); + } + //Send Invite + else + { + //Already on Team with Target + if (GetTeam(player) != null) + if (GetTeam(player).HasPlayer(ally)) + return; + + //Inform Player + UtilPlayer.message(player, F.main("Game", "You sent a Team Request to " + ally.getName() + "!")); + + //Inform Target + if (Recharge.Instance.use(player, "Team Req " + ally.getName(), 2000, false, false)) + { + UtilPlayer.message(ally, F.main("Game", player.getName() + " sent you a Team Request!")); + UtilPlayer.message(ally, F.main("Game", "Type " + F.elem("/team " + player.getName()) + " to accept!")); + } + + //Add Pref + _teamReqs.put(player, ally); + } + } + + @EventHandler + public void teamQuit(PlayerQuitEvent event) + { + if (GetState() != GameState.Recruit) + return; + + Player player = event.getPlayer(); + + if (GetTeam(player) != null) + GetTeam(player).DisbandTeam(); + + Iterator teamIter = _teamReqs.keySet().iterator(); + while (teamIter.hasNext()) + { + Player sender = teamIter.next(); + if (sender.equals(player) || _teamReqs.get(sender).equals(player)) + teamIter.remove(); + } + } + + public GameTeam getEmptyTeam() + { + for (GameTeam team : GetTeamList()) + { + if (team.GetPlayers(false).isEmpty()) + return team; + } + + return null; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/SnowFight.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/SnowFight.java index 5343d64f2..bf7e83c1c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/SnowFight.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/SnowFight.java @@ -1,58 +1,109 @@ package nautilus.game.arcade.game.games.snowfight; +import java.util.ArrayList; +import java.util.HashMap; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilSound; +import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilWorld; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.explosion.ExplosionEvent; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import mineplex.minecraft.game.core.explosion.CustomExplosion; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.GameType; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.TeamGame; +import nautilus.game.arcade.game.games.snowfight.kits.KitTactician; +import nautilus.game.arcade.game.games.snowfight.kits.KitMedic; +import nautilus.game.arcade.game.games.snowfight.kits.KitSportsman; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.SmashKit; +import net.minecraft.server.v1_7_R4.EntityFireball; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; import org.bukkit.Effect; +import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.World; import org.bukkit.World.Environment; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftFireball; +import org.bukkit.entity.Egg; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.FallingBlock; +import org.bukkit.entity.Fireball; import org.bukkit.entity.Player; import org.bukkit.entity.Projectile; import org.bukkit.entity.Snowball; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; +import org.bukkit.event.block.Action; import org.bukkit.event.block.BlockDamageEvent; +import org.bukkit.event.entity.EntityChangeBlockEvent; +import org.bukkit.event.entity.EntityRegainHealthEvent; +import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; - -import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilEvent; -import mineplex.core.common.util.UtilGear; -import mineplex.core.common.util.UtilInv; -import mineplex.core.common.util.UtilWorld; -import mineplex.core.common.util.UtilEvent.ActionType; -import mineplex.core.itemstack.ItemStackFactory; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.core.updater.UpdateType; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.GameType; -import nautilus.game.arcade.game.TeamGame; -import nautilus.game.arcade.kit.Kit; -import nautilus.game.arcade.kit.NullKit; +import org.bukkit.metadata.FixedMetadataValue; +import org.bukkit.potion.Potion; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.bukkit.potion.PotionType; +import org.bukkit.scheduler.BukkitRunnable; +import org.bukkit.util.Vector; public class SnowFight extends TeamGame { - public SnowFight(ArcadeManager manager) + + private HashMap _tiles; + private boolean _meteoroids; + + public SnowFight(ArcadeManager manager) { super(manager, GameType.SnowFight, - new Kit[] - { - new NullKit(manager) - }, + new Kit[] + { + new KitSportsman(manager), + new KitTactician(manager), + new KitMedic(manager) + }, + + new String[] + { + "Just like... kill your enemies. with snow.", + "Be careful if you are on Ice your body will freeze" + }); - new String[] - { - "Just like... kill your enemies. with snow." - }); - this.HungerSet = 20; + this.CompassEnabled = true; + this.CompassGiveItem = false; + this.TeamArmor = true; + this.TeamArmorHotbar = true; + this._tiles = new HashMap(); + this._meteoroids = false; } - @EventHandler public void Weather(UpdateEvent event) { @@ -70,6 +121,71 @@ public class SnowFight extends TeamGame world.setTime(4000); } + @EventHandler + public void KitItems(UpdateEvent event) + { + if(!IsLive()) + return; + + if (event.getType() == UpdateType.SLOWER) + { + for (Player player : GetPlayers(true)) + { + if (GetKit(player) instanceof KitTactician) + { + int amount = 0; + if (player.getInventory().getItem(1) != null && player.getInventory().getItem(1).getAmount() <= 2) + amount = 2; + else + amount = 1; + player.getInventory().setItem(1, ItemStackFactory.Instance.CreateStack(Material.EGG, (byte) 0, amount, "Slow Egg")); + } + } + } + } + + @EventHandler + public void IceDamage(UpdateEvent event) { + if(event.getType() != UpdateType.SEC) + return; + + if(!IsLive()) + return; + + for(Player player : GetPlayers(true)) + { + if(IsOnIce(player)) + { + Bukkit.getPluginManager().callEvent(new CustomDamageEvent(player, null, null, DamageCause.CUSTOM, 4.0D, false, true, true, "Ice", "Ice", false)); + } + } + + } + + @EventHandler + public void Meteor(UpdateEvent event) { + if(event.getType() != UpdateType.TWOSEC) + return; + + if(!IsLive()) + return; + + if(System.currentTimeMillis() <= getGameLiveTime() + (4 * 60 * 1000)) + return; + + if(!_meteoroids) + { + for(Player player : GetPlayers(false)) + { + player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 1F, 1F); + UtilTextMiddle.display(C.cGold + C.Bold + "ICE METEOROIDS!!!", "Avoid the Ice Fields", player); + } + this.Announce(C.cRed + C.Bold + "ALERT: " + ChatColor.RESET + C.Bold + "METEOROIDS START FALLING!"); + _meteoroids = true; + } + makeMeteor(); + } + @EventHandler public void BlockDamage(BlockDamageEvent event) { @@ -84,97 +200,119 @@ public class SnowFight extends TeamGame if (!IsSnow(event.getBlock())) return; - - if (UtilInv.contains(player, Material.SNOW_BALL, (byte)0, 16)) + if (UtilInv.contains(player, Material.SNOW_BALL, (byte) 0, 16)) return; - //Item - UtilInv.insert(player, new ItemStack(Material.SNOW_BALL)); + // Item - //Snow Height + if (!_tiles.containsKey(player)) + { + _tiles.put(player, 0); + } + + if (GetKit(player) instanceof KitSportsman) + UtilInv.insert(player, new ItemStack(Material.SNOW_BALL)); + + + int tiles = _tiles.get(player); + _tiles.put(player, tiles + 1); + + if (!(GetKit(player) instanceof KitSportsman)) + { + if (_tiles.get(player) == 2) + { + UtilInv.insert(player, new ItemStack(Material.SNOW_BALL)); + _tiles.put(player, 0); + } + } + + // Snow Height SnowDecrease(event.getBlock(), 1); - //Effect - event.getBlock().getWorld().playEffect(event.getBlock().getLocation(), Effect.STEP_SOUND, 80); + // Effect + event.getBlock().getWorld().playEffect(event.getBlock().getLocation(), Effect.STEP_SOUND, 80); } -// @EventHandler -// public void InteractSnowball(PlayerInteractEvent event) -// { -// Player player = event.getPlayer(); -// -// if (!IsLive()) -// return; -// -// if (!IsPlaying(player)) -// return; -// -// if (!UtilGear.isMat(player.getItemInHand(), Material.SNOW_BALL)) -// return; -// -// event.setCancelled(true); -// -// if (UtilEvent.isAction(event, ActionType.L)) -// SnowballThrow(player); -// -// else if (UtilEvent.isAction(event, ActionType.R_BLOCK)) -// SnowballPlace(player, event.getClickedBlock(), 1); -// } -// -// private void SnowballPlace(Player player, Block block, int above) -// { -// if (block.getTypeId() == 78 || UtilBlock.airFoliage(block)) -// { -// //Build -// if (block.getTypeId() == 78) -// { -// block.setTypeIdAndData(78, (byte)(block.getData() + 1), true); -// -// if (block.getData() >= 7) -// block.setTypeIdAndData(80, (byte)0, true); -// } -// else -// { -// block.setTypeIdAndData(78, (byte)0, true); -// } -// -// //Sound -// block.getWorld().playSound(block.getLocation(), Sound.STEP_SNOW, 1f, 0.6f); -// -// //Use Snow -// SnowballCount(player, -1); -// } -// else if ((IsSnow(block) || UtilBlock.solid(block)) && above > 0) -// { -// SnowballPlace(player, block.getRelative(BlockFace.UP), above - 1); -// } -// } -// -// private void SnowballThrow(Player player) -// { -// //Throw -// player.launchProjectile(Snowball.class); -// -// //Use Snow -// SnowballCount(player, -1); -// -// //Sound -// player.getWorld().playSound(player.getLocation(), Sound.STEP_SNOW, 3f, 1.5f); -// } + // @EventHandler + // public void InteractSnowball(PlayerInteractEvent event) + // { + // Player player = event.getPlayer(); + // + // if (!IsLive()) + // return; + // + // if (!IsPlaying(player)) + // return; + // + // if (!UtilGear.isMat(player.getItemInHand(), Material.SNOW_BALL)) + // return; + // + // event.setCancelled(true); + // + // if (UtilEvent.isAction(event, ActionType.L)) + // SnowballThrow(player); + // + // else if (UtilEvent.isAction(event, ActionType.R_BLOCK)) + // SnowballPlace(player, event.getClickedBlock(), 1); + // } + // + // private void SnowballPlace(Player player, Block block, int above) + // { + // if (block.getTypeId() == 78 || UtilBlock.airFoliage(block)) + // { + // //Build + // if (block.getTypeId() == 78) + // { + // block.setTypeIdAndData(78, (byte)(block.getData() + 1), true); + // + // if (block.getData() >= 7) + // block.setTypeIdAndData(80, (byte)0, true); + // } + // else + // { + // block.setTypeIdAndData(78, (byte)0, true); + // } + // + // //Sound + // block.getWorld().playSound(block.getLocation(), Sound.STEP_SNOW, 1f, + // 0.6f); + // + // //Use Snow + // SnowballCount(player, -1); + // } + // else if ((IsSnow(block) || UtilBlock.solid(block)) && above > 0) + // { + // SnowballPlace(player, block.getRelative(BlockFace.UP), above - 1); + // } + // } + // + // private void SnowballThrow(Player player) + // { + // //Throw + // player.launchProjectile(Snowball.class); + // + // //Use Snow + // SnowballCount(player, -1); + // + // //Sound + // player.getWorld().playSound(player.getLocation(), Sound.STEP_SNOW, 3f, + // 1.5f); + // } -// private void SnowballCount(Player player, int count) -// { -// if (player.getInventory().getItem(1) != null) -// count += player.getInventory().getItem(1).getAmount(); -// -// if (count > 16) -// count = 16; -// -// if (count > 0) -// player.getInventory().setItem(1, ItemStackFactory.Instance.CreateStack(Material.SNOW_BALL, count)); -// else -// player.getInventory().setItem(1, null); -// } + // private void SnowballCount(Player player, int count) + // { + // if (player.getInventory().getItem(1) != null) + // count += player.getInventory().getItem(1).getAmount(); + // + // if (count > 16) + // count = 16; + // + // if (count > 0) + // player.getInventory().setItem(1, + // ItemStackFactory.Instance.CreateStack(Material.SNOW_BALL, count)); + // else + // player.getInventory().setItem(1, null); + // } private void SnowDecrease(Block block, int height) { @@ -184,30 +322,46 @@ public class SnowFight extends TeamGame if (!IsSnow(block)) return; - //Shuffle Up + // Shuffle Up while (IsSnow(block.getRelative(BlockFace.UP))) block = block.getRelative(BlockFace.UP); - //Snow Block - int snowLevel = 8; - if (block.getTypeId() == 78) + // Snow Block + int snowLevel = 8; + if (block.getTypeId() == 78) snowLevel = block.getData() + 1; - //Lower + // Lower if (height >= snowLevel) { - block.setTypeIdAndData(0, (byte)0, true); - SnowDecrease(block.getRelative(BlockFace.DOWN), height-snowLevel); + block.setTypeIdAndData(0, (byte) 0, true); + SnowDecrease(block.getRelative(BlockFace.DOWN), height - snowLevel); } else { - block.setTypeIdAndData(78, (byte)(snowLevel-height-1), true); + block.setTypeIdAndData(78, (byte) (snowLevel - height - 1), true); } } + + @EventHandler + public void HealthRegen(EntityRegainHealthEvent event) + { + if(event.getRegainReason() == RegainReason.SATIATED) + { + event.setAmount(1); + } + } + + @EventHandler(priority = EventPriority.HIGH) + public void GenerallDamage(CustomDamageEvent event) + { + if(event.GetCause() == DamageCause.ENTITY_ATTACK) + event.AddMod(event.GetDamagerPlayer(false).getName(), "Melee", 1, true); + } @EventHandler(priority = EventPriority.HIGH) - public void SnowballDamage(CustomDamageEvent event) - { + public void SnowballEggDamage(CustomDamageEvent event) + { if (event.IsCancelled()) return; @@ -215,20 +369,220 @@ public class SnowFight extends TeamGame return; Projectile proj = event.GetProjectile(); - if (proj == null) return; - - if (!(proj instanceof Snowball)) + if (proj == null) return; - - event.AddMod("Snowball", "Snowball", 3, true); + + if(proj instanceof Fireball) + return; + + if(proj instanceof Egg) + { + event.GetDamageePlayer().addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 100, 1)); + event.GetDamageePlayer().addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 40, 0)); + event.AddMod("Egg", "Egg", 3, true); + } + + if(proj instanceof Snowball) + event.AddMod("Snowball", "Snowball", 2, true); + event.SetIgnoreRate(true); + event.SetIgnoreArmor(true); - //Effect - proj.getWorld().playEffect(proj.getLocation(), Effect.STEP_SOUND, 80); + // Effect + proj.getWorld().playEffect(proj.getLocation(), Effect.STEP_SOUND, 80); + ((Player) proj.getShooter()).playSound(((Player) proj.getShooter()).getLocation(), Sound.SUCCESSFUL_HIT, 1, 1); } private boolean IsSnow(Block block) { return block.getTypeId() == 78 || block.getTypeId() == 80; } + + private boolean IsOnIce(Player player) + { + return player.getLocation().getBlock().getRelative(BlockFace.DOWN).getType() == Material.ICE; + } + + + private void makeMeteor() + { + + Location loc = getEndgameLocation(); + + if (loc == null) + { + return; + } + + summonMeteor(loc, 20F); + + } + + private void summonMeteor(Location loc, float fireballSize) + { + Vector vector = new Vector(UtilMath.random.nextDouble() - 0.5D, 0.8, UtilMath.random.nextDouble() - 0.5D).normalize(); + + vector.multiply(40); + + loc.add((UtilMath.random.nextDouble() - 0.5) * 7, 0, (UtilMath.random.nextDouble() - 0.5) * 7); + + loc.add(vector); + + final FallingBlock fallingblock = loc.getWorld().spawnFallingBlock(loc, Material.ICE, (byte) 0); + + fallingblock.setMetadata("Meteor", new FixedMetadataValue(getArcadeManager().getPlugin(), fireballSize)); + + new BukkitRunnable() + { + int i; + + public void run() + { + if (fallingblock.isValid() && IsLive()) + { + UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, fallingblock.getLocation(), 0.3F, 0.3F, 0.3F, 0, 3, + ViewDist.MAX, UtilServer.getPlayers()); + + if (i++ % 6 == 0) + { + fallingblock.getWorld().playSound(fallingblock.getLocation(), Sound.CAT_HISS, 1.3F, 0F); + } + } + else + { + cancel(); + } + } + }.runTaskTimer(getArcadeManager().getPlugin(), 0, 0); + + vector.normalize().multiply(-(0.04 + ((0.5 - 0.05) / 2))); + fallingblock.setFireTicks(9999); + } + + @EventHandler + public void MeteorHit(EntityChangeBlockEvent event) + { + Entity projectile = event.getEntity(); + + int size = 3; + + for(int i = 1; i <= 10; i++) + { + if(System.currentTimeMillis() >= getGameLiveTime() + (((30 * i) + 300) * 1000)) + { + size = 3 * i; + } + } + + if (projectile.hasMetadata("Meteor")) + { + projectile.remove(); + + CustomExplosion explosion = new CustomExplosion(getArcadeManager().GetDamage(), getArcadeManager().GetExplosion(), + projectile.getLocation(), size, "Meteor"); + + explosion.setBlockExplosionSize(size); + + explosion.setFallingBlockExplosionAmount(20); + + explosion.setFallingBlockExplosion(false); + + explosion.setDropItems(false); + + explosion.setBlocksDamagedEqually(true); + + for(Block block : UtilBlock.getInRadius(event.getEntity().getLocation(), size).keySet()) + { + if(block.getType() != Material.AIR) + { + block.setType(Material.ICE); + if(block.getRelative(BlockFace.DOWN).getType() == Material.AIR) + { + block.getWorld().spawnFallingBlock(block.getLocation(), block.getType(), block.getData()); + block.setType(Material.AIR); + } + } + } + + } + } + + private Location getEndgameLocation() + { + int chance = UtilMath.r(50) + 3; + int accuracy = Math.max((int) (chance - (0.0001 * chance)), 1); + + ArrayList players = GetPlayers(true); + + for (int a = 0; a < 50; a++) + { + Player player = players.get(UtilMath.r(players.size())); + + Location location = player.getLocation().add(UtilMath.r(accuracy * 2) - accuracy, 0, + UtilMath.r(accuracy * 2) - accuracy); + + location = WorldData.World.getHighestBlockAt(location).getLocation().add(0.5, 0, 0.5); + + if (location.getBlock().getType() == Material.AIR) + { + location.add(0, -1, 0); + } + + if (location.getBlockY() > 0 && location.getBlock().getType() != Material.AIR) + { + return location; + } + } + + return null; + } + + @Override + @EventHandler + public void ScoreboardUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + Scoreboard.Reset(); + + Scoreboard.WriteBlank(); + if(GetPlayers(true).size() <= 8) + { + for (GameTeam team : this.GetTeamList()) + { + for(Player player : team.GetPlayers(true)) + { + Scoreboard.Write(team.GetColor() + player.getName()); + } + + Scoreboard.WriteBlank(); + } + } + else + { + for (GameTeam team : this.GetTeamList()) + { + Scoreboard.Write(team.GetColor() + C.Bold + team.GetName()); + Scoreboard.Write(team.GetColor() + "Alive " + team.GetPlayers(true).size()); + Scoreboard.WriteBlank(); + } + } + + long time = 1000 * 60 * 4 - (System.currentTimeMillis() - this.GetStateTime()); + + if (time > 0) + { + Scoreboard.Write(C.cYellow + C.Bold + "Meteoroids:"); + if(IsLive()) + Scoreboard.Write(UtilTime.MakeStr(time, 0)); + } + else + { + Scoreboard.Write(C.cGold + C.Bold + "Meteoroids!"); + } + + Scoreboard.Draw(); + } + } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/kits/KitMedic.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/kits/KitMedic.java new file mode 100644 index 000000000..99195e72c --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/kits/KitMedic.java @@ -0,0 +1,68 @@ +package nautilus.game.arcade.game.games.snowfight.kits; + +import mineplex.core.itemstack.ItemStackFactory; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; + +import org.bukkit.Color; +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.LeatherArmorMeta; +import org.bukkit.potion.Potion; +import org.bukkit.potion.PotionType; + +public class KitMedic extends Kit +{ + + public KitMedic(ArcadeManager manager) + { + super(manager, "Medic", KitAvailability.Free, + + new String[] + { + "To the rescue...!", + " ", + "Gets 1 Snowball every second tile.", + "Left-Click Snow to pick up Snowballs (Max. 16)", + "Right-Click Snowballs to throw them.", + " ", + "Has 5 Healing Potions.", + "Right-Click Potions to throw them and heal nearby Players." + }, + + new Perk[] + { + }, + EntityType.SKELETON, + new ItemStack(Material.POTION)); + + + } + + @Override + public void GiveItems(Player player) + { + player.getInventory().setItem(2, ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP)); + Potion potion = new Potion(PotionType.INSTANT_HEAL); + potion.setLevel(2); + potion.setSplash(true); + for(int i = 3; i <= 7; i++) { + player.getInventory().setItem(i, potion.toItemStack(1)); + } + } + + @Override + public void SpawnCustom(LivingEntity ent) + { + ent.getEquipment().setHelmet(new ItemStack(Material.LEATHER_HELMET)); + ent.getEquipment().setChestplate(new ItemStack(Material.LEATHER_CHESTPLATE)); + ent.getEquipment().setLeggings(new ItemStack(Material.LEATHER_LEGGINGS)); + ent.getEquipment().setBoots(new ItemStack(Material.LEATHER_BOOTS)); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/kits/KitSportsman.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/kits/KitSportsman.java new file mode 100644 index 000000000..78691a611 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/kits/KitSportsman.java @@ -0,0 +1,63 @@ +package nautilus.game.arcade.game.games.snowfight.kits; + +import org.bukkit.Color; +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.LeatherArmorMeta; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +import mineplex.core.itemstack.ItemStackFactory; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; + +public class KitSportsman extends Kit +{ + + public KitSportsman(ArcadeManager manager) + { + super(manager, "Sportsman", KitAvailability.Free, + + new String[] + { + "Trained to be the fastest on snow and ice.", + "", + "Gets 1 Snowball every tile", + "Left-Click Snow to pick up Snowballs (Max. 16)", + "Right-Click Snowballs to throw them.", + "", + "Use your compass to find and kill your enemies." + }, + + new Perk[] + { + }, + EntityType.SKELETON, + new ItemStack(Material.SNOW_BALL)); + + } + + @Override + public void GiveItems(Player player) + { + player.getInventory().setItem(1, ItemStackFactory.Instance.CreateStack(Material.COMPASS.getId(), (byte) 0, 1, "§a§lTracking Compass")); + player.getInventory().setItem(2, ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP)); + player.getInventory().setItem(3, ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP)); + player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 0)); + } + + @Override + public void SpawnCustom(LivingEntity ent) + { + ent.getEquipment().setHelmet(new ItemStack(Material.LEATHER_HELMET)); + ent.getEquipment().setChestplate(new ItemStack(Material.LEATHER_CHESTPLATE)); + ent.getEquipment().setLeggings(new ItemStack(Material.LEATHER_LEGGINGS)); + ent.getEquipment().setBoots(new ItemStack(Material.LEATHER_BOOTS)); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/kits/KitTactician.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/kits/KitTactician.java new file mode 100644 index 000000000..0dc4c3054 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/kits/KitTactician.java @@ -0,0 +1,60 @@ +package nautilus.game.arcade.game.games.snowfight.kits; + +import mineplex.core.itemstack.ItemStackFactory; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.perks.PerkFallDamage; + +import org.bukkit.Color; +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.LeatherArmorMeta; + +public class KitTactician extends Kit +{ + + public KitTactician(ArcadeManager manager) + { + super(manager, "Tactician", KitAvailability.Free, + new String[] + { + "No Snowfight is complete without a tactical game!", + " ", + "Gets 1 Snowball every second tile.", + "Left-Click Snow to pick up Snowballs (Max. 16)", + "Right-Click Snowballs to throw them.", + " ", + "Gets 1 Slow Egg every 16 seconds (Max. 2)", + "Right-Click Slow Eggs to throw them.", + "Causes Blindness and Slowness II when hit." + }, new Perk[] + { + new PerkFallDamage(2) + }, + EntityType.SKELETON, + new ItemStack(Material.EGG)); + + } + + @Override + public void GiveItems(Player player) + { + player.getInventory().setItem(2, ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP)); + player.getInventory().setItem(3, ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP)); + } + + @Override + public void SpawnCustom(LivingEntity ent) + { + ent.getEquipment().setHelmet(new ItemStack(Material.LEATHER_HELMET)); + ent.getEquipment().setChestplate(new ItemStack(Material.LEATHER_CHESTPLATE)); + ent.getEquipment().setLeggings(new ItemStack(Material.LEATHER_LEGGINGS)); + ent.getEquipment().setBoots(new ItemStack(Material.LEATHER_BOOTS)); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/squidshooter/SquidShooter.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/squidshooter/SquidShooter.java index c7334f60e..8842a3799 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/squidshooter/SquidShooter.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/squidshooter/SquidShooter.java @@ -48,7 +48,6 @@ public class SquidShooter extends SoloGame this.DamageSelf = false; this.DamageTeamSelf = true; this.PrepareFreeze = false; - this.SpawnDistanceRequirement = 16; this.CompassEnabled = true; this.KitRegisterState = GameState.Prepare; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SoloSurvivalGames.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SoloSurvivalGames.java new file mode 100644 index 000000000..c036edcbb --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SoloSurvivalGames.java @@ -0,0 +1,176 @@ +package nautilus.game.arcade.game.games.survivalgames; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +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; + +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +public class SoloSurvivalGames extends SurvivalGames +{ + + private GameTeam _players; + + public SoloSurvivalGames(ArcadeManager manager) + { + super(manager, GameType.SurvivalGames, + new String[] + { + "Search for chests to find loot", + + "Slaughter your opponents", + + "Stay away from the borders!", + + "Last tribute alive wins!" + }); + + this.DamageTeamSelf = true; + + } + + @EventHandler + public void CustomTeamGeneration(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Recruit) + return; + + _players = GetTeamList().get(0); + _players.SetColor(ChatColor.YELLOW); + _players.SetName("Players"); + _players.setDisplayName(C.cYellow + C.Bold + "Players"); + } + + @Override + @EventHandler + public void ScoreboardUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + if (GetTeamList().isEmpty()) + return; + + Scoreboard.Reset(); + + Scoreboard.WriteBlank(); + + GameTeam team = GetTeamList().get(0); + + Scoreboard.Write(C.cGreen + C.Bold + "Time"); + Scoreboard.Write(UtilTime.convertString(this.getSecondsSinceStart() * 1000, 0, TimeUnit.FIT)); + + Scoreboard.WriteBlank(); + + Scoreboard.Write(C.cYellow + C.Bold + "Tributes"); + if (team.GetPlayers(true).size() > 7) + { + Scoreboard.Write("" + team.GetPlayers(true).size()); + } + else + { + for (Player player : team.GetPlayers(true)) + { + Scoreboard.Write(C.cWhite + player.getName()); + } + } + + Scoreboard.WriteBlank(); + + if (this.getChestRefillTime() > 0 && this.getDeathMatchTime() > 60) + { + Scoreboard.Write(C.cGold + C.Bold + "Chest Refill"); + Scoreboard.Write(UtilTime.convertString(this.getChestRefillTime() * 1000, 0, TimeUnit.FIT)); + } + else if (this.getDeathMatchTime() > 0) + { + Scoreboard.Write(C.cRed + C.Bold + "Deathmatch"); + Scoreboard.Write(UtilTime.convertString( + Math.min(this.getDeathMatchTime(), this.isDeathMatchTeleported() ? 10 : this.getDeathMatchTime()) * 1000, 0, TimeUnit.FIT)); + } + else + { + Scoreboard.Write(C.cRed + C.Bold + "Game End"); + Scoreboard.Write(UtilTime.convertString(Math.max(0, this.getGameEndTime()) * 1000, 0, TimeUnit.FIT)); + } + + Scoreboard.Draw(); + } + + @Override + public void EndCheck() + { + if (!IsLive()) + return; + + if (GetPlayers(true).size() <= 1) + { + ArrayList places = GetTeamList().get(0).GetPlacements(true); + + //Announce + AnnounceEnd(places); + + //Gems + if (places.size() >= 1) + AddGems(places.get(0), 20, "1st Place", false, false); + + if (places.size() >= 2) + AddGems(places.get(1), 15, "2nd Place", false, false); + + if (places.size() >= 3) + AddGems(places.get(2), 10, "3rd Place", false, false); + + for (Player player : GetPlayers(false)) + if (player.isOnline()) + AddGems(player, 10, "Participation", false, false); + + //End + SetState(GameState.End); + } + } + + @Override + public List getWinners() + { + if (GetState().ordinal() >= GameState.End.ordinal()) + { + List places = GetTeamList().get(0).GetPlacements(true); + + if (places.isEmpty() || !places.get(0).isOnline()) + return Arrays.asList(); + else + return Arrays.asList(places.get(0)); + } + else + return null; + } + + @Override + public List getLosers() + { + List winners = getWinners(); + + if (winners == null) + return null; + + List losers = GetTeamList().get(0).GetPlayers(false); + + losers.removeAll(winners); + + return losers; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java index 71d2e3f5c..ce66cd5bd 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java @@ -114,7 +114,7 @@ import net.minecraft.server.v1_7_R4.TileEntityChest; import net.minecraft.server.v1_7_R4.WorldServer; import net.minecraft.util.com.mojang.authlib.GameProfile; -public class SurvivalGames extends SoloGame +public abstract class SurvivalGames extends Game { // Chest loot private ChestLoot _baseLoot = new ChestLoot(true); @@ -168,9 +168,9 @@ public class SurvivalGames extends SoloGame */ private Field _ticksField; - public SurvivalGames(ArcadeManager manager) + public SurvivalGames(ArcadeManager manager, GameType type, String[] description) { - super(manager, GameType.SurvivalGames, + super(manager, type, new Kit[] { @@ -195,18 +195,7 @@ public class SurvivalGames extends SoloGame new KitBarbarian(manager), new KitHorseman(manager), - }, - - new String[] - { - "Search for chests to find loot", - - "Slaughter your opponents", - - "Stay away from the borders!", - - "Last tribute alive wins!" - }); + }, description); _help = new String[] { @@ -220,6 +209,10 @@ public class SurvivalGames extends SoloGame // Manager.GetAntiStack().SetEnabled(false); StrictAntiHack = true; + + HideTeamSheep = true; + + this.ReplaceTeamsWithKits = true; GameTimeout = 1500000; @@ -227,8 +220,8 @@ public class SurvivalGames extends SoloGame WorldTimeSet = 0; WorldBoundaryKill = false; - - SpawnDistanceRequirement = 48; + SpawnNearAllies = true; + SpawnNearEnemies = true; //This is to ensure theres no 'gaps' of 1 between teams, hence forcing a team to get split. DamageSelf = true; DamageTeamSelf = true; @@ -1683,62 +1676,6 @@ public class SurvivalGames extends SoloGame } - @Override - @EventHandler - public void ScoreboardUpdate(UpdateEvent event) - { - if (event.getType() != UpdateType.FAST) - return; - - if (GetTeamList().isEmpty()) - return; - - Scoreboard.Reset(); - - Scoreboard.WriteBlank(); - - GameTeam team = GetTeamList().get(0); - - Scoreboard.Write(C.cGreen + C.Bold + "Time"); - Scoreboard.Write(UtilTime.convertString(_secondsSinceStart * 1000, 0, TimeUnit.FIT)); - - Scoreboard.WriteBlank(); - - Scoreboard.Write(C.cYellow + C.Bold + "Tributes"); - if (team.GetPlayers(true).size() > 7) - { - Scoreboard.Write("" + team.GetPlayers(true).size()); - } - else - { - for (Player player : team.GetPlayers(true)) - { - Scoreboard.Write(C.cWhite + player.getName()); - } - } - - Scoreboard.WriteBlank(); - - if (_chestRefillTime > 0 && _deathMatchTime > 60) - { - Scoreboard.Write(C.cGold + C.Bold + "Chest Refill"); - Scoreboard.Write(UtilTime.convertString(_chestRefillTime * 1000, 0, TimeUnit.FIT)); - } - else if (_deathMatchTime > 0) - { - Scoreboard.Write(C.cRed + C.Bold + "Deathmatch"); - Scoreboard.Write(UtilTime.convertString( - Math.min(_deathMatchTime, _deathMatchTeleported ? 10 : _deathMatchTime) * 1000, 0, TimeUnit.FIT)); - } - else - { - Scoreboard.Write(C.cRed + C.Bold + "Game End"); - Scoreboard.Write(UtilTime.convertString(Math.max(0, _gameEndTime) * 1000, 0, TimeUnit.FIT)); - } - - Scoreboard.Draw(); - } - private void setBorder() { _borderStartedMoving = System.currentTimeMillis(); @@ -2295,4 +2232,30 @@ public class SurvivalGames extends SoloGame } } } + + public int getSecondsSinceStart() + { + return this._secondsSinceStart; + } + + public int getChestRefillTime() + { + return this._chestRefillTime; + } + + public int getDeathMatchTime() + { + return this._deathMatchTime; + } + + public boolean isDeathMatchTeleported() + { + return this._deathMatchTeleported; + } + + public int getGameEndTime() + { + return this._gameEndTime; + } + } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGamesTeams.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGamesTeams.java index 3d2e51099..049b93826 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGamesTeams.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGamesTeams.java @@ -7,38 +7,6 @@ import java.util.HashSet; import java.util.Iterator; import java.util.Map.Entry; -import org.bukkit.*; -import org.bukkit.FireworkEffect.Type; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.block.Chest; -import org.bukkit.entity.Entity; -import org.bukkit.entity.ItemFrame; -import org.bukkit.entity.Player; -import org.bukkit.entity.Snowball; -import org.bukkit.entity.TNTPrimed; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.block.Action; -import org.bukkit.event.block.BlockBreakEvent; -import org.bukkit.event.block.BlockBurnEvent; -import org.bukkit.event.block.BlockFadeEvent; -import org.bukkit.event.block.BlockPlaceEvent; -import org.bukkit.event.block.BlockSpreadEvent; -import org.bukkit.event.block.LeavesDecayEvent; -import org.bukkit.event.entity.EntityExplodeEvent; -import org.bukkit.event.entity.ExplosionPrimeEvent; -import org.bukkit.event.entity.ItemSpawnEvent; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.event.hanging.HangingBreakEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerMoveEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; -import org.bukkit.util.Vector; - import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.MapUtil; @@ -52,9 +20,9 @@ import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime.TimeUnit; @@ -72,9 +40,56 @@ import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.TeamGame; -import nautilus.game.arcade.game.games.survivalgames.kit.*; +import nautilus.game.arcade.game.games.survivalgames.kit.KitArcher; +import nautilus.game.arcade.game.games.survivalgames.kit.KitAssassin; +import nautilus.game.arcade.game.games.survivalgames.kit.KitAxeman; +import nautilus.game.arcade.game.games.survivalgames.kit.KitBeastmaster; +import nautilus.game.arcade.game.games.survivalgames.kit.KitBomber; +import nautilus.game.arcade.game.games.survivalgames.kit.KitBrawler; +import nautilus.game.arcade.game.games.survivalgames.kit.KitHorseman; +import nautilus.game.arcade.game.games.survivalgames.kit.KitKnight; +import nautilus.game.arcade.game.games.survivalgames.kit.KitLooter; import nautilus.game.arcade.kit.Kit; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Color; +import org.bukkit.Effect; +import org.bukkit.FireworkEffect; +import org.bukkit.FireworkEffect.Type; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.block.Chest; +import org.bukkit.entity.Entity; +import org.bukkit.entity.ItemFrame; +import org.bukkit.entity.Player; +import org.bukkit.entity.Snowball; +import org.bukkit.entity.TNTPrimed; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.block.Action; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockBurnEvent; +import org.bukkit.event.block.BlockFadeEvent; +import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.block.BlockSpreadEvent; +import org.bukkit.event.block.LeavesDecayEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.event.entity.ExplosionPrimeEvent; +import org.bukkit.event.entity.ItemSpawnEvent; +import org.bukkit.event.hanging.HangingBreakEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.util.Vector; + public class SurvivalGamesTeams extends TeamGame { private HashSet _openedChest = new HashSet(); @@ -114,7 +129,7 @@ public class SurvivalGamesTeams extends TeamGame public SurvivalGamesTeams(ArcadeManager manager) { - super(manager, GameType.SurvivalGamesTeams, + super(manager, GameType.SurvivalGames, new Kit[] { @@ -161,7 +176,6 @@ public class SurvivalGamesTeams extends TeamGame this.WorldTimeSet = 0; this.WorldBoundaryKill = false; - this.SpawnDistanceRequirement = 48; this.DamageSelf = true; this.DamageTeamSelf = false; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/TeamSurvivalGames.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/TeamSurvivalGames.java new file mode 100644 index 000000000..75aede149 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/TeamSurvivalGames.java @@ -0,0 +1,441 @@ +package nautilus.game.arcade.game.games.survivalgames; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.GameTeam; + +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerInteractEntityEvent; +import org.bukkit.event.player.PlayerQuitEvent; + +public class TeamSurvivalGames extends SurvivalGames +{ + + public boolean ForceTeamSize = true; + public int PlayersPerTeam = 2; + public int TeamCount = 0; + + private NautHashMap _teamReqs = new NautHashMap(); + + public TeamSurvivalGames(ArcadeManager manager) + { + super(manager, GameType.SurvivalGamesTeams, + new String[] + { + "Search for chests to find loot", + "Slaughter your opponents", + "Stay away from the Deep Freeze!", + "Last team alive wins!" + }); + + this.PlayersPerTeam = 2; + this.FillTeamsInOrderToCount = 2; + + this.SpawnNearAllies = true; + this.SpawnNearEnemies = true; + + this.DamageTeamSelf = false; + + } + + @EventHandler + public void CustomTeamGeneration(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Recruit) + return; + + ArrayList spawns = this.GetTeamList().get(0).GetSpawns(); + this.GetTeamList().clear(); + + 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++) + { + //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); + } + } + } + + private enum TeamColors + { + + YELLOW(ChatColor.YELLOW, new String[]{"Bananna", "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; + } + + @Override + @EventHandler + public void ScoreboardUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + if (GetTeamList().isEmpty()) + return; + + Scoreboard.Reset(); + + Scoreboard.WriteBlank(); + + Scoreboard.Write(C.cGreen + C.Bold + "Time"); + Scoreboard.Write(UtilTime.convertString(this.getSecondsSinceStart() * 1000, 0, TimeUnit.FIT)); + + Scoreboard.WriteBlank(); + Scoreboard.Write(C.cYellow + C.Bold + "Teams"); + + ArrayList alive = new ArrayList(); + for (GameTeam team : GetTeamList()) + { + if (team.IsTeamAlive()) + alive.add(team); + } + + if (GetPlayers(true).size() <= 7) + { + for (GameTeam team : GetTeamList()) + { + for (Player player : team.GetPlayers(true)) + { + Scoreboard.Write(team.GetColor() + player.getName()); + } + } + } + else if (alive.size() <= 7) + { + for (GameTeam team : alive) + { + Scoreboard.Write(C.cWhite + team.GetPlayers(true).size() + " " + team.GetColor() + team.GetName()); + } + } + else + { + Scoreboard.Write(C.cWhite + alive.size() + " Alive"); + } + + Scoreboard.WriteBlank(); + + if (this.getChestRefillTime() > 0 && this.getDeathMatchTime() > 60) + { + Scoreboard.Write(C.cGold + C.Bold + "Chest Refill"); + Scoreboard.Write(UtilTime.convertString(this.getChestRefillTime() * 1000, 0, TimeUnit.FIT)); + } + else if (this.getDeathMatchTime() > 0) + { + Scoreboard.Write(C.cRed + C.Bold + "Deathmatch"); + Scoreboard.Write(UtilTime.convertString( + Math.min(this.getDeathMatchTime(), this.isDeathMatchTeleported() ? 10 : this.getDeathMatchTime()) * 1000, 0, TimeUnit.FIT)); + } + else + { + Scoreboard.Write(C.cRed + C.Bold + "Game End"); + Scoreboard.Write(UtilTime.convertString(Math.max(0, this.getGameEndTime()) * 1000, 0, TimeUnit.FIT)); + } + + Scoreboard.Draw(); + } + + @Override + public void EndCheck() + { + if (!IsLive()) + return; + + ArrayList teamsAlive = new ArrayList(); + + for (GameTeam team : this.GetTeamList()) + if (team.GetPlayers(true).size() > 0) + teamsAlive.add(team); + + if (teamsAlive.size() <= 1) + { + //Announce + if (teamsAlive.size() > 0) + AnnounceEnd(teamsAlive.get(0)); + + for (GameTeam team : GetTeamList()) + { + if (WinnerTeam != null && team.equals(WinnerTeam)) + { + for (Player player : team.GetPlayers(false)) + AddGems(player, 10, "Winning Team", false, false); + } + + for (Player player : team.GetPlayers(false)) + if (player.isOnline()) + AddGems(player, 10, "Participation", false, false); + } + + //End + SetState(GameState.End); + } + } + + @Override + public List getWinners() + { + if (WinnerTeam == null) + return null; + + return WinnerTeam.GetPlayers(false); + } + + @Override + public List getLosers() + { + if (WinnerTeam == null) + return null; + + List players = new ArrayList<>(); + + for (GameTeam team : GetTeamList()) + { + if (team != WinnerTeam) + players.addAll(team.GetPlayers(false)); + } + + return players; + } + + @Override + public boolean CanJoinTeam(GameTeam team) + { + return team.GetSize() < PlayersPerTeam; + } + + @EventHandler(priority = EventPriority.HIGH) + public void teamSelectInteract(PlayerInteractEntityEvent event) + { + if (GetState() != GameState.Recruit) + return; + + if (event.getRightClicked() == null) + return; + + if (!(event.getRightClicked() instanceof Player)) + return; + + Player player = event.getPlayer(); + + //Observer + if (Manager.IsObserver(player)) + { + UtilPlayer.message(player, F.main("Game", "Spectators cannot partake in games.")); + return; + } + + selectTeamMate(player, (Player)event.getRightClicked()); + } + + @EventHandler + public void teamSelectCommand(PlayerCommandPreprocessEvent event) + { + if (GetState() != GameState.Recruit) + return; + + if (!event.getMessage().toLowerCase().startsWith("/team ")) + return; + + event.setCancelled(true); + + Player target = UtilPlayer.searchOnline(event.getPlayer(), event.getMessage().split(" ")[1], true); + if (target == null) + return; + + //Observer + if (Manager.IsObserver(event.getPlayer())) + { + UtilPlayer.message(event.getPlayer(), F.main("Game", "Spectators cannot partake in games.")); + return; + } + + if (event.getPlayer().equals(target)) + return; + + selectTeamMate(event.getPlayer(), target); + } + + public void selectTeamMate(Player player, Player ally) + { + //Accept Invite + if (_teamReqs.containsKey(ally) && _teamReqs.get(ally).equals(player)) + { + //Remove Prefs + _teamReqs.remove(player); + _teamReqs.remove(ally); + + //Inform + UtilPlayer.message(player, F.main("Game", "You accepted " + ally.getName() + "'s Team Request!")); + UtilPlayer.message(ally, F.main("Game", player.getName() + " accepted your Team Request!")); + + //Leave Old Teams + if (GetTeam(player) != null) + GetTeam(player).DisbandTeam(); + + if (GetTeam(ally) != null) + GetTeam(ally).DisbandTeam(); + + //Get Team + GameTeam team = getEmptyTeam(); + if (team == null) + return; + + //Join Team + SetPlayerTeam(player, team, true); + SetPlayerTeam(ally, team, true); + } + //Send Invite + else + { + //Already on Team with Target + if (GetTeam(player) != null) + if (GetTeam(player).HasPlayer(ally)) + return; + + //Inform Player + UtilPlayer.message(player, F.main("Game", "You sent a Team Request to " + ally.getName() + "!")); + + //Inform Target + if (Recharge.Instance.use(player, "Team Req " + ally.getName(), 2000, false, false)) + { + UtilPlayer.message(ally, F.main("Game", player.getName() + " sent you a Team Request!")); + UtilPlayer.message(ally, F.main("Game", "Type " + F.elem("/team " + player.getName()) + " to accept!")); + } + + //Add Pref + _teamReqs.put(player, ally); + } + } + + @EventHandler + public void teamQuit(PlayerQuitEvent event) + { + if (GetState() != GameState.Recruit) + return; + + Player player = event.getPlayer(); + + if (GetTeam(player) != null) + GetTeam(player).DisbandTeam(); + + Iterator teamIter = _teamReqs.keySet().iterator(); + while (teamIter.hasNext()) + { + Player sender = teamIter.next(); + if (sender.equals(player) || _teamReqs.get(sender).equals(player)) + teamIter.remove(); + } + } + + public GameTeam getEmptyTeam() + { + for (GameTeam team : GetTeamList()) + { + if (team.GetPlayers(false).isEmpty()) + return team; + } + + return null; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameCreationManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameCreationManager.java index 401309e95..955a6e8f8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameCreationManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameCreationManager.java @@ -37,6 +37,7 @@ public class GameCreationManager implements Listener private ArrayList _lastGames = new ArrayList(); public String MapPref = null; + public String MapSource = null; public GameCreationManager(ArcadeManager manager) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLobbyManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLobbyManager.java index 47879e6e5..b7246e6f5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLobbyManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLobbyManager.java @@ -185,13 +185,20 @@ public class GameLobbyManager implements Listener, IPacketHandler { for (GameTeam team : Manager.GetGame().GetTeamList()) { - if (rank == Rank.ALL) + if(team.GetDisplaytag()) { - scoreboard.registerNewTeam(rank.Name + team.GetName().toUpperCase()).setPrefix(team.GetColor() + ""); + scoreboard.registerNewTeam(rank.Name + team.GetName().toUpperCase()).setPrefix(team.GetColor() + C.Bold + team.GetName() + team.GetColor() + " "); } - else + else { - scoreboard.registerNewTeam(rank.Name + team.GetName().toUpperCase()).setPrefix(rank.GetTag(true, true) + ChatColor.RESET + " " + team.GetColor()); + if (rank == Rank.ALL) + { + scoreboard.registerNewTeam(rank.Name + team.GetName().toUpperCase()).setPrefix(team.GetColor() + ""); + } + else + { + scoreboard.registerNewTeam(rank.Name + team.GetName().toUpperCase()).setPrefix(rank.GetTag(true, true) + ChatColor.RESET + " " + team.GetColor()); + } } } } @@ -323,7 +330,7 @@ public class GameLobbyManager implements Listener, IPacketHandler _teamBlocks.clear(); //Smash - if (game.GetType() == GameType.Smash || game.GetType() == GameType.SurvivalGames) + if (game.HideTeamSheep) { //Text WriteTeamLine("Select", 0, 159, (byte)15); @@ -332,60 +339,9 @@ public class GameLobbyManager implements Listener, IPacketHandler CreateScoreboards(); return; } - - //UHC - if (game.GetType() == GameType.UHC) - { -// if (game.GetTeamList().size() > 1) -// { -// //Text -// WriteTeamLine("", 0, 159, (byte)15); -// WriteTeamLine("", 1, 159, (byte)4); -// -// for (int i=0 ; i 1 || game.GetTeamList().size() < 6) + if ((game.GetKits().length > 1 || game.GetTeamList().size() < 6) && game.GetType() != GameType.SurvivalGamesTeams) { //Display ArrayList teams = new ArrayList(); @@ -558,7 +514,7 @@ public class GameLobbyManager implements Listener, IPacketHandler } //Smash - if (game.GetType() == GameType.Smash || game.GetType() == GameType.SurvivalGames) + if (game.ReplaceTeamsWithKits) { // WriteKitLine("Free", 0, 159, (byte)15); // WriteKitLine("Kits", 1, 159, (byte)4); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/scoreboard/GameScoreboard.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/scoreboard/GameScoreboard.java index 57524278e..bf6e1036c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/scoreboard/GameScoreboard.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/scoreboard/GameScoreboard.java @@ -124,7 +124,14 @@ public class GameScoreboard for (GameTeam team : Game.GetTeamList()) { System.out.println("Scoreboard Team: " + team.GetName().toUpperCase()); - _scoreboard.registerNewTeam(ParseTeamName(team.GetName().toUpperCase())).setPrefix(team.GetColor() + ""); + if(team.GetDisplaytag()) + { + _scoreboard.registerNewTeam(ParseTeamName(team.GetName().toUpperCase())).setPrefix(team.GetColor() + C.Bold + team.GetName() + team.GetColor() + " "); + } + else + { + _scoreboard.registerNewTeam(ParseTeamName(team.GetName().toUpperCase())).setPrefix(team.GetColor() + ""); + } } /* diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/world/WorldData.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/world/WorldData.java index 1f2a1c78c..1bb5955e0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/world/WorldData.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/world/WorldData.java @@ -16,6 +16,7 @@ import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.WorldUtil; import mineplex.core.common.util.ZipUtil; import mineplex.core.timing.TimingManager; +import nautilus.game.arcade.GameType; import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.games.uhc.UHC; import net.minecraft.server.v1_7_R4.ChunkPreLoadEvent; @@ -50,6 +51,8 @@ public class WorldData public String MapName = "Null"; public String MapAuthor = "Null"; + public GameType Game = null; + public HashMap> SpawnLocs = new HashMap>(); private HashMap> DataLocs = new HashMap>(); private HashMap> CustomLocs = new HashMap>(); @@ -67,6 +70,7 @@ public class WorldData public void Initialize() { final WorldData worldData = this; + GetFile(); UtilServer.getServer().getScheduler().runTaskAsynchronously(Host.Manager.getPlugin(), new Runnable() { @@ -121,18 +125,50 @@ public class WorldData }); } + protected GameType GetGame() + { + return Game; + } + protected String GetFile() { if (File == null) { - File = Host.GetFiles().get(UtilMath.r(Host.GetFiles().size())); + GameType game = null; + int gameRandom = UtilMath.r(Host.GetFiles().size()); + int i = 0; + for(GameType type : Host.GetFiles().keySet()) + { + if(i == gameRandom) + { + game = type; + break; + } + i++; + } + Game = game; + int map = UtilMath.r(Host.GetFiles().get(game).size()); + File = Host.GetFiles().get(game).get(map); //Don't allow repeat maps. if (Host.GetFiles().size() > 1) { while (File.equals(Host.Manager.GetGameCreationManager().GetLastMap())) { - File = Host.GetFiles().get(UtilMath.r(Host.GetFiles().size())); + GameType _game = null; + int _gameRandom = UtilMath.r(Host.GetFiles().size()); + int _i = 0; + for(GameType _type : Host.GetFiles().keySet()) + { + if(_i == _gameRandom) + { + _game = _type; + break; + } + _i++; + } + int _map = UtilMath.r(Host.GetFiles().get(game).size()); + File = Host.GetFiles().get(_game).get(_map); } } } @@ -144,9 +180,10 @@ public class WorldData public String GetFolder() { - if (Folder == null) - Folder = "Game" + Id + "_" + Host.GetName() + "_" + GetFile(); - + if (Folder == null) + { + Folder = "Game" + Id + "_" + GetGame().GetName() + "_" + GetFile(); + } return Folder; } @@ -160,7 +197,7 @@ public class WorldData TimingManager.stop("UnzipWorld creating folders"); TimingManager.start("UnzipWorld UnzipToDirectory"); - ZipUtil.UnzipToDirectory("../../update/maps/" + Host.GetName() + "/" + GetFile() + ".zip", folder); + ZipUtil.UnzipToDirectory("../../update/maps/" + GetGame().GetName() + "/" + GetFile() + ".zip", folder); TimingManager.stop("UnzipWorld UnzipToDirectory"); } @@ -523,4 +560,5 @@ public class WorldData { return _dataEntries.get(key); } + }