From b1487b500d1b7bd9b63f050dd713922fecfdc562 Mon Sep 17 00:00:00 2001 From: Harrison Date: Sat, 16 May 2020 18:50:00 -0500 Subject: [PATCH] Changed command name and added size command. Refactoring performed as well. --- .../commands/RegisteredCommands.java | 6 +++--- ...ighlightCommand.java => IslandCommand.java} | 18 +++++++++++------- .../{ValueRunnable.java => ValueCommand.java} | 2 +- .../world/Information/IslandInformation.java | 4 ++++ 4 files changed, 19 insertions(+), 11 deletions(-) rename src/main/java/ca/recrown/islandsurvivalcraft/interaction/commands/runnables/{HighlightCommand.java => IslandCommand.java} (82%) rename src/main/java/ca/recrown/islandsurvivalcraft/interaction/commands/runnables/{ValueRunnable.java => ValueCommand.java} (97%) diff --git a/src/main/java/ca/recrown/islandsurvivalcraft/interaction/commands/RegisteredCommands.java b/src/main/java/ca/recrown/islandsurvivalcraft/interaction/commands/RegisteredCommands.java index 426f7da..dbe75a2 100644 --- a/src/main/java/ca/recrown/islandsurvivalcraft/interaction/commands/RegisteredCommands.java +++ b/src/main/java/ca/recrown/islandsurvivalcraft/interaction/commands/RegisteredCommands.java @@ -1,13 +1,13 @@ package ca.recrown.islandsurvivalcraft.interaction.commands; -import ca.recrown.islandsurvivalcraft.interaction.commands.runnables.HighlightCommand; +import ca.recrown.islandsurvivalcraft.interaction.commands.runnables.IslandCommand; import ca.recrown.islandsurvivalcraft.interaction.commands.runnables.*; public enum RegisteredCommands { - HIGHLIGHT(new HighlightCommand()), + ISLAND(new IslandCommand()), HELP(new HelpCommand()), - VALUE(new ValueRunnable()), + VALUE(new ValueCommand()), ; private final CommandRunnable commandRunnable; diff --git a/src/main/java/ca/recrown/islandsurvivalcraft/interaction/commands/runnables/HighlightCommand.java b/src/main/java/ca/recrown/islandsurvivalcraft/interaction/commands/runnables/IslandCommand.java similarity index 82% rename from src/main/java/ca/recrown/islandsurvivalcraft/interaction/commands/runnables/HighlightCommand.java rename to src/main/java/ca/recrown/islandsurvivalcraft/interaction/commands/runnables/IslandCommand.java index 5dcc86f..45dc3af 100644 --- a/src/main/java/ca/recrown/islandsurvivalcraft/interaction/commands/runnables/HighlightCommand.java +++ b/src/main/java/ca/recrown/islandsurvivalcraft/interaction/commands/runnables/IslandCommand.java @@ -17,7 +17,7 @@ import ca.recrown.islandsurvivalcraft.utilities.datatypes.Point2; import ca.recrown.islandsurvivalcraft.world.WorldInfo; import ca.recrown.islandsurvivalcraft.world.Information.IslandInformation; -public class HighlightCommand implements CommandRunnable { +public class IslandCommand implements CommandRunnable { private IslandSurvivalCraft islandSurvivalCraft; private final Particle.DustOptions EDGE_DUST_OPTIONS = new Particle.DustOptions(Color.RED, 1f); private final Particle.DustOptions ORIGIN_DUST_OPTIONS = new Particle.DustOptions(Color.LIME, 1.5f); @@ -28,7 +28,7 @@ public class HighlightCommand implements CommandRunnable { @Override public String getDescription() { - return "Displays particle effects at edge of islands."; + return "Various debugging information about islands."; } @Override @@ -38,10 +38,10 @@ public class HighlightCommand implements CommandRunnable { return false; } Player player = (Player) sender; - if (args[0].isEmpty()) { + if (args.length == 0 || args[0].isEmpty()) { return false; } - if (args[0].toLowerCase().equals("start")) { + if (args[0].toLowerCase().equals("highlight")) { if (playersHighlighting.add(player)) { sender.sendMessage("You are now highlighting islands."); } else { @@ -56,6 +56,9 @@ public class HighlightCommand implements CommandRunnable { } else if (args[0].toLowerCase().equals("origin")) { Point2 playerLoc = new Point2(player.getLocation().getBlockX(), player.getLocation().getBlockZ()); sender.sendMessage("Current island's origin point: " + islandSurvivalCraft.getWorldInfoManager().retrieve(player.getWorld().getName()).getIslandInfoManager().getIslandInformation(playerLoc, true).getIslandOrigin()); + } else if (args[0].toLowerCase().equals("size")) { + Point2 playerLoc = new Point2(player.getLocation().getBlockX(), player.getLocation().getBlockZ()); + sender.sendMessage("Current island's raw size in blocks: " + islandSurvivalCraft.getWorldInfoManager().retrieve(player.getWorld().getName()).getIslandInfoManager().getIslandInformation(playerLoc, true).getIslandSize()); } else { return false; } @@ -103,9 +106,10 @@ public class HighlightCommand implements CommandRunnable { @Override public String getDetailedDescription() { - return "A helpful debugging command to analyze what the plugin considers an island by displaying particle effects around the player that is a part of the island. " + - "Red particles indicate the islands border, and green particles indicate the origin. " + - "The argument is required to dicate whether or not to start the highlighting or stop it."; + return "Usage: \"island \". replacing with \"highlight\" will start highlighting the island by " + + "displaying red particles that indicate the islands border, and green particles indicate the origin. \"stop\" will stop the highlighting. " + + "\"origin\" will print the current island's origin point. " + + "\"size\" will print the raw island size in blocks including the shallow portions."; } @Override diff --git a/src/main/java/ca/recrown/islandsurvivalcraft/interaction/commands/runnables/ValueRunnable.java b/src/main/java/ca/recrown/islandsurvivalcraft/interaction/commands/runnables/ValueCommand.java similarity index 97% rename from src/main/java/ca/recrown/islandsurvivalcraft/interaction/commands/runnables/ValueRunnable.java rename to src/main/java/ca/recrown/islandsurvivalcraft/interaction/commands/runnables/ValueCommand.java index 8b68939..4308da7 100644 --- a/src/main/java/ca/recrown/islandsurvivalcraft/interaction/commands/runnables/ValueRunnable.java +++ b/src/main/java/ca/recrown/islandsurvivalcraft/interaction/commands/runnables/ValueCommand.java @@ -6,7 +6,7 @@ import org.bukkit.entity.Player; import ca.recrown.islandsurvivalcraft.IslandSurvivalCraft; import ca.recrown.islandsurvivalcraft.world.IslandWorldMap; -public class ValueRunnable implements CommandRunnable { +public class ValueCommand implements CommandRunnable { private IslandSurvivalCraft isc; @Override diff --git a/src/main/java/ca/recrown/islandsurvivalcraft/world/Information/IslandInformation.java b/src/main/java/ca/recrown/islandsurvivalcraft/world/Information/IslandInformation.java index 2879bad..4d3f64c 100644 --- a/src/main/java/ca/recrown/islandsurvivalcraft/world/Information/IslandInformation.java +++ b/src/main/java/ca/recrown/islandsurvivalcraft/world/Information/IslandInformation.java @@ -74,6 +74,10 @@ public class IslandInformation { return chunkSpan.contains(chunkCoords); } + public int getIslandSize() { + return islandCoordinates.size(); + } + @Override public int hashCode() { return islandOrigin.hashCode();