diff options
Diffstat (limited to 'src/main/java/com/MylesAndMore/tumble/commands/StartGame.java')
-rw-r--r-- | src/main/java/com/MylesAndMore/tumble/commands/StartGame.java | 74 |
1 files changed, 40 insertions, 34 deletions
diff --git a/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java b/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java index 46ca6ce..d488fec 100644 --- a/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java +++ b/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java @@ -20,48 +20,54 @@ public class StartGame implements CommandExecutor { if (TumbleManager.getPlayersInLobby().size() > 0) { // Check if there is a gameWorld specified in config if (TumbleManager.getGameWorld() != null) { - sender.sendMessage(ChatColor.BLUE + "Starting game, please wait."); - // Use multiverse to load game world - // If the load was successful, start game - if (TumbleManager.getMVWorldManager().loadWorld(TumbleManager.getGameWorld())) { - // If there is no starting argument, - if (args.length == 0) { - // pull which gamemode to initiate from the config file - if (!Game.getGame().startGame(TumbleManager.getGameType())) { - // Sender feedback for if the game failed to start - if (Objects.equals(Game.getGame().getGameState(), "starting")) { - sender.sendMessage(ChatColor.RED + "A game is already starting!"); + // Check if a game is already pending to start + if (!Objects.equals(Game.getGame().getGameState(), "waiting")) { + sender.sendMessage(ChatColor.BLUE + "Starting game, please wait."); + // Use multiverse to load game world + // If the load was successful, start game + if (TumbleManager.getMVWorldManager().loadWorld(TumbleManager.getGameWorld())) { + // If there is no starting argument, + if (args.length == 0) { + // pull which gamemode to initiate from the config file + if (!Game.getGame().startGame(TumbleManager.getGameType())) { + // Sender feedback for if the game failed to start + if (Objects.equals(Game.getGame().getGameState(), "starting")) { + sender.sendMessage(ChatColor.RED + "A game is already starting!"); + } + else if (Objects.equals(Game.getGame().getGameState(), "running")) { + sender.sendMessage(ChatColor.RED + "A game is already running!"); + } + else { + sender.sendMessage(ChatColor.RED + "Failed to recognize game of type " + ChatColor.GRAY + TumbleManager.getPlugin().getConfig().getString("gameMode")); + } } - else if (Objects.equals(Game.getGame().getGameState(), "running")) { - sender.sendMessage(ChatColor.RED + "A game is already running!"); - } - else { - sender.sendMessage(ChatColor.RED + "Failed to recognize game of type " + ChatColor.GRAY + TumbleManager.getPlugin().getConfig().getString("gameMode")); + } + // If there was an argument for gameType, pass that into the startGame method + else { + if (!Game.getGame().startGame(args[0])) { + // Sender feedback for if the game failed to start + if (Objects.equals(Game.getGame().getGameState(), "starting")) { + sender.sendMessage(ChatColor.RED + "A game is already starting!"); + } + else if (Objects.equals(Game.getGame().getGameState(), "running")) { + sender.sendMessage(ChatColor.RED + "A game is already running!"); + } + else { + sender.sendMessage(ChatColor.RED + "Failed to recognize game of type " + ChatColor.GRAY + args[0]); + } } } } - // If there was an argument for gameType, pass that into the startGame method + // If load was unsuccessful, give feedback + // Note: this should not occur unless the config file was edited externally, + // because the plugin prevents adding "worlds" that are not actually present to the config. else { - if (!Game.getGame().startGame(args[0])) { - // Sender feedback for if the game failed to start - if (Objects.equals(Game.getGame().getGameState(), "starting")) { - sender.sendMessage(ChatColor.RED + "A game is already starting!"); - } - else if (Objects.equals(Game.getGame().getGameState(), "running")) { - sender.sendMessage(ChatColor.RED + "A game is already running!"); - } - else { - sender.sendMessage(ChatColor.RED + "Failed to recognize game of type " + ChatColor.GRAY + args[0]); - } - } + sender.sendMessage(ChatColor.RED + "Failed to find a world named " + ChatColor.GRAY + TumbleManager.getGameWorld()); + sender.sendMessage(ChatColor.RED + "Is the configuration file correct?"); } } - // If load was unsuccessful, give feedback - // Note: this should not occur unless the config file was edited externally, - // because the plugin prevents adding "worlds" that are not actually present to the config. else { - sender.sendMessage(ChatColor.RED + "Failed to find a world named " + ChatColor.GRAY + TumbleManager.getGameWorld()); - sender.sendMessage(ChatColor.RED + "Is the configuration file correct?"); + sender.sendMessage(ChatColor.RED + "A game is already queued to begin!"); } } // Feedback for if there is no gameWorld in the config |