Changed command name and added size command.

Refactoring performed as well.
This commit is contained in:
Harrison Deng 2020-05-16 18:50:00 -05:00
parent f95d0232b9
commit b1487b500d
4 changed files with 19 additions and 11 deletions

View File

@ -1,13 +1,13 @@
package ca.recrown.islandsurvivalcraft.interaction.commands; 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.*; import ca.recrown.islandsurvivalcraft.interaction.commands.runnables.*;
public enum RegisteredCommands { public enum RegisteredCommands {
HIGHLIGHT(new HighlightCommand()), ISLAND(new IslandCommand()),
HELP(new HelpCommand()), HELP(new HelpCommand()),
VALUE(new ValueRunnable()), VALUE(new ValueCommand()),
; ;
private final CommandRunnable commandRunnable; private final CommandRunnable commandRunnable;

View File

@ -17,7 +17,7 @@ import ca.recrown.islandsurvivalcraft.utilities.datatypes.Point2;
import ca.recrown.islandsurvivalcraft.world.WorldInfo; import ca.recrown.islandsurvivalcraft.world.WorldInfo;
import ca.recrown.islandsurvivalcraft.world.Information.IslandInformation; import ca.recrown.islandsurvivalcraft.world.Information.IslandInformation;
public class HighlightCommand implements CommandRunnable { public class IslandCommand implements CommandRunnable {
private IslandSurvivalCraft islandSurvivalCraft; private IslandSurvivalCraft islandSurvivalCraft;
private final Particle.DustOptions EDGE_DUST_OPTIONS = new Particle.DustOptions(Color.RED, 1f); 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); private final Particle.DustOptions ORIGIN_DUST_OPTIONS = new Particle.DustOptions(Color.LIME, 1.5f);
@ -28,7 +28,7 @@ public class HighlightCommand implements CommandRunnable {
@Override @Override
public String getDescription() { public String getDescription() {
return "Displays particle effects at edge of islands."; return "Various debugging information about islands.";
} }
@Override @Override
@ -38,10 +38,10 @@ public class HighlightCommand implements CommandRunnable {
return false; return false;
} }
Player player = (Player) sender; Player player = (Player) sender;
if (args[0].isEmpty()) { if (args.length == 0 || args[0].isEmpty()) {
return false; return false;
} }
if (args[0].toLowerCase().equals("start")) { if (args[0].toLowerCase().equals("highlight")) {
if (playersHighlighting.add(player)) { if (playersHighlighting.add(player)) {
sender.sendMessage("You are now highlighting islands."); sender.sendMessage("You are now highlighting islands.");
} else { } else {
@ -56,6 +56,9 @@ public class HighlightCommand implements CommandRunnable {
} else if (args[0].toLowerCase().equals("origin")) { } else if (args[0].toLowerCase().equals("origin")) {
Point2 playerLoc = new Point2(player.getLocation().getBlockX(), player.getLocation().getBlockZ()); 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()); 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 { } else {
return false; return false;
} }
@ -103,9 +106,10 @@ public class HighlightCommand implements CommandRunnable {
@Override @Override
public String getDetailedDescription() { 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. " + return "Usage: \"island <arg>\". replacing <args> with \"highlight\" will start highlighting the island by " +
"Red particles indicate the islands border, and green particles indicate the origin. " + "displaying red particles that indicate the islands border, and green particles indicate the origin. \"stop\" will stop the highlighting. " +
"The <start | stop> argument is required to dicate whether or not to start the highlighting or stop it."; "\"origin\" will print the current island's origin point. " +
"\"size\" will print the raw island size in blocks including the shallow portions.";
} }
@Override @Override

View File

@ -6,7 +6,7 @@ import org.bukkit.entity.Player;
import ca.recrown.islandsurvivalcraft.IslandSurvivalCraft; import ca.recrown.islandsurvivalcraft.IslandSurvivalCraft;
import ca.recrown.islandsurvivalcraft.world.IslandWorldMap; import ca.recrown.islandsurvivalcraft.world.IslandWorldMap;
public class ValueRunnable implements CommandRunnable { public class ValueCommand implements CommandRunnable {
private IslandSurvivalCraft isc; private IslandSurvivalCraft isc;
@Override @Override

View File

@ -74,6 +74,10 @@ public class IslandInformation {
return chunkSpan.contains(chunkCoords); return chunkSpan.contains(chunkCoords);
} }
public int getIslandSize() {
return islandCoordinates.size();
}
@Override @Override
public int hashCode() { public int hashCode() {
return islandOrigin.hashCode(); return islandOrigin.hashCode();