diff options
| author | Myles <mylesandmore9@gmail.com> | 2022-11-27 17:44:59 -0600 | 
|---|---|---|
| committer | Myles <mylesandmore9@gmail.com> | 2022-11-27 17:44:59 -0600 | 
| commit | 69b34776f33056febf7817188f4fe72aa9470e49 (patch) | |
| tree | 86016660ecf57c1f885633208a9dde364f518b6d /src/main/java | |
| parent | e0da8c48cc4fdc2c318e7aa26508ace144379e6e (diff) | |
| download | Tumble-69b34776f33056febf7817188f4fe72aa9470e49.tar.gz Tumble-69b34776f33056febf7817188f4fe72aa9470e49.tar.bz2 Tumble-69b34776f33056febf7817188f4fe72aa9470e49.zip  | |
reformat StartGame and integrate with GameManager
Diffstat (limited to '')
| -rw-r--r-- | src/main/java/com/MylesAndMore/tumble/commands/StartGame.java | 45 | 
1 files changed, 29 insertions, 16 deletions
diff --git a/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java b/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java index fd0b825..de82e09 100644 --- a/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java +++ b/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java @@ -1,5 +1,6 @@  package com.MylesAndMore.tumble.commands; +import com.MylesAndMore.tumble.GameManager;  import com.MylesAndMore.tumble.TumbleManager;  import org.bukkit.Bukkit;  import org.bukkit.ChatColor; @@ -9,6 +10,7 @@ import org.bukkit.command.CommandSender;  import org.bukkit.entity.Player;  import java.util.List; +import java.util.Objects;  public class StartGame implements CommandExecutor {      // Define the startGame method so that other classes can refrence it @@ -26,23 +28,16 @@ public class StartGame implements CommandExecutor {                          // If the load was successful, start game                          if (TumbleManager.getMVWorldManager().loadWorld(TumbleManager.getGameWorld())) {                              sender.sendMessage("Starting game, please wait."); - -                            // Generate the blocks in game world - - -                            // While there are still players in the lobby, send them to the gameWorld -                            // This is just a way of sending everybody in the lobby to the game -                            for (List<Player> playersInLobby = TumbleManager.getPlayersInLobby(); playersInLobby.size() > 0; playersInLobby = TumbleManager.getPlayersInLobby()) { -                                // Get a singular player from the player list -                                Player aPlayer = playersInLobby.get(0); -                                // Teleport that player to the spawn of the gameWorld -                                aPlayer.teleport(Bukkit.getWorld(TumbleManager.getGameWorld()).getSpawnLocation()); +                            // Check which gamemode to initiate from the config file +                            if (GameManager.createGame(TumbleManager.getPlugin().getConfig().getString("gameMode"))) { +                                // If game type exists, send players to the world +                                // At this point, layers have been generated, and items have been allotted from the createGame method +                                sendWorld(); +                            } +                            else { +                                // If game type does not exist, give sender feedback +                                sender.sendMessage(ChatColor.RED + "Failed to recognize game of type " + ChatColor.GRAY + TumbleManager.getPlugin().getConfig().getString("gameMode"));                              } - -                            // Give players game item (shovels/snowballs/etc.) - -                            // Add a little break because it can take the clients a bit to load into the new world -                            // Then, transition to another method because this one is getting really long                          }                          // If load was unsuccessful, give feedback                          // Note: this should not occur unless the config file was edited externally, @@ -72,6 +67,24 @@ public class StartGame implements CommandExecutor {          }      } +    public void sendWorld() { +        // Create Locations to scatter players around the first layer + +        // While there are still players in the lobby, send them to the gameWorld +        // This is just a way of sending everybody in the lobby to the game +        for (List<Player> playersInLobby = TumbleManager.getPlayersInLobby(); playersInLobby.size() > 0; playersInLobby = TumbleManager.getPlayersInLobby()) { +            // Get a singular player from the player list +            Player aPlayer = playersInLobby.get(0); +            // Teleport that player to the spawn of the gameWorld +            aPlayer.teleport(Bukkit.getWorld(TumbleManager.getGameWorld()).getSpawnLocation()); +        } + +        // Add a little break because it can take the clients a bit to load into the new world +        // Then, transition to another method because this one is getting really long +        // In that method: set a flag to monitor the playerDeathEvent so we know when all the players have died +        // Also start music +    } +      @Override      public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {          startGame(sender, args);  | 
