diff options
Diffstat (limited to 'src/main/java/com/MylesAndMore/tumble/commands')
5 files changed, 0 insertions, 412 deletions
diff --git a/src/main/java/com/MylesAndMore/tumble/commands/ReloadCommand.java b/src/main/java/com/MylesAndMore/tumble/commands/ReloadCommand.java deleted file mode 100644 index 4ca26f4..0000000 --- a/src/main/java/com/MylesAndMore/tumble/commands/ReloadCommand.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.MylesAndMore.tumble.commands; - -import com.MylesAndMore.tumble.TumbleManager; -import org.bukkit.ChatColor; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; - -public class ReloadCommand implements CommandExecutor { - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - // Check if the sender has perms to run command - if (sender.hasPermission("tumble.reload")) { - // If sender does have permission, reload the plugin's config and display a confirmation message - TumbleManager.getPlugin().reloadConfig(); - sender.sendMessage(ChatColor.GREEN + "Tumble configuration reloaded successfully."); - } - else { - // If sender does not have permission, display them the permissionMessage from the config - sender.sendMessage(ChatColor.RED + TumbleManager.getPermissionMessage()); - } - return true; - } -} diff --git a/src/main/java/com/MylesAndMore/tumble/commands/SetAutoStart.java b/src/main/java/com/MylesAndMore/tumble/commands/SetAutoStart.java deleted file mode 100644 index b5339b5..0000000 --- a/src/main/java/com/MylesAndMore/tumble/commands/SetAutoStart.java +++ /dev/null @@ -1,97 +0,0 @@ -package com.MylesAndMore.tumble.commands; - -import com.MylesAndMore.tumble.TumbleManager; -import org.bukkit.ChatColor; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; - -import java.util.Objects; - -public class SetAutoStart implements CommandExecutor{ - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - // Check if sender has perms to run command - if (sender.hasPermission("tumble.autostart")) { - // Check if game and lobby worlds are null - if (TumbleManager.getGameWorld() != null) { - if (TumbleManager.getLobbyWorld() != null) { - // Check the amount of args entered - if (args.length == 2) { - // Check the player # argument and parse it into an int - int args0; - try { - args0 = Integer.parseInt(args[0]); - } catch (NumberFormatException nfe){ - sender.sendMessage(ChatColor.RED + "Player amount must be a valid number."); - return true; - } catch (Exception e){ - sender.sendMessage(ChatColor.RED + "Invalid player amount."); - return true; - } - // PlayerAmount & enable/disable were entered - // Check if a playerAmount between 2-8 was entered - if ((args0 >= 2) && (args0 <= 8)) { - if (Objects.equals(args[1], "enable")) { - // Write values to the config - TumbleManager.getPlugin().getConfig().set("autoStart.players", args0); - TumbleManager.getPlugin().getConfig().set("autoStart.enabled", true); - TumbleManager.getPlugin().saveConfig(); - sender.sendMessage(ChatColor.GREEN + "Configuration saved!"); - sender.sendMessage(ChatColor.GREEN + "Run " + ChatColor.GRAY + "/tumble:reload " + ChatColor.GREEN + "the changes to take effect."); - } - else if (Objects.equals(args[1], "disable")) { - TumbleManager.getPlugin().getConfig().set("autoStart.players", args0); - TumbleManager.getPlugin().getConfig().set("autoStart.enabled", false); - TumbleManager.getPlugin().saveConfig(); - sender.sendMessage(ChatColor.GREEN + "Configuration saved!"); - sender.sendMessage(ChatColor.GREEN + "Run " + ChatColor.GRAY + "/tumble:reload " + ChatColor.GREEN + "the changes to take effect."); - } - else { - return false; - } - } - else { - sender.sendMessage(ChatColor.RED + "Please enter a player amount between two and eight!"); - } - } - else if (args.length == 1) { - // Only PlayerAmount was entered - int args0; - try { - args0 = Integer.parseInt(args[0]); - } catch (NumberFormatException nfe){ - sender.sendMessage(ChatColor.RED + "Player amount must be a valid number."); - return true; - } catch (Exception e){ - sender.sendMessage(ChatColor.RED + "Invalid player amount."); - return true; - } - if ((args0 >= 2) && (args0 <= 8)) { - TumbleManager.getPlugin().getConfig().set("autoStart.players", args0); - TumbleManager.getPlugin().saveConfig(); - sender.sendMessage(ChatColor.GREEN + "Configuration saved!"); - sender.sendMessage(ChatColor.GREEN + "Run " + ChatColor.GRAY + "/tumble:reload " + ChatColor.GREEN + "the changes to take effect."); - } - else { - sender.sendMessage(ChatColor.RED + "Please enter a player amount between two and eight!"); - } - } - else { - return false; - } - } - else { - sender.sendMessage(ChatColor.RED + "Please link a lobby world first!"); - } - } - else { - sender.sendMessage(ChatColor.RED + "Please link a game world first!"); - } - } - else { - sender.sendMessage(ChatColor.RED + TumbleManager.getPermissionMessage()); - } - return true; - } -} diff --git a/src/main/java/com/MylesAndMore/tumble/commands/SetWinnerLoc.java b/src/main/java/com/MylesAndMore/tumble/commands/SetWinnerLoc.java deleted file mode 100644 index ec145d1..0000000 --- a/src/main/java/com/MylesAndMore/tumble/commands/SetWinnerLoc.java +++ /dev/null @@ -1,115 +0,0 @@ -package com.MylesAndMore.tumble.commands; - -import com.MylesAndMore.tumble.TumbleManager; -import org.bukkit.ChatColor; -import org.bukkit.Location; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.command.ConsoleCommandSender; -import org.bukkit.entity.Player; - -public class SetWinnerLoc implements CommandExecutor { - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - // Check if sender has perms to run command - if (sender.hasPermission("tumble.winlocation")) { - // Check if the lobby world has been configured - if (TumbleManager.getLobbyWorld() != null) { - // Check if the sender is a player - if (sender instanceof Player) { - // Check the sender entered the correct number of args - if (args.length == 3) { - double args0 = 0; - double args1 = 0; - double args2 = 0; - try { - args0 = Double.parseDouble(args[0]); - args1 = Double.parseDouble(args[1]); - args2 = Double.parseDouble(args[2]); - } catch (NumberFormatException nfe){ - sender.sendMessage(ChatColor.RED + "Input arguments must be valid numbers."); - } catch (Exception e){ - sender.sendMessage(ChatColor.RED + "Invalid input arguments."); - } - // Check if any of the args were 0 (this will cause future problems so we prevent it here) - if (!((args0 == 0) || (args1 == 0) || (args2 == 0))) { - TumbleManager.getPlugin().getConfig().set("winnerTeleport.x", args0); - TumbleManager.getPlugin().getConfig().set("winnerTeleport.y", args1); - TumbleManager.getPlugin().getConfig().set("winnerTeleport.z", args2); - TumbleManager.getPlugin().saveConfig(); - sender.sendMessage(ChatColor.GREEN + "Win location successfully set!"); - sender.sendMessage(ChatColor.GREEN + "Run " + ChatColor.GRAY + "/tumble:reload " + ChatColor.GREEN + "the changes to take effect."); - } - else { - sender.sendMessage(ChatColor.RED + "Your coordinates cannot be zero!"); - sender.sendMessage(ChatColor.RED + "Use something like 0.5 (the middle of the block) instead."); - } - } - // If the sender entered no args, use their current location - else if (args.length == 0) { - Location senderPos = ((Player) sender).getLocation(); - // if so, check if any of their locations are zero - if (!((senderPos.getX() == 0) || (senderPos.getY() == 0) || (senderPos.getZ() == 0))) { - // set the config values to their current pos - TumbleManager.getPlugin().getConfig().set("winnerTeleport.x", senderPos.getX()); - TumbleManager.getPlugin().getConfig().set("winnerTeleport.y", senderPos.getY()); - TumbleManager.getPlugin().getConfig().set("winnerTeleport.z", senderPos.getZ()); - TumbleManager.getPlugin().saveConfig(); - sender.sendMessage(ChatColor.GREEN + "Win location successfully set!"); - sender.sendMessage(ChatColor.GREEN + "Run " + ChatColor.GRAY + "/tumble:reload " + ChatColor.GREEN + "the changes to take effect."); - } - else { - sender.sendMessage(ChatColor.RED + "Your coordinates cannot be zero!"); - sender.sendMessage(ChatColor.RED + "Use something like 0.5 (the middle of the block) instead."); - } - } - else { - return false; - } - } - // Check if the sender is the console - else if (sender instanceof ConsoleCommandSender) { - // Check if the correct # of args were entered - if (args.length == 3) { - double args0 = 0; - double args1 = 0; - double args2 = 0; - try { - args0 = Double.parseDouble(args[0]); - args1 = Double.parseDouble(args[1]); - args2 = Double.parseDouble(args[2]); - } catch (NumberFormatException nfe){ - sender.sendMessage(ChatColor.RED + "Input arguments must be valid numbers."); - } catch (Exception e){ - sender.sendMessage(ChatColor.RED + "Invalid input arguments."); - } - // Check if any of the args were 0 (this will cause future problems so we prevent it here) - if (!((args0 == 0) || (args1 == 0) || (args2 == 0))) { - TumbleManager.getPlugin().getConfig().set("winnerTeleport.x", args0); - TumbleManager.getPlugin().getConfig().set("winnerTeleport.y", args1); - TumbleManager.getPlugin().getConfig().set("winnerTeleport.z", args2); - TumbleManager.getPlugin().saveConfig(); - sender.sendMessage(ChatColor.GREEN + "Win location successfully set!"); - sender.sendMessage(ChatColor.GREEN + "Run " + ChatColor.GRAY + "/tumble:reload " + ChatColor.GREEN + "the changes to take effect."); - } - else { - sender.sendMessage(ChatColor.RED + "Your coordinates cannot be zero!"); - sender.sendMessage(ChatColor.RED + "Use something like 0.5 (the middle of the block) instead."); - } - } - else { - return false; - } - } - } - else { - sender.sendMessage(ChatColor.RED + "Please link a lobby world first!"); - } - } - else { - sender.sendMessage(ChatColor.RED + TumbleManager.getPermissionMessage()); - } - return true; - } -} diff --git a/src/main/java/com/MylesAndMore/tumble/commands/SetWorldConfig.java b/src/main/java/com/MylesAndMore/tumble/commands/SetWorldConfig.java deleted file mode 100644 index 695c248..0000000 --- a/src/main/java/com/MylesAndMore/tumble/commands/SetWorldConfig.java +++ /dev/null @@ -1,83 +0,0 @@ -package com.MylesAndMore.tumble.commands; - -import com.MylesAndMore.tumble.TumbleManager; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.GameRule; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; - -import java.util.Objects; - -public class SetWorldConfig implements CommandExecutor { - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - // Catch for null arguments - if (args.length == 2) { - // Check if sender has perms to run command - if (sender.hasPermission("tumble.link")){ - // Initialize vars for their respective command arguments - String world = args[0]; - String worldType = args[1]; - // Check if the world type is lobby - if (Objects.equals(worldType, "lobby")) { - // Check if the world is actually a world on the server - if (Bukkit.getWorld(world) != null) { - // Check if the world has already been configured - if (!Objects.equals(TumbleManager.getGameWorld(), world)) { - // Set the specified value of the world in the config under lobbyWorld - TumbleManager.getPlugin().getConfig().set("lobbyWorld", world); - // Save said config - TumbleManager.getPlugin().saveConfig(); - // Feedback - sender.sendMessage(ChatColor.GREEN + "Lobby world successfully linked: " + ChatColor.GRAY + world); - sender.sendMessage(ChatColor.GREEN + "Please restart your server for the changes to take effect; " + ChatColor.RED + "reloading the plugin is insufficient!"); - } - // Feedback for duplicate world configuration - else { - sender.sendMessage(ChatColor.RED + "That world has already been linked, please choose/create another world!"); - } - } - // Feedback for if the world doesn't exist - else { - sender.sendMessage(ChatColor.RED + "Failed to find a world named " + ChatColor.GRAY + world); - } - } - // Check if the world type is game - else if (Objects.equals(args[1], "game")) { - if (Bukkit.getWorld(world) != null) { - if (!Objects.equals(TumbleManager.getLobbyWorld(), world)) { - TumbleManager.getPlugin().getConfig().set("gameWorld", world); - TumbleManager.getPlugin().saveConfig(); - // Set the gamerule of doImmediateRespawn in the gameWorld for later - Bukkit.getWorld(world).setGameRule(GameRule.DO_IMMEDIATE_RESPAWN, true); - Bukkit.getWorld(world).setGameRule(GameRule.KEEP_INVENTORY, true); - sender.sendMessage(ChatColor.GREEN + "Game world successfully linked: " + ChatColor.GRAY + world); - sender.sendMessage(ChatColor.GREEN + "Please restart your server for the changes to take effect; " + ChatColor.RED + "reloading the plugin is insufficient!"); - } - else { - sender.sendMessage(ChatColor.RED + "That world has already been linked, please choose/create another world!"); - } - } - else { - sender.sendMessage(ChatColor.RED + "Failed to find a world named " + ChatColor.GRAY + world); - } - } - // Feedback for if lobby or game wasn't entered - else { - sender.sendMessage(ChatColor.RED + "Allowed world types are " + ChatColor.GRAY + "lobby " + ChatColor.RED + "and " + ChatColor.GRAY + "game" + ChatColor.RED + "."); - } - } - // Feedback for if sender has no perms - else { - sender.sendMessage(ChatColor.RED + TumbleManager.getPermissionMessage()); - } - } - // Feedback for if no args were entered - else { - return false; - } - return true; - } -} diff --git a/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java b/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java deleted file mode 100644 index c138cda..0000000 --- a/src/main/java/com/MylesAndMore/tumble/commands/StartGame.java +++ /dev/null @@ -1,93 +0,0 @@ -package com.MylesAndMore.tumble.commands; - -import com.MylesAndMore.tumble.Game; -import com.MylesAndMore.tumble.TumbleManager; -import org.bukkit.ChatColor; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; - -import java.util.Objects; - -public class StartGame implements CommandExecutor { - @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 - if (TumbleManager.getLobbyWorld() != null) { - // Check if there is more than one person in lobby - 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 - if (!Objects.equals(Game.getGame().getGameState(), "waiting")) { - 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())) { - // 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")); - } - } - } - // 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 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?"); - } - } - else { - sender.sendMessage(ChatColor.RED + "A game is already queued to begin!"); - } - } - // Feedback for if there is no gameWorld in the config - else { - sender.sendMessage(ChatColor.RED + "Please link a game world first!"); - } - } - // Feedback for if there is only one person online - else { - sender.sendMessage(ChatColor.RED + "You can't start a game with yourself!"); - } - } - else { - sender.sendMessage(ChatColor.RED + "Please link a lobby world first!"); - } - } - // Feedback for if the sender has no perms - else { - sender.sendMessage(ChatColor.RED + TumbleManager.getPermissionMessage()); - } - return true; - } -} |