From 6dd85e48baddcf6ca15db399b8c2626fe28e95c3 Mon Sep 17 00:00:00 2001 From: MattBDev <4009945+MattBDev@users.noreply.github.com> Date: Wed, 12 Feb 2020 16:18:36 -0500 Subject: [PATCH] Various changes the most notable change is that PlotSquared is being moved to the Bukkit module again to allow for future compatibility with version 5 of the plugin. --- .../com/boydti/fawe/bukkit/FaweBukkit.java | 14 +- .../regions/plotsquared}/CFIRedirect.java | 2 +- .../plotsquared}/FaweChunkManager.java | 36 +++-- .../plotsquared}/FaweLocalBlockQueue.java | 2 +- .../plotsquared}/FaweSchematicHandler.java | 9 +- .../bukkit/regions/plotsquared}/FaweTrim.java | 2 +- .../regions/plotsquared}/MoveTo512.java | 2 +- .../plotsquared}/PlotRegionFilter.java | 2 +- .../regions/plotsquared}/PlotSetBiome.java | 3 +- .../plotsquared}/PlotSquaredFeature.java | 2 +- .../regions/plotsquared}/ReplaceAll.java | 0 .../src/main/java/com/boydti/fawe/Fawe.java | 4 +- .../main/java/com/boydti/fawe/FaweAPI.java | 2 +- .../src/main/java/com/boydti/fawe/IFawe.java | 3 +- .../boydti/fawe/command/AnvilCommands.java | 2 +- .../regions/general/CuboidRegionFilter.java | 6 +- .../java/com/sk89q/worldedit/EditSession.java | 137 +++++++++++++----- .../worldedit/command/RegionCommands.java | 34 ++--- .../extent/AbstractDelegateExtent.java | 2 + 19 files changed, 178 insertions(+), 86 deletions(-) rename {worldedit-core/src/main/java/com/boydti/fawe/regions/general/integrations/plotquared => worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared}/CFIRedirect.java (97%) rename {worldedit-core/src/main/java/com/boydti/fawe/regions/general/integrations/plotquared => worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared}/FaweChunkManager.java (68%) rename {worldedit-core/src/main/java/com/boydti/fawe/regions/general/integrations/plotquared => worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared}/FaweLocalBlockQueue.java (98%) rename {worldedit-core/src/main/java/com/boydti/fawe/regions/general/integrations/plotquared => worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared}/FaweSchematicHandler.java (94%) rename {worldedit-core/src/main/java/com/boydti/fawe/regions/general/integrations/plotquared => worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared}/FaweTrim.java (97%) rename {worldedit-core/src/main/java/com/boydti/fawe/regions/general/integrations/plotquared => worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared}/MoveTo512.java (99%) rename {worldedit-core/src/main/java/com/boydti/fawe/regions/general/integrations/plotquared => worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared}/PlotRegionFilter.java (93%) rename {worldedit-core/src/main/java/com/boydti/fawe/regions/general/integrations/plotquared => worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared}/PlotSetBiome.java (97%) rename {worldedit-core/src/main/java/com/boydti/fawe/regions/general/integrations/plotquared => worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared}/PlotSquaredFeature.java (99%) rename {worldedit-core/src/main/java/com/boydti/fawe/regions/general/integrations/plotquared => worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared}/ReplaceAll.java (100%) diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java index f72295ec7..616aff519 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/FaweBukkit.java @@ -5,6 +5,7 @@ import com.boydti.fawe.IFawe; import com.boydti.fawe.beta.implementation.cache.preloader.AsyncPreloader; import com.boydti.fawe.beta.implementation.cache.preloader.Preloader; import com.boydti.fawe.beta.implementation.queue.QueueHandler; +import com.boydti.fawe.bukkit.regions.plotsquared.PlotSquaredFeature; import com.boydti.fawe.bukkit.adapter.BukkitQueueHandler; import com.boydti.fawe.bukkit.listener.BrushListener; import com.boydti.fawe.bukkit.listener.BukkitImageListener; @@ -26,6 +27,7 @@ import com.boydti.fawe.config.Settings; import com.boydti.fawe.regions.FaweMaskManager; import com.boydti.fawe.util.Jars; import com.boydti.fawe.util.TaskManager; +import com.boydti.fawe.util.WEManager; import com.boydti.fawe.util.image.ImageViewer; import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.bukkit.BukkitPlayer; @@ -37,7 +39,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.UUID; import java.util.function.Supplier; -import org.bstats.bukkit.Metrics; import org.bukkit.Bukkit; import org.bukkit.command.ConsoleCommandSender; import org.bukkit.entity.Player; @@ -228,11 +229,6 @@ public class FaweBukkit implements IFawe, Listener { return plugin; } - @Override - public String getWorldName(World world) { - return world.getName(); - } - /** * A mask manager handles region restrictions e.g., PlotSquared plots / WorldGuard regions */ @@ -347,4 +343,10 @@ public class FaweBukkit implements IFawe, Listener { } return null; } + + @Override + public void setupPlotSquared() { + WEManager.IMP.managers.add(new com.boydti.fawe.bukkit.regions.plotsquared.PlotSquaredFeature()); + log.debug("Plugin 'PlotSquared' found. Using it now."); + } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/regions/general/integrations/plotquared/CFIRedirect.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/CFIRedirect.java similarity index 97% rename from worldedit-core/src/main/java/com/boydti/fawe/regions/general/integrations/plotquared/CFIRedirect.java rename to worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/CFIRedirect.java index 743205223..b80ee9cc4 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/regions/general/integrations/plotquared/CFIRedirect.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/CFIRedirect.java @@ -1,4 +1,4 @@ -package com.boydti.fawe.regions.general.integrations.plotquared; +package com.boydti.fawe.bukkit.regions.plotsquared; import com.github.intellectualsites.plotsquared.commands.Command; import com.github.intellectualsites.plotsquared.commands.CommandDeclaration; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/regions/general/integrations/plotquared/FaweChunkManager.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/FaweChunkManager.java similarity index 68% rename from worldedit-core/src/main/java/com/boydti/fawe/regions/general/integrations/plotquared/FaweChunkManager.java rename to worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/FaweChunkManager.java index f2e2d0f01..12fd0a073 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/regions/general/integrations/plotquared/FaweChunkManager.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/FaweChunkManager.java @@ -1,4 +1,6 @@ -package com.boydti.fawe.regions.general.integrations.plotquared; +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; @@ -7,6 +9,8 @@ import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.util.ChunkManager; 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.operation.ForwardExtentCopy; import com.sk89q.worldedit.function.operation.Operations; import com.sk89q.worldedit.math.BlockVector2; @@ -14,6 +18,7 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.world.World; import java.util.concurrent.CompletableFuture; +import org.bukkit.Bukkit; public class FaweChunkManager extends ChunkManager { @@ -47,8 +52,13 @@ public class FaweChunkManager extends ChunkManager { public void swap(final Location pos1, final Location pos2, final Location pos3, final Location pos4, final Runnable whenDone) { TaskManager.IMP.async(() -> { synchronized (FaweChunkManager.class) { - EditSession sessionA = new EditSessionBuilder(pos1.getWorld()).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build(); - EditSession sessionB = new EditSessionBuilder(pos3.getWorld()).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build(); + //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())); + WorldEdit.getInstance().getEditSessionFactory().getEditSession( + pos1World,-1); + EditSession sessionA = new EditSessionBuilder(pos1World).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build(); + EditSession sessionB = new EditSessionBuilder(pos3World).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build(); CuboidRegion regionA = new CuboidRegion(BlockVector3.at(pos1.getX(), pos1.getY(), pos1.getZ()), BlockVector3.at(pos2.getX(), pos2.getY(), pos2.getZ())); CuboidRegion regionB = new CuboidRegion(BlockVector3.at(pos3.getX(), pos3.getY(), pos3.getZ()), BlockVector3.at(pos4.getX(), pos4.getY(), pos4.getZ())); ForwardExtentCopy copyA = new ForwardExtentCopy(sessionA, regionA, sessionB, regionB.getMinimumPoint()); @@ -70,8 +80,10 @@ public class FaweChunkManager extends ChunkManager { public boolean copyRegion(final Location pos1, final Location pos2, final Location pos3, final Runnable whenDone) { TaskManager.IMP.async(() -> { synchronized (FaweChunkManager.class) { - EditSession from = new EditSessionBuilder(pos1.getWorld()).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build(); - EditSession to = new EditSessionBuilder(pos3.getWorld()).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build(); + 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(); + EditSession to = new EditSessionBuilder(pos3World).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build(); CuboidRegion region = new CuboidRegion(BlockVector3.at(pos1.getX(), pos1.getY(), pos1.getZ()), BlockVector3.at(pos2.getX(), pos2.getY(), pos2.getZ())); ForwardExtentCopy copy = new ForwardExtentCopy(from, region, to, BlockVector3.at(pos3.getX(), pos3.getY(), pos3.getZ())); try { @@ -90,11 +102,15 @@ public class FaweChunkManager extends ChunkManager { public boolean regenerateRegion(final Location pos1, final Location pos2, boolean ignore, final Runnable whenDone) { TaskManager.IMP.async(() -> { synchronized (FaweChunkManager.class) { - EditSession editSession = new EditSessionBuilder(pos1.getWorld()).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build(); - World world = editSession.getWorld(); - CuboidRegion region = new CuboidRegion(BlockVector3.at(pos1.getX(), pos1.getY(), pos1.getZ()), BlockVector3.at(pos2.getX(), pos2.getY(), pos2.getZ())); - editSession.regenerate(region); - editSession.flushQueue(); + World pos1World = BukkitAdapter.adapt(getWorld(pos1.getWorld())); + try (EditSession editSession = new EditSessionBuilder(pos1World).checkMemory(false) + .fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build()) { + CuboidRegion region = new CuboidRegion( + BlockVector3.at(pos1.getX(), pos1.getY(), pos1.getZ()), + BlockVector3.at(pos2.getX(), pos2.getY(), pos2.getZ())); + editSession.regenerate(region); + editSession.flushQueue(); + } TaskManager.IMP.task(whenDone); } }); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/regions/general/integrations/plotquared/FaweLocalBlockQueue.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/FaweLocalBlockQueue.java similarity index 98% rename from worldedit-core/src/main/java/com/boydti/fawe/regions/general/integrations/plotquared/FaweLocalBlockQueue.java rename to worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/FaweLocalBlockQueue.java index ed10b172d..10c0883ab 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/regions/general/integrations/plotquared/FaweLocalBlockQueue.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/FaweLocalBlockQueue.java @@ -1,4 +1,4 @@ -package com.boydti.fawe.regions.general.integrations.plotquared; +package com.boydti.fawe.bukkit.regions.plotsquared; import com.boydti.fawe.Fawe; import com.boydti.fawe.FaweAPI; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/regions/general/integrations/plotquared/FaweSchematicHandler.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/FaweSchematicHandler.java similarity index 94% rename from worldedit-core/src/main/java/com/boydti/fawe/regions/general/integrations/plotquared/FaweSchematicHandler.java rename to worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/FaweSchematicHandler.java index 3a3eec8ff..0356c636a 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/regions/general/integrations/plotquared/FaweSchematicHandler.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/FaweSchematicHandler.java @@ -1,4 +1,6 @@ -package com.boydti.fawe.regions.general.integrations.plotquared; +package com.boydti.fawe.bukkit.regions.plotsquared; + +import static org.bukkit.Bukkit.getWorld; import com.boydti.fawe.FaweAPI; import com.boydti.fawe.FaweCache; @@ -19,12 +21,14 @@ import com.sk89q.jnbt.CompressedSchematicTag; import com.sk89q.jnbt.NBTOutputStream; import com.sk89q.jnbt.Tag; import com.sk89q.worldedit.EditSession; +import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.io.BuiltInClipboardFormat; import com.sk89q.worldedit.extent.clipboard.io.FastSchematicWriter; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.CuboidRegion; +import com.sk89q.worldedit.world.World; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileNotFoundException; @@ -53,8 +57,9 @@ public class FaweSchematicHandler extends SchematicHandler { Location[] corners = MainUtil.getCorners(world, regions); Location pos1 = corners[0]; Location pos2 = corners[1]; + World adaptedWorld = BukkitAdapter.adapt(getWorld(world)); final CuboidRegion region = new CuboidRegion(BlockVector3.at(pos1.getX(), pos1.getY(), pos1.getZ()), BlockVector3.at(pos2.getX(), pos2.getY(), pos2.getZ())); - final EditSession editSession = new EditSessionBuilder(world).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build(); + final EditSession editSession = new EditSessionBuilder(adaptedWorld).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build(); ReadOnlyClipboard clipboard = ReadOnlyClipboard.of(editSession, region); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/regions/general/integrations/plotquared/FaweTrim.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/FaweTrim.java similarity index 97% rename from worldedit-core/src/main/java/com/boydti/fawe/regions/general/integrations/plotquared/FaweTrim.java rename to worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/FaweTrim.java index 836bd11e6..25041f4e8 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/regions/general/integrations/plotquared/FaweTrim.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/FaweTrim.java @@ -1,4 +1,4 @@ -package com.boydti.fawe.regions.general.integrations.plotquared; +package com.boydti.fawe.bukkit.regions.plotsquared; import com.boydti.fawe.util.TaskManager; import com.github.intellectualsites.plotsquared.commands.CommandDeclaration; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/regions/general/integrations/plotquared/MoveTo512.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/MoveTo512.java similarity index 99% rename from worldedit-core/src/main/java/com/boydti/fawe/regions/general/integrations/plotquared/MoveTo512.java rename to worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/MoveTo512.java index cee667852..a9639da1e 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/regions/general/integrations/plotquared/MoveTo512.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/MoveTo512.java @@ -1,4 +1,4 @@ -package com.boydti.fawe.regions.general.integrations.plotquared; +package com.boydti.fawe.bukkit.regions.plotsquared; import com.github.intellectualsites.plotsquared.commands.CommandDeclaration; import com.github.intellectualsites.plotsquared.plot.commands.CommandCategory; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/regions/general/integrations/plotquared/PlotRegionFilter.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/PlotRegionFilter.java similarity index 93% rename from worldedit-core/src/main/java/com/boydti/fawe/regions/general/integrations/plotquared/PlotRegionFilter.java rename to worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/PlotRegionFilter.java index d02010126..725d6f8ea 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/regions/general/integrations/plotquared/PlotRegionFilter.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/PlotRegionFilter.java @@ -1,4 +1,4 @@ -package com.boydti.fawe.regions.general.integrations.plotquared; +package com.boydti.fawe.bukkit.regions.plotsquared; import static com.google.common.base.Preconditions.checkNotNull; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/regions/general/integrations/plotquared/PlotSetBiome.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/PlotSetBiome.java similarity index 97% rename from worldedit-core/src/main/java/com/boydti/fawe/regions/general/integrations/plotquared/PlotSetBiome.java rename to worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/PlotSetBiome.java index 20d7023c0..1d142d132 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/regions/general/integrations/plotquared/PlotSetBiome.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/PlotSetBiome.java @@ -1,4 +1,4 @@ -package com.boydti.fawe.regions.general.integrations.plotquared; +package com.boydti.fawe.bukkit.regions.plotsquared; import com.boydti.fawe.Fawe; import com.boydti.fawe.FaweAPI; @@ -17,7 +17,6 @@ import com.github.intellectualsites.plotsquared.plot.object.RunnableVal3; import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.Permissions; import com.github.intellectualsites.plotsquared.plot.util.StringMan; -import com.github.intellectualsites.plotsquared.plot.util.WorldUtil; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.extension.platform.Capability; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/regions/general/integrations/plotquared/PlotSquaredFeature.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/PlotSquaredFeature.java similarity index 99% rename from worldedit-core/src/main/java/com/boydti/fawe/regions/general/integrations/plotquared/PlotSquaredFeature.java rename to worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/PlotSquaredFeature.java index c0d24887c..2d2c31118 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/regions/general/integrations/plotquared/PlotSquaredFeature.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/PlotSquaredFeature.java @@ -1,4 +1,4 @@ -package com.boydti.fawe.regions.general.integrations.plotquared; +package com.boydti.fawe.bukkit.regions.plotsquared; import com.boydti.fawe.FaweAPI; import com.boydti.fawe.object.RegionWrapper; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/regions/general/integrations/plotquared/ReplaceAll.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/ReplaceAll.java similarity index 100% rename from worldedit-core/src/main/java/com/boydti/fawe/regions/general/integrations/plotquared/ReplaceAll.java rename to worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/regions/plotsquared/ReplaceAll.java diff --git a/worldedit-core/src/main/java/com/boydti/fawe/Fawe.java b/worldedit-core/src/main/java/com/boydti/fawe/Fawe.java index e810f9a5f..095d67cc6 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/Fawe.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/Fawe.java @@ -3,7 +3,6 @@ package com.boydti.fawe; import com.boydti.fawe.beta.implementation.queue.QueueHandler; import com.boydti.fawe.config.Settings; import com.boydti.fawe.object.brush.visualization.VisualQueue; -import com.boydti.fawe.regions.general.integrations.plotquared.PlotSquaredFeature; import com.boydti.fawe.util.CachedTextureUtil; import com.boydti.fawe.util.CleanTextureUtil; import com.boydti.fawe.util.FaweTimer; @@ -188,8 +187,7 @@ public class Fawe { // transformParser = new DefaultTransformParser(getWorldEdit()); visualQueue = new VisualQueue(3); WEManager.IMP.managers.addAll(Fawe.this.IMP.getMaskManagers()); - WEManager.IMP.managers.add(new PlotSquaredFeature()); - log.debug("Plugin 'PlotSquared' found. Using it now."); + IMP.setupPlotSquared(); } catch (Throwable ignored) {} }, 0); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/FaweAPI.java b/worldedit-core/src/main/java/com/boydti/fawe/FaweAPI.java index dfcff725f..e45d011c5 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/FaweAPI.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/FaweAPI.java @@ -299,7 +299,7 @@ public class FaweAPI { throw new IllegalArgumentException("Origin is not a valid world"); } World world = (World) extent; - File history = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY + File.separator + Fawe.imp().getWorldName(world)); + File history = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY + File.separator + world.getName()); if (!history.exists()) { return new ArrayList<>(); } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/IFawe.java b/worldedit-core/src/main/java/com/boydti/fawe/IFawe.java index 7c363351e..b2786538d 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/IFawe.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/IFawe.java @@ -23,8 +23,6 @@ public interface IFawe { TaskManager getTaskManager(); - String getWorldName(World world); - Collection getMaskManagers(); default ImageViewer getImageViewer(Player player) { @@ -49,4 +47,5 @@ public interface IFawe { Preloader getPreloader(); + void setupPlotSquared(); } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/command/AnvilCommands.java b/worldedit-core/src/main/java/com/boydti/fawe/command/AnvilCommands.java index 295ff09be..106ed9daf 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/command/AnvilCommands.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/command/AnvilCommands.java @@ -627,7 +627,7 @@ public class AnvilCommands { // int oX = offset.getBlockX(); // int oZ = offset.getBlockZ(); // RegionWrapper pasteRegion = new RegionWrapper(copyRegion.minX + oX, copyRegion.maxX + oX, copyRegion.minZ + oZ, copyRegion.maxZ + oZ); -// String pasteWorldName = Fawe.imp().getWorldName(editSession.getWorld()); +// String pasteWorldName = editSession.getWorld().getName(); // IQueueExtent tmpTo = SetQueue.IMP.getNewQueue(pasteWorldName, true, false); // MCAQueue copyQueue = clipboard.getQueue(); // MCAQueue pasteQueue = new MCAQueue(tmpTo); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/regions/general/CuboidRegionFilter.java b/worldedit-core/src/main/java/com/boydti/fawe/regions/general/CuboidRegionFilter.java index b3bfcd820..0e3402292 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/regions/general/CuboidRegionFilter.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/regions/general/CuboidRegionFilter.java @@ -43,9 +43,9 @@ public abstract class CuboidRegionFilter implements RegionFilter { int cz1 = pos1.getBlockZ() >> 4; int cx2 = pos2.getBlockX() >> 4; int cz2 = pos2.getBlockZ() >> 4; - for (int cz = cz1; cz <= cz2; cz++) { - for (int cx = cx1; cx <= cx2; cx++) { - unoccupiedChunks.remove(cx, cz); + for (int chunkZ = cz1; chunkZ <= cz2; chunkZ++) { + for (int chunkX = cx1; chunkX <= cx2; chunkX++) { + unoccupiedChunks.remove(chunkX, chunkZ); } } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java index 437095ca2..94b1813b5 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java @@ -144,7 +144,6 @@ import static com.sk89q.worldedit.regions.Regions.asFlatRegion; import static com.sk89q.worldedit.regions.Regions.maximumBlockY; import static com.sk89q.worldedit.regions.Regions.minimumBlockY; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Range; /** @@ -215,30 +214,23 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { private final int maxY; @Deprecated - public EditSession(@NotNull World world, @Nullable Player player, @Nullable FaweLimit limit, @Nullable AbstractChangeSet changeSet, @Nullable RegionWrapper[] allowedRegions, @Nullable Boolean autoQueue, @Nullable Boolean fastmode, @Nullable Boolean checkMemory, @Nullable Boolean combineStages, @Nullable BlockBag blockBag, @Nullable EventBus bus, @Nullable EditSessionEvent event) { - this(null, world, player, limit, changeSet, allowedRegions, autoQueue, fastmode, checkMemory, combineStages, blockBag, bus, event); + public EditSession(EventBus bus, World world, @Nullable Player player, + @Nullable FaweLimit limit, @Nullable AbstractChangeSet changeSet, + @Nullable RegionWrapper[] allowedRegions, @Nullable Boolean autoQueue, + @Nullable Boolean fastmode, @Nullable Boolean checkMemory, @Nullable Boolean combineStages, + @Nullable BlockBag blockBag, @Nullable EditSessionEvent event) { + this(bus, world, null, player, limit, changeSet, allowedRegions, autoQueue, fastmode, checkMemory, combineStages, blockBag, + event); } - public EditSession(@Nullable String worldName, @Nullable World world, @Nullable Player player, @Nullable FaweLimit limit, @Nullable AbstractChangeSet changeSet, @Nullable Region[] allowedRegions, @Nullable Boolean autoQueue, @Nullable Boolean fastmode, @Nullable Boolean checkMemory, @Nullable Boolean combineStages, @Nullable BlockBag blockBag, @Nullable EventBus bus, @Nullable EditSessionEvent event) { + public EditSession(EventBus bus, World world, String worldName, + @Nullable Player player, @Nullable FaweLimit limit, @Nullable AbstractChangeSet changeSet, + @Nullable Region[] allowedRegions, @Nullable Boolean autoQueue, @Nullable Boolean fastmode, + @Nullable Boolean checkMemory, @Nullable Boolean combineStages, @Nullable BlockBag blockBag, + @Nullable EditSessionEvent event) { this(new EditSessionBuilder(world, worldName).player(player).limit(limit).changeSet(changeSet).allowedRegions(allowedRegions).autoQueue(autoQueue).fastmode(fastmode).checkMemory(checkMemory).combineStages(combineStages).blockBag(blockBag).eventBus(bus).event(event)); } - public EditSession(EditSessionBuilder builder) { - super(builder.compile().getExtent()); - this.world = builder.getWorld(); - this.worldName = builder.getWorldName(); - this.wrapped = builder.isWrapped(); - this.bypassHistory = builder.getBypassHistory(); - this.bypassAll = builder.getBypassAll(); - this.originalLimit = builder.getLimit(); - this.limit = builder.getLimit().copy(); - this.player = builder.getPlayer(); - this.changeSet = builder.getChangeTask(); - this.maxY = builder.getMaxY(); - this.blockBag = builder.getBlockBag(); - this.history = changeSet != null; - } - /** * Construct the object with a maximum number of blocks and a block bag. * @@ -248,8 +240,24 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { * @param blockBag an optional {@link BlockBag} to use, otherwise null * @param event the event to call with the extent */ - public EditSession(EventBus eventBus, @NotNull World world, int maxBlocks, @Nullable BlockBag blockBag, EditSessionEvent event) { - this(world, null, null, null, null, true, null, null, null, blockBag, eventBus, event); + public EditSession(EventBus eventBus, World world, int maxBlocks, @Nullable BlockBag blockBag, EditSessionEvent event) { + this(eventBus, world, null, null, null, null, true, null, null, null, blockBag, event); + } + + public EditSession(EditSessionBuilder builder) { + super(builder.compile().getExtent()); + this.world = builder.getWorld(); + this.worldName = world.getName(); + this.wrapped = builder.isWrapped(); + this.bypassHistory = builder.getBypassHistory(); + this.bypassAll = builder.getBypassAll(); + this.originalLimit = builder.getLimit(); + this.limit = builder.getLimit().copy(); + this.player = builder.getPlayer(); + this.changeSet = builder.getChangeTask(); + this.maxY = builder.getMaxY(); + this.blockBag = builder.getBlockBag(); + this.history = changeSet != null; } /** @@ -575,6 +583,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { * * @param enabled true to enable */ + @Deprecated public void setFastMode(boolean enabled) { disableHistory(enabled); } @@ -584,12 +593,12 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { * * @param disableHistory */ + @Deprecated public void disableHistory(boolean disableHistory) { if (disableHistory) { if (this.history) { disableHistory(); this.history = false; - return; } } else { if (this.history) { @@ -609,6 +618,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { * * @return true if enabled */ + @Deprecated public boolean hasFastMode() { return getChangeSet() == null; } @@ -2498,6 +2508,8 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { * * @return number of blocks affected * @throws MaxChangedBlocksException thrown if too many blocks are changed + * + * @see #drawLine(Pattern, List, double, boolean) */ public int drawLine(Pattern pattern, BlockVector3 pos1, BlockVector3 pos2, double radius, boolean filled, boolean flat) throws MaxChangedBlocksException { @@ -2515,7 +2527,8 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { notdrawn = false; } - if (Math.max(Math.max(dx, dy), dz) == dx && notdrawn) { + int dMax = Math.max(Math.max(dx, dy), dz); + if (dMax == dx && notdrawn) { for (int domstep = 0; domstep <= dx; domstep++) { tipx = x1 + domstep * (x2 - x1 > 0 ? 1 : -1); tipy = (int) Math.round(y1 + domstep * (double) dy / (double) dx * (y2 - y1 > 0 ? 1 : -1)); @@ -2523,10 +2536,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { vset.add(BlockVector3.at(tipx, tipy, tipz)); } - notdrawn = false; - } - - if (Math.max(Math.max(dx, dy), dz) == dy && notdrawn) { + } else if (dMax == dy && notdrawn) { for (int domstep = 0; domstep <= dy; domstep++) { tipy = y1 + domstep * (y2 - y1 > 0 ? 1 : -1); tipx = (int) Math.round(x1 + domstep * (double) dx / (double) dy * (x2 - x1 > 0 ? 1 : -1)); @@ -2534,10 +2544,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { vset.add(BlockVector3.at(tipx, tipy, tipz)); } - notdrawn = false; - } - - if (Math.max(Math.max(dx, dy), dz) == dz && notdrawn) { + } else if (dMax == dz && notdrawn) { for (int domstep = 0; domstep <= dz; domstep++) { tipz = z1 + domstep * (z2 - z1 > 0 ? 1 : -1); tipy = (int) Math.round(y1 + domstep * (double) dy / (double) dz * (y2-y1>0 ? 1 : -1)); @@ -2545,7 +2552,6 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { vset.add(BlockVector3.at(tipx, tipy, tipz)); } - notdrawn = false; } Set newVset; if (flat) { @@ -2562,6 +2568,71 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { return setBlocks(newVset, pattern); } + /** + * Draws a line (out of blocks) between two or more vectors. + * + * @param pattern The block pattern used to draw the line. + * @param vectors the list of vectors to draw the line between + * @param radius The radius (thickness) of the line. + * @param filled If false, only a shell will be generated. + * + * @return number of blocks affected + * @throws MaxChangedBlocksException thrown if too many blocks are changed + */ + public int drawLine(Pattern pattern, List vectors, double radius, boolean filled) + throws MaxChangedBlocksException { + + Set vset = new HashSet<>(); + + for (int i = 0; vectors.size() != 0 && i < vectors.size() - 1; i++) { + BlockVector3 pos1 = vectors.get(i); + BlockVector3 pos2 = vectors.get(i + 1); + + int x1 = pos1.getBlockX(), y1 = pos1.getBlockY(), z1 = pos1.getBlockZ(); + int x2 = pos2.getBlockX(), y2 = pos2.getBlockY(), z2 = pos2.getBlockZ(); + int tipx = x1, tipy = y1, tipz = z1; + int dx = Math.abs(x2 - x1), dy = Math.abs(y2 - y1), dz = Math.abs(z2 - z1); + + if (dx + dy + dz == 0) { + vset.add(BlockVector3.at(tipx, tipy, tipz)); + continue; + } + + int dMax = Math.max(Math.max(dx, dy), dz); + if (dMax == dx) { + for (int domstep = 0; domstep <= dx; domstep++) { + tipx = x1 + domstep * (x2 - x1 > 0 ? 1 : -1); + tipy = (int) Math.round(y1 + domstep * ((double) dy) / ((double) dx) * (y2 - y1 > 0 ? 1 : -1)); + tipz = (int) Math.round(z1 + domstep * ((double) dz) / ((double) dx) * (z2 - z1 > 0 ? 1 : -1)); + + vset.add(BlockVector3.at(tipx, tipy, tipz)); + } + } else if (dMax == dy) { + for (int domstep = 0; domstep <= dy; domstep++) { + tipy = y1 + domstep * (y2 - y1 > 0 ? 1 : -1); + tipx = (int) Math.round(x1 + domstep * ((double) dx) / ((double) dy) * (x2 - x1 > 0 ? 1 : -1)); + tipz = (int) Math.round(z1 + domstep * ((double) dz) / ((double) dy) * (z2 - z1 > 0 ? 1 : -1)); + + vset.add(BlockVector3.at(tipx, tipy, tipz)); + } + } else /* if (dMax == dz) */ { + for (int domstep = 0; domstep <= dz; domstep++) { + tipz = z1 + domstep * (z2 - z1 > 0 ? 1 : -1); + tipy = (int) Math.round(y1 + domstep * ((double) dy) / ((double) dz) * (y2-y1>0 ? 1 : -1)); + tipx = (int) Math.round(x1 + domstep * ((double) dx) / ((double) dz) * (x2-x1>0 ? 1 : -1)); + + vset.add(BlockVector3.at(tipx, tipy, tipz)); + } + } + } + + vset = getBallooned(vset, radius); + if (!filled) { + vset = getHollowed(vset); + } + return setBlocks(vset, pattern); + } + /** * Draws a spline (out of blocks) between specified vectors. * diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java index 8f5d8f51b..56437fcb9 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java @@ -115,7 +115,7 @@ public class RegionCommands { System.out.println("TODO FIXME TIPS"); // TranslatableComponent.of("fawe.tips.tip.fast").or(TranslatableComponent.of("fawe.tips.tip.cancel"), TranslatableComponent.of("fawe.tips.tip.mask"), TranslatableComponent.of("fawe.tips.tip.mask.angle"), TranslatableComponent.of("fawe.tips.tip.set.linear"), TranslatableComponent.of("fawe.tips.tip.surface.spread"), TranslatableComponent.of("fawe.tips.tip.set.hand")).send(actor); } - return 0; + return affected; } @Command( @@ -313,7 +313,7 @@ public class RegionCommands { @Confirm(Confirm.Processor.REGION) public int overlay(Actor actor, EditSession editSession, @Selection Region region, @Arg(desc = "The pattern of blocks to overlay") - Pattern pattern) throws WorldEditException { + Pattern pattern) throws WorldEditException { int affected = editSession.overlayCuboidBlocks(region, pattern); actor.printInfo(TranslatableComponent.of("worldedit.overlay.overlaid", TextComponent.of(affected))); return affected; @@ -470,9 +470,9 @@ public class RegionCommands { @Command( - name = "/move", - aliases = {"/mv"}, - desc = "Move the contents of the selection" + name = "/move", + aliases = {"/mv"}, + desc = "Move the contents of the selection" ) @CommandPermissions("worldedit.region.move") @Logging(ORIENTATION_REGION) @@ -480,25 +480,25 @@ public class RegionCommands { public int move(Actor actor, World world, EditSession editSession, LocalSession session, @Selection Region region, @Arg(desc = "# of blocks to move", def = "1") - int count, + int count, @Arg(desc = "The direction to move", def = Direction.AIM) @Direction(includeDiagonals = true) - BlockVector3 direction, + BlockVector3 direction, @Arg(desc = "The pattern of blocks to leave", def = "air") - Pattern replace, + Pattern replace, @Switch(name = 's', desc = "Shift the selection to the target location") - boolean moveSelection, + boolean moveSelection, @Switch(name = 'a', desc = "Ignore air blocks") - boolean ignoreAirBlocks, + boolean ignoreAirBlocks, @Switch(name = 'e', desc = "Also copy entities") boolean copyEntities, @Switch(name = 'b', desc = "Also copy biomes") - boolean copyBiomes, + boolean copyBiomes, @ArgFlag(name = 'm', desc = "Set the include mask, non-matching blocks become air", def = "") - Mask mask) throws WorldEditException { + Mask mask) throws WorldEditException { checkCommandArgument(count >= 1, "Count must be >= 1"); - Mask combinedMask; + Mask combinedMask; if (ignoreAirBlocks) { if (mask == null) { combinedMask = new ExistingBlockMask(editSession); @@ -568,7 +568,7 @@ public class RegionCommands { @ArgFlag(name = 'm', desc = "Set the include mask, non-matching blocks become air", def = "") Mask mask) throws WorldEditException { - Mask combinedMask; + Mask combinedMask; if (ignoreAirBlocks) { if (mask == null) { combinedMask = new ExistingBlockMask(editSession); @@ -583,9 +583,9 @@ public class RegionCommands { if (moveSelection) { try { - final BlockVector3 size = region.getMaximumPoint().subtract(region.getMinimumPoint()).add(1, 1, 1); + final BlockVector3 size = region.getMaximumPoint().subtract(region.getMinimumPoint()).add(1, 1, 1); - final BlockVector3 shiftVector = direction.multiply(size).multiply(count); + final BlockVector3 shiftVector = direction.multiply(size).multiply(count); region.shift(shiftVector); session.getRegionSelector(world).learnChanges(); @@ -623,7 +623,7 @@ public class RegionCommands { session.setSourceMask(mask); } if (success) { - actor.printInfo(TranslatableComponent.of("worldedit.regen.regenerated")); + actor.printInfo(TranslatableComponent.of("worldedit.regen.regenerated")); } else { actor.printError(TranslatableComponent.of("worldedit.regen.failed")); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/AbstractDelegateExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/AbstractDelegateExtent.java index baa9c6946..d74001ed7 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/AbstractDelegateExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/AbstractDelegateExtent.java @@ -43,7 +43,9 @@ import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; + import java.util.List; + import javax.annotation.Nullable; import org.jetbrains.annotations.Range;