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;
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;

View File

@ -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 <start | stop> argument is required to dicate whether or not to start the highlighting or stop it.";
return "Usage: \"island <arg>\". replacing <args> 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

View File

@ -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

View File

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