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();
}
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;
}
Aggregations