Improving Map System: GameTypes can have more mapSources now.
This commit is contained in:
parent
2b10aa2cf9
commit
3a2011ee6a
@ -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<? extends Game> _gameClass;
|
||||
|
||||
@ -134,26 +147,27 @@ public enum GameType
|
||||
|
||||
GameType(Class<? extends Game> gameClass, GameDisplay display)
|
||||
{
|
||||
this(gameClass, display, null, false, null);
|
||||
this(gameClass, display, null, false, null, true);
|
||||
}
|
||||
|
||||
GameType(Class<? extends Game> gameClass, GameDisplay display, String resourcePackUrl, boolean enforceResourcePack)
|
||||
{
|
||||
this(gameClass, display, resourcePackUrl, enforceResourcePack, null);
|
||||
this(gameClass, display, resourcePackUrl, enforceResourcePack, null, true);
|
||||
}
|
||||
|
||||
GameType(Class<? extends Game> gameClass, GameDisplay display, GameType mapSource)
|
||||
GameType(Class<? extends Game> gameClass, GameDisplay display, GameType[] mapSource, boolean ownMap)
|
||||
{
|
||||
this(gameClass, display, null, false, mapSource);
|
||||
this(gameClass, display, null, false, mapSource, ownMap);
|
||||
}
|
||||
|
||||
GameType(Class<? extends Game> gameClass, GameDisplay display, String resourcePackUrl, boolean enforceResourcePack, GameType mapSource)
|
||||
GameType(Class<? extends Game> 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<? extends Game> getGameClass()
|
||||
@ -171,11 +185,16 @@ public enum GameType
|
||||
return _resourcePack;
|
||||
}
|
||||
|
||||
public GameType getMapSource()
|
||||
public GameType[] getMapSource()
|
||||
{
|
||||
return _mapSource;
|
||||
}
|
||||
|
||||
public boolean ownMaps()
|
||||
{
|
||||
return _ownMaps;
|
||||
}
|
||||
|
||||
public String GetName()
|
||||
{
|
||||
return _display.getName();
|
||||
@ -200,4 +219,5 @@ public enum GameType
|
||||
{
|
||||
return _display.getGameCategory();
|
||||
}
|
||||
|
||||
}
|
@ -25,7 +25,7 @@ public class GameCommand extends MultiCommandBase<ArcadeManager>
|
||||
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 <GameType> (Map)", "Set the current game or next game", Rank.ADMIN));
|
||||
UtilPlayer.message(caller, F.help("/game set <GameType> (MapSource) (Map)", "Set the current game or next game", Rank.ADMIN));
|
||||
UtilPlayer.message(caller, F.main("Tip", "Use TAB for games/maps!"));
|
||||
}
|
||||
}
|
||||
|
@ -29,16 +29,31 @@ public class SetCommand extends CommandBase<ArcadeManager>
|
||||
|
||||
if (args == null || args.length == 0)
|
||||
{
|
||||
caller.sendMessage(F.help("/game set <GameType> (Map)", "Set the current game or next game", Rank.ADMIN));
|
||||
caller.sendMessage(F.help("/game set <GameType> (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
|
||||
|
@ -86,7 +86,7 @@ public abstract class Game implements Listener
|
||||
protected String[] _gameDesc;
|
||||
|
||||
//Map
|
||||
private ArrayList<String> _files;
|
||||
private HashMap<GameType, ArrayList<String>> _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<GameType, ArrayList<String>>();
|
||||
for(GameType type : GetWorldHostNames())
|
||||
{
|
||||
_files.put(type, Manager.LoadFiles(type.GetName()));
|
||||
}
|
||||
if (Manager.GetGameCreationManager().MapPref != null)
|
||||
{
|
||||
ArrayList<String> matches = new ArrayList<String>();
|
||||
for (String cur : _files)
|
||||
HashMap<GameType, ArrayList<String>> matches = new HashMap<GameType, ArrayList<String>>();
|
||||
for (GameType game : _files.keySet())
|
||||
{
|
||||
if (cur.toLowerCase().contains(Manager.GetGameCreationManager().MapPref.toLowerCase()))
|
||||
ArrayList<String> list = new ArrayList<String>();
|
||||
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<String> GetFiles()
|
||||
public HashMap<GameType, ArrayList<String>> GetFiles()
|
||||
{
|
||||
return _files;
|
||||
}
|
||||
@ -342,16 +355,60 @@ 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<String> maps)
|
||||
{
|
||||
for(GameType game : _files.keySet())
|
||||
{
|
||||
if(maps.equals(_files.get(game)))
|
||||
{
|
||||
return game;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String GetMode()
|
||||
{
|
||||
return null;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -36,6 +36,7 @@ public class GameCreationManager implements Listener
|
||||
private String _lastMap = "";
|
||||
private ArrayList<GameType> _lastGames = new ArrayList<GameType>();
|
||||
|
||||
public String MapSource = null;
|
||||
public String MapPref = null;
|
||||
|
||||
public GameCreationManager(ArcadeManager manager)
|
||||
|
@ -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<String, ArrayList<Location>> SpawnLocs = new HashMap<String, ArrayList<Location>>();
|
||||
private HashMap<String, ArrayList<Location>> DataLocs = new HashMap<String, ArrayList<Location>>();
|
||||
private HashMap<String, ArrayList<Location>> CustomLocs = new HashMap<String, ArrayList<Location>>();
|
||||
@ -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");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user