aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java
diff options
context:
space:
mode:
authorMyles <mylesandmore9@gmail.com>2022-12-07 21:54:26 -0600
committerMyles <mylesandmore9@gmail.com>2022-12-07 21:54:26 -0600
commit102627d4b28589676ddccc359a9ecd0dffa13f85 (patch)
tree87d30fa50159732410155e1d3ab938e9764219d3 /src/main/java/com/MylesAndMore/tumble/commands/StartGame.java
parent777f510256896bbf7cd73b6da7109b875ef6218e (diff)
downloadTumble-102627d4b28589676ddccc359a9ecd0dffa13f85.tar.gz
Tumble-102627d4b28589676ddccc359a9ecd0dffa13f85.tar.bz2
Tumble-102627d4b28589676ddccc359a9ecd0dffa13f85.zip
rewrite basically an entire method (rip my sanity)
you can now specify what type of game in the cmd and not just the config file (although the config file still works) but now testing should be easier! and also flexibility is cool I wonder how many bugs this will cause in the future...
Diffstat (limited to 'src/main/java/com/MylesAndMore/tumble/commands/StartGame.java')
-rw-r--r--src/main/java/com/MylesAndMore/tumble/commands/StartGame.java40
1 files changed, 29 insertions, 11 deletions
diff --git a/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java b/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java
index 315219a..17d2a34 100644
--- a/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java
+++ b/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java
@@ -19,21 +19,39 @@ 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())) {
- // Check which gamemode to initiate from the config file
- if (!Game.getGame().startGame()) {
- sender.sendMessage(ChatColor.BLUE + "Starting game, please wait.");
- // 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!");
+ // 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]);
+ }
}
}
}