From 23531b7610aa1a8a10cce2a355ad0fad76d8d230 Mon Sep 17 00:00:00 2001 From: Myles Date: Fri, 2 Dec 2022 23:30:04 -0600 Subject: slight reformat in StartGame for the Game management refactors --- src/main/java/com/MylesAndMore/tumble/commands/StartGame.java | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'src/main/java/com/MylesAndMore/tumble/commands/StartGame.java') diff --git a/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java b/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java index 9daa959..df5f316 100644 --- a/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java +++ b/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java @@ -1,6 +1,6 @@ package com.MylesAndMore.tumble.commands; -import com.MylesAndMore.tumble.GameManager; +import com.MylesAndMore.tumble.Game; import com.MylesAndMore.tumble.TumbleManager; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -19,7 +19,7 @@ public class StartGame implements CommandExecutor { // Check if there is a lobbyWorld specified in config if (TumbleManager.getLobbyWorld() != null) { // Check if there is more than one person in lobby - if (TumbleManager.getPlayersInLobby().size() > 1) { + if (TumbleManager.getPlayersInLobby().size() > 0) { // Check if there is a gameWorld specified in config if (TumbleManager.getGameWorld() != null) { sender.sendMessage("Checking world, this could take a few moments..."); @@ -28,12 +28,7 @@ public class StartGame implements CommandExecutor { if (TumbleManager.getMVWorldManager().loadWorld(TumbleManager.getGameWorld())) { sender.sendMessage("Generating layers..."); // 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.getGame().startGame()) { // 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")); } -- cgit v1.2.3 From dfe8b42a59c4c088d53447af2eef2b71792554b9 Mon Sep 17 00:00:00 2001 From: Myles Date: Sat, 3 Dec 2022 14:12:14 -0600 Subject: slight change to start message --- src/main/java/com/MylesAndMore/tumble/commands/StartGame.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/main/java/com/MylesAndMore/tumble/commands/StartGame.java') diff --git a/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java b/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java index df5f316..aad4b9e 100644 --- a/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java +++ b/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java @@ -22,11 +22,10 @@ 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("Checking world, this could take a few moments..."); + sender.sendMessage("Starting game, please wait."); // Use multiverse to load game world // If the load was successful, start game if (TumbleManager.getMVWorldManager().loadWorld(TumbleManager.getGameWorld())) { - sender.sendMessage("Generating layers..."); // Check which gamemode to initiate from the config file if (!Game.getGame().startGame()) { // If game type does not exist, give sender feedback -- cgit v1.2.3 From 6be45c6cdfb243fc872b7073729a755f8f1ee193 Mon Sep 17 00:00:00 2001 From: Myles Date: Sat, 3 Dec 2022 16:34:13 -0600 Subject: carver is too good at bug fixing --- .../com/MylesAndMore/tumble/commands/StartGame.java | 19 ------------------- 1 file changed, 19 deletions(-) (limited to 'src/main/java/com/MylesAndMore/tumble/commands/StartGame.java') diff --git a/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java b/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java index aad4b9e..85fd705 100644 --- a/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java +++ b/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java @@ -12,7 +12,6 @@ import org.bukkit.entity.Player; import java.util.List; public class StartGame implements CommandExecutor { - // Define the startGame method so that other classes can refrence it public void startGame(CommandSender sender, String[] args) { // Check if sender has perms to run command if (sender.hasPermission("tumble.start")) { @@ -60,24 +59,6 @@ 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 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); -- cgit v1.2.3 From 14b9a1aec413fc0affe7de02e5d875e251bb15dd Mon Sep 17 00:00:00 2001 From: Myles <43725835+MylesAndMore@users.noreply.github.com> Date: Mon, 5 Dec 2022 19:20:54 +0000 Subject: reformatting (this may break things) removed some flagged imports and changed some of the regen code might need to revert the commit... --- src/main/java/com/MylesAndMore/tumble/commands/StartGame.java | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/main/java/com/MylesAndMore/tumble/commands/StartGame.java') diff --git a/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java b/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java index 85fd705..2e531ef 100644 --- a/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java +++ b/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java @@ -2,14 +2,10 @@ package com.MylesAndMore.tumble.commands; import com.MylesAndMore.tumble.Game; import com.MylesAndMore.tumble.TumbleManager; -import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import java.util.List; public class StartGame implements CommandExecutor { public void startGame(CommandSender sender, String[] args) { -- cgit v1.2.3 From 0860c7913225943cd16f8a149ec9cf0b407ce359 Mon Sep 17 00:00:00 2001 From: Myles Date: Wed, 7 Dec 2022 19:06:55 -0600 Subject: bug fixes and duplicate game glitch fixed --- .../java/com/MylesAndMore/tumble/commands/StartGame.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src/main/java/com/MylesAndMore/tumble/commands/StartGame.java') diff --git a/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java b/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java index 2e531ef..5577173 100644 --- a/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java +++ b/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java @@ -7,6 +7,8 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; +import java.util.Objects; + public class StartGame implements CommandExecutor { public void startGame(CommandSender sender, String[] args) { // Check if sender has perms to run command @@ -17,14 +19,22 @@ 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("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()) { - // 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")); + // 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")); + } + sender.sendMessage(ChatColor.BLUE + "Starting game, please wait."); } } // If load was unsuccessful, give feedback -- cgit v1.2.3 From 1a8b11f68e1e8089f5c145e4dc7335c296d5e6a4 Mon Sep 17 00:00:00 2001 From: Myles Date: Wed, 7 Dec 2022 21:12:39 -0600 Subject: I broke things (as usual) --- src/main/java/com/MylesAndMore/tumble/commands/StartGame.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main/java/com/MylesAndMore/tumble/commands/StartGame.java') diff --git a/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java b/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java index 5577173..315219a 100644 --- a/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java +++ b/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java @@ -24,6 +24,7 @@ public class StartGame implements CommandExecutor { 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!"); @@ -34,7 +35,6 @@ public class StartGame implements CommandExecutor { else { sender.sendMessage(ChatColor.RED + "Failed to recognize game of type " + ChatColor.GRAY + TumbleManager.getPlugin().getConfig().getString("gameMode")); } - sender.sendMessage(ChatColor.BLUE + "Starting game, please wait."); } } // If load was unsuccessful, give feedback -- cgit v1.2.3 From 102627d4b28589676ddccc359a9ecd0dffa13f85 Mon Sep 17 00:00:00 2001 From: Myles Date: Wed, 7 Dec 2022 21:54:26 -0600 Subject: 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... --- .../MylesAndMore/tumble/commands/StartGame.java | 40 ++++++++++++++++------ 1 file changed, 29 insertions(+), 11 deletions(-) (limited to 'src/main/java/com/MylesAndMore/tumble/commands/StartGame.java') 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]); + } } } } -- cgit v1.2.3 From 7c669404f8d7cdfc68ead2dd9c8128f627fadd4f Mon Sep 17 00:00:00 2001 From: Myles <43725835+MylesAndMore@users.noreply.github.com> Date: Thu, 8 Dec 2022 17:07:12 +0000 Subject: remove deprecated startGame method in command --- src/main/java/com/MylesAndMore/tumble/commands/StartGame.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'src/main/java/com/MylesAndMore/tumble/commands/StartGame.java') diff --git a/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java b/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java index 17d2a34..46ca6ce 100644 --- a/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java +++ b/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java @@ -10,7 +10,8 @@ import org.bukkit.command.CommandSender; import java.util.Objects; public class StartGame implements CommandExecutor { - public void startGame(CommandSender sender, String[] args) { + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { // Check if sender has perms to run command if (sender.hasPermission("tumble.start")) { // Check if there is a lobbyWorld specified in config @@ -81,11 +82,6 @@ public class StartGame implements CommandExecutor { else { sender.sendMessage(ChatColor.RED + TumbleManager.getPermissionMessage()); } - } - - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - startGame(sender, args); return true; } } -- cgit v1.2.3 From 2d7de58b65fb7ecdd7c784707dbe2a39fa3d6e27 Mon Sep 17 00:00:00 2001 From: Myles Date: Thu, 8 Dec 2022 20:04:41 -0600 Subject: fix (most of) the bugs --- .../MylesAndMore/tumble/commands/StartGame.java | 74 ++++++++++++---------- 1 file changed, 40 insertions(+), 34 deletions(-) (limited to 'src/main/java/com/MylesAndMore/tumble/commands/StartGame.java') 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 -- cgit v1.2.3 From 735fd623a2cb14223df65b17705c4eb6e01a681a Mon Sep 17 00:00:00 2001 From: Myles Date: Sat, 10 Dec 2022 14:49:09 -0600 Subject: lang changes --- src/main/java/com/MylesAndMore/tumble/commands/StartGame.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main/java/com/MylesAndMore/tumble/commands/StartGame.java') diff --git a/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java b/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java index d488fec..652b222 100644 --- a/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java +++ b/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java @@ -22,7 +22,7 @@ public class StartGame implements CommandExecutor { if (TumbleManager.getGameWorld() != null) { // Check if a game is already pending to start if (!Objects.equals(Game.getGame().getGameState(), "waiting")) { - sender.sendMessage(ChatColor.BLUE + "Starting game, please wait."); + sender.sendMessage(ChatColor.BLUE + "Generating layers, please wait."); // Use multiverse to load game world // If the load was successful, start game if (TumbleManager.getMVWorldManager().loadWorld(TumbleManager.getGameWorld())) { -- cgit v1.2.3 From bfc632c3d5d9b4419de023542c32a58869c7eb60 Mon Sep 17 00:00:00 2001 From: Myles Date: Sun, 11 Dec 2022 01:08:11 -0600 Subject: fix bugs --- src/main/java/com/MylesAndMore/tumble/commands/StartGame.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main/java/com/MylesAndMore/tumble/commands/StartGame.java') diff --git a/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java b/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java index 652b222..c138cda 100644 --- a/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java +++ b/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java @@ -17,7 +17,7 @@ public class StartGame implements CommandExecutor { // Check if there is a lobbyWorld specified in config if (TumbleManager.getLobbyWorld() != null) { // Check if there is more than one person in lobby - if (TumbleManager.getPlayersInLobby().size() > 0) { + if (TumbleManager.getPlayersInLobby().size() > 1) { // Check if there is a gameWorld specified in config if (TumbleManager.getGameWorld() != null) { // Check if a game is already pending to start -- cgit v1.2.3