From ace286c9826aa320d21baf1e17f38df960aa6dba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beatrice=20Dellac=C3=A0?= Date: Thu, 11 Aug 2022 19:43:14 +0200 Subject: [PATCH] Clean up code --- .../uhccore/commands/UhcCoreCommand.java | 28 ++++++------------- .../commands/uhccommands/ReloadCommand.java | 8 +++--- ...StartUhcCommand.java => StartCommand.java} | 6 ++-- .../wtf/beatrice/uhccore/utils/Cache.java | 6 +++- 4 files changed, 21 insertions(+), 27 deletions(-) rename src/main/java/wtf/beatrice/uhccore/commands/uhccommands/{StartUhcCommand.java => StartCommand.java} (95%) diff --git a/src/main/java/wtf/beatrice/uhccore/commands/UhcCoreCommand.java b/src/main/java/wtf/beatrice/uhccore/commands/UhcCoreCommand.java index 99d7947..c20a649 100644 --- a/src/main/java/wtf/beatrice/uhccore/commands/UhcCoreCommand.java +++ b/src/main/java/wtf/beatrice/uhccore/commands/UhcCoreCommand.java @@ -16,7 +16,7 @@ import java.util.logging.Level; public class UhcCoreCommand implements CommandExecutor { - // Initialize the plugin variable so we can access all of the plugin's data. + // Initialize the plugin variable, so we can access all the plugin's data. private UhcCore plugin; // Initialize the debugger so I can debug the plugin. @@ -46,15 +46,18 @@ public class UhcCoreCommand implements CommandExecutor } // Check if there are any args. - if(args.length == 0 || args[0].equalsIgnoreCase("help")) + if(args.length == 0) { - HelpCommand.infoCommand(commandSender, plugin); } // Check if there is a single argument after the command itself. else if (args.length == 1) { - // Check if the args are "reload" and in case, do it. - if(args[0].equalsIgnoreCase("reload")) + // Check subcommands. + if(args[0].equalsIgnoreCase("help")) + { + HelpCommand.infoCommand(commandSender, plugin); + } + else if(args[0].equalsIgnoreCase("reload")) { ReloadCommand.reloadCommand(commandSender); } @@ -86,23 +89,10 @@ public class UhcCoreCommand implements CommandExecutor } else if(args[0].equalsIgnoreCase("start")) { - StartUhcCommand.startUhcCommand(commandSender, plugin); + StartCommand.startUhcCommand(commandSender, plugin); } // TODO: PERMISSIONS! CONFIG! - - // Check if the args are "textcomponent" and run that command. - /*else if (args[0].equalsIgnoreCase("textcomponent")) - { - // We do not want the console to receive the TextComponent, so we're gonna disable it. - if(senderIsConsole) - { - MessageUtils.sendLocalizedMessage(commandSender.getName(), LocalizedMessages.ERROR_CONSOLE_ACCESS_BLOCKED); - return true; - } - // Everyone else will be able to run the TextComponent message. - TextComponentCommand.textComponentCommand(commandSender); - }*/ } return true; } diff --git a/src/main/java/wtf/beatrice/uhccore/commands/uhccommands/ReloadCommand.java b/src/main/java/wtf/beatrice/uhccore/commands/uhccommands/ReloadCommand.java index 398fc67..105ea40 100644 --- a/src/main/java/wtf/beatrice/uhccore/commands/uhccommands/ReloadCommand.java +++ b/src/main/java/wtf/beatrice/uhccore/commands/uhccommands/ReloadCommand.java @@ -12,11 +12,11 @@ public class ReloadCommand public static void reloadCommand(CommandSender commandSender) { - debugger.sendDebugMessage(Level.INFO, "Reloading YAMLS..."); - commandSender.sendMessage("Reloading YAMLs..."); + debugger.sendDebugMessage(Level.INFO, "Reloading configuration files..."); + commandSender.sendMessage("Reloading configuration files..."); FileUtils.checkFiles(); FileUtils.reloadYamls(); - commandSender.sendMessage("Reloaded YAMLs!"); - debugger.sendDebugMessage(Level.INFO, "Reloaded YAMLs!"); + commandSender.sendMessage("Reloaded configuration files!"); + debugger.sendDebugMessage(Level.INFO, "Reloaded configuration files!"); } } diff --git a/src/main/java/wtf/beatrice/uhccore/commands/uhccommands/StartUhcCommand.java b/src/main/java/wtf/beatrice/uhccore/commands/uhccommands/StartCommand.java similarity index 95% rename from src/main/java/wtf/beatrice/uhccore/commands/uhccommands/StartUhcCommand.java rename to src/main/java/wtf/beatrice/uhccore/commands/uhccommands/StartCommand.java index 90d124b..a2a07c7 100644 --- a/src/main/java/wtf/beatrice/uhccore/commands/uhccommands/StartUhcCommand.java +++ b/src/main/java/wtf/beatrice/uhccore/commands/uhccommands/StartCommand.java @@ -12,9 +12,9 @@ import java.util.HashMap; import java.util.logging.Level; -public class StartUhcCommand { +public class StartCommand { - private static Debugger debugger = new Debugger(StartUhcCommand.class.getName()); + private static Debugger debugger = new Debugger(StartCommand.class.getName()); private static int loadDelay = 10; @@ -47,7 +47,7 @@ public class StartUhcCommand { double x = NumberUtils.getRandomNumberInRange(borderX - range + 1, borderX + range - 1) + 0.5; double z = NumberUtils.getRandomNumberInRange(borderZ - range + 1, borderZ + range - 1) + 0.5; - int y = spawnWorld.getHighestBlockYAt((int) x, (int) z); // todo: this method is shit, ushe the one i already implemented in Factions... + int y = spawnWorld.getHighestBlockYAt((int) x, (int) z); // todo: this method is shit, use the one i already implemented in Factions... Location loc = new Location(spawnWorld, x, y + 1, z); diff --git a/src/main/java/wtf/beatrice/uhccore/utils/Cache.java b/src/main/java/wtf/beatrice/uhccore/utils/Cache.java index 0fbe2e2..f94e8dd 100644 --- a/src/main/java/wtf/beatrice/uhccore/utils/Cache.java +++ b/src/main/java/wtf/beatrice/uhccore/utils/Cache.java @@ -48,7 +48,11 @@ public class Cache { public static ListfireworksLocations = new ArrayList<>(); - public static int borderX, borderZ, borderSize; + // boolean to store whether the server has been set up for gameplay or not. + // TODO: we haven't implemented any checks for this boolean in the loading phase. + // we should implement it and use it eg. when people are joining the server, starting the game, etc... + public static boolean isServerReady = false; + }