Update to latest p2 v5

(implement FAWE biome setting)
This commit is contained in:
dordsor21 2020-05-14 16:20:17 +01:00
parent 5225099ec0
commit bdc129cf7b
4 changed files with 40 additions and 25 deletions

View File

@ -8,6 +8,7 @@ fun Project.applyCommonConfiguration() {
repositories { repositories {
mavenCentral() mavenCentral()
mavenLocal() mavenLocal()
maven { url = uri("https://mvn.intellectualsites.com/content/groups/public/") }
maven { url = uri("https://plotsquared.com/mvn/") } maven { url = uri("https://plotsquared.com/mvn/") }
maven { url = uri("https://maven.sk89q.com/repo/") } maven { url = uri("https://maven.sk89q.com/repo/") }
maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots/") } maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots/") }

View File

@ -6,24 +6,27 @@ import com.boydti.fawe.util.EditSessionBuilder;
import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.util.TaskManager;
import com.plotsquared.core.location.Location; import com.plotsquared.core.location.Location;
import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.util.ChunkManager; import com.plotsquared.core.util.RegionManager;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.function.FlatRegionFunction;
import com.sk89q.worldedit.function.biome.BiomeReplace;
import com.sk89q.worldedit.function.operation.ForwardExtentCopy; import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
import com.sk89q.worldedit.function.operation.Operations; import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.function.visitor.FlatRegionVisitor;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.Regions;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import java.util.concurrent.CompletableFuture; import com.sk89q.worldedit.world.biome.BiomeType;
public class FaweChunkManager extends ChunkManager { public class FaweRegionManager extends RegionManager {
private ChunkManager parent; private RegionManager parent;
public FaweChunkManager(ChunkManager parent) { public FaweRegionManager(RegionManager parent) {
this.parent = parent; this.parent = parent;
} }
@ -32,16 +35,6 @@ public class FaweChunkManager extends ChunkManager {
return parent.countEntities(plot); return parent.countEntities(plot);
} }
@Override
public CompletableFuture loadChunk(String world, BlockVector2 loc, boolean force) {
return parent.loadChunk(world, loc, force);
}
@Override
public void unloadChunk(String world, BlockVector2 loc, boolean save) {
parent.unloadChunk(world, loc, save);
}
@Override @Override
public void clearAllEntities(Location pos1, Location pos2) { public void clearAllEntities(Location pos1, Location pos2) {
parent.clearAllEntities(pos1, pos2); parent.clearAllEntities(pos1, pos2);
@ -50,7 +43,7 @@ public class FaweChunkManager extends ChunkManager {
@Override @Override
public void swap(final Location pos1, final Location pos2, final Location pos3, final Location pos4, final Runnable whenDone) { public void swap(final Location pos1, final Location pos2, final Location pos3, final Location pos4, final Runnable whenDone) {
TaskManager.IMP.async(() -> { TaskManager.IMP.async(() -> {
synchronized (FaweChunkManager.class) { synchronized (FaweRegionManager.class) {
//todo because of the following code this should proably be in the Bukkit module //todo because of the following code this should proably be in the Bukkit module
World pos1World = BukkitAdapter.adapt(getWorld(pos1.getWorld())); World pos1World = BukkitAdapter.adapt(getWorld(pos1.getWorld()));
World pos3World = BukkitAdapter.adapt(getWorld(pos3.getWorld())); World pos3World = BukkitAdapter.adapt(getWorld(pos3.getWorld()));
@ -75,10 +68,30 @@ public class FaweChunkManager extends ChunkManager {
}); });
} }
@Override
public void setBiome(CuboidRegion region, int extendBiome, BiomeType biome, String world, Runnable whenDone) {
region.expand(BlockVector3.at(extendBiome, 0, extendBiome));
region.expand(BlockVector3.at(-extendBiome, 0, -extendBiome));
TaskManager.IMP.async(() -> {
synchronized (FaweRegionManager.class) {
EditSession editSession = new EditSessionBuilder(BukkitAdapter.adapt(getWorld(world))).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build();
FlatRegionFunction replace = new BiomeReplace(editSession, biome);
FlatRegionVisitor visitor = new FlatRegionVisitor(region, replace);
try {
Operations.completeLegacy(visitor);
editSession.flushQueue();
} catch (MaxChangedBlocksException e) {
e.printStackTrace();
}
TaskManager.IMP.task(whenDone);
}
});
}
@Override @Override
public boolean copyRegion(final Location pos1, final Location pos2, final Location pos3, final Runnable whenDone) { public boolean copyRegion(final Location pos1, final Location pos2, final Location pos3, final Runnable whenDone) {
TaskManager.IMP.async(() -> { TaskManager.IMP.async(() -> {
synchronized (FaweChunkManager.class) { synchronized (FaweRegionManager.class) {
World pos1World = BukkitAdapter.adapt(getWorld(pos1.getWorld())); World pos1World = BukkitAdapter.adapt(getWorld(pos1.getWorld()));
World pos3World = BukkitAdapter.adapt(getWorld(pos3.getWorld())); World pos3World = BukkitAdapter.adapt(getWorld(pos3.getWorld()));
EditSession from = new EditSessionBuilder(pos1World).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build(); EditSession from = new EditSessionBuilder(pos1World).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build();
@ -100,7 +113,7 @@ public class FaweChunkManager extends ChunkManager {
@Override @Override
public boolean regenerateRegion(final Location pos1, final Location pos2, boolean ignore, final Runnable whenDone) { public boolean regenerateRegion(final Location pos1, final Location pos2, boolean ignore, final Runnable whenDone) {
TaskManager.IMP.async(() -> { TaskManager.IMP.async(() -> {
synchronized (FaweChunkManager.class) { synchronized (FaweRegionManager.class) {
World pos1World = BukkitAdapter.adapt(getWorld(pos1.getWorld())); World pos1World = BukkitAdapter.adapt(getWorld(pos1.getWorld()));
try (EditSession editSession = new EditSessionBuilder(pos1World).checkMemory(false) try (EditSession editSession = new EditSessionBuilder(pos1World).checkMemory(false)
.fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build()) { .fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build()) {

View File

@ -15,7 +15,7 @@ import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.flag.implementations.DoneFlag; import com.plotsquared.core.plot.flag.implementations.DoneFlag;
import com.plotsquared.core.plot.flag.implementations.NoWorldeditFlag; import com.plotsquared.core.plot.flag.implementations.NoWorldeditFlag;
import com.plotsquared.core.util.ChunkManager; import com.plotsquared.core.util.RegionManager;
import com.plotsquared.core.util.SchematicHandler; import com.plotsquared.core.util.SchematicHandler;
import com.plotsquared.core.util.WEManager; import com.plotsquared.core.util.WEManager;
import com.plotsquared.core.util.uuid.UUIDHandler; import com.plotsquared.core.util.uuid.UUIDHandler;
@ -45,7 +45,7 @@ public class PlotSquaredFeature extends FaweMaskManager {
try { try {
setupBlockQueue(); setupBlockQueue();
setupSchematicHandler(); setupSchematicHandler();
setupChunkManager(); setupRegionManager();
} catch (Throwable ignored) { } catch (Throwable ignored) {
log.debug("Please update PlotSquared: http://ci.athion.net/job/PlotSquared/"); log.debug("Please update PlotSquared: http://ci.athion.net/job/PlotSquared/");
} }
@ -81,9 +81,9 @@ public class PlotSquaredFeature extends FaweMaskManager {
log.debug(" - HybridPlotManager.REGENERATIVE_CLEAR: " + HybridPlotManager.REGENERATIVE_CLEAR); log.debug(" - HybridPlotManager.REGENERATIVE_CLEAR: " + HybridPlotManager.REGENERATIVE_CLEAR);
} }
private void setupChunkManager() throws RuntimeException { private void setupRegionManager() throws RuntimeException {
ChunkManager.manager = new FaweChunkManager(ChunkManager.manager); RegionManager.manager = new FaweRegionManager(RegionManager.manager);
log.debug(" - ChunkManager: " + ChunkManager.manager); log.debug(" - RegionManager: " + RegionManager.manager);
} }
private void setupSchematicHandler() throws RuntimeException { private void setupSchematicHandler() throws RuntimeException {

View File

@ -15,6 +15,7 @@ plugins {
repositories { repositories {
maven { url = uri("https://plotsquared.com/mvn") } maven { url = uri("https://plotsquared.com/mvn") }
maven { url = uri("https://mvn.intellectualsites.com/content/groups/public/") }
mavenCentral() mavenCentral()
} }
@ -58,7 +59,7 @@ dependencies {
"compile"("com.github.intellectualsites.plotsquared:PlotSquared-API:latest") { "compile"("com.github.intellectualsites.plotsquared:PlotSquared-API:latest") {
isTransitive = false isTransitive = false
} }
"compile"("com.plotsquared:PlotSquared:5.1") { "compile"("com.plotsquared:PlotSquared:5.11.1") {
isTransitive = false isTransitive = false
} }
implementation(kotlin("stdlib-jdk8", "1.3.61")) implementation(kotlin("stdlib-jdk8", "1.3.61"))