Update to p2 5.12.2 and implement clear pipeline

This commit is contained in:
dordsor21 2020-07-02 14:34:05 +01:00
parent 6f71aa7804
commit d3afc9c65d
No known key found for this signature in database
GPG Key ID: 1E53E88969FFCF0B
4 changed files with 85 additions and 4 deletions

View File

@ -2,14 +2,22 @@ package com.boydti.fawe.bukkit.regions.plotsquared;
import com.boydti.fawe.util.EditSessionBuilder;
import com.boydti.fawe.util.TaskManager;
import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.generator.HybridPlotManager;
import com.plotsquared.core.generator.HybridPlotWorld;
import com.plotsquared.core.location.Location;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.PlotAreaTerrainType;
import com.plotsquared.core.plot.PlotAreaType;
import com.plotsquared.core.plot.PlotManager;
import com.plotsquared.core.util.RegionManager;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
import com.sk89q.worldedit.function.FlatRegionFunction;
import com.sk89q.worldedit.function.biome.BiomeReplace;
import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
@ -21,7 +29,12 @@ import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockTypes;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Set;
import static org.bukkit.Bukkit.getWorld;
@ -65,6 +78,75 @@ public class FaweRegionManager extends RegionManager {
return true;
}
@Override
public boolean notifyClear(PlotManager manager) {
if (!(manager instanceof HybridPlotManager)) {
return false;
}
final HybridPlotWorld hpw = ((HybridPlotManager) manager).getHybridPlotWorld();
return hpw.getType() != PlotAreaType.AUGMENTED || hpw.getTerrain() == PlotAreaTerrainType.NONE;
}
@Override
public boolean handleClear(final Plot plot, final Runnable whenDone, final PlotManager manager) {
if (!(manager instanceof HybridPlotManager)) {
return false;
}
TaskManager.IMP.async(() -> {
synchronized (FaweRegionManager.class) {
final HybridPlotWorld hybridPlotWorld = ((HybridPlotManager) manager).getHybridPlotWorld();
EditSession editSession = new EditSessionBuilder(BukkitAdapter.adapt(getWorld(hybridPlotWorld.getWorldName()))).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build();
if (!hybridPlotWorld.PLOT_SCHEMATIC || !Settings.Schematics.PASTE_ON_TOP) {
final BlockState bedrock;
final BlockState air = BlockTypes.AIR.getDefaultState();
if (hybridPlotWorld.PLOT_BEDROCK) {
bedrock = BlockTypes.BEDROCK.getDefaultState();
} else {
bedrock = air;
}
final Pattern filling = hybridPlotWorld.MAIN_BLOCK.toPattern();
final Pattern plotfloor = hybridPlotWorld.TOP_BLOCK.toPattern();
BlockVector3 pos1 = plot.getBottomAbs().getBlockVector3();
BlockVector3 pos2 = plot.getExtendedTopAbs().getBlockVector3();
Region bedrockRegion = new CuboidRegion(pos1.withY(0), pos2.withY(0));
Region fillingRegion = new CuboidRegion(pos1.withY(1), pos2.withY(hybridPlotWorld.PLOT_HEIGHT - 1));
Region floorRegion = new CuboidRegion(pos1.withY(hybridPlotWorld.PLOT_HEIGHT),
pos2.withY(hybridPlotWorld.PLOT_HEIGHT));
Region airRegion = new CuboidRegion(pos1.withY(hybridPlotWorld.PLOT_HEIGHT + 1),
pos2.withY(manager.getWorldHeight()));
editSession.setBlocks(bedrockRegion, bedrock);
editSession.setBlocks(fillingRegion, filling);
editSession.setBlocks(floorRegion, plotfloor);
editSession.setBlocks(airRegion, air);
}
if (hybridPlotWorld.PLOT_SCHEMATIC) {
File schematicFile = new File(hybridPlotWorld.getRoot(), "plot.schem");
if (!schematicFile.exists()) {
schematicFile = new File(hybridPlotWorld.getRoot(), "plot.schematic");
}
BlockVector3 to = plot.getBottomAbs().getBlockVector3().withY(Settings.Schematics.PASTE_ON_TOP ? hybridPlotWorld.SCHEM_Y : 1);
try {
Clipboard clip = ClipboardFormats.findByFile(schematicFile).getReader(new FileInputStream(schematicFile)).read();
clip.paste(editSession, to, true, true, true);
} catch (IOException e) {
e.printStackTrace();
}
}
editSession.flushQueue();
TaskManager.IMP.task(whenDone);
}
});
return true;
}
@Override
public void swap(final Location pos1, final Location pos2, final Location pos3, final Location pos4, final Runnable whenDone) {
TaskManager.IMP.async(() -> {

View File

@ -45,7 +45,7 @@ public class PlotSetBiome extends Command {
}
@Override
public CompletableFuture<Boolean> execute(final PlotPlayer player, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
public CompletableFuture<Boolean> execute(final PlotPlayer<?> player, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
final Plot plot = check(player.getCurrentPlot(), Captions.NOT_IN_PLOT);
checkTrue(plot.isOwner(player.getUUID()) || Permissions
.hasPermission(player, "plots.admin.command.generatebiome"), Captions.NO_PLOT_PERMS);

View File

@ -5,11 +5,11 @@ import com.boydti.fawe.object.RegionWrapper;
import com.boydti.fawe.regions.FaweMask;
import com.boydti.fawe.regions.FaweMaskManager;
import com.boydti.fawe.regions.general.RegionFilter;
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.command.MainCommand;
import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.database.DBFunc;
import com.plotsquared.core.generator.HybridPlotManager;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea;
@ -18,7 +18,6 @@ import com.plotsquared.core.plot.flag.implementations.NoWorldeditFlag;
import com.plotsquared.core.util.RegionManager;
import com.plotsquared.core.util.SchematicHandler;
import com.plotsquared.core.util.WEManager;
import com.plotsquared.core.util.uuid.UUIDHandler;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion;

View File

@ -59,7 +59,7 @@ dependencies {
"compile"("com.github.intellectualsites.plotsquared:PlotSquared-API:latest") {
isTransitive = false
}
"compile"("com.plotsquared:PlotSquared-Core:5.11.2") {
"compile"("com.plotsquared:PlotSquared-Core:5.12.2") {
isTransitive = false
}
implementation(kotlin("stdlib-jdk8", "1.3.61"))