From bdc129cf7b36b49f4c4d11c9db0912616252991b Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Thu, 14 May 2020 16:20:17 +0100 Subject: [PATCH] Update to latest p2 v5 (implement FAWE biome setting) --- buildSrc/src/main/kotlin/CommonConfig.kt | 1 + ...unkManager.java => FaweRegionManager.java} | 51 ++++++++++++------- .../plotsquared/PlotSquaredFeature.java | 10 ++-- worldedit-core/build.gradle.kts | 3 +- 4 files changed, 40 insertions(+), 25 deletions(-) rename worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/{FaweChunkManager.java => FaweRegionManager.java} (75%) diff --git a/buildSrc/src/main/kotlin/CommonConfig.kt b/buildSrc/src/main/kotlin/CommonConfig.kt index 8751d3f42..197e4bcde 100644 --- a/buildSrc/src/main/kotlin/CommonConfig.kt +++ b/buildSrc/src/main/kotlin/CommonConfig.kt @@ -8,6 +8,7 @@ fun Project.applyCommonConfiguration() { repositories { mavenCentral() mavenLocal() + maven { url = uri("https://mvn.intellectualsites.com/content/groups/public/") } maven { url = uri("https://plotsquared.com/mvn/") } maven { url = uri("https://maven.sk89q.com/repo/") } maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots/") } diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/FaweChunkManager.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/FaweRegionManager.java similarity index 75% rename from worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/FaweChunkManager.java rename to worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/FaweRegionManager.java index a33de77c1..ecfb03a07 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/FaweChunkManager.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/FaweRegionManager.java @@ -6,24 +6,27 @@ import com.boydti.fawe.util.EditSessionBuilder; import com.boydti.fawe.util.TaskManager; import com.plotsquared.core.location.Location; 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.MaxChangedBlocksException; import com.sk89q.worldedit.WorldEdit; 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.Operations; -import com.sk89q.worldedit.math.BlockVector2; +import com.sk89q.worldedit.function.visitor.FlatRegionVisitor; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.CuboidRegion; +import com.sk89q.worldedit.regions.Regions; 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; } @@ -32,16 +35,6 @@ public class FaweChunkManager extends ChunkManager { 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 public void clearAllEntities(Location pos1, Location pos2) { parent.clearAllEntities(pos1, pos2); @@ -50,7 +43,7 @@ public class FaweChunkManager extends ChunkManager { @Override public void swap(final Location pos1, final Location pos2, final Location pos3, final Location pos4, final Runnable whenDone) { TaskManager.IMP.async(() -> { - synchronized (FaweChunkManager.class) { + synchronized (FaweRegionManager.class) { //todo because of the following code this should proably be in the Bukkit module World pos1World = BukkitAdapter.adapt(getWorld(pos1.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 public boolean copyRegion(final Location pos1, final Location pos2, final Location pos3, final Runnable whenDone) { TaskManager.IMP.async(() -> { - synchronized (FaweChunkManager.class) { + synchronized (FaweRegionManager.class) { World pos1World = BukkitAdapter.adapt(getWorld(pos1.getWorld())); World pos3World = BukkitAdapter.adapt(getWorld(pos3.getWorld())); EditSession from = new EditSessionBuilder(pos1World).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build(); @@ -100,7 +113,7 @@ public class FaweChunkManager extends ChunkManager { @Override public boolean regenerateRegion(final Location pos1, final Location pos2, boolean ignore, final Runnable whenDone) { TaskManager.IMP.async(() -> { - synchronized (FaweChunkManager.class) { + synchronized (FaweRegionManager.class) { World pos1World = BukkitAdapter.adapt(getWorld(pos1.getWorld())); try (EditSession editSession = new EditSessionBuilder(pos1World).checkMemory(false) .fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build()) { diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/PlotSquaredFeature.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/PlotSquaredFeature.java index daa26448f..b59d78efa 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/PlotSquaredFeature.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/PlotSquaredFeature.java @@ -15,7 +15,7 @@ import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.flag.implementations.DoneFlag; 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.WEManager; import com.plotsquared.core.util.uuid.UUIDHandler; @@ -45,7 +45,7 @@ public class PlotSquaredFeature extends FaweMaskManager { try { setupBlockQueue(); setupSchematicHandler(); - setupChunkManager(); + setupRegionManager(); } catch (Throwable ignored) { 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); } - private void setupChunkManager() throws RuntimeException { - ChunkManager.manager = new FaweChunkManager(ChunkManager.manager); - log.debug(" - ChunkManager: " + ChunkManager.manager); + private void setupRegionManager() throws RuntimeException { + RegionManager.manager = new FaweRegionManager(RegionManager.manager); + log.debug(" - RegionManager: " + RegionManager.manager); } private void setupSchematicHandler() throws RuntimeException { diff --git a/worldedit-core/build.gradle.kts b/worldedit-core/build.gradle.kts index f88a2a6ac..6c4d9f0ea 100644 --- a/worldedit-core/build.gradle.kts +++ b/worldedit-core/build.gradle.kts @@ -15,6 +15,7 @@ plugins { repositories { maven { url = uri("https://plotsquared.com/mvn") } + maven { url = uri("https://mvn.intellectualsites.com/content/groups/public/") } mavenCentral() } @@ -58,7 +59,7 @@ dependencies { "compile"("com.github.intellectualsites.plotsquared:PlotSquared-API:latest") { isTransitive = false } - "compile"("com.plotsquared:PlotSquared:5.1") { + "compile"("com.plotsquared:PlotSquared:5.11.1") { isTransitive = false } implementation(kotlin("stdlib-jdk8", "1.3.61"))