mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13:16:45 +01:00
Add setCuboids method to RegionManager
- Allow FAWE to take charge of big operations like /plot set all
This commit is contained in:
parent
7aba70ea65
commit
0160c2bb55
@ -36,6 +36,7 @@ import com.plotsquared.core.queue.GlobalBlockQueue;
|
|||||||
import com.plotsquared.core.queue.LocalBlockQueue;
|
import com.plotsquared.core.queue.LocalBlockQueue;
|
||||||
import com.plotsquared.core.util.BlockUtil;
|
import com.plotsquared.core.util.BlockUtil;
|
||||||
import com.plotsquared.core.util.MathMan;
|
import com.plotsquared.core.util.MathMan;
|
||||||
|
import com.plotsquared.core.util.RegionManager;
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
@ -92,75 +93,38 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
|
|
||||||
public boolean setFloor(PlotId plotId, Pattern blocks) {
|
public boolean setFloor(PlotId plotId, Pattern blocks) {
|
||||||
Plot plot = classicPlotWorld.getPlotAbs(plotId);
|
Plot plot = classicPlotWorld.getPlotAbs(plotId);
|
||||||
LocalBlockQueue queue = classicPlotWorld.getQueue(false);
|
|
||||||
if (plot.isBasePlot()) {
|
if (plot.isBasePlot()) {
|
||||||
for (CuboidRegion region : plot.getRegions()) {
|
return RegionManager.manager.setCuboids(classicPlotWorld, plot.getRegions(), blocks,
|
||||||
Location pos1 =
|
classicPlotWorld.PLOT_HEIGHT, classicPlotWorld.PLOT_HEIGHT);
|
||||||
new Location(classicPlotWorld.getWorldName(), region.getMinimumPoint().getX(),
|
|
||||||
classicPlotWorld.PLOT_HEIGHT, region.getMinimumPoint().getZ());
|
|
||||||
Location pos2 =
|
|
||||||
new Location(classicPlotWorld.getWorldName(), region.getMaximumPoint().getX(),
|
|
||||||
classicPlotWorld.PLOT_HEIGHT, region.getMaximumPoint().getZ());
|
|
||||||
queue.setCuboid(pos1, pos2, blocks);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return queue.enqueue();
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean setAll(PlotId plotId, Pattern blocks) {
|
public boolean setAll(PlotId plotId, Pattern blocks) {
|
||||||
Plot plot = classicPlotWorld.getPlotAbs(plotId);
|
Plot plot = classicPlotWorld.getPlotAbs(plotId);
|
||||||
if (!plot.isBasePlot()) {
|
if (plot.isBasePlot()) {
|
||||||
return false;
|
return RegionManager.manager
|
||||||
|
.setCuboids(classicPlotWorld, plot.getRegions(), blocks, 1, getWorldHeight());
|
||||||
}
|
}
|
||||||
LocalBlockQueue queue = classicPlotWorld.getQueue(false);
|
return false;
|
||||||
int maxY = getWorldHeight();
|
|
||||||
for (CuboidRegion region : plot.getRegions()) {
|
|
||||||
Location pos1 =
|
|
||||||
new Location(classicPlotWorld.getWorldName(), region.getMinimumPoint().getX(), 1,
|
|
||||||
region.getMinimumPoint().getZ());
|
|
||||||
Location pos2 =
|
|
||||||
new Location(classicPlotWorld.getWorldName(), region.getMaximumPoint().getX(), maxY,
|
|
||||||
region.getMaximumPoint().getZ());
|
|
||||||
queue.setCuboid(pos1, pos2, blocks);
|
|
||||||
}
|
|
||||||
return queue.enqueue();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean setAir(PlotId plotId, Pattern blocks) {
|
public boolean setAir(PlotId plotId, Pattern blocks) {
|
||||||
Plot plot = classicPlotWorld.getPlotAbs(plotId);
|
Plot plot = classicPlotWorld.getPlotAbs(plotId);
|
||||||
if (!plot.isBasePlot()) {
|
if (plot.isBasePlot()) {
|
||||||
return false;
|
return RegionManager.manager.setCuboids(classicPlotWorld, plot.getRegions(), blocks,
|
||||||
|
classicPlotWorld.PLOT_HEIGHT + 1, getWorldHeight());
|
||||||
}
|
}
|
||||||
LocalBlockQueue queue = classicPlotWorld.getQueue(false);
|
return false;
|
||||||
int maxY = getWorldHeight();
|
|
||||||
for (CuboidRegion region : plot.getRegions()) {
|
|
||||||
Location pos1 =
|
|
||||||
new Location(classicPlotWorld.getWorldName(), region.getMinimumPoint().getX(),
|
|
||||||
classicPlotWorld.PLOT_HEIGHT + 1, region.getMinimumPoint().getZ());
|
|
||||||
Location pos2 =
|
|
||||||
new Location(classicPlotWorld.getWorldName(), region.getMaximumPoint().getX(), maxY,
|
|
||||||
region.getMaximumPoint().getZ());
|
|
||||||
queue.setCuboid(pos1, pos2, blocks);
|
|
||||||
}
|
|
||||||
return queue.enqueue();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean setMain(PlotId plotId, Pattern blocks) {
|
public boolean setMain(PlotId plotId, Pattern blocks) {
|
||||||
Plot plot = classicPlotWorld.getPlotAbs(plotId);
|
Plot plot = classicPlotWorld.getPlotAbs(plotId);
|
||||||
if (!plot.isBasePlot()) {
|
if (plot.isBasePlot()) {
|
||||||
return false;
|
return RegionManager.manager.setCuboids(classicPlotWorld, plot.getRegions(), blocks, 1,
|
||||||
|
classicPlotWorld.PLOT_HEIGHT - 1);
|
||||||
}
|
}
|
||||||
LocalBlockQueue queue = classicPlotWorld.getQueue(false);
|
return false;
|
||||||
for (CuboidRegion region : plot.getRegions()) {
|
|
||||||
Location pos1 =
|
|
||||||
new Location(classicPlotWorld.getWorldName(), region.getMinimumPoint().getX(), 1,
|
|
||||||
region.getMinimumPoint().getZ());
|
|
||||||
Location pos2 =
|
|
||||||
new Location(classicPlotWorld.getWorldName(), region.getMaximumPoint().getX(),
|
|
||||||
classicPlotWorld.PLOT_HEIGHT - 1, region.getMaximumPoint().getZ());
|
|
||||||
queue.setCuboid(pos1, pos2, blocks);
|
|
||||||
}
|
|
||||||
return queue.enqueue();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean setMiddle(PlotId plotId, Pattern blocks) {
|
public boolean setMiddle(PlotId plotId, Pattern blocks) {
|
||||||
|
@ -28,8 +28,11 @@ package com.plotsquared.core.util;
|
|||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.location.Location;
|
import com.plotsquared.core.location.Location;
|
||||||
import com.plotsquared.core.plot.Plot;
|
import com.plotsquared.core.plot.Plot;
|
||||||
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
|
import com.plotsquared.core.queue.LocalBlockQueue;
|
||||||
import com.plotsquared.core.util.task.RunnableVal;
|
import com.plotsquared.core.util.task.RunnableVal;
|
||||||
import com.plotsquared.core.util.task.TaskManager;
|
import com.plotsquared.core.util.task.TaskManager;
|
||||||
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
@ -147,6 +150,19 @@ public abstract class RegionManager {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean setCuboids(final PlotArea area, final Set<CuboidRegion> regions,
|
||||||
|
final Pattern blocks, int minY, int maxY) {
|
||||||
|
LocalBlockQueue queue = area.getQueue(false);
|
||||||
|
for (CuboidRegion region : regions) {
|
||||||
|
Location pos1 = new Location(area.getWorldName(), region.getMinimumPoint().getX(), minY,
|
||||||
|
region.getMinimumPoint().getZ());
|
||||||
|
Location pos2 = new Location(area.getWorldName(), region.getMaximumPoint().getX(), maxY,
|
||||||
|
region.getMaximumPoint().getZ());
|
||||||
|
queue.setCuboid(pos1, pos2, blocks);
|
||||||
|
}
|
||||||
|
return queue.enqueue();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy a region to a new location (in the same world)
|
* Copy a region to a new location (in the same world)
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user