From 9085365165dcf1b8035b70f6228a54bc25073563 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Wed, 20 May 2020 09:44:59 +0100 Subject: [PATCH] Override P2's /plot set --- .../plotsquared/FaweRegionManager.java | 32 +++++++++++++++++-- worldedit-core/build.gradle.kts | 2 +- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/FaweRegionManager.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/FaweRegionManager.java index ecfb03a07..7aff976cf 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/FaweRegionManager.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/FaweRegionManager.java @@ -1,11 +1,10 @@ package com.boydti.fawe.bukkit.regions.plotsquared; -import static org.bukkit.Bukkit.getWorld; - 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.plot.PlotArea; import com.plotsquared.core.util.RegionManager; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.MaxChangedBlocksException; @@ -15,13 +14,18 @@ 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.function.pattern.Pattern; 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.regions.Region; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.biome.BiomeType; +import java.util.Set; + +import static org.bukkit.Bukkit.getWorld; + public class FaweRegionManager extends RegionManager { private RegionManager parent; @@ -40,6 +44,28 @@ public class FaweRegionManager extends RegionManager { parent.clearAllEntities(pos1, pos2); } + @Override + public boolean setCuboids(final PlotArea area, final Set regions, final Pattern blocks, final int minY, final int maxY) { + TaskManager.IMP.async(() -> { + synchronized (FaweRegionManager.class) { + World world = BukkitAdapter.adapt(getWorld(area.getWorldName())); + EditSession session = new EditSessionBuilder(world).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build(); + for (CuboidRegion region : regions) { + System.out.println(minY + " " + maxY); + region.setPos1(region.getPos1().withY(minY)); + region.setPos2(region.getPos2().withY(maxY)); + session.setBlocks((Region) region, blocks); + } + try { + session.flushQueue(); + } catch (MaxChangedBlocksException e) { + e.printStackTrace(); + } + } + }); + return true; + } + @Override public void swap(final Location pos1, final Location pos2, final Location pos3, final Location pos4, final Runnable whenDone) { TaskManager.IMP.async(() -> { diff --git a/worldedit-core/build.gradle.kts b/worldedit-core/build.gradle.kts index 6c4d9f0ea..e364ec7b6 100644 --- a/worldedit-core/build.gradle.kts +++ b/worldedit-core/build.gradle.kts @@ -59,7 +59,7 @@ dependencies { "compile"("com.github.intellectualsites.plotsquared:PlotSquared-API:latest") { isTransitive = false } - "compile"("com.plotsquared:PlotSquared:5.11.1") { + "compile"("com.plotsquared:PlotSquared:5.11.2") { isTransitive = false } implementation(kotlin("stdlib-jdk8", "1.3.61"))