|
|
@@ -2,8 +2,10 @@ package org.aubrithehuman.townyrangelimit;
|
|
|
|
|
|
|
|
|
|
|
|
import com.palmergames.bukkit.towny.TownyAPI;
|
|
|
|
import com.palmergames.bukkit.towny.TownyAPI;
|
|
|
|
import com.palmergames.bukkit.towny.TownySettings;
|
|
|
|
import com.palmergames.bukkit.towny.TownySettings;
|
|
|
|
import com.palmergames.bukkit.towny.exceptions.TownyException;
|
|
|
|
import com.palmergames.bukkit.towny.event.NationPreAddTownEvent;
|
|
|
|
import com.palmergames.bukkit.towny.object.*;
|
|
|
|
import com.palmergames.bukkit.towny.object.*;
|
|
|
|
|
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.event.EventHandler;
|
|
|
|
import org.bukkit.event.EventHandler;
|
|
|
|
import org.bukkit.event.EventPriority;
|
|
|
|
import org.bukkit.event.EventPriority;
|
|
|
|
import org.bukkit.event.Listener;
|
|
|
|
import org.bukkit.event.Listener;
|
|
|
@@ -12,6 +14,7 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import java.util.logging.Level;
|
|
|
|
|
|
|
|
|
|
|
|
public final class TownyRangeLimit extends JavaPlugin implements Listener {
|
|
|
|
public final class TownyRangeLimit extends JavaPlugin implements Listener {
|
|
|
|
|
|
|
|
|
|
|
@@ -22,8 +25,20 @@ public final class TownyRangeLimit extends JavaPlugin implements Listener {
|
|
|
|
this.getLogger().info("TownyRangeLimit loaded with limit of: " + this.getConfig().getInt("townblockRangeMax") + " townblocks");
|
|
|
|
this.getLogger().info("TownyRangeLimit loaded with limit of: " + this.getConfig().getInt("townblockRangeMax") + " townblocks");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@EventHandler(priority = EventPriority.HIGHEST)
|
|
|
|
public void onDisable() {
|
|
|
|
public void nationInvite(NationPreAddTownEvent event) {
|
|
|
|
|
|
|
|
Town t = event.getTown();
|
|
|
|
|
|
|
|
Nation n = event.getNation();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Bukkit.getLogger().info("[TownyRangeLimit] Calculating between " + t.getName() + " and " + n.getName());
|
|
|
|
|
|
|
|
int dist = shortestDistance(t, n, event);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Bukkit.getLogger().info("[TownyRangeLimit] Calculated distance of " + dist + " between " + t.getName() + " and " + n.getName());
|
|
|
|
|
|
|
|
if (dist > this.getConfig().getInt("townblockRangeMax")) {
|
|
|
|
|
|
|
|
event.setCancelMessage("§c" + t.getName() + " is too far away from any town in your nation. Must be within " + (this.getConfig().getInt("townblockRangeMax") * TownySettings.getTownBlockSize()) + " blocks of the nearest town in either nation!");
|
|
|
|
|
|
|
|
event.setCancelled(true);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@EventHandler(priority = EventPriority.HIGHEST)
|
|
|
|
@EventHandler(priority = EventPriority.HIGHEST)
|
|
|
@@ -40,45 +55,12 @@ public final class TownyRangeLimit extends JavaPlugin implements Listener {
|
|
|
|
Nation nation2 = TownyAPI.getInstance().getNation(args[2]);
|
|
|
|
Nation nation2 = TownyAPI.getInstance().getNation(args[2]);
|
|
|
|
|
|
|
|
|
|
|
|
if(nation1 == null || nation2 == null) return;
|
|
|
|
if(nation1 == null || nation2 == null) return;
|
|
|
|
int dist = shortestDistance(nation1, nation2);
|
|
|
|
Bukkit.getLogger().info("[TownyRangeLimit] Calculating between " + nation1.getName() + " and " + nation2.getName());
|
|
|
|
|
|
|
|
int dist = shortestDistance(nation1, nation2, event.getPlayer());
|
|
|
|
|
|
|
|
Bukkit.getLogger().info("[TownyRangeLimit] Calculated distance of " + dist + " between " + nation1.getName() + " and " + nation2.getName());
|
|
|
|
|
|
|
|
|
|
|
|
if (dist > this.getConfig().getInt("townblockRangeMax")) {
|
|
|
|
if (dist > this.getConfig().getInt("townblockRangeMax")) {
|
|
|
|
event.getPlayer().sendMessage("§e[Towny]" + "§c" + nation2.getName() + " is too far away from any town in your nation. Must be within " + (this.getConfig().getInt("townblockRangeMax") * TownySettings.getTownBlockSize()) + " blocks of the nearest town in either nation!");
|
|
|
|
event.getPlayer().sendMessage("§e[Towny] " + "§c" + args[2] + " is too far away from any town in your nation. Must be within " + (this.getConfig().getInt("townblockRangeMax") * TownySettings.getTownBlockSize()) + " blocks of the nearest town in either nation!");
|
|
|
|
event.setCancelled(true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//n invite
|
|
|
|
|
|
|
|
else if (args[1].equalsIgnoreCase("invite")) {
|
|
|
|
|
|
|
|
if (!args[2].equalsIgnoreCase("deny") && !args[1].equalsIgnoreCase("accept")) {
|
|
|
|
|
|
|
|
TownyWorld tw = WorldCoord.parseWorldCoord(event.getPlayer()).getTownyWorld();
|
|
|
|
|
|
|
|
if(tw == null) return;
|
|
|
|
|
|
|
|
Town town = tw.getTowns().get(args[2]);
|
|
|
|
|
|
|
|
Resident r = TownyAPI.getInstance().getResident(event.getPlayer());
|
|
|
|
|
|
|
|
if(r == null) return;
|
|
|
|
|
|
|
|
Nation nation = r.getNationOrNull();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int dist = shortestDistance(town, nation);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (dist > this.getConfig().getInt("townblockRangeMax")) {
|
|
|
|
|
|
|
|
event.getPlayer().sendMessage("§e[Towny]" + "§c" + town.getName() + " is too far away from any town in your nation. Must be within " + (this.getConfig().getInt("townblockRangeMax") * TownySettings.getTownBlockSize()) + " blocks of the nearest town in your nation!");
|
|
|
|
|
|
|
|
event.setCancelled(true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//n join (public)
|
|
|
|
|
|
|
|
else if (args[1].equalsIgnoreCase("join")) {
|
|
|
|
|
|
|
|
Nation nation = TownyAPI.getInstance().getNation(args[2]);
|
|
|
|
|
|
|
|
if(nation == null) return;
|
|
|
|
|
|
|
|
if(nation.isOpen()) {
|
|
|
|
|
|
|
|
Resident r = TownyAPI.getInstance().getResident(event.getPlayer());
|
|
|
|
|
|
|
|
if(r == null) return;
|
|
|
|
|
|
|
|
Town town = r.getTownOrNull();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int dist = shortestDistance(town, nation);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (dist > this.getConfig().getInt("townblockRangeMax")) {
|
|
|
|
|
|
|
|
event.getPlayer().sendMessage("§e[Towny]" + "§c" + nation.getName() + " is too far away from any town in your town. Must be within " + (this.getConfig().getInt("townblockRangeMax") * TownySettings.getTownBlockSize()) + " blocks of the nearest town in that nation!");
|
|
|
|
|
|
|
|
event.setCancelled(true);
|
|
|
|
event.setCancelled(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@@ -96,10 +78,12 @@ public final class TownyRangeLimit extends JavaPlugin implements Listener {
|
|
|
|
|
|
|
|
|
|
|
|
if(town1 == null || town2 == null) return;
|
|
|
|
if(town1 == null || town2 == null) return;
|
|
|
|
|
|
|
|
|
|
|
|
int dist = shortestDistance(town1, town2);
|
|
|
|
Bukkit.getLogger().info("[TownyRangeLimit] Calculating between " + town1.getName() + " and " + town2.getName());
|
|
|
|
|
|
|
|
int dist = shortestDistance(town1, town2, event.getPlayer());
|
|
|
|
|
|
|
|
Bukkit.getLogger().info("[TownyRangeLimit] Calculated distance of " + dist + " between " + town1.getName() + " and " + town2.getName());
|
|
|
|
|
|
|
|
|
|
|
|
if (dist > this.getConfig().getInt("townblockRangeMax")) {
|
|
|
|
if (dist > this.getConfig().getInt("townblockRangeMax")) {
|
|
|
|
event.getPlayer().sendMessage("§e[Towny]" + "§c" + town2.getName() + " is too far away from your town. Must be within " + (this.getConfig().getInt("townblockRangeMax") * TownySettings.getTownBlockSize()) + " blocks of the nearest chunk in your town!");
|
|
|
|
event.getPlayer().sendMessage("§e[Towny] " + "§c" + args[2] + " is too far away from your town. Must be within " + (this.getConfig().getInt("townblockRangeMax") * TownySettings.getTownBlockSize()) + " blocks of the nearest chunk in your town!");
|
|
|
|
event.setCancelled(true);
|
|
|
|
event.setCancelled(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@@ -108,50 +92,125 @@ public final class TownyRangeLimit extends JavaPlugin implements Listener {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Finds the shortest distance (in townblocks) between two towns
|
|
|
|
* Finds the shortest distance (in townblocks) between two towns
|
|
|
|
* @param town1
|
|
|
|
* @param town1 town1
|
|
|
|
* @param town2
|
|
|
|
* @param town2 town1
|
|
|
|
* @return
|
|
|
|
* @return shortest distance
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private static int shortestDistance(Town town1, Town town2) {
|
|
|
|
private static int shortestDistance(Town town1, Town town2, Player e) {
|
|
|
|
//max possible range (60M*sqrt2)
|
|
|
|
//max possible range (60M*sqrt2)
|
|
|
|
// 16 is block size
|
|
|
|
// 16 is block size
|
|
|
|
int dist = 84852814 / 16;
|
|
|
|
int dist = 84852814 / 16;
|
|
|
|
if (town1 != null && town2 != null) {
|
|
|
|
if (town1 != null && town2 != null) {
|
|
|
|
try {
|
|
|
|
TownBlock townHomeBlock1 = town1.getHomeBlockOrNull();
|
|
|
|
ArrayList<WorldCoord> clusterInvited = getCluster(town1.getHomeBlock().getWorldCoord());
|
|
|
|
TownBlock townHomeBlock2 = town2.getHomeBlockOrNull();
|
|
|
|
ArrayList<WorldCoord> clusterInviter = getCluster(town2.getHomeBlock().getWorldCoord());
|
|
|
|
if(townHomeBlock1 == null) {
|
|
|
|
WorldCoord invitedHomeblock = town1.getHomeBlock().getWorldCoord();
|
|
|
|
Bukkit.getLogger().log(Level.SEVERE, "[TownyRangeLimit] " + town1.getName() + " has not set a home block! Town must have a homeblock! Failing automatically.");
|
|
|
|
WorldCoord inviterHomeblock = town2.getHomeBlock().getWorldCoord();
|
|
|
|
e.sendMessage("[TownyRangeLimit] " + town1.getName() + " has not set a home block! Town must have a homeblock! Failing automatically.");
|
|
|
|
|
|
|
|
return dist;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(townHomeBlock2 == null) {
|
|
|
|
|
|
|
|
Bukkit.getLogger().log(Level.SEVERE, "[TownyRangeLimit] " + town2.getName() + " has not set a home block! Town must have a homeblock! Failing automatically.");
|
|
|
|
|
|
|
|
e.sendMessage("[TownyRangeLimit] " + town2.getName() + " has not set a home block! Town must have a homeblock! Failing automatically.");
|
|
|
|
|
|
|
|
return dist;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ArrayList<WorldCoord> clusterInvited = getCluster(townHomeBlock1.getWorldCoord());
|
|
|
|
|
|
|
|
ArrayList<WorldCoord> clusterInviter = getCluster(townHomeBlock2.getWorldCoord());
|
|
|
|
|
|
|
|
WorldCoord invitedHomeblock = townHomeBlock1.getWorldCoord();
|
|
|
|
|
|
|
|
WorldCoord inviterHomeblock = townHomeBlock2.getWorldCoord();
|
|
|
|
|
|
|
|
|
|
|
|
//find nearest block to inviter homeblock
|
|
|
|
//find nearest block to inviter homeblock
|
|
|
|
WorldCoord nearestInviter = null;
|
|
|
|
WorldCoord nearestInviter = null;
|
|
|
|
int distInviter = 84852814 / 16;
|
|
|
|
int distInviter = 84852814 / 16;
|
|
|
|
for (WorldCoord coord1 : clusterInvited) {
|
|
|
|
for (WorldCoord coord1 : clusterInvited) {
|
|
|
|
int distX = inviterHomeblock.getX() - coord1.getX();
|
|
|
|
int distX = inviterHomeblock.getX() - coord1.getX();
|
|
|
|
int distZ = inviterHomeblock.getZ() - coord1.getZ();
|
|
|
|
int distZ = inviterHomeblock.getZ() - coord1.getZ();
|
|
|
|
if (distX < 0) distX *= -1;
|
|
|
|
if (distX < 0) distX *= -1;
|
|
|
|
if (distZ < 0) distZ *= -1;
|
|
|
|
if (distZ < 0) distZ *= -1;
|
|
|
|
//pythagorus my boi
|
|
|
|
//pythagorus my boi
|
|
|
|
int dist1 = (int) Math.sqrt((distX * distX) + (distZ * distZ));
|
|
|
|
int dist1 = (int) Math.sqrt((distX * distX) + (distZ * distZ));
|
|
|
|
|
|
|
|
|
|
|
|
//if we find a new min, save it
|
|
|
|
//if we find a new min, save it
|
|
|
|
if (dist1 <= distInviter) {
|
|
|
|
if (dist1 <= distInviter) {
|
|
|
|
distInviter = dist1;
|
|
|
|
distInviter = dist1;
|
|
|
|
nearestInviter = coord1;
|
|
|
|
nearestInviter = coord1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//if we didn't find anything for some reason? IDK its worth putting
|
|
|
|
|
|
|
|
if(nearestInviter == null) {
|
|
|
|
|
|
|
|
return dist;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//find nearest block to the found block
|
|
|
|
|
|
|
|
WorldCoord nearestInvited = nearestInviter;
|
|
|
|
|
|
|
|
int distInvited = 84852814 / 16;
|
|
|
|
|
|
|
|
for (WorldCoord coord2 : clusterInviter) {
|
|
|
|
|
|
|
|
int distX = invitedHomeblock.getX() - coord2.getX();
|
|
|
|
|
|
|
|
int distZ = invitedHomeblock.getZ() - coord2.getZ();
|
|
|
|
|
|
|
|
if (distX < 0) distX *= -1;
|
|
|
|
|
|
|
|
if (distZ < 0) distZ *= -1;
|
|
|
|
|
|
|
|
//pythagorus my boi
|
|
|
|
|
|
|
|
int dist2 = (int) Math.sqrt((distX * distX) + (distZ * distZ));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//if we find a new min, save it
|
|
|
|
|
|
|
|
if (dist2 <= distInvited) {
|
|
|
|
|
|
|
|
distInvited = dist2;
|
|
|
|
|
|
|
|
nearestInvited = coord2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//if we didnt find anything for some reason? idk its worth putting
|
|
|
|
dist = (int) Math.sqrt(((nearestInviter.getX() - nearestInvited.getX()) * (nearestInviter.getX() - nearestInvited.getX())) + ((nearestInviter.getZ() - nearestInvited.getZ()) * (nearestInviter.getZ() - nearestInvited.getZ())));
|
|
|
|
if(nearestInviter == null) {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return dist;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Finds the shortest distance (in townblocks) between a town and a nation
|
|
|
|
|
|
|
|
* @param town town
|
|
|
|
|
|
|
|
* @param nation nation
|
|
|
|
|
|
|
|
* @return shortest distance
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private static int shortestDistance(Town town, Nation nation, NationPreAddTownEvent e) {
|
|
|
|
|
|
|
|
//max possible range (60M*sqrt2)
|
|
|
|
|
|
|
|
// 16 is block size
|
|
|
|
|
|
|
|
int dist = 84852814 / 16;
|
|
|
|
|
|
|
|
if (town != null && nation != null) {
|
|
|
|
|
|
|
|
TownBlock townHomeBlockM = town.getHomeBlockOrNull();
|
|
|
|
|
|
|
|
if(townHomeBlockM == null) {
|
|
|
|
|
|
|
|
Bukkit.getLogger().log(Level.SEVERE, "[TownyRangeLimit] " + town.getName() + " has not set a home block! Town must have a homeblock! Failing automatically.");
|
|
|
|
|
|
|
|
e.setCancelMessage("[TownyRangeLimit] " + town.getName() + " has not set a home block! Town must have a homeblock! Failing automatically.");
|
|
|
|
|
|
|
|
e.setCancelled(true);
|
|
|
|
|
|
|
|
return dist;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ArrayList<WorldCoord> clusterInvited = getCluster(townHomeBlockM.getWorldCoord());
|
|
|
|
|
|
|
|
WorldCoord invitedHomeblock = townHomeBlockM.getWorldCoord();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Grab all the towns in the nation
|
|
|
|
|
|
|
|
List<Town> nation1Towns = nation.getTowns();
|
|
|
|
|
|
|
|
ArrayList<ArrayList<WorldCoord>> clustersInviter = new ArrayList<>();
|
|
|
|
|
|
|
|
ArrayList<WorldCoord> inviterHomeblocks = new ArrayList<>();
|
|
|
|
|
|
|
|
for (Town t : nation1Towns) {
|
|
|
|
|
|
|
|
TownBlock townHomeBlock = t.getHomeBlockOrNull();
|
|
|
|
|
|
|
|
if(townHomeBlock == null) {
|
|
|
|
|
|
|
|
Bukkit.getLogger().log(Level.SEVERE, "[TownyRangeLimit] " + t.getName() + " has not set a home block! Town must have a homeblock! Failing automatically.");
|
|
|
|
|
|
|
|
e.setCancelMessage("[TownyRangeLimit] " + t.getName() + " has not set a home block! Town must have a homeblock! Failing automatically.");
|
|
|
|
|
|
|
|
e.setCancelled(true);
|
|
|
|
return dist;
|
|
|
|
return dist;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
clustersInviter.add(getCluster(townHomeBlock.getWorldCoord()));
|
|
|
|
|
|
|
|
//grab homeblocks
|
|
|
|
|
|
|
|
inviterHomeblocks.add(townHomeBlock.getWorldCoord());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//find nearest block to the found block
|
|
|
|
//find nearest block to invited homeblock
|
|
|
|
WorldCoord nearestInvited = nearestInviter;
|
|
|
|
WorldCoord nearestInvited = null;
|
|
|
|
int distInvited = 84852814 / 16;
|
|
|
|
int distInvited = 84852814 / 16;
|
|
|
|
for (WorldCoord coord2 : clusterInviter) {
|
|
|
|
for (ArrayList<WorldCoord> cluster : clustersInviter) {
|
|
|
|
|
|
|
|
for (WorldCoord coord2 : cluster) {
|
|
|
|
int distX = invitedHomeblock.getX() - coord2.getX();
|
|
|
|
int distX = invitedHomeblock.getX() - coord2.getX();
|
|
|
|
int distZ = invitedHomeblock.getZ() - coord2.getZ();
|
|
|
|
int distZ = invitedHomeblock.getZ() - coord2.getZ();
|
|
|
|
if (distX < 0) distX *= -1;
|
|
|
|
if (distX < 0) distX *= -1;
|
|
|
@@ -163,217 +222,167 @@ public final class TownyRangeLimit extends JavaPlugin implements Listener {
|
|
|
|
if (dist2 <= distInvited) {
|
|
|
|
if (dist2 <= distInvited) {
|
|
|
|
distInvited = dist2;
|
|
|
|
distInvited = dist2;
|
|
|
|
nearestInvited = coord2;
|
|
|
|
nearestInvited = coord2;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
dist = (int) Math.sqrt(((nearestInviter.getX() - nearestInvited.getX()) * (nearestInviter.getX() - nearestInvited.getX())) + ((nearestInviter.getZ() - nearestInvited.getZ()) * (nearestInviter.getZ() - nearestInvited.getZ())));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (TownyException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return dist;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
//if we didn't find anything for some reason? IDK its worth putting
|
|
|
|
* Finds the shortest distance (in townblocks) between a town and a nation
|
|
|
|
if(nearestInvited == null) {
|
|
|
|
* @param town
|
|
|
|
return dist;
|
|
|
|
* @param nation
|
|
|
|
|
|
|
|
* @return
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private static int shortestDistance(Town town, Nation nation) {
|
|
|
|
|
|
|
|
//max possible range (60M*sqrt2)
|
|
|
|
|
|
|
|
// 16 is block size
|
|
|
|
|
|
|
|
int dist = 84852814 / 16;
|
|
|
|
|
|
|
|
if (town != null && nation != null) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
ArrayList<WorldCoord> clusterInvited = getCluster(town.getHomeBlock().getWorldCoord());
|
|
|
|
|
|
|
|
WorldCoord invitedHomeblock = town.getHomeBlock().getWorldCoord();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Grab all of the towns in the nation
|
|
|
|
|
|
|
|
List<Town> nation1Towns = nation.getTowns();
|
|
|
|
|
|
|
|
ArrayList<ArrayList<WorldCoord>> clustersInviter = new ArrayList<ArrayList<WorldCoord>>();
|
|
|
|
|
|
|
|
ArrayList<WorldCoord> inviterHomeblocks = new ArrayList<WorldCoord>();
|
|
|
|
|
|
|
|
for (Town t : nation1Towns) {
|
|
|
|
|
|
|
|
clustersInviter.add(getCluster(nation.getCapital().getHomeBlock().getWorldCoord()));
|
|
|
|
|
|
|
|
//grab homeblocks
|
|
|
|
|
|
|
|
inviterHomeblocks.add(t.getHomeBlock().getWorldCoord());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//find nearest block to invited homeblock
|
|
|
|
|
|
|
|
WorldCoord nearestInvited = null;
|
|
|
|
|
|
|
|
int distInvited = 84852814 / 16;
|
|
|
|
|
|
|
|
for (ArrayList<WorldCoord> cluster : clustersInviter) {
|
|
|
|
|
|
|
|
for (WorldCoord coord2 : cluster) {
|
|
|
|
|
|
|
|
int distX = invitedHomeblock.getX() - coord2.getX();
|
|
|
|
|
|
|
|
int distZ = invitedHomeblock.getZ() - coord2.getZ();
|
|
|
|
|
|
|
|
if (distX < 0) distX *= -1;
|
|
|
|
|
|
|
|
if (distZ < 0) distZ *= -1;
|
|
|
|
|
|
|
|
//pythagorus my boi
|
|
|
|
|
|
|
|
int dist2 = (int) Math.sqrt((distX * distX) + (distZ * distZ));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//if we find a new min, save it
|
|
|
|
|
|
|
|
if (dist2 <= distInvited) {
|
|
|
|
|
|
|
|
distInvited = dist2;
|
|
|
|
|
|
|
|
nearestInvited = coord2;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//if we didnt find anything for some reason? idk its worth putting
|
|
|
|
|
|
|
|
if(nearestInvited == null) {
|
|
|
|
|
|
|
|
return dist;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//find nearest block to found block
|
|
|
|
|
|
|
|
WorldCoord nearestInviter = invitedHomeblock;
|
|
|
|
|
|
|
|
int distInviter = 84852814 / 16;
|
|
|
|
|
|
|
|
for (WorldCoord coord1 : clusterInvited) {
|
|
|
|
|
|
|
|
int distX = nearestInvited.getX() - coord1.getX();
|
|
|
|
|
|
|
|
int distZ = nearestInvited.getZ() - coord1.getZ();
|
|
|
|
|
|
|
|
if (distX < 0) distX *= -1;
|
|
|
|
|
|
|
|
if (distZ < 0) distZ *= -1;
|
|
|
|
|
|
|
|
//pythagorus my boi
|
|
|
|
|
|
|
|
int dist1 = (int) Math.sqrt((distX * distX) + (distZ * distZ));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//if we find a new min, save it
|
|
|
|
|
|
|
|
if (dist1 <= distInviter) {
|
|
|
|
|
|
|
|
distInviter = dist1;
|
|
|
|
|
|
|
|
nearestInviter = coord1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dist = (int) Math.sqrt(((nearestInviter.getX() - nearestInvited.getX()) * (nearestInviter.getX() - nearestInvited.getX())) + ((nearestInviter.getZ() - nearestInvited.getZ()) * (nearestInviter.getZ() - nearestInvited.getZ())));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (TownyException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//find nearest block to found block
|
|
|
|
|
|
|
|
WorldCoord nearestInviter = invitedHomeblock;
|
|
|
|
|
|
|
|
int distInviter = 84852814 / 16;
|
|
|
|
|
|
|
|
for (WorldCoord coord1 : clusterInvited) {
|
|
|
|
|
|
|
|
int distX = nearestInvited.getX() - coord1.getX();
|
|
|
|
|
|
|
|
int distZ = nearestInvited.getZ() - coord1.getZ();
|
|
|
|
|
|
|
|
if (distX < 0) distX *= -1;
|
|
|
|
|
|
|
|
if (distZ < 0) distZ *= -1;
|
|
|
|
|
|
|
|
//pythagorus my boi
|
|
|
|
|
|
|
|
int dist1 = (int) Math.sqrt((distX * distX) + (distZ * distZ));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//if we find a new min, save it
|
|
|
|
|
|
|
|
if (dist1 <= distInviter) {
|
|
|
|
|
|
|
|
distInviter = dist1;
|
|
|
|
|
|
|
|
nearestInviter = coord1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dist = (int) Math.sqrt(((nearestInviter.getX() - nearestInvited.getX()) * (nearestInviter.getX() - nearestInvited.getX())) + ((nearestInviter.getZ() - nearestInvited.getZ()) * (nearestInviter.getZ() - nearestInvited.getZ())));
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return dist;
|
|
|
|
return dist;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Finds the shortest distance (in townblocks) between two nations
|
|
|
|
* Finds the shortest distance (in townblocks) between two nations
|
|
|
|
* @param nation1
|
|
|
|
* @param nation1 nation1
|
|
|
|
* @param nation2
|
|
|
|
* @param nation2 nation2
|
|
|
|
* @return
|
|
|
|
* @return shortest distance
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
private static int shortestDistance(Nation nation1, Nation nation2) {
|
|
|
|
private static int shortestDistance(Nation nation1, Nation nation2, Player e) {
|
|
|
|
//max possible range (60M*sqrt2)
|
|
|
|
//max possible range (60M*sqrt2)
|
|
|
|
// 16 is block size
|
|
|
|
// 16 is block size
|
|
|
|
int dist = 84852814 / 16;
|
|
|
|
int dist = 84852814 / 16;
|
|
|
|
if (nation1 != null && nation2 != null) {
|
|
|
|
if (nation1 != null && nation2 != null) {
|
|
|
|
try {
|
|
|
|
//Grab all the towns in the nation
|
|
|
|
|
|
|
|
List<Town> nation1Towns = nation1.getTowns();
|
|
|
|
//Grab all of the towns in the nation
|
|
|
|
ArrayList<ArrayList<WorldCoord>> clustersInviter = new ArrayList<>();
|
|
|
|
List<Town> nation1Towns = nation1.getTowns();
|
|
|
|
ArrayList<WorldCoord> inviterHomeblocks = new ArrayList<>();
|
|
|
|
ArrayList<ArrayList<WorldCoord>> clustersInviter = new ArrayList<ArrayList<WorldCoord>>();
|
|
|
|
for (Town t : nation1Towns) {
|
|
|
|
ArrayList<WorldCoord> inviterHomeblocks = new ArrayList<WorldCoord>();
|
|
|
|
TownBlock townHomeBlock = t.getHomeBlockOrNull();
|
|
|
|
for (Town t : nation1Towns) {
|
|
|
|
if(townHomeBlock == null) {
|
|
|
|
clustersInviter.add(getCluster(nation1.getCapital().getHomeBlock().getWorldCoord()));
|
|
|
|
Bukkit.getLogger().log(Level.SEVERE, "[TownyRangeLimit] " + t.getName() + " has not set a home block! Town must have a homeblock! Failing automatically.");
|
|
|
|
inviterHomeblocks.add(t.getHomeBlock().getWorldCoord());
|
|
|
|
e.sendMessage("[TownyRangeLimit] " + t.getName() + " has not set a home block! Town must have a homeblock! Failing automatically.");
|
|
|
|
|
|
|
|
return dist;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
clustersInviter.add(getCluster(townHomeBlock.getWorldCoord()));
|
|
|
|
|
|
|
|
inviterHomeblocks.add(townHomeBlock.getWorldCoord());
|
|
|
|
|
|
|
|
|
|
|
|
//Grab all of the towns in the nation
|
|
|
|
|
|
|
|
List<Town> nation2Towns = nation2.getTowns();
|
|
|
|
|
|
|
|
ArrayList<ArrayList<WorldCoord>> clustersInvited = new ArrayList<ArrayList<WorldCoord>>();
|
|
|
|
|
|
|
|
ArrayList<WorldCoord> invitedHomeblocks = new ArrayList<WorldCoord>();
|
|
|
|
|
|
|
|
for (Town t : nation2Towns) {
|
|
|
|
|
|
|
|
clustersInvited.add(getCluster(nation2.getCapital().getHomeBlock().getWorldCoord()));
|
|
|
|
|
|
|
|
invitedHomeblocks.add(t.getHomeBlock().getWorldCoord());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//This may take forever :skull: at like multiple 900 size towns it takes like 1mil iterations?????
|
|
|
|
|
|
|
|
//idk how tf else to check this
|
|
|
|
|
|
|
|
//find nearest block to invited homeblock
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
WorldCoord nearestInvited1 = null;
|
|
|
|
|
|
|
|
int distInvited1 = 84852814 / 16;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (WorldCoord homeblock1 : invitedHomeblocks) {
|
|
|
|
|
|
|
|
WorldCoord nearestInvited2 = null;
|
|
|
|
|
|
|
|
int distInvited2 = 84852814 / 16;
|
|
|
|
|
|
|
|
for (ArrayList<WorldCoord> cluster2 : clustersInviter) {
|
|
|
|
|
|
|
|
for (WorldCoord coord2 : cluster2) {
|
|
|
|
|
|
|
|
int distX = homeblock1.getX() - coord2.getX();
|
|
|
|
|
|
|
|
int distZ = homeblock1.getZ() - coord2.getZ();
|
|
|
|
|
|
|
|
if (distX < 0) distX *= -1;
|
|
|
|
|
|
|
|
if (distZ < 0) distZ *= -1;
|
|
|
|
|
|
|
|
//pythagorus my boi
|
|
|
|
|
|
|
|
int dist2 = (int) Math.sqrt((distX * distX) + (distZ * distZ));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//if we find a new min, save it
|
|
|
|
|
|
|
|
if (dist2 <= distInvited2) {
|
|
|
|
|
|
|
|
distInvited2 = dist2;
|
|
|
|
|
|
|
|
nearestInvited2 = coord2;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//compare to other homeblock searches
|
|
|
|
|
|
|
|
if (distInvited2 <= distInvited1) {
|
|
|
|
|
|
|
|
distInvited1 = distInvited2;
|
|
|
|
|
|
|
|
nearestInvited1 = nearestInvited2;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//repeat in the other direction
|
|
|
|
|
|
|
|
WorldCoord nearestInviter1 = null;
|
|
|
|
|
|
|
|
int distInviter1 = 84852814 / 16;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (WorldCoord homeblock1 : inviterHomeblocks) {
|
|
|
|
|
|
|
|
WorldCoord nearestInviter2 = null;
|
|
|
|
|
|
|
|
int distInviter2 = 84852814 / 16;
|
|
|
|
|
|
|
|
for (ArrayList<WorldCoord> cluster2 : clustersInvited) {
|
|
|
|
|
|
|
|
for (WorldCoord coord2 : cluster2) {
|
|
|
|
|
|
|
|
int distX = homeblock1.getX() - coord2.getX();
|
|
|
|
|
|
|
|
int distZ = homeblock1.getZ() - coord2.getZ();
|
|
|
|
|
|
|
|
if (distX < 0) distX *= -1;
|
|
|
|
|
|
|
|
if (distZ < 0) distZ *= -1;
|
|
|
|
|
|
|
|
//pythagorus my boi
|
|
|
|
|
|
|
|
int dist2 = (int) Math.sqrt((distX * distX) + (distZ * distZ));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//if we find a new min, save it
|
|
|
|
|
|
|
|
if (dist2 <= distInviter2) {
|
|
|
|
|
|
|
|
distInviter2 = dist2;
|
|
|
|
|
|
|
|
nearestInviter2 = coord2;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//compare to other homeblock searches
|
|
|
|
|
|
|
|
if (distInviter2 <= distInviter1) {
|
|
|
|
|
|
|
|
distInviter1 = distInviter2;
|
|
|
|
|
|
|
|
nearestInviter1 = nearestInviter2;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(nearestInviter1 == null || nearestInvited1 == null) throw new NullPointerException();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dist = (int) Math.sqrt(((nearestInviter1.getX() - nearestInvited1.getX()) * (nearestInviter1.getX() - nearestInvited1.getX())) + ((nearestInviter1.getZ() - nearestInvited1.getZ()) * (nearestInviter1.getZ() - nearestInvited1.getZ())));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (TownyException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Grab all the towns in the nation
|
|
|
|
|
|
|
|
List<Town> nation2Towns = nation2.getTowns();
|
|
|
|
|
|
|
|
ArrayList<ArrayList<WorldCoord>> clustersInvited = new ArrayList<>();
|
|
|
|
|
|
|
|
ArrayList<WorldCoord> invitedHomeblocks = new ArrayList<>();
|
|
|
|
|
|
|
|
for (Town t : nation2Towns) {
|
|
|
|
|
|
|
|
TownBlock townHomeBlock = t.getHomeBlockOrNull();
|
|
|
|
|
|
|
|
if(townHomeBlock == null) {
|
|
|
|
|
|
|
|
Bukkit.getLogger().log(Level.SEVERE, "[TownyRangeLimit] " + t.getName() + " has not set a home block! Town must have a homeblock! Failing automatically.");
|
|
|
|
|
|
|
|
e.sendMessage("[TownyRangeLimit] " + t.getName() + " has not set a home block! Town must have a homeblock! Failing automatically.");
|
|
|
|
|
|
|
|
return dist;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
clustersInvited.add(getCluster(townHomeBlock.getWorldCoord()));
|
|
|
|
|
|
|
|
invitedHomeblocks.add(townHomeBlock.getWorldCoord());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//This may take forever :skull: at like multiple 900 size towns it takes like 1mil iterations?????
|
|
|
|
|
|
|
|
//IDK how tf else to check this
|
|
|
|
|
|
|
|
//find nearest block to invited homeblock
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
WorldCoord nearestInvited1 = null;
|
|
|
|
|
|
|
|
int distInvited1 = 84852814 / 16;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (WorldCoord homeblock1 : invitedHomeblocks) {
|
|
|
|
|
|
|
|
WorldCoord nearestInvited2 = null;
|
|
|
|
|
|
|
|
int distInvited2 = 84852814 / 16;
|
|
|
|
|
|
|
|
for (ArrayList<WorldCoord> cluster2 : clustersInviter) {
|
|
|
|
|
|
|
|
for (WorldCoord coord2 : cluster2) {
|
|
|
|
|
|
|
|
int distX = homeblock1.getX() - coord2.getX();
|
|
|
|
|
|
|
|
int distZ = homeblock1.getZ() - coord2.getZ();
|
|
|
|
|
|
|
|
if (distX < 0) distX *= -1;
|
|
|
|
|
|
|
|
if (distZ < 0) distZ *= -1;
|
|
|
|
|
|
|
|
//pythagorus my boi
|
|
|
|
|
|
|
|
int dist2 = (int) Math.sqrt((distX * distX) + (distZ * distZ));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//if we find a new min, save it
|
|
|
|
|
|
|
|
if (dist2 <= distInvited2) {
|
|
|
|
|
|
|
|
distInvited2 = dist2;
|
|
|
|
|
|
|
|
nearestInvited2 = coord2;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//compare to other homeblock searches
|
|
|
|
|
|
|
|
if (distInvited2 <= distInvited1) {
|
|
|
|
|
|
|
|
distInvited1 = distInvited2;
|
|
|
|
|
|
|
|
nearestInvited1 = nearestInvited2;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//repeat in the other direction
|
|
|
|
|
|
|
|
WorldCoord nearestInviter1 = null;
|
|
|
|
|
|
|
|
int distInviter1 = 84852814 / 16;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (WorldCoord homeblock1 : inviterHomeblocks) {
|
|
|
|
|
|
|
|
WorldCoord nearestInviter2 = null;
|
|
|
|
|
|
|
|
int distInviter2 = 84852814 / 16;
|
|
|
|
|
|
|
|
for (ArrayList<WorldCoord> cluster2 : clustersInvited) {
|
|
|
|
|
|
|
|
for (WorldCoord coord2 : cluster2) {
|
|
|
|
|
|
|
|
int distX = homeblock1.getX() - coord2.getX();
|
|
|
|
|
|
|
|
int distZ = homeblock1.getZ() - coord2.getZ();
|
|
|
|
|
|
|
|
if (distX < 0) distX *= -1;
|
|
|
|
|
|
|
|
if (distZ < 0) distZ *= -1;
|
|
|
|
|
|
|
|
//pythagorus my boi
|
|
|
|
|
|
|
|
int dist2 = (int) Math.sqrt((distX * distX) + (distZ * distZ));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//if we find a new min, save it
|
|
|
|
|
|
|
|
if (dist2 <= distInviter2) {
|
|
|
|
|
|
|
|
distInviter2 = dist2;
|
|
|
|
|
|
|
|
nearestInviter2 = coord2;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//compare to other homeblock searches
|
|
|
|
|
|
|
|
if (distInviter2 <= distInviter1) {
|
|
|
|
|
|
|
|
distInviter1 = distInviter2;
|
|
|
|
|
|
|
|
nearestInviter1 = nearestInviter2;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(nearestInviter1 == null || nearestInvited1 == null) throw new NullPointerException();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dist = (int) Math.sqrt(((nearestInviter1.getX() - nearestInvited1.getX()) * (nearestInviter1.getX() - nearestInvited1.getX())) + ((nearestInviter1.getZ() - nearestInvited1.getZ()) * (nearestInviter1.getZ() - nearestInvited1.getZ())));
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return dist;
|
|
|
|
return dist;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param worldCoord
|
|
|
|
* @param worldCoord worldCoord
|
|
|
|
* @return
|
|
|
|
* @return List of connected chunks
|
|
|
|
* @author NinjaMandalorian
|
|
|
|
* @author NinjaMandalorian
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private static ArrayList<WorldCoord> getAdjCells(WorldCoord worldCoord) {
|
|
|
|
private static ArrayList<WorldCoord> getAdjCells(WorldCoord worldCoord) {
|
|
|
|
ArrayList<WorldCoord> ReturnList = new ArrayList<WorldCoord>();
|
|
|
|
ArrayList<WorldCoord> ReturnList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
int[][] XZarray = new int[][]{
|
|
|
|
int[][] XZarray = new int[][]{
|
|
|
|
{-1, 0},
|
|
|
|
{-1, 0},
|
|
|
@@ -399,8 +408,8 @@ public final class TownyRangeLimit extends JavaPlugin implements Listener {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static ArrayList<WorldCoord> getCluster(WorldCoord chunkCoord){
|
|
|
|
public static ArrayList<WorldCoord> getCluster(WorldCoord chunkCoord){
|
|
|
|
// WCoordList is the returning array, SearchList is the to-search list.
|
|
|
|
// WCoordList is the returning array, SearchList is the to-search list.
|
|
|
|
ArrayList<WorldCoord> WCoordList = new ArrayList<WorldCoord>();
|
|
|
|
ArrayList<WorldCoord> WCoordList = new ArrayList<>();
|
|
|
|
ArrayList<WorldCoord> SearchList = new ArrayList<WorldCoord>();
|
|
|
|
ArrayList<WorldCoord> SearchList = new ArrayList<>();
|
|
|
|
SearchList.add(chunkCoord); // Adds 1st chunk to list
|
|
|
|
SearchList.add(chunkCoord); // Adds 1st chunk to list
|
|
|
|
|
|
|
|
|
|
|
|
// Iterates through SearchList, to create a full list of every adjacent cell.
|
|
|
|
// Iterates through SearchList, to create a full list of every adjacent cell.
|
|
|
|