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 f02cf0d08..f38aace98 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java @@ -1,5 +1,7 @@ package nautilus.game.arcade; +import java.util.Arrays; + import mineplex.core.game.GameCategory; import mineplex.core.game.GameDisplay; import nautilus.game.arcade.game.Game; @@ -99,7 +101,7 @@ public enum GameType Smash(SoloSuperSmash.class, GameDisplay.Smash), SmashDomination(SuperSmashDominate.class, GameDisplay.SmashDomination), - SmashTeams(TeamSuperSmash.class, GameDisplay.SmashTeams, GameType.Smash), + 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,7 +110,7 @@ public enum GameType SquidShooter(SquidShooter.class, GameDisplay.SquidShooter), Stacker(Stacker.class, GameDisplay.Stacker), SurvivalGames(SoloSurvivalGames.class, GameDisplay.SurvivalGames), - SurvivalGamesTeams(TeamSurvivalGames.class, GameDisplay.SurvivalGamesTeams, GameType.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), @@ -119,13 +121,24 @@ public enum GameType Build(Build.class, GameDisplay.Build), Cards(Cards.class, GameDisplay.Cards), Skywars(SoloSkywars.class, GameDisplay.Skywars), - SkywarsTeams(TeamSkywars.class, GameDisplay.SkywarsTeams, GameType.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; + GameType[] _mapSource; + boolean _ownMaps; String _resourcePack; Class _gameClass; @@ -134,28 +147,29 @@ public enum GameType GameType(Class gameClass, GameDisplay display) { - this(gameClass, display, null, false, null); + this(gameClass, display, null, false, null, true); } GameType(Class gameClass, GameDisplay display, String resourcePackUrl, boolean enforceResourcePack) { - this(gameClass, display, resourcePackUrl, enforceResourcePack, null); + this(gameClass, display, resourcePackUrl, enforceResourcePack, null, true); } - GameType(Class gameClass, GameDisplay display, GameType mapSource) + GameType(Class gameClass, GameDisplay display, GameType[] mapSource, boolean ownMap) { - this(gameClass, display, null, false, mapSource); + this(gameClass, display, null, false, mapSource, ownMap); } - GameType(Class gameClass, GameDisplay display, String resourcePackUrl, boolean enforceResourcePack, GameType mapSource) + 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; @@ -171,10 +185,15 @@ public enum GameType return _resourcePack; } - public GameType getMapSource() + public GameType[] getMapSource() { return _mapSource; } + + public boolean ownMaps() + { + return _ownMaps; + } public String GetName() { @@ -200,4 +219,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 ec1eb238f..a341ddc18 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 7db88b496..9460da68a 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 0c7ce873d..7a413d04a 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; @@ -281,16 +281,28 @@ public abstract class Game implements Listener Scoreboard = new GameScoreboard(this); //Map Select - _files = Manager.LoadFiles(GetWorldHostName()); + _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 +310,7 @@ public abstract class Game implements Listener _files = matches; Manager.GetGameCreationManager().MapPref = null; + Manager.GetGameCreationManager().MapSource = null; } WorldData = new WorldData(this); @@ -332,7 +345,7 @@ public abstract class Game implements Listener _kits = kits; } - public ArrayList GetFiles() + public HashMap> GetFiles() { return _files; } @@ -342,15 +355,59 @@ public abstract class Game implements Listener return _gameType.GetName(); } - public String GetWorldHostName() + public GameType[] GetWorldHostNames() { - String mapSource = GetName(); + GameType[] mapSource = new GameType[]{GetType()}; if(GetType().getMapSource() != null) { - mapSource = GetType().getMapSource().GetName(); + 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() { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/TeamSkywars.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/TeamSkywars.java index 3be8754db..3a372bdd5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/TeamSkywars.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/skywars/TeamSkywars.java @@ -12,7 +12,6 @@ import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.GameTeam; -import nautilus.game.arcade.game.games.smash.TeamSuperSmash.TeamColors; import org.bukkit.ChatColor; import org.bukkit.Location; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/TeamSuperSmash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/TeamSuperSmash.java index a0a690ba1..8da1dd80b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/TeamSuperSmash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/TeamSuperSmash.java @@ -9,7 +9,6 @@ import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.GameTeam; -import nautilus.game.arcade.game.games.skywars.TeamSkywars.TeamColors; import org.bukkit.ChatColor; import org.bukkit.Location; 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..812aa7757 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 @@ -36,6 +36,7 @@ public class GameCreationManager implements Listener private String _lastMap = ""; private ArrayList _lastGames = new ArrayList(); + public String MapSource = null; public String MapPref = null; public GameCreationManager(ArcadeManager manager) 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 a416be365..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); } } } @@ -146,7 +182,7 @@ public class WorldData { if (Folder == null) { - Folder = "Game" + Id + "_" + Host.GetWorldHostName() + "_" + GetFile(); + Folder = "Game" + Id + "_" + GetGame().GetName() + "_" + GetFile(); } return Folder; } @@ -161,7 +197,7 @@ public class WorldData TimingManager.stop("UnzipWorld creating folders"); TimingManager.start("UnzipWorld UnzipToDirectory"); - ZipUtil.UnzipToDirectory("../../update/maps/" + Host.GetWorldHostName() + "/" + GetFile() + ".zip", folder); + ZipUtil.UnzipToDirectory("../../update/maps/" + GetGame().GetName() + "/" + GetFile() + ".zip", folder); TimingManager.stop("UnzipWorld UnzipToDirectory"); }