Search in sources :

Example 66 with Location

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;
}
Also used : CuboidRegion(com.sk89q.worldedit.regions.CuboidRegion) Location(com.plotsquared.core.location.Location)

Example 67 with Location

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;
    }
}
Also used : ClassicPlotWorld(com.plotsquared.core.generator.ClassicPlotWorld) BlockLoc(com.plotsquared.core.location.BlockLoc) Location(com.plotsquared.core.location.Location)

Example 68 with 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()));
    }
}
Also used : DBFunc(com.plotsquared.core.database.DBFunc) Location(com.plotsquared.core.location.Location) HashSet(java.util.HashSet) Consumer(java.util.function.Consumer) RegionUtil(com.plotsquared.core.util.RegionUtil) NonNull(org.checkerframework.checker.nullness.qual.NonNull) PlotSquared(com.plotsquared.core.PlotSquared) BlockLoc(com.plotsquared.core.location.BlockLoc) CuboidRegion(com.sk89q.worldedit.regions.CuboidRegion) UUID(java.util.UUID) Nullable(org.checkerframework.checker.nullness.qual.Nullable) BlockLoc(com.plotsquared.core.location.BlockLoc) Location(com.plotsquared.core.location.Location)

Example 69 with Location

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();
}
Also used : Pattern(com.sk89q.worldedit.function.pattern.Pattern) BiomeType(com.sk89q.worldedit.world.biome.BiomeType) CuboidRegion(com.sk89q.worldedit.regions.CuboidRegion) Location(com.plotsquared.core.location.Location)

Example 70 with Location

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();
}
Also used : PlotId(com.plotsquared.core.plot.PlotId) Location(com.plotsquared.core.location.Location)

Aggregations

Location (com.plotsquared.core.location.Location)82 Plot (com.plotsquared.core.plot.Plot)41 PlotArea (com.plotsquared.core.plot.PlotArea)26 EventHandler (org.bukkit.event.EventHandler)15 CuboidRegion (com.sk89q.worldedit.regions.CuboidRegion)14 PlotPlayer (com.plotsquared.core.player.PlotPlayer)12 UUID (java.util.UUID)12 HashSet (java.util.HashSet)10 TranslatableCaption (com.plotsquared.core.configuration.caption.TranslatableCaption)9 NonNull (org.checkerframework.checker.nullness.qual.NonNull)9 QueueCoordinator (com.plotsquared.core.queue.QueueCoordinator)8 Caption (com.plotsquared.core.configuration.caption.Caption)7 BlockLoc (com.plotsquared.core.location.BlockLoc)7 Template (net.kyori.adventure.text.minimessage.Template)7 Entity (org.bukkit.entity.Entity)7 Settings (com.plotsquared.core.configuration.Settings)6 ClassicPlotWorld (com.plotsquared.core.generator.ClassicPlotWorld)6 PlotFlag (com.plotsquared.core.plot.flag.PlotFlag)6 SinglePlotArea (com.plotsquared.core.plot.world.SinglePlotArea)6 PlotSquared (com.plotsquared.core.PlotSquared)5