Added better origin highlighting to highlight command.
This commit is contained in:
parent
ea4ba47427
commit
63ecfedf71
@ -12,14 +12,15 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import ca.recrown.islandsurvivalcraft.IslandSurvivalCraft;
|
||||
import ca.recrown.islandsurvivalcraft.utilities.GeneralUtilities;
|
||||
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 {
|
||||
private boolean requiresInit = true;
|
||||
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.GREEN, 1f);
|
||||
private final Particle.DustOptions ORIGIN_DUST_OPTIONS = new Particle.DustOptions(Color.LIME, 1.5f);
|
||||
private final int PARTICLE_AMOUNT = 1;
|
||||
private final double OFFSET_X = 0.0d, OFFSET_Y = 6.0d, OFFSET_Z = 0.0d;
|
||||
private final double EXTRA = 0d;
|
||||
@ -52,6 +53,9 @@ public class HighlightCommand implements CommandRunnable {
|
||||
} else {
|
||||
sender.sendMessage("You weren't highlighting islands.");
|
||||
}
|
||||
} 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).getIslandOrigin());
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@ -60,7 +64,7 @@ public class HighlightCommand implements CommandRunnable {
|
||||
|
||||
@Override
|
||||
public void initialize(IslandSurvivalCraft islandsurvivalcraft) {
|
||||
requiresInit = false;
|
||||
this.islandSurvivalCraft = islandsurvivalcraft;
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(islandsurvivalcraft, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -79,9 +83,13 @@ public class HighlightCommand implements CommandRunnable {
|
||||
if (islandInfo != null) {
|
||||
Set<Point2> islandBorder = islandInfo.getEdgeCoordinates();
|
||||
for (Point2 current : islandBorder) {
|
||||
spawnParticle(world, current.x, playerY, current.y, EDGE_DUST_OPTIONS);
|
||||
spawnParticle(false, true, world, current.x, playerY, current.y, EDGE_DUST_OPTIONS);
|
||||
}
|
||||
spawnParticle(world, islandInfo.getIslandOrigin().x, playerY, islandInfo.getIslandOrigin().y, ORIGIN_DUST_OPTIONS);
|
||||
Point2 islandOrigin = islandInfo.getIslandOrigin();
|
||||
int xDirection = GeneralUtilities.addMagnitude(Math.max(Math.min(1, islandOrigin.x - playerX), -1), 1) + playerX;
|
||||
int yDirection = GeneralUtilities.addMagnitude(Math.max(Math.min(1, islandOrigin.y - playerZ), -1), 1) + playerZ;
|
||||
spawnParticle(false, false, world, xDirection, playerY, yDirection, ORIGIN_DUST_OPTIONS);
|
||||
spawnParticle(true, true, world, islandOrigin.x, playerY, islandOrigin.y, ORIGIN_DUST_OPTIONS);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -89,8 +97,8 @@ public class HighlightCommand implements CommandRunnable {
|
||||
|
||||
}
|
||||
|
||||
private void spawnParticle(World world, double x, double y, double z, Particle.DustOptions dustOptions) {
|
||||
world.spawnParticle(Particle.REDSTONE, x, y, z, PARTICLE_AMOUNT, OFFSET_X, OFFSET_Y, OFFSET_Z, EXTRA, dustOptions, false);
|
||||
private void spawnParticle(boolean focus, boolean column, World world, double x, double y, double z, Particle.DustOptions dustOptions) {
|
||||
world.spawnParticle(Particle.REDSTONE, x, y, z, focus ? PARTICLE_AMOUNT * 2 : PARTICLE_AMOUNT, OFFSET_X, column ? OFFSET_Y : 0.2, OFFSET_Z, EXTRA, dustOptions, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -102,6 +110,6 @@ public class HighlightCommand implements CommandRunnable {
|
||||
|
||||
@Override
|
||||
public boolean requiresInitialization() {
|
||||
return requiresInit;
|
||||
return islandSurvivalCraft == null;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user