mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
clusters
This commit is contained in:
parent
c09179e9cd
commit
c55961e299
@ -9,7 +9,6 @@ import java.util.Random;
|
|||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.generator.BlockPopulator;
|
import org.bukkit.generator.BlockPopulator;
|
||||||
@ -18,6 +17,7 @@ import com.intellectualcrafters.plot.PlotSquared;
|
|||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.generator.AugmentedPopulator;
|
import com.intellectualcrafters.plot.generator.AugmentedPopulator;
|
||||||
import com.intellectualcrafters.plot.object.BlockLoc;
|
import com.intellectualcrafters.plot.object.BlockLoc;
|
||||||
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotCluster;
|
import com.intellectualcrafters.plot.object.PlotCluster;
|
||||||
import com.intellectualcrafters.plot.object.PlotClusterId;
|
import com.intellectualcrafters.plot.object.PlotClusterId;
|
||||||
@ -25,6 +25,7 @@ import com.intellectualcrafters.plot.object.PlotId;
|
|||||||
import com.intellectualcrafters.plot.object.PlotManager;
|
import com.intellectualcrafters.plot.object.PlotManager;
|
||||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||||
import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager;
|
import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager;
|
||||||
|
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
||||||
|
|
||||||
public class ClusterManager {
|
public class ClusterManager {
|
||||||
public static HashMap<String, HashSet<PlotCluster>> clusters;
|
public static HashMap<String, HashSet<PlotCluster>> clusters;
|
||||||
@ -50,25 +51,24 @@ public class ClusterManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Location getHome(PlotCluster cluster) {
|
public static Location getHome(PlotCluster cluster) {
|
||||||
World world = Bukkit.getWorld(cluster.world);
|
|
||||||
BlockLoc home = cluster.settings.getPosition();
|
BlockLoc home = cluster.settings.getPosition();
|
||||||
Location toReturn;
|
Location toReturn;
|
||||||
if (home.y == 0) {
|
if (home.y == 0) {
|
||||||
// default pos
|
// default pos
|
||||||
PlotId center = getCenterPlot(cluster);
|
PlotId center = getCenterPlot(cluster);
|
||||||
toReturn = PlotHelper.getPlotHome(world, center);
|
toReturn = PlotHelper.getPlotHome(cluster.world, center);
|
||||||
if (toReturn.getBlockY() == 0) {
|
if (toReturn.getY() == 0) {
|
||||||
final PlotManager manager = PlotSquared.getPlotManager(world);
|
final PlotManager manager = PlotSquared.getPlotManager(cluster.world);
|
||||||
final PlotWorld plotworld = PlotSquared.getWorldSettings(world);
|
final PlotWorld plotworld = PlotSquared.getWorldSettings(cluster.world);
|
||||||
final Location loc = manager.getSignLoc(world, plotworld, PlotHelper.getPlot(world, center));
|
final Location loc = manager.getSignLoc(plotworld, PlotHelper.getPlot(cluster.world, center));
|
||||||
toReturn.setY(loc.getY());
|
toReturn.setY(loc.getY());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
toReturn = getClusterBottom(cluster).add(home.x, home.y, home.z);
|
toReturn = getClusterBottom(cluster).add(home.x, home.y, home.z);
|
||||||
}
|
}
|
||||||
int max = world.getHighestBlockAt(toReturn).getY();
|
int max = BukkitUtil.getHeighestBlock(cluster.world, toReturn.getX(), toReturn.getZ());
|
||||||
if (max > toReturn.getBlockY()) {
|
if (max > toReturn.getY()) {
|
||||||
toReturn.setY(max);
|
toReturn.setY(max);
|
||||||
}
|
}
|
||||||
return toReturn;
|
return toReturn;
|
||||||
@ -107,12 +107,12 @@ public class ClusterManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean contains(PlotCluster cluster, Location loc) {
|
public static boolean contains(PlotCluster cluster, Location loc) {
|
||||||
String world = loc.getWorld().getName();
|
String world = loc.getWorld();
|
||||||
PlotManager manager = PlotSquared.getPlotManager(world);
|
PlotManager manager = PlotSquared.getPlotManager(world);
|
||||||
PlotWorld plotworld = PlotSquared.getWorldSettings(world);
|
PlotWorld plotworld = PlotSquared.getWorldSettings(world);
|
||||||
Location bot = manager.getPlotBottomLocAbs(plotworld, cluster.getP1());
|
Location bot = manager.getPlotBottomLocAbs(plotworld, cluster.getP1());
|
||||||
Location top = manager.getPlotTopLocAbs(plotworld, cluster.getP2()).add(1,0,1);
|
Location top = manager.getPlotTopLocAbs(plotworld, cluster.getP2()).add(1,0,1);
|
||||||
if (bot.getBlockX() < loc.getBlockX() && bot.getBlockZ() < loc.getBlockZ() && top.getBlockX() > loc.getBlockX() && top.getBlockZ() > loc.getBlockZ()) {
|
if (bot.getX() < loc.getX() && bot.getZ() < loc.getZ() && top.getX() > loc.getX() && top.getZ() > loc.getZ()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -145,7 +145,7 @@ public class ClusterManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static PlotCluster getCluster(Location loc) {
|
public static PlotCluster getCluster(Location loc) {
|
||||||
String world = loc.getWorld().getName();
|
String world = loc.getWorld();
|
||||||
if (last != null && last.world.equals(world)) {
|
if (last != null && last.world.equals(world)) {
|
||||||
if (contains(last, loc)) {
|
if (contains(last, loc)) {
|
||||||
return last;
|
return last;
|
||||||
@ -222,7 +222,7 @@ public class ClusterManager {
|
|||||||
int xw;
|
int xw;
|
||||||
int zw;
|
int zw;
|
||||||
|
|
||||||
String world = loc.getWorld().getName();
|
String world = loc.getWorld();
|
||||||
PlotWorld plotworld = PlotSquared.getWorldSettings(world);
|
PlotWorld plotworld = PlotSquared.getWorldSettings(world);
|
||||||
if (plotworld == null) {
|
if (plotworld == null) {
|
||||||
xw = 39;
|
xw = 39;
|
||||||
@ -233,12 +233,12 @@ public class ClusterManager {
|
|||||||
Location al = manager.getPlotBottomLocAbs(plotworld, a);
|
Location al = manager.getPlotBottomLocAbs(plotworld, a);
|
||||||
Location bl = manager.getPlotBottomLocAbs(plotworld, b);
|
Location bl = manager.getPlotBottomLocAbs(plotworld, b);
|
||||||
|
|
||||||
xw = bl.getBlockX() - al.getBlockX();
|
xw = bl.getX() - al.getX();
|
||||||
zw = bl.getBlockZ() - al.getBlockZ();
|
zw = bl.getZ() - al.getZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
int x = loc.getBlockX();
|
int x = loc.getX();
|
||||||
int z = loc.getBlockZ();
|
int z = loc.getZ();
|
||||||
|
|
||||||
return new PlotId((x/xw) + 1,(z/zw) + 1);
|
return new PlotId((x/xw) + 1,(z/zw) + 1);
|
||||||
}
|
}
|
||||||
@ -257,10 +257,10 @@ public class ClusterManager {
|
|||||||
Location bot = getClusterBottom(cluster);
|
Location bot = getClusterBottom(cluster);
|
||||||
Location top = getClusterTop(cluster);
|
Location top = getClusterTop(cluster);
|
||||||
|
|
||||||
int minChunkX = bot.getBlockX() >> 4;
|
int minChunkX = bot.getX() >> 4;
|
||||||
int maxChunkX = (top.getBlockX() >> 4) + 1;
|
int maxChunkX = (top.getX() >> 4) + 1;
|
||||||
int minChunkZ = bot.getBlockZ() >> 4;
|
int minChunkZ = bot.getZ() >> 4;
|
||||||
int maxChunkZ = (top.getBlockZ() >> 4) + 1;
|
int maxChunkZ = (top.getZ() >> 4) + 1;
|
||||||
|
|
||||||
final AugmentedPopulator populator = getPopulator(cluster);
|
final AugmentedPopulator populator = getPopulator(cluster);
|
||||||
final ArrayList<Chunk> chunks = new ArrayList<>();
|
final ArrayList<Chunk> chunks = new ArrayList<>();
|
||||||
|
Loading…
Reference in New Issue
Block a user