use of com.plotsquared.core.location.Location in project PlotSquared by IntellectualSites.
the class SquarePlotManager method clearPlot.
@Override
public boolean clearPlot(@NonNull final Plot plot, @Nullable final Runnable whenDone, @Nullable PlotPlayer<?> actor, @Nullable QueueCoordinator queue) {
final Set<CuboidRegion> regions = plot.getRegions();
Runnable run = new Runnable() {
@Override
public void run() {
if (regions.isEmpty()) {
if (whenDone != null) {
whenDone.run();
}
return;
}
Iterator<CuboidRegion> iterator = regions.iterator();
CuboidRegion region = iterator.next();
iterator.remove();
final Location pos1 = Location.at(plot.getWorldName(), region.getMinimumPoint());
final Location pos2 = Location.at(plot.getWorldName(), region.getMaximumPoint());
regionManager.regenerateRegion(pos1, pos2, false, this);
}
};
run.run();
return true;
}
use of com.plotsquared.core.location.Location in project PlotSquared by IntellectualSites.
the class Plot method getHomeSynchronous.
/**
* @return the plot home location
* @deprecated May cause synchronous chunk loading
*/
@Deprecated
public Location getHomeSynchronous() {
BlockLoc home = this.getPosition();
if (home == null || home.getX() == 0 && home.getZ() == 0) {
return this.getDefaultHomeSynchronous(true);
} else {
Location bottom = this.getBottomAbs();
if (!isLoaded()) {
return Location.at("", 0, this.getArea() instanceof ClassicPlotWorld ? ((ClassicPlotWorld) this.getArea()).PLOT_HEIGHT + 1 : 4, 0);
}
Location location = toHomeLocation(bottom, home);
if (!this.worldUtil.getBlockSynchronous(location).getBlockType().getMaterial().isAir()) {
location = location.withY(Math.max(1 + this.worldUtil.getHighestBlockSynchronous(this.getWorldName(), location.getX(), location.getZ()), bottom.getY()));
}
return location;
}
}
use of com.plotsquared.core.location.Location in project PlotSquared by IntellectualSites.
the class PlotCluster method getHome.
public void getHome(@NonNull final Consumer<Location> result) {
final BlockLoc home = this.settings.getPosition();
Consumer<Location> locationConsumer = toReturn -> PlotSquared.platform().worldUtil().getHighestBlock(this.area.getWorldName(), toReturn.getX(), toReturn.getZ(), highest -> {
if (highest <= area.getMinBuildHeight()) {
highest = 63;
}
if (highest > toReturn.getY()) {
result.accept(toReturn.withY(1 + highest));
} else {
result.accept(toReturn);
}
});
if (home.getY() == Integer.MIN_VALUE) {
// default pos
Plot center = getCenterPlot();
center.getHome(location -> {
Location toReturn = location;
if (toReturn.getY() <= area.getMinBuildHeight()) {
PlotManager manager = this.area.getPlotManager();
Location locationSign = manager.getSignLoc(center);
toReturn = toReturn.withY(locationSign.getY());
}
locationConsumer.accept(toReturn);
});
} else {
locationConsumer.accept(getClusterBottom().add(home.getX(), home.getY(), home.getZ()));
}
}
use of com.plotsquared.core.location.Location in project PlotSquared by IntellectualSites.
the class HybridPlotManager method clearPlot.
@Override
public boolean clearPlot(@NonNull final Plot plot, @Nullable final Runnable whenDone, @Nullable PlotPlayer<?> actor, @Nullable QueueCoordinator queue) {
if (this.regionManager.notifyClear(this)) {
// If this returns false, the clear didn't work
if (this.regionManager.handleClear(plot, whenDone, this, actor)) {
return true;
}
}
final Location pos1 = plot.getBottomAbs();
final Location pos2 = plot.getExtendedTopAbs();
// If augmented
final boolean canRegen = (hybridPlotWorld.getType() == PlotAreaType.AUGMENTED) && (hybridPlotWorld.getTerrain() != PlotAreaTerrainType.NONE) && REGENERATIVE_CLEAR;
// The component blocks
final Pattern plotfloor = hybridPlotWorld.TOP_BLOCK.toPattern();
final Pattern filling = hybridPlotWorld.MAIN_BLOCK.toPattern();
final Pattern bedrock;
if (hybridPlotWorld.PLOT_BEDROCK) {
bedrock = BlockTypes.BEDROCK.getDefaultState();
} else {
bedrock = hybridPlotWorld.MAIN_BLOCK.toPattern();
}
final BiomeType biome = hybridPlotWorld.getPlotBiome();
boolean enqueue = false;
if (queue == null) {
enqueue = true;
queue = hybridPlotWorld.getQueue();
}
if (actor != null && Settings.QUEUE.NOTIFY_PROGRESS) {
queue.addProgressSubscriber(subscriberFactory.createWithActor(actor));
}
if (whenDone != null) {
queue.setCompleteTask(whenDone);
}
if (!canRegen) {
queue.setCuboid(pos1.withY(hybridPlotWorld.getMinGenHeight()), pos2.withY(hybridPlotWorld.getMinGenHeight()), hybridPlotWorld.PLOT_BEDROCK ? bedrock : filling);
// Each component has a different layer
queue.setCuboid(pos1.withY(hybridPlotWorld.getMinGenHeight() + 1), pos2.withY(hybridPlotWorld.PLOT_HEIGHT - 1), filling);
queue.setCuboid(pos1.withY(hybridPlotWorld.PLOT_HEIGHT), pos2.withY(hybridPlotWorld.PLOT_HEIGHT), plotfloor);
queue.setCuboid(pos1.withY(hybridPlotWorld.PLOT_HEIGHT + 1), pos2.withY(hybridPlotWorld.getMaxGenHeight()), BlockTypes.AIR.getDefaultState());
queue.setBiomeCuboid(pos1, pos2, biome);
} else {
queue.setRegenRegion(new CuboidRegion(pos1.getBlockVector3(), pos2.getBlockVector3()));
}
pastePlotSchematic(queue, pos1, pos2);
return !enqueue || queue.enqueue();
}
use of com.plotsquared.core.location.Location in project PlotSquared by IntellectualSites.
the class HybridPlotManager method createRoadSouthEast.
@Override
public boolean createRoadSouthEast(@NonNull final Plot plot, @Nullable QueueCoordinator queue) {
boolean enqueue = false;
if (queue == null) {
enqueue = true;
queue = hybridPlotWorld.getQueue();
}
super.createRoadSouthEast(plot, queue);
PlotId id = plot.getId();
PlotId id2 = PlotId.of(id.getX() + 1, id.getY() + 1);
Location pos1 = getPlotTopLocAbs(id).add(1, 0, 1);
Location pos2 = getPlotBottomLocAbs(id2);
createSchemAbs(queue, pos1, pos2, true);
if (hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) {
createSchemAbs(queue, pos1, pos2, true);
}
return !enqueue || queue.enqueue();
}
Aggregations