mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-12-27 17:28:28 +01:00
Allow forcing of queues down pipelines to ensure whenDone runnables are called correctly
Also remove autoQueue since it's never used and would be a bad idea
This commit is contained in:
parent
57af50ed49
commit
03983e8886
@ -57,7 +57,7 @@ final class BlockStatePopulator extends BlockPopulator {
|
||||
@Nonnull final Chunk source) {
|
||||
if (this.queue == null) {
|
||||
this.queue = PlotSquared.platform().getGlobalBlockQueue()
|
||||
.getNewQueue(world.getName(), false);
|
||||
.getNewQueue(world.getName());
|
||||
}
|
||||
final PlotArea area = this.plotAreaManager.getPlotArea(world.getName(), null);
|
||||
if (area == null) {
|
||||
|
@ -46,6 +46,15 @@ import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* Utility that allows for the loading and coordination of chunk actions
|
||||
* <p>
|
||||
* The coordinator takes in collection of chunk coordinates, loads them
|
||||
* and allows the caller to specify a sink for the loaded chunks. The
|
||||
* coordinator will prevent the chunks from being unloaded until the sink
|
||||
* has fully consumed the chunk
|
||||
* <p>
|
||||
**/
|
||||
public final class BukkitChunkCoordinator extends ChunkCoordinator {
|
||||
|
||||
private final List<ProgressSubscriber> progressSubscribers = new LinkedList<>();
|
||||
|
@ -78,9 +78,9 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
BukkitWorld bukkitWorld2 = new BukkitWorld(world2);
|
||||
|
||||
QueueCoordinator queue1 =
|
||||
PlotSquared.platform().getGlobalBlockQueue().getNewQueue(bukkitWorld1, false);
|
||||
PlotSquared.platform().getGlobalBlockQueue().getNewQueue(bukkitWorld1);
|
||||
QueueCoordinator queue2 =
|
||||
PlotSquared.platform().getGlobalBlockQueue().getNewQueue(bukkitWorld2, false);
|
||||
PlotSquared.platform().getGlobalBlockQueue().getNewQueue(bukkitWorld2);
|
||||
|
||||
for (int x = Math.max(r1.getMinimumPoint().getX(), sx);
|
||||
x <= Math.min(r1.getMaximumPoint().getX(), sx + 15); x++) {
|
||||
|
@ -220,7 +220,7 @@ public class BukkitRegionManager extends RegionManager {
|
||||
assert oldWorld.equals(newWorld);
|
||||
final ContentMap map = new ContentMap();
|
||||
final QueueCoordinator queue =
|
||||
PlotSquared.platform().getGlobalBlockQueue().getNewQueue(newWorld, false);
|
||||
PlotSquared.platform().getGlobalBlockQueue().getNewQueue(newWorld);
|
||||
chunkCoordinatorBuilderFactory.create(chunkCoordinatorFactory).inWorld(newWorld)
|
||||
.withRegion(pos1, pos2).withThrowableConsumer(Throwable::printStackTrace)
|
||||
.withRegion(pos1, pos2).withInitialBatchSize(4).withMaxIterationTime(45)
|
||||
@ -279,7 +279,7 @@ public class BukkitRegionManager extends RegionManager {
|
||||
}
|
||||
|
||||
final QueueCoordinator queue =
|
||||
PlotSquared.platform().getGlobalBlockQueue().getNewQueue(world, false);
|
||||
PlotSquared.platform().getGlobalBlockQueue().getNewQueue(world);
|
||||
chunkCoordinatorBuilderFactory.create(chunkCoordinatorFactory).inWorld(world)
|
||||
.withRegion(pos1, pos2).withThrowableConsumer(Throwable::printStackTrace)
|
||||
.withRegion(pos1, pos2).withInitialBatchSize(4).withMaxIterationTime(45)
|
||||
@ -457,7 +457,7 @@ public class BukkitRegionManager extends RegionManager {
|
||||
Location pos2 = Location.at(world, region.getMaximumPoint().getX() + extendBiome,
|
||||
region.getMaximumPoint().getY(), region.getMaximumPoint().getZ() + extendBiome);
|
||||
final QueueCoordinator queue = PlotSquared.platform().getGlobalBlockQueue()
|
||||
.getNewQueue(worldUtil.getWeWorld(world), false);
|
||||
.getNewQueue(worldUtil.getWeWorld(world));
|
||||
|
||||
final int minX = pos1.getX();
|
||||
final int minZ = pos1.getZ();
|
||||
|
@ -35,6 +35,7 @@ import com.plotsquared.core.plot.Plot;
|
||||
import com.plotsquared.core.plot.PlotArea;
|
||||
import com.plotsquared.core.plot.PlotManager;
|
||||
import com.plotsquared.core.queue.GlobalBlockQueue;
|
||||
import com.plotsquared.core.queue.QueueCoordinator;
|
||||
import com.plotsquared.core.util.MainUtil;
|
||||
import com.plotsquared.core.util.PatternUtil;
|
||||
import com.plotsquared.core.util.Permissions;
|
||||
@ -157,11 +158,13 @@ public class Set extends SubCommand {
|
||||
|
||||
BackupManager.backup(player, plot, () -> {
|
||||
plot.addRunning();
|
||||
QueueCoordinator queue = plotArea.getQueue();
|
||||
for (Plot current : plot.getConnectedPlots()) {
|
||||
current.setComponent(component, pattern);
|
||||
current.setComponent(component, pattern, queue);
|
||||
}
|
||||
queue.setCompleteTask(plot::removeRunning);
|
||||
queue.enqueue();
|
||||
MainUtil.sendMessage(player, Captions.GENERATING_COMPONENT);
|
||||
blockQueue.addEmptyTask(plot::removeRunning);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
@ -190,7 +190,7 @@ public class Trim extends SubCommand {
|
||||
}
|
||||
}
|
||||
}
|
||||
final QueueCoordinator queue = blockQueue.getNewQueue(worldUtil.getWeWorld(world), false);
|
||||
final QueueCoordinator queue = blockQueue.getNewQueue(worldUtil.getWeWorld(world));
|
||||
TaskManager.getPlatformImplementation().objectTask(chunks, new RunnableVal<BlockVector2>() {
|
||||
@Override public void run(BlockVector2 value) {
|
||||
queue.regenChunk(value.getX(), value.getZ());
|
||||
|
@ -37,6 +37,7 @@ import com.plotsquared.core.player.PlotPlayer;
|
||||
import com.plotsquared.core.plot.Plot;
|
||||
import com.plotsquared.core.plot.PlotInventory;
|
||||
import com.plotsquared.core.plot.PlotItemStack;
|
||||
import com.plotsquared.core.queue.QueueCoordinator;
|
||||
import com.plotsquared.core.util.EconHandler;
|
||||
import com.plotsquared.core.util.InventoryUtil;
|
||||
import com.plotsquared.core.util.MainUtil;
|
||||
@ -44,11 +45,11 @@ import com.plotsquared.core.util.PatternUtil;
|
||||
import com.plotsquared.core.util.Permissions;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.world.item.ItemTypes;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
@ -61,18 +62,20 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class ComponentPresetManager {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger("P2/" + ComponentPresetManager.class.getSimpleName());
|
||||
private static final Logger logger =
|
||||
LoggerFactory.getLogger("P2/" + ComponentPresetManager.class.getSimpleName());
|
||||
|
||||
private final List<ComponentPreset> presets;
|
||||
private final String guiName;
|
||||
private final EconHandler econHandler;
|
||||
private final InventoryUtil inventoryUtil;
|
||||
|
||||
@Inject public ComponentPresetManager(@Nullable final EconHandler econHandler, @Nonnull final
|
||||
InventoryUtil inventoryUtil) {
|
||||
@Inject public ComponentPresetManager(@Nullable final EconHandler econHandler,
|
||||
@Nonnull final InventoryUtil inventoryUtil) {
|
||||
this.econHandler = econHandler;
|
||||
this.inventoryUtil = inventoryUtil;
|
||||
final File file = new File(Objects.requireNonNull(PlotSquared.platform()).getDirectory(), "components.yml");
|
||||
final File file = new File(Objects.requireNonNull(PlotSquared.platform()).getDirectory(),
|
||||
"components.yml");
|
||||
if (!file.exists()) {
|
||||
boolean created = false;
|
||||
try {
|
||||
@ -103,13 +106,14 @@ public class ComponentPresetManager {
|
||||
this.guiName = yamlConfiguration.getString("title", "&6Plot Components");
|
||||
|
||||
if (yamlConfiguration.contains("presets")) {
|
||||
this.presets = yamlConfiguration.getMapList("presets").stream().map(o -> (Map<String, Object>) o)
|
||||
.map(ComponentPreset::deserialize).collect(Collectors.toList());
|
||||
this.presets =
|
||||
yamlConfiguration.getMapList("presets").stream().map(o -> (Map<String, Object>) o)
|
||||
.map(ComponentPreset::deserialize).collect(Collectors.toList());
|
||||
} else {
|
||||
final List<ComponentPreset> defaultPreset =
|
||||
Collections.singletonList(new ComponentPreset(ClassicPlotManagerComponent.FLOOR,
|
||||
"##wool", 0, "", "&6D&ai&cs&ec&bo &2F&3l&do&9o&4r",
|
||||
Arrays.asList("&6Spice up your plot floor"), ItemTypes.YELLOW_WOOL));
|
||||
final List<ComponentPreset> defaultPreset = Collections.singletonList(
|
||||
new ComponentPreset(ClassicPlotManagerComponent.FLOOR, "##wool", 0, "",
|
||||
"&6D&ai&cs&ec&bo &2F&3l&do&9o&4r", Arrays.asList("&6Spice up your plot floor"),
|
||||
ItemTypes.YELLOW_WOOL));
|
||||
yamlConfiguration.set("presets", defaultPreset.stream().map(ComponentPreset::serialize)
|
||||
.collect(Collectors.toList()));
|
||||
try {
|
||||
@ -139,7 +143,8 @@ public class ComponentPresetManager {
|
||||
} else if (!plot.hasOwner()) {
|
||||
Captions.PLOT_UNOWNED.send(player);
|
||||
return null;
|
||||
} else if (!plot.isOwner(player.getUUID()) && !plot.getTrusted().contains(player.getUUID())) {
|
||||
} else if (!plot.isOwner(player.getUUID()) && !plot.getTrusted()
|
||||
.contains(player.getUUID())) {
|
||||
Captions.NO_PLOT_PERMS.send(player);
|
||||
return null;
|
||||
}
|
||||
@ -153,71 +158,78 @@ public class ComponentPresetManager {
|
||||
allowedPresets.add(componentPreset);
|
||||
}
|
||||
final int size = (int) Math.ceil((double) allowedPresets.size() / 9.0D);
|
||||
final PlotInventory plotInventory = new PlotInventory(this.inventoryUtil, player, size, this.guiName) {
|
||||
@Override public boolean onClick(final int index) {
|
||||
if (!player.getCurrentPlot().equals(plot)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (index < 0 || index >= allowedPresets.size()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final ComponentPreset componentPreset = allowedPresets.get(index);
|
||||
if (componentPreset == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (plot.getRunning() > 0) {
|
||||
Captions.WAIT_FOR_TIMER.send(player);
|
||||
return false;
|
||||
}
|
||||
|
||||
final Pattern pattern = PatternUtil.parse(null, componentPreset.getPattern(), false);
|
||||
if (pattern == null) {
|
||||
Captions.PRESET_INVALID.send(player);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (componentPreset.getCost() > 0.0D && econHandler != null && plot.getArea().useEconomy()) {
|
||||
if (econHandler.getMoney(player) < componentPreset.getCost()) {
|
||||
Captions.PRESET_CANNOT_AFFORD.send(player);
|
||||
final PlotInventory plotInventory =
|
||||
new PlotInventory(this.inventoryUtil, player, size, this.guiName) {
|
||||
@Override public boolean onClick(final int index) {
|
||||
if (!player.getCurrentPlot().equals(plot)) {
|
||||
return false;
|
||||
} else {
|
||||
econHandler.withdrawMoney(player, componentPreset.getCost());
|
||||
Captions.REMOVED_BALANCE.send(player, componentPreset.getCost() + "");
|
||||
}
|
||||
}
|
||||
|
||||
BackupManager.backup(player, plot, () -> {
|
||||
plot.addRunning();
|
||||
for (Plot current : plot.getConnectedPlots()) {
|
||||
current.setComponent(componentPreset.getComponent().name(), pattern);
|
||||
if (index < 0 || index >= allowedPresets.size()) {
|
||||
return false;
|
||||
}
|
||||
MainUtil.sendMessage(player, Captions.GENERATING_COMPONENT);
|
||||
PlotSquared.platform().getGlobalBlockQueue().addEmptyTask(plot::removeRunning);
|
||||
});
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
final ComponentPreset componentPreset = allowedPresets.get(index);
|
||||
if (componentPreset == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (plot.getRunning() > 0) {
|
||||
Captions.WAIT_FOR_TIMER.send(player);
|
||||
return false;
|
||||
}
|
||||
|
||||
final Pattern pattern =
|
||||
PatternUtil.parse(null, componentPreset.getPattern(), false);
|
||||
if (pattern == null) {
|
||||
Captions.PRESET_INVALID.send(player);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (componentPreset.getCost() > 0.0D && econHandler != null && plot.getArea()
|
||||
.useEconomy()) {
|
||||
if (econHandler.getMoney(player) < componentPreset.getCost()) {
|
||||
Captions.PRESET_CANNOT_AFFORD.send(player);
|
||||
return false;
|
||||
} else {
|
||||
econHandler.withdrawMoney(player, componentPreset.getCost());
|
||||
Captions.REMOVED_BALANCE.send(player, componentPreset.getCost() + "");
|
||||
}
|
||||
}
|
||||
|
||||
BackupManager.backup(player, plot, () -> {
|
||||
plot.addRunning();
|
||||
QueueCoordinator queue = plot.getArea().getQueue();
|
||||
for (Plot current : plot.getConnectedPlots()) {
|
||||
current.setComponent(componentPreset.getComponent().name(), pattern,
|
||||
queue);
|
||||
}
|
||||
queue.setCompleteTask(plot::removeRunning);
|
||||
queue.enqueue();
|
||||
MainUtil.sendMessage(player, Captions.GENERATING_COMPONENT);
|
||||
});
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
for (int i = 0; i < allowedPresets.size(); i++) {
|
||||
final ComponentPreset preset = allowedPresets.get(i);
|
||||
final List<String> lore = new ArrayList<>();
|
||||
if (preset.getCost() > 0 && this.econHandler != null && plot.getArea().useEconomy()){
|
||||
lore.add(Captions.PRESET_LORE_COST.getTranslated().replace("%cost%",
|
||||
String.format("%.2f", preset.getCost())));
|
||||
if (preset.getCost() > 0 && this.econHandler != null && plot.getArea().useEconomy()) {
|
||||
lore.add(Captions.PRESET_LORE_COST.getTranslated()
|
||||
.replace("%cost%", String.format("%.2f", preset.getCost())));
|
||||
}
|
||||
lore.add(Captions.PRESET_LORE_COMPONENT.getTranslated().replace("%component%",
|
||||
preset.getComponent().name().toLowerCase()));
|
||||
lore.add(Captions.PRESET_LORE_COMPONENT.getTranslated()
|
||||
.replace("%component%", preset.getComponent().name().toLowerCase()));
|
||||
lore.removeIf(String::isEmpty);
|
||||
if (!lore.isEmpty()) {
|
||||
lore.add("&6");
|
||||
}
|
||||
lore.addAll(preset.getDescription());
|
||||
plotInventory.setItem(i, new PlotItemStack(preset.getIcon().getId().replace("minecraft:", ""),
|
||||
1, preset.getDisplayName(), lore.toArray(new String[0])));
|
||||
plotInventory.setItem(i,
|
||||
new PlotItemStack(preset.getIcon().getId().replace("minecraft:", ""), 1,
|
||||
preset.getDisplayName(), lore.toArray(new String[0])));
|
||||
}
|
||||
|
||||
return plotInventory;
|
||||
|
@ -87,7 +87,7 @@ public class AugmentedUtils {
|
||||
IndependentPlotGenerator generator = area.getGenerator();
|
||||
// Mask
|
||||
if (queue == null) {
|
||||
queue = PlotSquared.platform().getGlobalBlockQueue().getNewQueue(PlotSquared.platform().getWorldUtil().getWeWorld(world), false);
|
||||
queue = PlotSquared.platform().getGlobalBlockQueue().getNewQueue(PlotSquared.platform().getWorldUtil().getWeWorld(world));
|
||||
queue.setChunkObject(chunkObject);
|
||||
}
|
||||
QueueCoordinator primaryMask;
|
||||
|
@ -40,8 +40,9 @@ import com.plotsquared.core.util.task.TaskManager;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@ -54,98 +55,107 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
private final RegionManager regionManager;
|
||||
|
||||
public ClassicPlotManager(@Nonnull final ClassicPlotWorld classicPlotWorld,
|
||||
@Nonnull final RegionManager regionManager) {
|
||||
@Nonnull final RegionManager regionManager) {
|
||||
super(classicPlotWorld, regionManager);
|
||||
this.classicPlotWorld = classicPlotWorld;
|
||||
this.regionManager = regionManager;
|
||||
}
|
||||
|
||||
@Override public boolean setComponent(PlotId plotId, String component, Pattern blocks) {
|
||||
@Override public boolean setComponent(PlotId plotId, String component, Pattern blocks,
|
||||
@Nullable QueueCoordinator queue) {
|
||||
final Optional<ClassicPlotManagerComponent> componentOptional =
|
||||
ClassicPlotManagerComponent.fromString(component);
|
||||
if (componentOptional.isPresent()) {
|
||||
switch (componentOptional.get()) {
|
||||
case FLOOR:
|
||||
return setFloor(plotId, blocks);
|
||||
return setFloor(plotId, blocks, queue);
|
||||
case WALL:
|
||||
return setWallFilling(plotId, blocks);
|
||||
return setWallFilling(plotId, blocks, queue);
|
||||
case AIR:
|
||||
return setAir(plotId, blocks);
|
||||
return setAir(plotId, blocks, queue);
|
||||
case MAIN:
|
||||
return setMain(plotId, blocks);
|
||||
return setMain(plotId, blocks, queue);
|
||||
case MIDDLE:
|
||||
return setMiddle(plotId, blocks);
|
||||
return setMiddle(plotId, blocks, queue);
|
||||
case OUTLINE:
|
||||
return setOutline(plotId, blocks);
|
||||
return setOutline(plotId, blocks, queue);
|
||||
case BORDER:
|
||||
return setWall(plotId, blocks);
|
||||
return setWall(plotId, blocks, queue);
|
||||
case ALL:
|
||||
return setAll(plotId, blocks);
|
||||
return setAll(plotId, blocks, queue);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override public boolean unClaimPlot(Plot plot, Runnable whenDone) {
|
||||
setWallFilling(plot.getId(), classicPlotWorld.WALL_FILLING.toPattern());
|
||||
@Override public boolean unClaimPlot(Plot plot, @Nullable Runnable whenDone,
|
||||
@Nullable QueueCoordinator queue) {
|
||||
setWallFilling(plot.getId(), classicPlotWorld.WALL_FILLING.toPattern(), queue);
|
||||
if (!classicPlotWorld.WALL_BLOCK.isAir() || !classicPlotWorld.WALL_BLOCK
|
||||
.equals(classicPlotWorld.CLAIMED_WALL_BLOCK)) {
|
||||
setWall(plot.getId(), classicPlotWorld.WALL_BLOCK.toPattern());
|
||||
setWall(plot.getId(), classicPlotWorld.WALL_BLOCK.toPattern(), queue);
|
||||
}
|
||||
TaskManager.runTask(whenDone);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean setFloor(PlotId plotId, Pattern blocks) {
|
||||
public boolean setFloor(PlotId plotId, Pattern blocks, @Nullable QueueCoordinator queue) {
|
||||
Plot plot = classicPlotWorld.getPlotAbs(plotId);
|
||||
if (plot.isBasePlot()) {
|
||||
if (plot != null && plot.isBasePlot()) {
|
||||
return this.regionManager.setCuboids(classicPlotWorld, plot.getRegions(), blocks,
|
||||
classicPlotWorld.PLOT_HEIGHT, classicPlotWorld.PLOT_HEIGHT);
|
||||
classicPlotWorld.PLOT_HEIGHT, classicPlotWorld.PLOT_HEIGHT, queue);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean setAll(PlotId plotId, Pattern blocks) {
|
||||
public boolean setAll(PlotId plotId, Pattern blocks, @Nullable QueueCoordinator queue) {
|
||||
Plot plot = classicPlotWorld.getPlotAbs(plotId);
|
||||
if (plot.isBasePlot()) {
|
||||
return this.regionManager.setCuboids(classicPlotWorld, plot.getRegions(), blocks, 1, getWorldHeight());
|
||||
if (plot != null && plot.isBasePlot()) {
|
||||
return this.regionManager
|
||||
.setCuboids(classicPlotWorld, plot.getRegions(), blocks, 1, getWorldHeight(),
|
||||
queue);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean setAir(PlotId plotId, Pattern blocks) {
|
||||
public boolean setAir(PlotId plotId, Pattern blocks, @Nullable QueueCoordinator queue) {
|
||||
Plot plot = classicPlotWorld.getPlotAbs(plotId);
|
||||
if (plot.isBasePlot()) {
|
||||
if (plot != null && plot.isBasePlot()) {
|
||||
return this.regionManager.setCuboids(classicPlotWorld, plot.getRegions(), blocks,
|
||||
classicPlotWorld.PLOT_HEIGHT + 1, getWorldHeight());
|
||||
classicPlotWorld.PLOT_HEIGHT + 1, getWorldHeight(), queue);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean setMain(PlotId plotId, Pattern blocks) {
|
||||
public boolean setMain(PlotId plotId, Pattern blocks, @Nullable QueueCoordinator queue) {
|
||||
Plot plot = classicPlotWorld.getPlotAbs(plotId);
|
||||
if (plot.isBasePlot()) {
|
||||
if (plot == null || plot.isBasePlot()) {
|
||||
return this.regionManager.setCuboids(classicPlotWorld, plot.getRegions(), blocks, 1,
|
||||
classicPlotWorld.PLOT_HEIGHT - 1);
|
||||
classicPlotWorld.PLOT_HEIGHT - 1, queue);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean setMiddle(PlotId plotId, Pattern blocks) {
|
||||
public boolean setMiddle(PlotId plotId, Pattern blocks, @Nullable QueueCoordinator queue) {
|
||||
Plot plot = classicPlotWorld.getPlotAbs(plotId);
|
||||
if (!plot.isBasePlot()) {
|
||||
if (plot == null || !plot.isBasePlot()) {
|
||||
return false;
|
||||
}
|
||||
Location[] corners = plot.getCorners();
|
||||
QueueCoordinator queue = classicPlotWorld.getQueue(false);
|
||||
|
||||
boolean enqueue = false;
|
||||
if (queue == null) {
|
||||
queue = classicPlotWorld.getQueue();
|
||||
enqueue = true;
|
||||
}
|
||||
|
||||
int x = MathMan.average(corners[0].getX(), corners[1].getX());
|
||||
int z = MathMan.average(corners[0].getZ(), corners[1].getZ());
|
||||
queue.setBlock(x, classicPlotWorld.PLOT_HEIGHT, z, blocks);
|
||||
return queue.enqueue();
|
||||
return !enqueue || queue.enqueue();
|
||||
}
|
||||
|
||||
public boolean setOutline(PlotId plotId, Pattern blocks) {
|
||||
public boolean setOutline(PlotId plotId, Pattern blocks, @Nullable QueueCoordinator queue) {
|
||||
if (classicPlotWorld.ROAD_WIDTH == 0) {
|
||||
return false;
|
||||
}
|
||||
@ -156,9 +166,18 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
return true;
|
||||
}
|
||||
Plot plot = classicPlotWorld.getPlotAbs(plotId);
|
||||
if (plot == null) {
|
||||
return false;
|
||||
}
|
||||
Location bottom = plot.getBottomAbs();
|
||||
Location top = plot.getExtendedTopAbs();
|
||||
QueueCoordinator queue = classicPlotWorld.getQueue(false);
|
||||
|
||||
boolean enqueue = false;
|
||||
if (queue == null) {
|
||||
queue = classicPlotWorld.getQueue();
|
||||
enqueue = true;
|
||||
}
|
||||
|
||||
int maxY = classicPlotWorld.getPlotManager().getWorldHeight();
|
||||
if (!plot.getMerged(Direction.NORTH)) {
|
||||
int z = bottom.getZ();
|
||||
@ -195,19 +214,19 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
}
|
||||
if (plot.isBasePlot()) {
|
||||
for (CuboidRegion region : plot.getRegions()) {
|
||||
Location pos1 =
|
||||
Location.at(classicPlotWorld.getWorldName(), region.getMinimumPoint().getX(),
|
||||
maxY, region.getMinimumPoint().getZ());
|
||||
Location pos2 =
|
||||
Location.at(classicPlotWorld.getWorldName(), region.getMaximumPoint().getX(),
|
||||
maxY, region.getMaximumPoint().getZ());
|
||||
Location pos1 = Location
|
||||
.at(classicPlotWorld.getWorldName(), region.getMinimumPoint().getX(), maxY,
|
||||
region.getMinimumPoint().getZ());
|
||||
Location pos2 = Location
|
||||
.at(classicPlotWorld.getWorldName(), region.getMaximumPoint().getX(), maxY,
|
||||
region.getMaximumPoint().getZ());
|
||||
queue.setCuboid(pos1, pos2, blocks);
|
||||
}
|
||||
}
|
||||
return queue.enqueue();
|
||||
return !enqueue || queue.enqueue();
|
||||
}
|
||||
|
||||
public boolean setWallFilling(PlotId plotId, Pattern blocks) {
|
||||
public boolean setWallFilling(PlotId plotId, Pattern blocks, @Nullable QueueCoordinator queue) {
|
||||
if (classicPlotWorld.ROAD_WIDTH == 0) {
|
||||
return false;
|
||||
}
|
||||
@ -218,11 +237,20 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
return true;
|
||||
}
|
||||
Plot plot = classicPlotWorld.getPlotAbs(plotId);
|
||||
if (plot == null) {
|
||||
return false;
|
||||
}
|
||||
Location bot = plot.getExtendedBottomAbs()
|
||||
.subtract(plot.getMerged(Direction.WEST) ? 0 : 1, 0,
|
||||
plot.getMerged(Direction.NORTH) ? 0 : 1);
|
||||
Location top = plot.getExtendedTopAbs().add(1, 0, 1);
|
||||
QueueCoordinator queue = classicPlotWorld.getQueue(false);
|
||||
|
||||
boolean enqueue = false;
|
||||
if (queue == null) {
|
||||
queue = classicPlotWorld.getQueue();
|
||||
enqueue = true;
|
||||
}
|
||||
|
||||
if (!plot.getMerged(Direction.NORTH)) {
|
||||
int z = bot.getZ();
|
||||
for (int x = bot.getX(); x < top.getX(); x++) {
|
||||
@ -257,10 +285,10 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
return queue.enqueue();
|
||||
return !enqueue || queue.enqueue();
|
||||
}
|
||||
|
||||
public boolean setWall(PlotId plotId, Pattern blocks) {
|
||||
public boolean setWall(PlotId plotId, Pattern blocks, @Nullable QueueCoordinator queue) {
|
||||
if (classicPlotWorld.ROAD_WIDTH == 0) {
|
||||
return false;
|
||||
}
|
||||
@ -271,11 +299,20 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
return true;
|
||||
}
|
||||
Plot plot = classicPlotWorld.getPlotAbs(plotId);
|
||||
if (plot == null) {
|
||||
return false;
|
||||
}
|
||||
Location bot = plot.getExtendedBottomAbs()
|
||||
.subtract(plot.getMerged(Direction.WEST) ? 0 : 1, 0,
|
||||
plot.getMerged(Direction.NORTH) ? 0 : 1);
|
||||
Location top = plot.getExtendedTopAbs().add(1, 0, 1);
|
||||
QueueCoordinator queue = classicPlotWorld.getQueue(false);
|
||||
|
||||
boolean enqueue = false;
|
||||
if (queue == null) {
|
||||
enqueue = true;
|
||||
queue = classicPlotWorld.getQueue();
|
||||
}
|
||||
|
||||
int y = classicPlotWorld.WALL_HEIGHT + 1;
|
||||
if (!plot.getMerged(Direction.NORTH)) {
|
||||
int z = bot.getZ();
|
||||
@ -303,23 +340,29 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
queue.setBlock(x, y, z, blocks);
|
||||
}
|
||||
}
|
||||
return queue.enqueue();
|
||||
return !enqueue || queue.enqueue();
|
||||
}
|
||||
|
||||
/**
|
||||
* PLOT MERGING.
|
||||
*/
|
||||
@Override public boolean createRoadEast(Plot plot) {
|
||||
@Override public boolean createRoadEast(Plot plot, @Nullable QueueCoordinator queue) {
|
||||
Location pos1 = getPlotBottomLocAbs(plot.getId());
|
||||
Location pos2 = getPlotTopLocAbs(plot.getId());
|
||||
int sx = pos2.getX() + 1;
|
||||
int ex = sx + classicPlotWorld.ROAD_WIDTH - 1;
|
||||
int sz = pos1.getZ() - 2;
|
||||
int ez = pos2.getZ() + 2;
|
||||
QueueCoordinator queue = classicPlotWorld.getQueue(false);
|
||||
|
||||
boolean enqueue = false;
|
||||
if (queue == null) {
|
||||
queue = classicPlotWorld.getQueue();
|
||||
enqueue = true;
|
||||
}
|
||||
|
||||
int maxY = getWorldHeight();
|
||||
queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx,
|
||||
Math.min(classicPlotWorld.WALL_HEIGHT, classicPlotWorld.ROAD_HEIGHT) + 1, sz + 1),
|
||||
Math.min(classicPlotWorld.WALL_HEIGHT, classicPlotWorld.ROAD_HEIGHT) + 1, sz + 1),
|
||||
Location.at(classicPlotWorld.getWorldName(), ex, maxY, ez - 1),
|
||||
BlockTypes.AIR.getDefaultState());
|
||||
queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx, 0, sz + 1),
|
||||
@ -328,37 +371,43 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx, 1, sz + 1),
|
||||
Location.at(classicPlotWorld.getWorldName(), sx, classicPlotWorld.WALL_HEIGHT, ez - 1),
|
||||
classicPlotWorld.WALL_FILLING.toPattern());
|
||||
queue.setCuboid(
|
||||
Location.at(classicPlotWorld.getWorldName(), sx, classicPlotWorld.WALL_HEIGHT + 1,
|
||||
sz + 1),
|
||||
Location.at(classicPlotWorld.getWorldName(), sx, classicPlotWorld.WALL_HEIGHT + 1,
|
||||
ez - 1), classicPlotWorld.WALL_BLOCK.toPattern());
|
||||
queue.setCuboid(Location
|
||||
.at(classicPlotWorld.getWorldName(), sx, classicPlotWorld.WALL_HEIGHT + 1, sz + 1),
|
||||
Location
|
||||
.at(classicPlotWorld.getWorldName(), sx, classicPlotWorld.WALL_HEIGHT + 1, ez - 1),
|
||||
classicPlotWorld.WALL_BLOCK.toPattern());
|
||||
queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), ex, 1, sz + 1),
|
||||
Location.at(classicPlotWorld.getWorldName(), ex, classicPlotWorld.WALL_HEIGHT, ez - 1),
|
||||
classicPlotWorld.WALL_FILLING.toPattern());
|
||||
queue.setCuboid(
|
||||
Location.at(classicPlotWorld.getWorldName(), ex, classicPlotWorld.WALL_HEIGHT + 1,
|
||||
sz + 1),
|
||||
Location.at(classicPlotWorld.getWorldName(), ex, classicPlotWorld.WALL_HEIGHT + 1,
|
||||
ez - 1), classicPlotWorld.WALL_BLOCK.toPattern());
|
||||
queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx + 1, 1, sz + 1),
|
||||
Location.at(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.ROAD_HEIGHT,
|
||||
ez - 1), classicPlotWorld.ROAD_BLOCK.toPattern());
|
||||
return queue.enqueue();
|
||||
queue.setCuboid(Location
|
||||
.at(classicPlotWorld.getWorldName(), ex, classicPlotWorld.WALL_HEIGHT + 1, sz + 1),
|
||||
Location
|
||||
.at(classicPlotWorld.getWorldName(), ex, classicPlotWorld.WALL_HEIGHT + 1, ez - 1),
|
||||
classicPlotWorld.WALL_BLOCK.toPattern());
|
||||
queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx + 1, 1, sz + 1), Location
|
||||
.at(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.ROAD_HEIGHT, ez - 1),
|
||||
classicPlotWorld.ROAD_BLOCK.toPattern());
|
||||
return !enqueue || queue.enqueue();
|
||||
}
|
||||
|
||||
@Override public boolean createRoadSouth(Plot plot) {
|
||||
@Override public boolean createRoadSouth(Plot plot, @Nullable QueueCoordinator queue) {
|
||||
Location pos1 = getPlotBottomLocAbs(plot.getId());
|
||||
Location pos2 = getPlotTopLocAbs(plot.getId());
|
||||
int sz = pos2.getZ() + 1;
|
||||
int ez = sz + classicPlotWorld.ROAD_WIDTH - 1;
|
||||
int sx = pos1.getX() - 2;
|
||||
int ex = pos2.getX() + 2;
|
||||
QueueCoordinator queue = classicPlotWorld.getQueue(false);
|
||||
|
||||
boolean enqueue = false;
|
||||
if (queue == null) {
|
||||
queue = classicPlotWorld.getQueue();
|
||||
enqueue = true;
|
||||
}
|
||||
|
||||
queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx + 1,
|
||||
Math.min(classicPlotWorld.WALL_HEIGHT, classicPlotWorld.ROAD_HEIGHT) + 1, sz),
|
||||
Location.at(classicPlotWorld.getWorldName(), ex - 1,
|
||||
classicPlotWorld.getPlotManager().getWorldHeight(), ez),
|
||||
Math.min(classicPlotWorld.WALL_HEIGHT, classicPlotWorld.ROAD_HEIGHT) + 1, sz), Location
|
||||
.at(classicPlotWorld.getWorldName(), ex - 1,
|
||||
classicPlotWorld.getPlotManager().getWorldHeight(), ez),
|
||||
BlockTypes.AIR.getDefaultState());
|
||||
queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx + 1, 0, sz),
|
||||
Location.at(classicPlotWorld.getWorldName(), ex - 1, 0, ez),
|
||||
@ -366,104 +415,128 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx + 1, 1, sz),
|
||||
Location.at(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.WALL_HEIGHT, sz),
|
||||
classicPlotWorld.WALL_FILLING.toPattern());
|
||||
queue.setCuboid(
|
||||
Location.at(classicPlotWorld.getWorldName(), sx + 1, classicPlotWorld.WALL_HEIGHT + 1,
|
||||
sz),
|
||||
Location.at(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.WALL_HEIGHT + 1,
|
||||
sz), classicPlotWorld.WALL_BLOCK.toPattern());
|
||||
queue.setCuboid(Location
|
||||
.at(classicPlotWorld.getWorldName(), sx + 1, classicPlotWorld.WALL_HEIGHT + 1, sz),
|
||||
Location
|
||||
.at(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.WALL_HEIGHT + 1, sz),
|
||||
classicPlotWorld.WALL_BLOCK.toPattern());
|
||||
queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx + 1, 1, ez),
|
||||
Location.at(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.WALL_HEIGHT, ez),
|
||||
classicPlotWorld.WALL_FILLING.toPattern());
|
||||
queue.setCuboid(
|
||||
Location.at(classicPlotWorld.getWorldName(), sx + 1, classicPlotWorld.WALL_HEIGHT + 1,
|
||||
ez),
|
||||
Location.at(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.WALL_HEIGHT + 1,
|
||||
ez), classicPlotWorld.WALL_BLOCK.toPattern());
|
||||
queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx + 1, 1, sz + 1),
|
||||
Location.at(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.ROAD_HEIGHT,
|
||||
ez - 1), classicPlotWorld.ROAD_BLOCK.toPattern());
|
||||
return queue.enqueue();
|
||||
queue.setCuboid(Location
|
||||
.at(classicPlotWorld.getWorldName(), sx + 1, classicPlotWorld.WALL_HEIGHT + 1, ez),
|
||||
Location
|
||||
.at(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.WALL_HEIGHT + 1, ez),
|
||||
classicPlotWorld.WALL_BLOCK.toPattern());
|
||||
queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx + 1, 1, sz + 1), Location
|
||||
.at(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.ROAD_HEIGHT, ez - 1),
|
||||
classicPlotWorld.ROAD_BLOCK.toPattern());
|
||||
return !enqueue || queue.enqueue();
|
||||
}
|
||||
|
||||
@Override public boolean createRoadSouthEast(Plot plot) {
|
||||
@Override public boolean createRoadSouthEast(Plot plot, @Nullable QueueCoordinator queue) {
|
||||
Location pos2 = getPlotTopLocAbs(plot.getId());
|
||||
int sx = pos2.getX() + 1;
|
||||
int ex = sx + classicPlotWorld.ROAD_WIDTH - 1;
|
||||
int sz = pos2.getZ() + 1;
|
||||
int ez = sz + classicPlotWorld.ROAD_WIDTH - 1;
|
||||
QueueCoordinator queue = classicPlotWorld.getQueue(false);
|
||||
queue.setCuboid(
|
||||
Location.at(classicPlotWorld.getWorldName(), sx + 1, classicPlotWorld.ROAD_HEIGHT + 1,
|
||||
sz + 1), Location.at(classicPlotWorld.getWorldName(), ex - 1,
|
||||
|
||||
boolean enqueue = false;
|
||||
if (queue == null) {
|
||||
queue = classicPlotWorld.getQueue();
|
||||
enqueue = true;
|
||||
}
|
||||
|
||||
queue.setCuboid(Location
|
||||
.at(classicPlotWorld.getWorldName(), sx + 1, classicPlotWorld.ROAD_HEIGHT + 1, sz + 1),
|
||||
Location.at(classicPlotWorld.getWorldName(), ex - 1,
|
||||
classicPlotWorld.getPlotManager().getWorldHeight(), ez - 1),
|
||||
BlockTypes.AIR.getDefaultState());
|
||||
queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx + 1, 0, sz + 1),
|
||||
Location.at(classicPlotWorld.getWorldName(), ex - 1, 0, ez - 1),
|
||||
BlockUtil.get((short) 7, (byte) 0));
|
||||
queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx + 1, 1, sz + 1),
|
||||
Location.at(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.ROAD_HEIGHT,
|
||||
ez - 1), classicPlotWorld.ROAD_BLOCK.toPattern());
|
||||
return queue.enqueue();
|
||||
queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx + 1, 1, sz + 1), Location
|
||||
.at(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.ROAD_HEIGHT, ez - 1),
|
||||
classicPlotWorld.ROAD_BLOCK.toPattern());
|
||||
return !enqueue || queue.enqueue();
|
||||
}
|
||||
|
||||
@Override public boolean removeRoadEast(Plot plot) {
|
||||
@Override public boolean removeRoadEast(Plot plot, @Nullable QueueCoordinator queue) {
|
||||
Location pos1 = getPlotBottomLocAbs(plot.getId());
|
||||
Location pos2 = getPlotTopLocAbs(plot.getId());
|
||||
int sx = pos2.getX() + 1;
|
||||
int ex = sx + classicPlotWorld.ROAD_WIDTH - 1;
|
||||
int sz = pos1.getZ() - 1;
|
||||
int ez = pos2.getZ() + 1;
|
||||
QueueCoordinator queue = classicPlotWorld.getQueue(false);
|
||||
|
||||
boolean enqueue = false;
|
||||
if (queue == null) {
|
||||
queue = classicPlotWorld.getQueue();
|
||||
enqueue = true;
|
||||
}
|
||||
|
||||
queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx,
|
||||
Math.min(classicPlotWorld.PLOT_HEIGHT, classicPlotWorld.ROAD_HEIGHT) + 1, sz),
|
||||
Location.at(classicPlotWorld.getWorldName(), ex,
|
||||
classicPlotWorld.getPlotManager().getWorldHeight(), ez),
|
||||
Math.min(classicPlotWorld.PLOT_HEIGHT, classicPlotWorld.ROAD_HEIGHT) + 1, sz), Location
|
||||
.at(classicPlotWorld.getWorldName(), ex,
|
||||
classicPlotWorld.getPlotManager().getWorldHeight(), ez),
|
||||
BlockTypes.AIR.getDefaultState());
|
||||
queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx, 1, sz + 1),
|
||||
Location.at(classicPlotWorld.getWorldName(), ex, classicPlotWorld.PLOT_HEIGHT - 1,
|
||||
ez - 1), classicPlotWorld.MAIN_BLOCK.toPattern());
|
||||
queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx, 1, sz + 1), Location
|
||||
.at(classicPlotWorld.getWorldName(), ex, classicPlotWorld.PLOT_HEIGHT - 1, ez - 1),
|
||||
classicPlotWorld.MAIN_BLOCK.toPattern());
|
||||
queue.setCuboid(
|
||||
Location.at(classicPlotWorld.getWorldName(), sx, classicPlotWorld.PLOT_HEIGHT, sz + 1),
|
||||
Location.at(classicPlotWorld.getWorldName(), ex, classicPlotWorld.PLOT_HEIGHT, ez - 1),
|
||||
classicPlotWorld.TOP_BLOCK.toPattern());
|
||||
return queue.enqueue();
|
||||
return !enqueue || queue.enqueue();
|
||||
}
|
||||
|
||||
@Override public boolean removeRoadSouth(Plot plot) {
|
||||
@Override public boolean removeRoadSouth(Plot plot, @Nullable QueueCoordinator queue) {
|
||||
Location pos1 = getPlotBottomLocAbs(plot.getId());
|
||||
Location pos2 = getPlotTopLocAbs(plot.getId());
|
||||
int sz = pos2.getZ() + 1;
|
||||
int ez = sz + classicPlotWorld.ROAD_WIDTH - 1;
|
||||
int sx = pos1.getX() - 1;
|
||||
int ex = pos2.getX() + 1;
|
||||
QueueCoordinator queue = classicPlotWorld.getQueue(false);
|
||||
|
||||
boolean enqueue = false;
|
||||
if (queue == null) {
|
||||
queue = classicPlotWorld.getQueue();
|
||||
enqueue = true;
|
||||
}
|
||||
|
||||
queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx,
|
||||
Math.min(classicPlotWorld.PLOT_HEIGHT, classicPlotWorld.ROAD_HEIGHT) + 1, sz),
|
||||
Location.at(classicPlotWorld.getWorldName(), ex,
|
||||
classicPlotWorld.getPlotManager().getWorldHeight(), ez),
|
||||
Math.min(classicPlotWorld.PLOT_HEIGHT, classicPlotWorld.ROAD_HEIGHT) + 1, sz), Location
|
||||
.at(classicPlotWorld.getWorldName(), ex,
|
||||
classicPlotWorld.getPlotManager().getWorldHeight(), ez),
|
||||
BlockTypes.AIR.getDefaultState());
|
||||
queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx + 1, 1, sz),
|
||||
Location.at(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.PLOT_HEIGHT - 1,
|
||||
ez), classicPlotWorld.MAIN_BLOCK.toPattern());
|
||||
queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx + 1, 1, sz), Location
|
||||
.at(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.PLOT_HEIGHT - 1, ez),
|
||||
classicPlotWorld.MAIN_BLOCK.toPattern());
|
||||
queue.setCuboid(
|
||||
Location.at(classicPlotWorld.getWorldName(), sx + 1, classicPlotWorld.PLOT_HEIGHT, sz),
|
||||
Location.at(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.PLOT_HEIGHT, ez),
|
||||
classicPlotWorld.TOP_BLOCK.toPattern());
|
||||
return queue.enqueue();
|
||||
return !enqueue || queue.enqueue();
|
||||
}
|
||||
|
||||
@Override public boolean removeRoadSouthEast(Plot plot) {
|
||||
@Override public boolean removeRoadSouthEast(Plot plot, @Nullable QueueCoordinator queue) {
|
||||
Location location = getPlotTopLocAbs(plot.getId());
|
||||
int sx = location.getX() + 1;
|
||||
int ex = sx + classicPlotWorld.ROAD_WIDTH - 1;
|
||||
int sz = location.getZ() + 1;
|
||||
int ez = sz + classicPlotWorld.ROAD_WIDTH - 1;
|
||||
QueueCoordinator queue = classicPlotWorld.getQueue(false);
|
||||
|
||||
boolean enqueue = false;
|
||||
if (queue == null) {
|
||||
queue = classicPlotWorld.getQueue();
|
||||
enqueue = true;
|
||||
}
|
||||
|
||||
queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx,
|
||||
Math.min(classicPlotWorld.PLOT_HEIGHT, classicPlotWorld.ROAD_HEIGHT) + 1, sz),
|
||||
Location.at(classicPlotWorld.getWorldName(), ex,
|
||||
classicPlotWorld.getPlotManager().getWorldHeight(), ez),
|
||||
BlockTypes.AIR.getDefaultState());
|
||||
Math.min(classicPlotWorld.PLOT_HEIGHT, classicPlotWorld.ROAD_HEIGHT) + 1, sz), Location
|
||||
.at(classicPlotWorld.getWorldName(), ex,
|
||||
classicPlotWorld.getPlotManager().getWorldHeight(), ez),
|
||||
BlockTypes.AIR.getDefaultState());
|
||||
queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx, 1, sz),
|
||||
Location.at(classicPlotWorld.getWorldName(), ex, classicPlotWorld.PLOT_HEIGHT - 1, ez),
|
||||
classicPlotWorld.MAIN_BLOCK.toPattern());
|
||||
@ -471,7 +544,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
Location.at(classicPlotWorld.getWorldName(), sx, classicPlotWorld.PLOT_HEIGHT, sz),
|
||||
Location.at(classicPlotWorld.getWorldName(), ex, classicPlotWorld.PLOT_HEIGHT, ez),
|
||||
classicPlotWorld.TOP_BLOCK.toPattern());
|
||||
return queue.enqueue();
|
||||
return !enqueue || queue.enqueue();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -479,44 +552,48 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
*
|
||||
* @return false if part of the merge failed, otherwise true if successful.
|
||||
*/
|
||||
@Override public boolean finishPlotMerge(List<PlotId> plotIds) {
|
||||
@Override public boolean finishPlotMerge(List<PlotId> plotIds,
|
||||
@Nullable QueueCoordinator queue) {
|
||||
final BlockBucket claim = classicPlotWorld.CLAIMED_WALL_BLOCK;
|
||||
if (!claim.isAir() || !claim.equals(classicPlotWorld.WALL_BLOCK)) {
|
||||
for (PlotId plotId : plotIds) {
|
||||
setWall(plotId, claim.toPattern());
|
||||
setWall(plotId, claim.toPattern(), queue);
|
||||
}
|
||||
}
|
||||
if (Settings.General.MERGE_REPLACE_WALL) {
|
||||
final BlockBucket wallBlock = classicPlotWorld.WALL_FILLING;
|
||||
for (PlotId id : plotIds) {
|
||||
setWallFilling(id, wallBlock.toPattern());
|
||||
setWallFilling(id, wallBlock.toPattern(), queue);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override public boolean finishPlotUnlink(List<PlotId> plotIds) {
|
||||
@Override
|
||||
public boolean finishPlotUnlink(List<PlotId> plotIds, @Nullable QueueCoordinator queue) {
|
||||
final BlockBucket claim = classicPlotWorld.CLAIMED_WALL_BLOCK;
|
||||
if (!claim.isAir() || !claim.equals(classicPlotWorld.WALL_BLOCK)) {
|
||||
for (PlotId id : plotIds) {
|
||||
setWall(id, claim.toPattern());
|
||||
setWall(id, claim.toPattern(), queue);
|
||||
}
|
||||
}
|
||||
return true; // return false if unlink has been denied
|
||||
}
|
||||
|
||||
@Override public boolean startPlotMerge(List<PlotId> plotIds) {
|
||||
@Override
|
||||
public boolean startPlotMerge(List<PlotId> plotIds, @Nullable QueueCoordinator queue) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override public boolean startPlotUnlink(List<PlotId> plotIds) {
|
||||
@Override
|
||||
public boolean startPlotUnlink(List<PlotId> plotIds, @Nullable QueueCoordinator queue) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override public boolean claimPlot(Plot plot) {
|
||||
@Override public boolean claimPlot(Plot plot, @Nullable QueueCoordinator queue) {
|
||||
final BlockBucket claim = classicPlotWorld.CLAIMED_WALL_BLOCK;
|
||||
if (!claim.isAir() || !claim.equals(classicPlotWorld.WALL_BLOCK)) {
|
||||
return setWall(plot.getId(), claim.toPattern());
|
||||
return setWall(plot.getId(), claim.toPattern(), queue);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -534,8 +611,9 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
@Override public Location getSignLoc(Plot plot) {
|
||||
plot = plot.getBasePlot(false);
|
||||
final Location bot = plot.getBottomAbs();
|
||||
return Location.at(classicPlotWorld.getWorldName(), bot.getX() - 1,
|
||||
classicPlotWorld.ROAD_HEIGHT + 1, bot.getZ() - 2);
|
||||
return Location
|
||||
.at(classicPlotWorld.getWorldName(), bot.getX() - 1, classicPlotWorld.ROAD_HEIGHT + 1,
|
||||
bot.getZ() - 2);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
if (!hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) {
|
||||
return true;
|
||||
}
|
||||
QueueCoordinator queue = hybridPlotWorld.getQueue(false);
|
||||
QueueCoordinator queue = hybridPlotWorld.getQueue();
|
||||
createSchemAbs(queue, pos1, pos2, true);
|
||||
queue.enqueue();
|
||||
return true;
|
||||
@ -178,7 +178,7 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
if (!hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) {
|
||||
return true;
|
||||
}
|
||||
QueueCoordinator queue = hybridPlotWorld.getQueue(false);
|
||||
QueueCoordinator queue = hybridPlotWorld.getQueue();
|
||||
createSchemAbs(queue, pos1, pos2, true);
|
||||
queue.enqueue();
|
||||
return true;
|
||||
@ -190,7 +190,7 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
PlotId id2 = new PlotId(id.x + 1, id.y + 1);
|
||||
Location pos1 = getPlotTopLocAbs(id).add(1, 0, 1).withY(0);
|
||||
Location pos2 = getPlotBottomLocAbs(id2).withY(Math.min(getWorldHeight(), 255));
|
||||
QueueCoordinator queue = hybridPlotWorld.getQueue(false);
|
||||
QueueCoordinator queue = hybridPlotWorld.getQueue();
|
||||
createSchemAbs(queue, pos1, pos2, true);
|
||||
if (hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) {
|
||||
createSchemAbs(queue, pos1, pos2, true);
|
||||
@ -232,7 +232,7 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
}
|
||||
|
||||
final BiomeType biome = hybridPlotWorld.getPlotBiome();
|
||||
final QueueCoordinator queue = hybridPlotWorld.getQueue(false);
|
||||
final QueueCoordinator queue = hybridPlotWorld.getQueue();
|
||||
ChunkManager.chunkTask(pos1, pos2, new RunnableVal<int[]>() {
|
||||
@Override public void run(int[] value) {
|
||||
// If the chunk isn't near the edge and it isn't an augmented world we can just regen the whole chunk
|
||||
|
@ -128,7 +128,7 @@ public class HybridUtils {
|
||||
*
|
||||
*/
|
||||
TaskManager.runTaskAsync(() -> {
|
||||
final QueueCoordinator queue = blockQueue.getNewQueue(worldUtil.getWeWorld(world), false);
|
||||
final QueueCoordinator queue = blockQueue.getNewQueue(worldUtil.getWeWorld(world));
|
||||
|
||||
final BlockVector3 bot = region.getMinimumPoint();
|
||||
final BlockVector3 top = region.getMaximumPoint();
|
||||
@ -520,7 +520,7 @@ public class HybridUtils {
|
||||
|
||||
public boolean setupRoadSchematic(Plot plot) {
|
||||
final String world = plot.getWorldName();
|
||||
final QueueCoordinator queue = blockQueue.getNewQueue(worldUtil.getWeWorld(world), false);
|
||||
final QueueCoordinator queue = blockQueue.getNewQueue(worldUtil.getWeWorld(world));
|
||||
Location bot = plot.getBottomAbs().subtract(1, 0, 1);
|
||||
Location top = plot.getTopAbs();
|
||||
final HybridPlotWorld plotworld = (HybridPlotWorld) plot.getArea();
|
||||
@ -607,7 +607,7 @@ public class HybridUtils {
|
||||
z -= plotWorld.ROAD_OFFSET_Z;
|
||||
final int finalX = x;
|
||||
final int finalZ = z;
|
||||
QueueCoordinator queue = this.blockQueue.getNewQueue(worldUtil.getWeWorld(plotWorld.getWorldName()), false);
|
||||
QueueCoordinator queue = this.blockQueue.getNewQueue(worldUtil.getWeWorld(plotWorld.getWorldName()));
|
||||
if (id1 == null || id2 == null || id1 != id2) {
|
||||
this.chunkManager.loadChunk(area.getWorldName(), chunk, false).thenRun(() -> {
|
||||
if (id1 != null) {
|
||||
|
@ -30,13 +30,15 @@ import com.plotsquared.core.location.Location;
|
||||
import com.plotsquared.core.plot.Plot;
|
||||
import com.plotsquared.core.plot.PlotArea;
|
||||
import com.plotsquared.core.plot.PlotId;
|
||||
import com.plotsquared.core.queue.QueueCoordinator;
|
||||
import com.plotsquared.core.util.MainUtil;
|
||||
import com.plotsquared.core.util.RegionManager;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
@ -45,18 +47,21 @@ import java.util.Set;
|
||||
*/
|
||||
public abstract class SquarePlotManager extends GridPlotManager {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger("P2/" + SquarePlotManager.class.getSimpleName());
|
||||
private static final Logger logger =
|
||||
LoggerFactory.getLogger("P2/" + SquarePlotManager.class.getSimpleName());
|
||||
|
||||
private final SquarePlotWorld squarePlotWorld;
|
||||
private final RegionManager regionManager;
|
||||
|
||||
public SquarePlotManager(@Nonnull final SquarePlotWorld squarePlotWorld, @Nonnull final RegionManager regionManager) {
|
||||
public SquarePlotManager(@Nonnull final SquarePlotWorld squarePlotWorld,
|
||||
@Nonnull final RegionManager regionManager) {
|
||||
super(squarePlotWorld);
|
||||
this.squarePlotWorld = squarePlotWorld;
|
||||
this.regionManager = regionManager;
|
||||
}
|
||||
|
||||
@Override public boolean clearPlot(final Plot plot, final Runnable whenDone) {
|
||||
@Override public boolean clearPlot(final Plot plot, final Runnable whenDone,
|
||||
@Nullable QueueCoordinator queue) {
|
||||
final Set<CuboidRegion> regions = plot.getRegions();
|
||||
Runnable run = new Runnable() {
|
||||
@Override public void run() {
|
||||
@ -230,8 +235,8 @@ public abstract class SquarePlotManager extends GridPlotManager {
|
||||
return plot.getMerged(Direction.NORTHWEST) ? id : null;
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
logger.error( "Invalid plot / road width in settings.yml for world: {}", squarePlotWorld
|
||||
.getWorldName());
|
||||
logger.error("Invalid plot / road width in settings.yml for world: {}",
|
||||
squarePlotWorld.getWorldName());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -248,6 +253,7 @@ public abstract class SquarePlotManager extends GridPlotManager {
|
||||
int z = (squarePlotWorld.ROAD_OFFSET_Z + (pz * (squarePlotWorld.ROAD_WIDTH
|
||||
+ squarePlotWorld.PLOT_WIDTH))) - squarePlotWorld.PLOT_WIDTH - (int) Math
|
||||
.floor(squarePlotWorld.ROAD_WIDTH / 2);
|
||||
return Location.at(squarePlotWorld.getWorldName(), x, squarePlotWorld.getMinBuildHeight(), z);
|
||||
return Location
|
||||
.at(squarePlotWorld.getWorldName(), x, squarePlotWorld.getMinBuildHeight(), z);
|
||||
}
|
||||
}
|
||||
|
@ -1033,26 +1033,28 @@ public class Plot {
|
||||
ids.add(current.getId());
|
||||
}
|
||||
this.clearRatings();
|
||||
QueueCoordinator queue = null;
|
||||
if (createSign) {
|
||||
this.removeSign();
|
||||
queue = getArea().getQueue();
|
||||
}
|
||||
PlotManager manager = this.area.getPlotManager();
|
||||
if (createRoad) {
|
||||
manager.startPlotUnlink(ids);
|
||||
manager.startPlotUnlink(ids, queue);
|
||||
}
|
||||
if (this.area.getTerrain() != PlotAreaTerrainType.ALL && createRoad) {
|
||||
for (Plot current : plots) {
|
||||
if (current.getMerged(Direction.EAST)) {
|
||||
manager.createRoadEast(current);
|
||||
manager.createRoadEast(current, queue);
|
||||
if (current.getMerged(Direction.SOUTH)) {
|
||||
manager.createRoadSouth(current);
|
||||
manager.createRoadSouth(current, queue);
|
||||
if (current.getMerged(Direction.SOUTHEAST)) {
|
||||
manager.createRoadSouthEast(current);
|
||||
manager.createRoadSouthEast(current, queue);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (current.getMerged(Direction.SOUTH)) {
|
||||
manager.createRoadSouth(current);
|
||||
manager.createRoadSouth(current, queue);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1061,14 +1063,14 @@ public class Plot {
|
||||
current.setMerged(merged);
|
||||
}
|
||||
if (createSign) {
|
||||
TaskManager.runTaskAsync(() -> {
|
||||
queue.setCompleteTask(() -> TaskManager.runTaskAsync(() -> {
|
||||
for (Plot current : plots) {
|
||||
current.setSign(MainUtil.getName(current.getOwnerAbs()));
|
||||
}
|
||||
});
|
||||
}));
|
||||
}
|
||||
if (createRoad) {
|
||||
manager.finishPlotUnlink(ids);
|
||||
manager.finishPlotUnlink(ids, queue);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -1686,7 +1688,7 @@ public class Plot {
|
||||
*/
|
||||
public void refreshChunks() {
|
||||
QueueCoordinator queue = this.blockQueue
|
||||
.getNewQueue(PlotSquared.platform().getWorldUtil().getWeWorld(getWorldName()), false);
|
||||
.getNewQueue(PlotSquared.platform().getWorldUtil().getWeWorld(getWorldName()));
|
||||
HashSet<BlockVector2> chunks = new HashSet<>();
|
||||
for (CuboidRegion region : Plot.this.getRegions()) {
|
||||
for (int x = region.getMinimumPoint().getX() >> 4;
|
||||
@ -1710,8 +1712,7 @@ public class Plot {
|
||||
return;
|
||||
}
|
||||
Location location = manager.getSignLoc(this);
|
||||
QueueCoordinator queue =
|
||||
this.blockQueue.getNewQueue(worldUtil.getWeWorld(getWorldName()), false);
|
||||
QueueCoordinator queue = this.blockQueue.getNewQueue(worldUtil.getWeWorld(getWorldName()));
|
||||
queue.setBlock(location.getX(), location.getY(), location.getZ(),
|
||||
BlockTypes.AIR.getDefaultState());
|
||||
queue.enqueue();
|
||||
@ -1852,12 +1853,13 @@ public class Plot {
|
||||
* Sets components such as border, wall, floor.
|
||||
* (components are generator specific)
|
||||
*/
|
||||
@Deprecated public boolean setComponent(String component, String blocks) {
|
||||
@Deprecated public boolean setComponent(String component, String blocks,
|
||||
QueueCoordinator queue) {
|
||||
BlockBucket parsed = ConfigurationUtil.BLOCK_BUCKET.parseString(blocks);
|
||||
if (parsed != null && parsed.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
return this.setComponent(component, parsed.toPattern());
|
||||
return this.setComponent(component, parsed.toPattern(), queue);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3052,12 +3054,13 @@ public class Plot {
|
||||
* @param blocks Pattern to use the generation
|
||||
* @return True if the component was set successfully
|
||||
*/
|
||||
public boolean setComponent(String component, Pattern blocks) {
|
||||
public boolean setComponent(String component, Pattern blocks,
|
||||
@Nullable QueueCoordinator queue) {
|
||||
PlotComponentSetEvent event =
|
||||
this.eventDispatcher.callComponentSet(this, component, blocks);
|
||||
component = event.getComponent();
|
||||
blocks = event.getPattern();
|
||||
return this.getManager().setComponent(this.getId(), component, blocks);
|
||||
return this.getManager().setComponent(this.getId(), component, blocks, queue);
|
||||
}
|
||||
|
||||
public int getDistanceFromOrigin() {
|
||||
|
@ -172,8 +172,8 @@ public abstract class PlotArea {
|
||||
|
||||
@Nonnull protected abstract PlotManager createManager();
|
||||
|
||||
public QueueCoordinator getQueue(final boolean autoQueue) {
|
||||
return this.globalBlockQueue.getNewQueue(PlotSquared.platform().getWorldUtil().getWeWorld(worldName), autoQueue);
|
||||
public QueueCoordinator getQueue() {
|
||||
return this.globalBlockQueue.getNewQueue(PlotSquared.platform().getWorldUtil().getWeWorld(worldName));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -28,9 +28,11 @@ package com.plotsquared.core.plot;
|
||||
import com.plotsquared.core.command.Template;
|
||||
import com.plotsquared.core.configuration.Settings;
|
||||
import com.plotsquared.core.location.Location;
|
||||
import com.plotsquared.core.queue.QueueCoordinator;
|
||||
import com.plotsquared.core.util.FileBytes;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
@ -61,11 +63,27 @@ public abstract class PlotManager {
|
||||
/*
|
||||
* Plot clearing (return false if you do not support some method)
|
||||
*/
|
||||
public abstract boolean clearPlot(Plot plot, Runnable whenDone);
|
||||
public boolean clearPlot(Plot plot, Runnable whenDone) {
|
||||
return clearPlot(plot, whenDone, null);
|
||||
}
|
||||
|
||||
public abstract boolean claimPlot(Plot plot);
|
||||
public boolean claimPlot(Plot plot) {
|
||||
return claimPlot(plot, null);
|
||||
|
||||
public abstract boolean unClaimPlot(Plot plot, Runnable whenDone);
|
||||
}
|
||||
|
||||
public boolean unClaimPlot(Plot plot, Runnable whenDone) {
|
||||
return unClaimPlot(plot, whenDone, null);
|
||||
|
||||
}
|
||||
|
||||
public abstract boolean clearPlot(Plot plot, Runnable whenDone,
|
||||
@Nullable QueueCoordinator queue);
|
||||
|
||||
public abstract boolean claimPlot(Plot plot, @Nullable QueueCoordinator queue);
|
||||
|
||||
public abstract boolean unClaimPlot(Plot plot, Runnable whenDone,
|
||||
@Nullable QueueCoordinator queue);
|
||||
|
||||
/**
|
||||
* Retrieves the location of where a sign should be for a plot.
|
||||
@ -81,31 +99,77 @@ public abstract class PlotManager {
|
||||
*/
|
||||
public abstract String[] getPlotComponents(PlotId plotId);
|
||||
|
||||
public abstract boolean setComponent(PlotId plotId, String component, Pattern blocks);
|
||||
public boolean setComponent(PlotId plotId, String component, Pattern blocks) {
|
||||
return setComponent(plotId, component, blocks, null);
|
||||
}
|
||||
|
||||
public abstract boolean setComponent(PlotId plotId, String component, Pattern blocks,
|
||||
@Nullable QueueCoordinator queue);
|
||||
|
||||
/*
|
||||
* PLOT MERGING (return false if your generator does not support plot
|
||||
* merging).
|
||||
*/
|
||||
public abstract boolean createRoadEast(Plot plot);
|
||||
public boolean createRoadEast(Plot plot) {
|
||||
return createRoadEast(plot, null);
|
||||
}
|
||||
|
||||
public abstract boolean createRoadSouth(Plot plot);
|
||||
public boolean createRoadSouth(Plot plot) {
|
||||
return createRoadSouth(plot, null);
|
||||
}
|
||||
|
||||
public abstract boolean createRoadSouthEast(Plot plot);
|
||||
public boolean createRoadSouthEast(Plot plot) {
|
||||
return createRoadSouthEast(plot, null);
|
||||
}
|
||||
|
||||
public abstract boolean removeRoadEast(Plot plot);
|
||||
public boolean removeRoadEast(Plot plot) {
|
||||
return removeRoadEast(plot, null);
|
||||
}
|
||||
|
||||
public abstract boolean removeRoadSouth(Plot plot);
|
||||
public boolean removeRoadSouth(Plot plot) {
|
||||
return removeRoadSouth(plot, null);
|
||||
}
|
||||
|
||||
public abstract boolean removeRoadSouthEast(Plot plot);
|
||||
public boolean removeRoadSouthEast(Plot plot) {
|
||||
return removeRoadSouthEast(plot, null);
|
||||
}
|
||||
|
||||
public abstract boolean startPlotMerge(List<PlotId> plotIds);
|
||||
public boolean startPlotMerge(List<PlotId> plotIds) {
|
||||
return startPlotMerge(plotIds, null);
|
||||
}
|
||||
|
||||
public abstract boolean startPlotUnlink(List<PlotId> plotIds);
|
||||
public boolean startPlotUnlink(List<PlotId> plotIds) {
|
||||
return startPlotUnlink(plotIds, null);
|
||||
}
|
||||
|
||||
public abstract boolean finishPlotMerge(List<PlotId> plotIds);
|
||||
public boolean finishPlotMerge(List<PlotId> plotIds) {
|
||||
return finishPlotMerge(plotIds, null);
|
||||
}
|
||||
|
||||
public abstract boolean finishPlotUnlink(List<PlotId> plotIds);
|
||||
public boolean finishPlotUnlink(List<PlotId> plotIds) {
|
||||
return finishPlotUnlink(plotIds, null);
|
||||
}
|
||||
|
||||
public abstract boolean createRoadEast(Plot plot, @Nullable QueueCoordinator queue);
|
||||
|
||||
public abstract boolean createRoadSouth(Plot plot, @Nullable QueueCoordinator queue);
|
||||
|
||||
public abstract boolean createRoadSouthEast(Plot plot, @Nullable QueueCoordinator queue);
|
||||
|
||||
public abstract boolean removeRoadEast(Plot plot, @Nullable QueueCoordinator queue);
|
||||
|
||||
public abstract boolean removeRoadSouth(Plot plot, @Nullable QueueCoordinator queue);
|
||||
|
||||
public abstract boolean removeRoadSouthEast(Plot plot, @Nullable QueueCoordinator queue);
|
||||
|
||||
public abstract boolean startPlotMerge(List<PlotId> plotIds, @Nullable QueueCoordinator queue);
|
||||
|
||||
public abstract boolean startPlotUnlink(List<PlotId> plotIds, @Nullable QueueCoordinator queue);
|
||||
|
||||
public abstract boolean finishPlotMerge(List<PlotId> plotIds, @Nullable QueueCoordinator queue);
|
||||
|
||||
public abstract boolean finishPlotUnlink(List<PlotId> plotIds,
|
||||
@Nullable QueueCoordinator queue);
|
||||
|
||||
public void exportTemplate() throws IOException {
|
||||
HashSet<FileBytes> files = new HashSet<>(Collections.singletonList(
|
||||
@ -124,12 +188,16 @@ public abstract class PlotManager {
|
||||
* @return true if the wall blocks were successfully set
|
||||
*/
|
||||
public boolean regenerateAllPlotWalls() {
|
||||
return regenerateAllPlotWalls(null);
|
||||
}
|
||||
|
||||
public boolean regenerateAllPlotWalls(@Nullable QueueCoordinator queue) {
|
||||
boolean success = true;
|
||||
for (Plot plot : plotArea.getPlots()) {
|
||||
if (plot.hasOwner()) {
|
||||
success &= claimPlot(plot);
|
||||
success &= claimPlot(plot, queue);
|
||||
} else {
|
||||
success &= unClaimPlot(plot, null);
|
||||
success &= unClaimPlot(plot, null, queue);
|
||||
}
|
||||
}
|
||||
return success;
|
||||
|
@ -31,11 +31,13 @@ import com.plotsquared.core.plot.Plot;
|
||||
import com.plotsquared.core.plot.PlotArea;
|
||||
import com.plotsquared.core.plot.PlotId;
|
||||
import com.plotsquared.core.plot.PlotManager;
|
||||
import com.plotsquared.core.queue.QueueCoordinator;
|
||||
import com.plotsquared.core.util.MainUtil;
|
||||
import com.plotsquared.core.util.task.TaskManager;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
@ -61,9 +63,11 @@ public class SinglePlotManager extends PlotManager {
|
||||
return Location.at(plotId.toCommaSeparatedString(), 30000000, 0, 30000000);
|
||||
}
|
||||
|
||||
@Override public boolean clearPlot(Plot plot, final Runnable whenDone) {
|
||||
@Override
|
||||
public boolean clearPlot(Plot plot, final Runnable whenDone, @Nullable QueueCoordinator queue) {
|
||||
PlotSquared.platform().getSetupUtils().unload(plot.getWorldName(), false);
|
||||
final File worldFolder = new File(PlotSquared.platform().getWorldContainer(), plot.getWorldName());
|
||||
final File worldFolder =
|
||||
new File(PlotSquared.platform().getWorldContainer(), plot.getWorldName());
|
||||
TaskManager.getPlatformImplementation().taskAsync(() -> {
|
||||
MainUtil.deleteDirectory(worldFolder);
|
||||
if (whenDone != null) {
|
||||
@ -73,12 +77,13 @@ public class SinglePlotManager extends PlotManager {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override public boolean claimPlot(Plot plot) {
|
||||
@Override public boolean claimPlot(Plot plot, @Nullable QueueCoordinator queue) {
|
||||
// TODO
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override public boolean unClaimPlot(Plot plot, Runnable whenDone) {
|
||||
@Override
|
||||
public boolean unClaimPlot(Plot plot, Runnable whenDone, @Nullable QueueCoordinator queue) {
|
||||
if (whenDone != null) {
|
||||
whenDone.run();
|
||||
}
|
||||
@ -93,51 +98,56 @@ public class SinglePlotManager extends PlotManager {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
@Override public boolean setComponent(PlotId plotId, String component, Pattern blocks) {
|
||||
@Override public boolean setComponent(PlotId plotId, String component, Pattern blocks,
|
||||
@Nullable QueueCoordinator queue) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override public boolean createRoadEast(Plot plot) {
|
||||
@Override public boolean createRoadEast(Plot plot, @Nullable QueueCoordinator queue) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override public boolean createRoadSouth(Plot plot) {
|
||||
@Override public boolean createRoadSouth(Plot plot, @Nullable QueueCoordinator queue) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override public boolean createRoadSouthEast(Plot plot) {
|
||||
@Override public boolean createRoadSouthEast(Plot plot, @Nullable QueueCoordinator queue) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override public boolean removeRoadEast(Plot plot) {
|
||||
@Override public boolean removeRoadEast(Plot plot, @Nullable QueueCoordinator queue) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override public boolean removeRoadSouth(Plot plot) {
|
||||
@Override public boolean removeRoadSouth(Plot plot, @Nullable QueueCoordinator queue) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override public boolean removeRoadSouthEast(Plot plot) {
|
||||
@Override public boolean removeRoadSouthEast(Plot plot, @Nullable QueueCoordinator queue) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override public boolean startPlotMerge(List<PlotId> plotIds) {
|
||||
@Override
|
||||
public boolean startPlotMerge(List<PlotId> plotIds, @Nullable QueueCoordinator queue) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override public boolean startPlotUnlink(List<PlotId> plotIds) {
|
||||
@Override
|
||||
public boolean startPlotUnlink(List<PlotId> plotIds, @Nullable QueueCoordinator queue) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override public boolean finishPlotMerge(List<PlotId> plotIds) {
|
||||
@Override
|
||||
public boolean finishPlotMerge(List<PlotId> plotIds, @Nullable QueueCoordinator queue) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override public boolean finishPlotUnlink(List<PlotId> plotIds) {
|
||||
@Override
|
||||
public boolean finishPlotUnlink(List<PlotId> plotIds, @Nullable QueueCoordinator queue) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override public boolean regenerateAllPlotWalls() {
|
||||
@Override public boolean regenerateAllPlotWalls(@Nullable QueueCoordinator queue) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -42,13 +42,10 @@ public class GlobalBlockQueue {
|
||||
this.activeQueues = new ConcurrentLinkedDeque<>();
|
||||
}
|
||||
|
||||
public QueueCoordinator getNewQueue(World world, boolean autoQueue) {
|
||||
public QueueCoordinator getNewQueue(World world) {
|
||||
QueueCoordinator queue = provider.getNewQueue(world);
|
||||
// Auto-inject into the queue
|
||||
PlotSquared.platform().getInjector().injectMembers(queue);
|
||||
if (autoQueue) {
|
||||
queue.enqueue();
|
||||
}
|
||||
return queue;
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ public abstract class ChunkManager {
|
||||
public static void setChunkInPlotArea(RunnableVal<ScopedQueueCoordinator> force,
|
||||
RunnableVal<ScopedQueueCoordinator> add, String world, BlockVector2 loc) {
|
||||
QueueCoordinator queue =
|
||||
PlotSquared.platform().getGlobalBlockQueue().getNewQueue(PlotSquared.platform().getWorldUtil().getWeWorld(world), false);
|
||||
PlotSquared.platform().getGlobalBlockQueue().getNewQueue(PlotSquared.platform().getWorldUtil().getWeWorld(world));
|
||||
if (PlotSquared.get().getPlotAreaManager().isAugmented(world) && PlotSquared.get()
|
||||
.isNonStandardGeneration(world, loc)) {
|
||||
int blockX = loc.getX() << 4;
|
||||
|
@ -31,7 +31,6 @@ import com.plotsquared.core.location.Location;
|
||||
import com.plotsquared.core.plot.Plot;
|
||||
import com.plotsquared.core.plot.PlotArea;
|
||||
import com.plotsquared.core.plot.PlotManager;
|
||||
import com.plotsquared.core.queue.ChunkCoordinatorBuilder;
|
||||
import com.plotsquared.core.queue.QueueCoordinator;
|
||||
import com.plotsquared.core.util.task.RunnableVal;
|
||||
import com.plotsquared.core.util.task.TaskManager;
|
||||
@ -44,6 +43,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
@ -169,7 +169,17 @@ public abstract class RegionManager {
|
||||
|
||||
public boolean setCuboids(final PlotArea area, final Set<CuboidRegion> regions,
|
||||
final Pattern blocks, int minY, int maxY) {
|
||||
QueueCoordinator queue = area.getQueue(false);
|
||||
return setCuboids(area, regions, blocks, minY, maxY, null);
|
||||
}
|
||||
|
||||
|
||||
public boolean setCuboids(final PlotArea area, final Set<CuboidRegion> regions,
|
||||
final Pattern blocks, int minY, int maxY, @Nullable QueueCoordinator queue) {
|
||||
boolean enqueue = false;
|
||||
if(queue == null) {
|
||||
queue = area.getQueue();
|
||||
enqueue = true;
|
||||
}
|
||||
for (CuboidRegion region : regions) {
|
||||
Location pos1 = Location.at(area.getWorldName(), region.getMinimumPoint().getX(), minY,
|
||||
region.getMinimumPoint().getZ());
|
||||
@ -177,7 +187,7 @@ public abstract class RegionManager {
|
||||
region.getMaximumPoint().getZ());
|
||||
queue.setCuboid(pos1, pos2, blocks);
|
||||
}
|
||||
return queue.enqueue();
|
||||
return !enqueue || queue.enqueue();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -194,7 +194,7 @@ public abstract class SchematicHandler {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
final QueueCoordinator queue = plot.getArea().getQueue(false);
|
||||
final QueueCoordinator queue = plot.getArea().getQueue();
|
||||
BlockVector3 dimension = schematic.getClipboard().getDimensions();
|
||||
final int WIDTH = dimension.getX();
|
||||
final int LENGTH = dimension.getZ();
|
||||
|
Loading…
Reference in New Issue
Block a user