Search in sources :

Example 81 with Location

use of com.plotsquared.core.location.Location in project PlotSquared by IntellectualSites.

the class RegionManager method setCuboids.

/**
 * Set a number of cuboids to a certain block between two y values.
 *
 * @param area    plot area
 * @param regions cuboid regions
 * @param blocks  pattern
 * @param minY    y to set from
 * @param maxY    y to set to
 * @param actor   the actor associated with the cuboid set
 * @param queue   Nullable {@link QueueCoordinator}. If null, creates own queue and enqueues,
 *                otherwise writes to the queue but does not enqueue.
 * @return {@code true} if not enqueued, otherwise whether the created queue enqueued.
 */
public boolean setCuboids(@NonNull final PlotArea area, @NonNull final Set<CuboidRegion> regions, @NonNull final Pattern blocks, int minY, int maxY, @Nullable PlotPlayer<?> actor, @Nullable QueueCoordinator queue) {
    boolean enqueue = false;
    if (queue == null) {
        queue = area.getQueue();
        enqueue = true;
        if (actor != null && Settings.QUEUE.NOTIFY_PROGRESS) {
            queue.addProgressSubscriber(subscriberFactory.createWithActor(actor));
        }
    }
    for (CuboidRegion region : regions) {
        Location pos1 = Location.at(area.getWorldName(), region.getMinimumPoint().getX(), minY, region.getMinimumPoint().getZ());
        Location pos2 = Location.at(area.getWorldName(), region.getMaximumPoint().getX(), maxY, region.getMaximumPoint().getZ());
        queue.setCuboid(pos1, pos2, blocks);
    }
    return !enqueue || queue.enqueue();
}
Also used : CuboidRegion(com.sk89q.worldedit.regions.CuboidRegion) Location(com.plotsquared.core.location.Location)

Example 82 with Location

use of com.plotsquared.core.location.Location in project PlotSquared by IntellectualSites.

the class WEManager method getMask.

public static HashSet<CuboidRegion> getMask(PlotPlayer<?> player) {
    HashSet<CuboidRegion> regions = new HashSet<>();
    UUID uuid = player.getUUID();
    Location location = player.getLocation();
    String world = location.getWorldName();
    if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(world)) {
        regions.add(new CuboidRegion(MIN, MAX));
        return regions;
    }
    PlotArea area = player.getApplicablePlotArea();
    if (area == null) {
        return regions;
    }
    boolean allowMember = player.hasPermission("plots.worldedit.member");
    Plot plot = player.getCurrentPlot();
    try (final MetaDataAccess<Plot> metaDataAccess = player.accessTemporaryMetaData(PlayerMetaDataKeys.TEMPORARY_WORLD_EDIT_REGION_PLOT)) {
        if (plot == null) {
            plot = metaDataAccess.get().orElse(null);
        }
        if (plot != null && (!Settings.Done.RESTRICT_BUILDING || !DoneFlag.isDone(plot)) && ((allowMember && plot.isAdded(uuid)) || (!allowMember && plot.isOwner(uuid) || plot.getTrusted().contains(uuid))) && !plot.getFlag(NoWorldeditFlag.class)) {
            for (CuboidRegion region : plot.getRegions()) {
                BlockVector3 pos1 = region.getMinimumPoint().withY(area.getMinBuildHeight());
                BlockVector3 pos2 = region.getMaximumPoint().withY(area.getMaxBuildHeight());
                CuboidRegion copy = new CuboidRegion(pos1, pos2);
                regions.add(copy);
            }
            metaDataAccess.set(plot);
        }
    }
    return regions;
}
Also used : PlotArea(com.plotsquared.core.plot.PlotArea) Plot(com.plotsquared.core.plot.Plot) CuboidRegion(com.sk89q.worldedit.regions.CuboidRegion) UUID(java.util.UUID) BlockVector3(com.sk89q.worldedit.math.BlockVector3) HashSet(java.util.HashSet) 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