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 57b22fcc4..765ff2f00 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 @@ -1364,7 +1364,7 @@ public abstract class Game extends ListenerComponent implements Lifetimed UtilPlayer.message(player, ArcadeFormat.Line); - UtilPlayer.message(player, C.cGreen + "Game - " + C.cWhiteB + GetName()); + UtilPlayer.message(player, C.cGreen + "Game - " + C.cYellowB + GetName()); UtilPlayer.message(player, ""); for (String line : this.GetDesc()) @@ -1434,7 +1434,7 @@ public abstract class Game extends ListenerComponent implements Lifetimed UtilPlayer.message(player, ""); UtilPlayer.message(player, ArcadeFormat.Line); - UtilPlayer.message(player, "§aGame - §f§l" + this.GetName()); + UtilPlayer.message(player, C.cGreen + "Game - " + C.cYellowB + GetName()); UtilPlayer.message(player, ""); UtilPlayer.message(player, ""); @@ -1507,7 +1507,7 @@ public abstract class Game extends ListenerComponent implements Lifetimed UtilPlayer.message(player, ""); UtilPlayer.message(player, ArcadeFormat.Line); - UtilPlayer.message(player, "§aGame - §f§l" + this.GetName()); + UtilPlayer.message(player, C.cGreen + "Game - " + C.cYellowB + GetName()); UtilPlayer.message(player, ""); if (places == null || places.isEmpty()) 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 67c63e135..af74cb497 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 @@ -81,6 +81,8 @@ public class GameCreationManager implements Listener createGame(); } + checkMapVoting(); + //Archive Game if (Manager.GetGame() != null && Manager.GetGame().GetState() == GameState.Dead) { @@ -176,7 +178,7 @@ public class GameCreationManager implements Listener _votingManager.updateMapRatings(); _votingManager.deactivate(); } - else if (_votingManager.isVoteInProgress()) + else if (_votingManager.isVoteBlocking()) { return; } @@ -242,20 +244,6 @@ public class GameCreationManager implements Listener Class gameClass = gameType.getGameClass(); - // If map voting and ONLY map voting is enabled - // Also need to make sure a map and game haven't been selected by /game set beforehand - if (MapPref == null && _nextGame == null && Manager.GetServerConfig().MapVoting && !Manager.GetServerConfig().GameVoting) - { - if (!_votingManager.canStartVote()) - { - return; - } - - _nextGame = gameType; - _votingManager.callVote(new MapVote(Manager, gameType, getMapsToVote(gameType))); - return; - } - _nextGame = null; //Reset Changes @@ -299,12 +287,22 @@ public class GameCreationManager implements Listener try { - // Maps - loadMaps(gameType); + // No map voting, load the maps now + boolean loadMapsNow = !Manager.GetServerConfig().MapVoting; + + if (loadMapsNow) + { + loadMaps(gameType); + } // Create Game instance Game game = gameClass.getConstructor(ArcadeManager.class).newInstance(Manager); + if (loadMapsNow) + { + game.WorldData.Initialize(); + } + Manager.SetGame(game); } catch (NoSuchMethodException ex) @@ -338,6 +336,32 @@ public class GameCreationManager implements Listener TimingManager.stop("registerEvents"); } + private void checkMapVoting() + { + Game game = Manager.GetGame(); + + if (game == null || MapPref != null || !Manager.GetServerConfig().MapVoting || Manager.GetServerConfig().GameVoting) + { + return; + } + + if (_votingManager.getFinishedVote() != null) + { + MapPref = _votingManager.getFinishedVote().getWinner().getName(); + _votingManager.deactivate(); + + // Load maps for the running game + loadMaps(game.GetType()); + + // Load the world data + game.WorldData.Initialize(); + } + else if (!_votingManager.isVoteInProgress() && _votingManager.canStartVote()) + { + _votingManager.callVote(new MapVote(Manager, game.GetType(), getMapsToVote(game.GetType()))); + } + } + private void loadMaps(GameType gameType) { _maps = new HashMap<>(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/lobby/LobbyManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/lobby/LobbyManager.java index 485cdc1f1..3be5f0227 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/lobby/LobbyManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/lobby/LobbyManager.java @@ -724,12 +724,26 @@ public abstract class LobbyManager implements Listener @EventHandler public void eqiupKitOnJoin(PlayerJoinEvent event) { - if (_manager.GetGame() == null) + Game game = _manager.GetGame(); + + if (game == null) { return; } - equipActiveKit(event.getPlayer()); + Player player = event.getPlayer(); + + if (game.InProgress()) + { + GameTeam team = game.GetTeam(player); + + if (team == null || !team.IsAlive(player)) + { + return; + } + } + + equipActiveKit(player); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/voting/Vote.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/voting/Vote.java index 1d7e89b24..6aabf24dc 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/voting/Vote.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/voting/Vote.java @@ -59,6 +59,8 @@ public abstract class Vote public abstract List getMapRatings(); + public abstract boolean isBlocking(); + public void vote(Player player, T value) { if (value == null) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/voting/VotingManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/voting/VotingManager.java index 96826433a..4bf0c5421 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/voting/VotingManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/voting/VotingManager.java @@ -254,6 +254,11 @@ public class VotingManager extends ListenerComponent implements Lifetimed return _currentVote != null; } + public boolean isVoteBlocking() + { + return isVoteInProgress() && getCurrentVote().isBlocking(); + } + public boolean canStartVote() { if (_manager.getValidPlayersForGameStart().size() < _manager.GetPlayerMin()) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/voting/types/GameVote.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/voting/types/GameVote.java index 90b79fdb0..f5dafb314 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/voting/types/GameVote.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/voting/types/GameVote.java @@ -113,6 +113,12 @@ public class GameVote extends Vote return _winningMapVote.getMapRatings(); } + @Override + public boolean isBlocking() + { + return true; + } + public MapVote getWinningMapVote() { return _winningMapVote; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/voting/types/MapVote.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/voting/types/MapVote.java index 7795e235b..7cfa50d7c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/voting/types/MapVote.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/voting/types/MapVote.java @@ -63,4 +63,10 @@ public class MapVote extends Vote .map(votableMap -> new VoteRating(_gameType.getGameId(), votableMap.getDisplayName(), winner.equals(votableMap) ? ratingWin : ratingLose)) .collect(Collectors.toList()); } + + @Override + public boolean isBlocking() + { + return false; + } } 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 4c93332f1..6bbd1c2de 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 @@ -64,8 +64,6 @@ public class WorldData { Host = game; Id = GetNewId(); - - Initialize(); } public void Initialize()