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