From df9e9e510a728ff3daa253bdfe690a204d356101 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Sat, 2 Nov 2019 12:13:42 +0100 Subject: [PATCH] Limit processing --- .../com/boydti/fawe/bukkit/FaweBukkit.java | 7 +- .../bukkit/adapter/BukkitQueueHandler.java | 2 +- .../adapter/mc1_14/BukkitGetBlocks_1_14.java | 4 +- .../adapter/mc1_14/MapChunkUtil_1_14.java | 4 +- .../adapter/mc1_14/Spigot_v1_14_R4.java | 2 +- .../sk89q/worldedit/bukkit/BukkitWorld.java | 4 +- .../bukkit/adapter/BukkitImplAdapter.java | 2 +- .../src/main/java/com/boydti/fawe/Fawe.java | 6 +- .../main/java/com/boydti/fawe/FaweAPI.java | 3 +- .../main/java/com/boydti/fawe/FaweCache.java | 1 + .../src/main/java/com/boydti/fawe/IFawe.java | 6 +- .../java/com/boydti/fawe/beta/Filter.java | 1 + .../com/boydti/fawe/beta/FilterBlockMask.java | 2 + .../main/java/com/boydti/fawe/beta/Flood.java | 2 +- .../com/boydti/fawe/beta/IBatchProcessor.java | 4 +- .../java/com/boydti/fawe/beta/IChunk.java | 7 +- .../{implementation => }/IChunkCache.java | 2 +- .../com/boydti/fawe/beta/IDelegateChunk.java | 6 +- .../com/boydti/fawe/beta/IDelegateFilter.java | 1 + .../fawe/beta/IDelegateQueueExtent.java | 4 +- .../com/boydti/fawe/beta/IQueueExtent.java | 8 +- .../{implementation => }/IQueueWrapper.java | 2 +- .../{ => blocks}/DelegateChunkSet.java | 2 +- .../{ => blocks}/FallbackChunkGet.java | 2 +- .../{ => blocks}/NullChunkGet.java | 2 +- .../{ => cache}/ChunkCache.java | 5 +- .../cache}/preloader/AsyncPreloader.java | 2 +- .../cache}/preloader/Preloader.java | 2 +- .../{holder => chunk}/ChunkHolder.java | 9 +- .../{holder => chunk}/DelegateChunk.java | 2 +- .../{holder => chunk}/FinalizedChunk.java | 2 +- .../beta/implementation/chunk/NullChunk.java | 137 ++++ .../{holder => chunk}/ReferenceChunk.java | 2 +- .../{holder => chunk}/SoftChunk.java | 2 +- .../{holder => chunk}/WeakChunk.java | 8 +- .../filter}/ArrayImageMask.java | 4 +- .../filter}/CountFilter.java | 4 +- .../filter}/DistrFilter.java | 4 +- .../filter}/ForkedFilter.java | 2 +- .../filter}/SetFilter.java | 4 +- .../filter/block}/AbstractFilterBlock.java | 2 +- .../block}/AbstractSingleFilterBlock.java | 2 +- .../filter/block}/ArrayFilterBlock.java | 5 +- .../filter/block}/CharFilterBlock.java | 8 +- .../filter/block}/ChunkFilterBlock.java | 9 +- .../filter/block}/DelegateFilter.java | 5 +- .../filter/block}/DelegateFilterBlock.java | 2 +- .../filter/block}/ExtentFilterBlock.java | 2 +- .../filter/block}/FilterBlock.java | 2 +- .../filter/block}/SimpleFilterBlock.java | 2 +- .../filter/block}/SingleFilterBlock.java | 2 +- .../block}/VectorSingleFilterBlock.java | 2 +- .../{ => packet}/ChunkPacket.java | 2 +- .../BatchProcessorHolder.java | 2 +- .../{ => processors}/ChunkSendProcessor.java | 4 +- .../{ => processors}/EmptyBatchProcessor.java | 2 +- .../IBatchProcessorHolder.java | 2 +- .../processors/LimitExtent.java | 634 ++++++++++++++++++ .../processors/LimitProcessor.java | 47 ++ .../{ => processors}/MultiBatchProcessor.java | 2 +- .../{ => processors}/NullProcessor.java | 2 +- .../{ => queue}/ParallelQueueExtent.java | 11 +- .../{ => queue}/QueueHandler.java | 4 +- .../{ => queue}/SingleThreadQueueExtent.java | 27 +- .../com/boydti/fawe/command/CFICommands.java | 3 +- .../com/boydti/fawe/jnbt/anvil/MCAFile.java | 6 +- .../fawe/jnbt/anvil/mcatest/MCATest.java | 14 + .../com/boydti/fawe/object/FaweLimit.java | 91 +++ .../cfi/HeightMapMCAGenerator.java | 17 +- .../object/clipboard/LinearClipboard.java | 2 +- .../pattern/RandomFullClipboardPattern.java | 6 +- .../fawe/object/schematic/Schematic.java | 267 -------- .../boydti/fawe/util/EditSessionBuilder.java | 13 +- .../com/boydti/fawe/util/TaskManager.java | 4 +- .../com/boydti/fawe/util/TextureUtil.java | 2 +- .../boydti/fawe/util/task/TaskBuilder.java | 2 +- .../boydti/fawe/wrappers/WorldWrapper.java | 2 +- .../worldedit/command/ClipboardCommands.java | 27 +- .../worldedit/command/RegionCommands.java | 6 +- .../com/sk89q/worldedit/entity/Player.java | 2 - .../platform/AbstractPlayerActor.java | 11 +- .../platform/PlatformCommandManager.java | 6 +- .../com/sk89q/worldedit/extent/Extent.java | 4 +- .../worldedit/extent/clipboard/Clipboard.java | 238 ++++++- .../extent/clipboard/io/ClipboardFormat.java | 7 +- .../worldedit/function/RegionFunction.java | 2 +- .../function/generator/SchemGen.java | 6 +- .../worldedit/function/mask/InverseMask.java | 1 - .../mask/InverseSingleBlockStateMask.java | 4 - .../sk89q/worldedit/function/mask/Mask.java | 2 +- .../worldedit/function/mask/MaskFilter.java | 4 +- .../function/mask/SingleBlockStateMask.java | 4 - .../worldedit/function/pattern/Pattern.java | 2 +- .../function/pattern/RandomPattern.java | 1 - .../sk89q/worldedit/regions/CuboidRegion.java | 7 +- .../worldedit/regions/CylinderRegion.java | 2 +- .../worldedit/regions/EllipsoidRegion.java | 2 +- .../com/sk89q/worldedit/regions/Region.java | 6 +- .../com/sk89q/worldedit/world/NullWorld.java | 4 +- .../java/com/sk89q/worldedit/world/World.java | 4 +- .../worldedit/world/block/BlockState.java | 1 - .../world/block/ImmutableBaseBlock.java | 1 - 102 files changed, 1339 insertions(+), 501 deletions(-) rename worldedit-core/src/main/java/com/boydti/fawe/beta/{implementation => }/IChunkCache.java (89%) rename worldedit-core/src/main/java/com/boydti/fawe/beta/{implementation => }/IQueueWrapper.java (78%) rename worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/{ => blocks}/DelegateChunkSet.java (98%) rename worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/{ => blocks}/FallbackChunkGet.java (99%) rename worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/{ => blocks}/NullChunkGet.java (97%) rename worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/{ => cache}/ChunkCache.java (95%) rename worldedit-core/src/main/java/com/boydti/fawe/beta/{ => implementation/cache}/preloader/AsyncPreloader.java (98%) rename worldedit-core/src/main/java/com/boydti/fawe/beta/{ => implementation/cache}/preloader/Preloader.java (69%) rename worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/{holder => chunk}/ChunkHolder.java (98%) rename worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/{holder => chunk}/DelegateChunk.java (90%) rename worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/{holder => chunk}/FinalizedChunk.java (93%) create mode 100644 worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/NullChunk.java rename worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/{holder => chunk}/ReferenceChunk.java (94%) rename worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/{holder => chunk}/SoftChunk.java (90%) rename worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/{holder => chunk}/WeakChunk.java (67%) rename worldedit-core/src/main/java/com/boydti/fawe/beta/{filters => implementation/filter}/ArrayImageMask.java (85%) rename worldedit-core/src/main/java/com/boydti/fawe/beta/{filters => implementation/filter}/CountFilter.java (82%) rename worldedit-core/src/main/java/com/boydti/fawe/beta/{filters => implementation/filter}/DistrFilter.java (96%) rename worldedit-core/src/main/java/com/boydti/fawe/beta/{filters => implementation/filter}/ForkedFilter.java (94%) rename worldedit-core/src/main/java/com/boydti/fawe/beta/{filters => implementation/filter}/SetFilter.java (74%) rename worldedit-core/src/main/java/com/boydti/fawe/beta/{ => implementation/filter/block}/AbstractFilterBlock.java (97%) rename worldedit-core/src/main/java/com/boydti/fawe/beta/{ => implementation/filter/block}/AbstractSingleFilterBlock.java (97%) rename worldedit-core/src/main/java/com/boydti/fawe/beta/{ => implementation/filter/block}/ArrayFilterBlock.java (95%) rename worldedit-core/src/main/java/com/boydti/fawe/beta/{ => implementation/filter/block}/CharFilterBlock.java (97%) rename worldedit-core/src/main/java/com/boydti/fawe/beta/{ => implementation/filter/block}/ChunkFilterBlock.java (72%) rename worldedit-core/src/main/java/com/boydti/fawe/beta/{ => implementation/filter/block}/DelegateFilter.java (66%) rename worldedit-core/src/main/java/com/boydti/fawe/beta/{ => implementation/filter/block}/DelegateFilterBlock.java (99%) rename worldedit-core/src/main/java/com/boydti/fawe/beta/{ => implementation/filter/block}/ExtentFilterBlock.java (93%) rename worldedit-core/src/main/java/com/boydti/fawe/beta/{ => implementation/filter/block}/FilterBlock.java (98%) rename worldedit-core/src/main/java/com/boydti/fawe/beta/{ => implementation/filter/block}/SimpleFilterBlock.java (84%) rename worldedit-core/src/main/java/com/boydti/fawe/beta/{ => implementation/filter/block}/SingleFilterBlock.java (90%) rename worldedit-core/src/main/java/com/boydti/fawe/beta/{ => implementation/filter/block}/VectorSingleFilterBlock.java (91%) rename worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/{ => packet}/ChunkPacket.java (98%) rename worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/{ => processors}/BatchProcessorHolder.java (93%) rename worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/{ => processors}/ChunkSendProcessor.java (91%) rename worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/{ => processors}/EmptyBatchProcessor.java (91%) rename worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/{ => processors}/IBatchProcessorHolder.java (95%) create mode 100644 worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/LimitExtent.java create mode 100644 worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/LimitProcessor.java rename worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/{ => processors}/MultiBatchProcessor.java (98%) rename worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/{ => processors}/NullProcessor.java (90%) rename worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/{ => queue}/ParallelQueueExtent.java (96%) rename worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/{ => queue}/QueueHandler.java (98%) rename worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/{ => queue}/SingleThreadQueueExtent.java (93%) create mode 100644 worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/mcatest/MCATest.java delete mode 100644 worldedit-core/src/main/java/com/boydti/fawe/object/schematic/Schematic.java 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 10f0f6722..e54581984 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 @@ -2,11 +2,10 @@ package com.boydti.fawe.bukkit; import com.boydti.fawe.Fawe; import com.boydti.fawe.IFawe; -import com.boydti.fawe.beta.implementation.QueueHandler; -import com.boydti.fawe.beta.preloader.AsyncPreloader; -import com.boydti.fawe.beta.preloader.Preloader; +import com.boydti.fawe.beta.implementation.queue.QueueHandler; +import com.boydti.fawe.beta.implementation.cache.preloader.AsyncPreloader; +import com.boydti.fawe.beta.implementation.cache.preloader.Preloader; import com.boydti.fawe.bukkit.adapter.BukkitQueueHandler; -import com.boydti.fawe.bukkit.adapter.mc1_14.test.TestChunkPacketSend; import com.boydti.fawe.bukkit.listener.BrushListener; import com.boydti.fawe.bukkit.listener.BukkitImageListener; import com.boydti.fawe.bukkit.listener.ChunkListener_8; diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/BukkitQueueHandler.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/BukkitQueueHandler.java index 0822b5385..f7ca9fd9c 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/BukkitQueueHandler.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/BukkitQueueHandler.java @@ -1,7 +1,7 @@ package com.boydti.fawe.bukkit.adapter; import com.boydti.fawe.Fawe; -import com.boydti.fawe.beta.implementation.QueueHandler; +import com.boydti.fawe.beta.implementation.queue.QueueHandler; import com.boydti.fawe.bukkit.listener.ChunkListener; import java.lang.reflect.Field; diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_14/BukkitGetBlocks_1_14.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_14/BukkitGetBlocks_1_14.java index 2d8342522..272d27412 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_14/BukkitGetBlocks_1_14.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_14/BukkitGetBlocks_1_14.java @@ -3,11 +3,10 @@ package com.boydti.fawe.bukkit.adapter.mc1_14; import com.boydti.fawe.Fawe; import com.boydti.fawe.FaweCache; import com.boydti.fawe.beta.IChunkSet; -import com.boydti.fawe.beta.implementation.QueueHandler; +import com.boydti.fawe.beta.implementation.queue.QueueHandler; import com.boydti.fawe.beta.implementation.blocks.CharGetBlocks; import com.boydti.fawe.bukkit.adapter.DelegateLock; import com.boydti.fawe.object.collection.AdaptedMap; -import com.boydti.fawe.object.collection.AdaptedSetCollection; import com.boydti.fawe.object.collection.BitArray4096; import com.boydti.fawe.util.ReflectionUtils; import com.google.common.collect.Iterables; @@ -22,7 +21,6 @@ import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter; import com.sk89q.worldedit.internal.Constants; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.biome.BiomeType; -import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockTypes; import net.minecraft.server.v1_14_R1.BiomeBase; import net.minecraft.server.v1_14_R1.BlockPosition; diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_14/MapChunkUtil_1_14.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_14/MapChunkUtil_1_14.java index 3448c0c76..ce5559f6c 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_14/MapChunkUtil_1_14.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_14/MapChunkUtil_1_14.java @@ -1,9 +1,7 @@ package com.boydti.fawe.bukkit.adapter.mc1_14; -import com.boydti.fawe.beta.implementation.ChunkPacket; -import com.boydti.fawe.util.ReflectionUtils; +import com.boydti.fawe.beta.implementation.packet.ChunkPacket; import com.sk89q.jnbt.CompoundTag; -import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter; import com.sk89q.worldedit.math.BlockVector3; import net.minecraft.server.v1_14_R1.NBTBase; diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_14/Spigot_v1_14_R4.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_14/Spigot_v1_14_R4.java index bbde523c5..66c0a9af9 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_14/Spigot_v1_14_R4.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_14/Spigot_v1_14_R4.java @@ -21,7 +21,7 @@ package com.boydti.fawe.bukkit.adapter.mc1_14; import com.boydti.fawe.Fawe; import com.boydti.fawe.FaweCache; -import com.boydti.fawe.beta.implementation.ChunkPacket; +import com.boydti.fawe.beta.implementation.packet.ChunkPacket; import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java index b0cdda41d..33786c3ce 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java @@ -23,7 +23,7 @@ import static com.google.common.base.Preconditions.checkNotNull; import com.boydti.fawe.Fawe; import com.boydti.fawe.beta.IChunkGet; -import com.boydti.fawe.beta.implementation.ChunkPacket; +import com.boydti.fawe.beta.implementation.packet.ChunkPacket; import com.boydti.fawe.bukkit.FaweBukkit; import com.boydti.fawe.bukkit.adapter.mc1_14.BukkitGetBlocks_1_14; import com.boydti.fawe.config.Settings; @@ -35,7 +35,6 @@ import com.sk89q.worldedit.blocks.BaseItemStack; import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter; import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.Player; -import com.sk89q.worldedit.extension.platform.PlayerProxy; import com.sk89q.worldedit.history.change.BlockChange; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; @@ -58,7 +57,6 @@ import java.util.Locale; import java.util.Map; import javax.annotation.Nullable; -import org.bukkit.Bukkit; import org.bukkit.Effect; import org.bukkit.TreeType; import org.bukkit.World; diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/BukkitImplAdapter.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/BukkitImplAdapter.java index 62c78a64d..079866df3 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/BukkitImplAdapter.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/BukkitImplAdapter.java @@ -20,7 +20,7 @@ package com.sk89q.worldedit.bukkit.adapter; import com.boydti.fawe.Fawe; -import com.boydti.fawe.beta.implementation.ChunkPacket; +import com.boydti.fawe.beta.implementation.packet.ChunkPacket; import com.boydti.fawe.bukkit.FaweBukkit; import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.Tag; 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 ea1d641f9..465e94a92 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/Fawe.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/Fawe.java @@ -1,6 +1,6 @@ package com.boydti.fawe; -import com.boydti.fawe.beta.implementation.QueueHandler; +import com.boydti.fawe.beta.implementation.queue.QueueHandler; import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.Settings; import com.boydti.fawe.object.brush.visualization.VisualQueue; @@ -16,7 +16,6 @@ import com.boydti.fawe.util.TextureUtil; import com.boydti.fawe.util.WEManager; import com.github.luben.zstd.util.Native; import com.sk89q.worldedit.WorldEdit; -import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.factory.DefaultTransformParser; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.session.request.Request; @@ -30,12 +29,9 @@ import java.lang.management.ManagementFactory; import java.lang.management.MemoryMXBean; import java.lang.management.MemoryPoolMXBean; import java.lang.management.MemoryUsage; -import java.util.Collection; import java.util.Date; import java.util.List; import java.util.Objects; -import java.util.UUID; -import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.TimeUnit; import javax.annotation.Nullable; import javax.management.InstanceAlreadyExistsException; 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 4904f6e88..62bce6fea 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/FaweAPI.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/FaweAPI.java @@ -7,7 +7,6 @@ import com.boydti.fawe.object.RegionWrapper; import com.boydti.fawe.object.changeset.DiskStorageHistory; import com.boydti.fawe.object.exception.FaweException; import com.boydti.fawe.object.extent.LightingExtent; -import com.boydti.fawe.object.schematic.Schematic; import com.boydti.fawe.regions.FaweMaskManager; import com.boydti.fawe.util.EditSessionBuilder; import com.boydti.fawe.util.MainUtil; @@ -192,7 +191,7 @@ public class FaweAPI { * @see ClipboardFormat * @see Schematic */ - public static Schematic load(File file) throws IOException { + public static Clipboard load(File file) throws IOException { return ClipboardFormats.findByFile(file).load(file); } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/FaweCache.java b/worldedit-core/src/main/java/com/boydti/fawe/FaweCache.java index d8d113b5d..ec9b19d3c 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/FaweCache.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/FaweCache.java @@ -203,6 +203,7 @@ public enum FaweCache implements Trimable { public static final FaweException LOW_MEMORY = new FaweException(BBC.WORLDEDIT_CANCEL_REASON_LOW_MEMORY); public static final FaweException MAX_ENTITIES = new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_ENTITIES); public static final FaweException MAX_TILES = new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_TILES); + public static final FaweException MAX_ITERATIONS = new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_ITERATIONS); /* thread cache 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 f10cffab2..2883a874d 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/IFawe.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/IFawe.java @@ -1,13 +1,11 @@ package com.boydti.fawe; -import com.boydti.fawe.beta.implementation.QueueHandler; -import com.boydti.fawe.beta.preloader.AsyncPreloader; -import com.boydti.fawe.beta.preloader.Preloader; +import com.boydti.fawe.beta.implementation.queue.QueueHandler; +import com.boydti.fawe.beta.implementation.cache.preloader.Preloader; import com.boydti.fawe.object.FaweCommand; import com.boydti.fawe.regions.FaweMaskManager; import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.util.image.ImageViewer; -import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.world.World; import java.io.File; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/Filter.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/Filter.java index a459a751c..a4aaf9b3f 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/Filter.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/Filter.java @@ -1,5 +1,6 @@ package com.boydti.fawe.beta; +import com.boydti.fawe.beta.implementation.filter.block.FilterBlock; import com.sk89q.worldedit.regions.Region; import javax.annotation.Nullable; import org.jetbrains.annotations.Range; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/FilterBlockMask.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/FilterBlockMask.java index 7ad53d554..7db8c83b8 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/FilterBlockMask.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/FilterBlockMask.java @@ -1,5 +1,7 @@ package com.boydti.fawe.beta; +import com.boydti.fawe.beta.implementation.filter.block.FilterBlock; + public interface FilterBlockMask { boolean applyBlock(FilterBlock block); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/Flood.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/Flood.java index 961dfba08..9143a86a2 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/Flood.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/Flood.java @@ -1,7 +1,7 @@ package com.boydti.fawe.beta; import com.boydti.fawe.Fawe; -import com.boydti.fawe.beta.implementation.QueueHandler; +import com.boydti.fawe.beta.implementation.queue.QueueHandler; import com.boydti.fawe.util.MathMan; import com.sk89q.worldedit.util.Direction; import com.sk89q.worldedit.world.World; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/IBatchProcessor.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/IBatchProcessor.java index 97898fb85..1dfacbb24 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/IBatchProcessor.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/IBatchProcessor.java @@ -1,8 +1,8 @@ package com.boydti.fawe.beta; import com.boydti.fawe.FaweCache; -import com.boydti.fawe.beta.implementation.EmptyBatchProcessor; -import com.boydti.fawe.beta.implementation.MultiBatchProcessor; +import com.boydti.fawe.beta.implementation.processors.EmptyBatchProcessor; +import com.boydti.fawe.beta.implementation.processors.MultiBatchProcessor; import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector3; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunk.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunk.java index 3894a0c9f..74298b190 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunk.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunk.java @@ -1,5 +1,6 @@ package com.boydti.fawe.beta; +import com.boydti.fawe.beta.implementation.filter.block.ChunkFilterBlock; import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.world.biome.BiomeType; @@ -27,12 +28,6 @@ public interface IChunk> extends Trimable, Callable, IChu */ void init(IQueueExtent extent, int x, int z); - /** - * Get the queue - * @return - */ - IQueueExtent getQueue(); - /** * Get chunkX * @return diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/IChunkCache.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunkCache.java similarity index 89% rename from worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/IChunkCache.java rename to worldedit-core/src/main/java/com/boydti/fawe/beta/IChunkCache.java index 7724e74ef..480db7063 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/IChunkCache.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunkCache.java @@ -1,4 +1,4 @@ -package com.boydti.fawe.beta.implementation; +package com.boydti.fawe.beta; import com.boydti.fawe.beta.Trimable; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/IDelegateChunk.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/IDelegateChunk.java index eb0b7b742..74c36d532 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/IDelegateChunk.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/IDelegateChunk.java @@ -1,5 +1,6 @@ package com.boydti.fawe.beta; +import com.boydti.fawe.beta.implementation.filter.block.ChunkFilterBlock; import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.Region; @@ -38,11 +39,6 @@ public interface IDelegateChunk extends IChunk { return getParent().call(set, finalize); } - @Override - default IQueueExtent getQueue() { - return getParent().getQueue(); - } - @Override default CompoundTag getTag(int x, int y, int z) { return getParent().getTag(x, y, z); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/IDelegateFilter.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/IDelegateFilter.java index 89736bb90..6149266df 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/IDelegateFilter.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/IDelegateFilter.java @@ -1,5 +1,6 @@ package com.boydti.fawe.beta; +import com.boydti.fawe.beta.implementation.filter.block.FilterBlock; import com.sk89q.worldedit.regions.Region; import javax.annotation.Nullable; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/IDelegateQueueExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/IDelegateQueueExtent.java index bd0cfc147..2b87445b0 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/IDelegateQueueExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/IDelegateQueueExtent.java @@ -1,13 +1,11 @@ package com.boydti.fawe.beta; -import com.boydti.fawe.beta.implementation.IChunkCache; -import com.boydti.fawe.beta.implementation.MultiBatchProcessor; +import com.boydti.fawe.beta.implementation.filter.block.ChunkFilterBlock; import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.Entity; -import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; import com.sk89q.worldedit.function.generator.GenBase; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/IQueueExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/IQueueExtent.java index 27cb8d558..219b37ff2 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/IQueueExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/IQueueExtent.java @@ -1,12 +1,10 @@ package com.boydti.fawe.beta; import com.boydti.fawe.FaweCache; -import com.boydti.fawe.beta.implementation.IBatchProcessorHolder; -import com.boydti.fawe.beta.implementation.IChunkCache; -import com.boydti.fawe.beta.implementation.MultiBatchProcessor; +import com.boydti.fawe.beta.implementation.filter.block.ChunkFilterBlock; +import com.boydti.fawe.beta.implementation.processors.IBatchProcessorHolder; import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.WorldEditException; -import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.operation.Operation; import com.sk89q.worldedit.math.BlockVector2; @@ -19,8 +17,6 @@ import com.sk89q.worldedit.world.block.BlockStateHolder; import javax.annotation.Nullable; import java.io.Flushable; -import java.util.Iterator; -import java.util.List; import java.util.Set; import java.util.concurrent.Future; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/IQueueWrapper.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/IQueueWrapper.java similarity index 78% rename from worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/IQueueWrapper.java rename to worldedit-core/src/main/java/com/boydti/fawe/beta/IQueueWrapper.java index 8c4957ce2..fe9ab65a2 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/IQueueWrapper.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/IQueueWrapper.java @@ -1,4 +1,4 @@ -package com.boydti.fawe.beta.implementation; +package com.boydti.fawe.beta; import com.boydti.fawe.beta.IQueueExtent; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/DelegateChunkSet.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/DelegateChunkSet.java similarity index 98% rename from worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/DelegateChunkSet.java rename to worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/DelegateChunkSet.java index 94e202072..e288ebd9c 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/DelegateChunkSet.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/DelegateChunkSet.java @@ -1,4 +1,4 @@ -package com.boydti.fawe.beta.implementation; +package com.boydti.fawe.beta.implementation.blocks; import com.boydti.fawe.beta.IChunkSet; import com.sk89q.jnbt.CompoundTag; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/FallbackChunkGet.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/FallbackChunkGet.java similarity index 99% rename from worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/FallbackChunkGet.java rename to worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/FallbackChunkGet.java index 7579bb5de..8cc1b5b9c 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/FallbackChunkGet.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/FallbackChunkGet.java @@ -1,4 +1,4 @@ -package com.boydti.fawe.beta.implementation; +package com.boydti.fawe.beta.implementation.blocks; import com.boydti.fawe.FaweCache; import com.boydti.fawe.beta.IBlocks; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/NullChunkGet.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/NullChunkGet.java similarity index 97% rename from worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/NullChunkGet.java rename to worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/NullChunkGet.java index 9bf8bc6a3..b6996623a 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/NullChunkGet.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/NullChunkGet.java @@ -1,4 +1,4 @@ -package com.boydti.fawe.beta.implementation; +package com.boydti.fawe.beta.implementation.blocks; import com.boydti.fawe.FaweCache; import com.boydti.fawe.beta.IBlocks; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/ChunkCache.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/cache/ChunkCache.java similarity index 95% rename from worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/ChunkCache.java rename to worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/cache/ChunkCache.java index 00b5ff35b..b83f6cade 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/ChunkCache.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/cache/ChunkCache.java @@ -1,9 +1,8 @@ -package com.boydti.fawe.beta.implementation; +package com.boydti.fawe.beta.implementation.cache; -import com.boydti.fawe.beta.IChunkGet; +import com.boydti.fawe.beta.IChunkCache; import com.boydti.fawe.beta.Trimable; import com.boydti.fawe.util.MathMan; -import com.sk89q.worldedit.world.World; import it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap; import it.unimi.dsi.fastutil.longs.Long2ObjectMap; import it.unimi.dsi.fastutil.objects.ObjectIterator; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/preloader/AsyncPreloader.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/cache/preloader/AsyncPreloader.java similarity index 98% rename from worldedit-core/src/main/java/com/boydti/fawe/beta/preloader/AsyncPreloader.java rename to worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/cache/preloader/AsyncPreloader.java index 99b955074..14933971a 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/preloader/AsyncPreloader.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/cache/preloader/AsyncPreloader.java @@ -1,4 +1,4 @@ -package com.boydti.fawe.beta.preloader; +package com.boydti.fawe.beta.implementation.cache.preloader; import com.boydti.fawe.Fawe; import com.boydti.fawe.object.collection.MutablePair; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/preloader/Preloader.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/cache/preloader/Preloader.java similarity index 69% rename from worldedit-core/src/main/java/com/boydti/fawe/beta/preloader/Preloader.java rename to worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/cache/preloader/Preloader.java index e24a974f9..db32604be 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/preloader/Preloader.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/cache/preloader/Preloader.java @@ -1,4 +1,4 @@ -package com.boydti.fawe.beta.preloader; +package com.boydti.fawe.beta.implementation.cache.preloader; import com.sk89q.worldedit.entity.Player; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/ChunkHolder.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/ChunkHolder.java similarity index 98% rename from worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/ChunkHolder.java rename to worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/ChunkHolder.java index d17cff999..91db98cc0 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/ChunkHolder.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/ChunkHolder.java @@ -1,7 +1,7 @@ -package com.boydti.fawe.beta.implementation.holder; +package com.boydti.fawe.beta.implementation.chunk; import com.boydti.fawe.FaweCache; -import com.boydti.fawe.beta.ChunkFilterBlock; +import com.boydti.fawe.beta.implementation.filter.block.ChunkFilterBlock; import com.boydti.fawe.beta.Filter; import com.boydti.fawe.beta.FilterBlockMask; import com.boydti.fawe.beta.Flood; @@ -59,11 +59,6 @@ public class ChunkHolder> implements IChunk { return delegate; } - @Override - public IQueueExtent getQueue() { - return extent; - } - @Override public boolean setTile(int x, int y, int z, CompoundTag tag) { return false; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/DelegateChunk.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/DelegateChunk.java similarity index 90% rename from worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/DelegateChunk.java rename to worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/DelegateChunk.java index c5f17ba16..7cc7bfb01 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/DelegateChunk.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/DelegateChunk.java @@ -1,4 +1,4 @@ -package com.boydti.fawe.beta.implementation.holder; +package com.boydti.fawe.beta.implementation.chunk; import com.boydti.fawe.beta.IChunk; import com.boydti.fawe.beta.IDelegateChunk; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/FinalizedChunk.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/FinalizedChunk.java similarity index 93% rename from worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/FinalizedChunk.java rename to worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/FinalizedChunk.java index cc0d59fdb..539923000 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/FinalizedChunk.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/FinalizedChunk.java @@ -1,4 +1,4 @@ -package com.boydti.fawe.beta.implementation.holder; +package com.boydti.fawe.beta.implementation.chunk; import com.boydti.fawe.beta.IChunk; import com.boydti.fawe.beta.IQueueExtent; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/NullChunk.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/NullChunk.java new file mode 100644 index 000000000..c93d0b43b --- /dev/null +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/NullChunk.java @@ -0,0 +1,137 @@ +package com.boydti.fawe.beta.implementation.chunk; + +import com.boydti.fawe.beta.implementation.filter.block.ChunkFilterBlock; +import com.boydti.fawe.beta.Filter; +import com.boydti.fawe.beta.FilterBlockMask; +import com.boydti.fawe.beta.Flood; +import com.boydti.fawe.beta.IChunk; +import com.boydti.fawe.beta.IChunkSet; +import com.boydti.fawe.beta.IQueueExtent; +import com.sk89q.jnbt.CompoundTag; +import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.regions.Region; +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 com.sk89q.worldedit.world.block.BlockTypes; + +import javax.annotation.Nullable; +import java.util.Collections; +import java.util.Map; +import java.util.Set; +import java.util.UUID; +import java.util.concurrent.Future; + +public enum NullChunk implements IChunk { + INSTANCE; + + @Override + public void init(IQueueExtent extent, int x, int z) {} + + @Override + public int getX() { + return 0; + } + + @Override + public int getZ() { + return 0; + } + + @Override + public boolean isEmpty() { + return true; + } + + @Override + public Future call() { + return null; + } + + @Override + public void filterBlocks(Filter filter, ChunkFilterBlock block, @Nullable Region region) { + + } + + @Override + public void flood(Flood flood, FilterBlockMask mask, ChunkFilterBlock block) { + + } + + @Override + public boolean setBiome(int x, int y, int z, BiomeType biome) { + return false; + } + + @Override + public boolean setTile(int x, int y, int z, CompoundTag tag) { + return false; + } + + @Override + public boolean setBlock(int x, int y, int z, BlockStateHolder block) { + return false; + } + + @Override + public BiomeType getBiomeType(int x, int z) { + return null; + } + + @Override + public boolean hasSection(int layer) { + return false; + } + + @Override + public char[] getArray(int layer) { + return null; + } + + @Override + public BlockState getBlock(int x, int y, int z) { + return BlockTypes.__RESERVED__.getDefaultState(); + } + + @Override + public BaseBlock getFullBlock(int x, int y, int z) { + return BlockTypes.__RESERVED__.getDefaultState().toBaseBlock(); + } + + @Override + public CompoundTag getTag(int x, int y, int z) { + return null; + } + + @Override + public Map getTiles() { + return Collections.emptyMap(); + } + + @Override + public Set getEntities() { + return Collections.emptySet(); + } + + @Override + public char[] load(int layer) { + return null; + } + + @Override + public CompoundTag getEntity(UUID uuid) { + return null; + } + + @Override + public Future call(IChunkSet set, Runnable finalize) { + return null; + } + + @Override + public boolean trim(boolean aggressive) { + return true; + } +} + diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/ReferenceChunk.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/ReferenceChunk.java similarity index 94% rename from worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/ReferenceChunk.java rename to worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/ReferenceChunk.java index 4e5c799c8..4c8190066 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/ReferenceChunk.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/ReferenceChunk.java @@ -1,4 +1,4 @@ -package com.boydti.fawe.beta.implementation.holder; +package com.boydti.fawe.beta.implementation.chunk; import com.boydti.fawe.beta.IChunk; import com.boydti.fawe.beta.IDelegateChunk; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/SoftChunk.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/SoftChunk.java similarity index 90% rename from worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/SoftChunk.java rename to worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/SoftChunk.java index 29ea78386..ee69d6452 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/SoftChunk.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/SoftChunk.java @@ -1,4 +1,4 @@ -package com.boydti.fawe.beta.implementation.holder; +package com.boydti.fawe.beta.implementation.chunk; import com.boydti.fawe.beta.IChunk; import com.boydti.fawe.beta.IQueueExtent; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/WeakChunk.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/WeakChunk.java similarity index 67% rename from worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/WeakChunk.java rename to worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/WeakChunk.java index a2c43733d..6b7d24561 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/holder/WeakChunk.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/WeakChunk.java @@ -1,16 +1,10 @@ -package com.boydti.fawe.beta.implementation.holder; +package com.boydti.fawe.beta.implementation.chunk; import com.boydti.fawe.beta.IChunk; import com.boydti.fawe.beta.IQueueExtent; -import com.sk89q.jnbt.CompoundTag; -import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.world.biome.BiomeType; import java.lang.ref.Reference; import java.lang.ref.WeakReference; -import java.util.Map; -import java.util.Set; -import java.util.UUID; /** * A {@link ReferenceChunk} using {@link WeakReference} to hold the chunk. diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/filters/ArrayImageMask.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/ArrayImageMask.java similarity index 85% rename from worldedit-core/src/main/java/com/boydti/fawe/beta/filters/ArrayImageMask.java rename to worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/ArrayImageMask.java index bc8bb0f46..e47b25a27 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/filters/ArrayImageMask.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/ArrayImageMask.java @@ -1,6 +1,6 @@ -package com.boydti.fawe.beta.filters; +package com.boydti.fawe.beta.implementation.filter; -import com.boydti.fawe.beta.FilterBlock; +import com.boydti.fawe.beta.implementation.filter.block.FilterBlock; import com.boydti.fawe.beta.FilterBlockMask; import java.awt.image.BufferedImage; import java.util.concurrent.ThreadLocalRandom; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/filters/CountFilter.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/CountFilter.java similarity index 82% rename from worldedit-core/src/main/java/com/boydti/fawe/beta/filters/CountFilter.java rename to worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/CountFilter.java index 111502781..fa16fee03 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/filters/CountFilter.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/CountFilter.java @@ -1,6 +1,6 @@ -package com.boydti.fawe.beta.filters; +package com.boydti.fawe.beta.implementation.filter; -import com.boydti.fawe.beta.FilterBlock; +import com.boydti.fawe.beta.implementation.filter.block.FilterBlock; public class CountFilter extends ForkedFilter { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/filters/DistrFilter.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/DistrFilter.java similarity index 96% rename from worldedit-core/src/main/java/com/boydti/fawe/beta/filters/DistrFilter.java rename to worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/DistrFilter.java index 91ddf73e2..82d169b4c 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/filters/DistrFilter.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/DistrFilter.java @@ -1,6 +1,6 @@ -package com.boydti.fawe.beta.filters; +package com.boydti.fawe.beta.implementation.filter; -import com.boydti.fawe.beta.FilterBlock; +import com.boydti.fawe.beta.implementation.filter.block.FilterBlock; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.function.mask.ABlockMask; import com.sk89q.worldedit.util.Countable; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/filters/ForkedFilter.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/ForkedFilter.java similarity index 94% rename from worldedit-core/src/main/java/com/boydti/fawe/beta/filters/ForkedFilter.java rename to worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/ForkedFilter.java index 64827ffd0..dc2e33f7c 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/filters/ForkedFilter.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/ForkedFilter.java @@ -1,4 +1,4 @@ -package com.boydti.fawe.beta.filters; +package com.boydti.fawe.beta.implementation.filter; import com.boydti.fawe.beta.Filter; import java.util.Map; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/filters/SetFilter.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/SetFilter.java similarity index 74% rename from worldedit-core/src/main/java/com/boydti/fawe/beta/filters/SetFilter.java rename to worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/SetFilter.java index 0ba970ea5..153313469 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/filters/SetFilter.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/SetFilter.java @@ -1,7 +1,7 @@ -package com.boydti.fawe.beta.filters; +package com.boydti.fawe.beta.implementation.filter; import com.boydti.fawe.beta.Filter; -import com.boydti.fawe.beta.FilterBlock; +import com.boydti.fawe.beta.implementation.filter.block.FilterBlock; import com.sk89q.worldedit.world.block.BlockState; public class SetFilter implements Filter { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/AbstractFilterBlock.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/AbstractFilterBlock.java similarity index 97% rename from worldedit-core/src/main/java/com/boydti/fawe/beta/AbstractFilterBlock.java rename to worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/AbstractFilterBlock.java index 2f544a47d..0a40471b6 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/AbstractFilterBlock.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/AbstractFilterBlock.java @@ -1,4 +1,4 @@ -package com.boydti.fawe.beta; +package com.boydti.fawe.beta.implementation.filter.block; import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.WorldEditException; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/AbstractSingleFilterBlock.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/AbstractSingleFilterBlock.java similarity index 97% rename from worldedit-core/src/main/java/com/boydti/fawe/beta/AbstractSingleFilterBlock.java rename to worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/AbstractSingleFilterBlock.java index 171cda55a..45c972b6b 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/AbstractSingleFilterBlock.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/AbstractSingleFilterBlock.java @@ -1,4 +1,4 @@ -package com.boydti.fawe.beta; +package com.boydti.fawe.beta.implementation.filter.block; import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.WorldEditException; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/ArrayFilterBlock.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/ArrayFilterBlock.java similarity index 95% rename from worldedit-core/src/main/java/com/boydti/fawe/beta/ArrayFilterBlock.java rename to worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/ArrayFilterBlock.java index 3fd3c0a07..ad7ca5da0 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/ArrayFilterBlock.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/ArrayFilterBlock.java @@ -1,10 +1,9 @@ -package com.boydti.fawe.beta; +package com.boydti.fawe.beta.implementation.filter.block; +import com.boydti.fawe.beta.Filter; import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.Extent; -import com.sk89q.worldedit.math.BlockVector2; -import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/CharFilterBlock.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/CharFilterBlock.java similarity index 97% rename from worldedit-core/src/main/java/com/boydti/fawe/beta/CharFilterBlock.java rename to worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/CharFilterBlock.java index eeabb1713..d010ad3d9 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/CharFilterBlock.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/CharFilterBlock.java @@ -1,7 +1,13 @@ -package com.boydti.fawe.beta; +package com.boydti.fawe.beta.implementation.filter.block; import static com.sk89q.worldedit.world.block.BlockTypes.states; +import com.boydti.fawe.beta.Filter; +import com.boydti.fawe.beta.FilterBlockMask; +import com.boydti.fawe.beta.Flood; +import com.boydti.fawe.beta.IChunkGet; +import com.boydti.fawe.beta.IChunkSet; +import com.boydti.fawe.beta.IQueueExtent; import com.boydti.fawe.beta.implementation.blocks.CharGetBlocks; import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.WorldEditException; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/ChunkFilterBlock.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/ChunkFilterBlock.java similarity index 72% rename from worldedit-core/src/main/java/com/boydti/fawe/beta/ChunkFilterBlock.java rename to worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/ChunkFilterBlock.java index d87a536f5..a254b7f2f 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/ChunkFilterBlock.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/ChunkFilterBlock.java @@ -1,5 +1,10 @@ -package com.boydti.fawe.beta; +package com.boydti.fawe.beta.implementation.filter.block; +import com.boydti.fawe.beta.Filter; +import com.boydti.fawe.beta.FilterBlockMask; +import com.boydti.fawe.beta.Flood; +import com.boydti.fawe.beta.IChunkGet; +import com.boydti.fawe.beta.IChunkSet; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.regions.Region; @@ -15,7 +20,7 @@ public abstract class ChunkFilterBlock extends SimpleFilterBlock { int layer); public abstract void flood(IChunkGet iget, IChunkSet iset, int layer, - Flood flood, FilterBlockMask mask); + Flood flood, FilterBlockMask mask); public abstract void filter(Filter filter, int x, int y, int z); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/DelegateFilter.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/DelegateFilter.java similarity index 66% rename from worldedit-core/src/main/java/com/boydti/fawe/beta/DelegateFilter.java rename to worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/DelegateFilter.java index 21dbd8291..f51d85b3f 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/DelegateFilter.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/DelegateFilter.java @@ -1,4 +1,7 @@ -package com.boydti.fawe.beta; +package com.boydti.fawe.beta.implementation.filter.block; + +import com.boydti.fawe.beta.Filter; +import com.boydti.fawe.beta.IDelegateFilter; public abstract class DelegateFilter implements IDelegateFilter { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/DelegateFilterBlock.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/DelegateFilterBlock.java similarity index 99% rename from worldedit-core/src/main/java/com/boydti/fawe/beta/DelegateFilterBlock.java rename to worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/DelegateFilterBlock.java index 61a0d6b4b..1e5985aa8 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/DelegateFilterBlock.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/DelegateFilterBlock.java @@ -1,4 +1,4 @@ -package com.boydti.fawe.beta; +package com.boydti.fawe.beta.implementation.filter.block; import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.MaxChangedBlocksException; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/ExtentFilterBlock.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/ExtentFilterBlock.java similarity index 93% rename from worldedit-core/src/main/java/com/boydti/fawe/beta/ExtentFilterBlock.java rename to worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/ExtentFilterBlock.java index b5cb81c07..4397f94dd 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/ExtentFilterBlock.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/ExtentFilterBlock.java @@ -1,4 +1,4 @@ -package com.boydti.fawe.beta; +package com.boydti.fawe.beta.implementation.filter.block; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector3; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/FilterBlock.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/FilterBlock.java similarity index 98% rename from worldedit-core/src/main/java/com/boydti/fawe/beta/FilterBlock.java rename to worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/FilterBlock.java index 36a4a04d9..c432a233c 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/FilterBlock.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/FilterBlock.java @@ -1,4 +1,4 @@ -package com.boydti.fawe.beta; +package com.boydti.fawe.beta.implementation.filter.block; import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.StringTag; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/SimpleFilterBlock.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/SimpleFilterBlock.java similarity index 84% rename from worldedit-core/src/main/java/com/boydti/fawe/beta/SimpleFilterBlock.java rename to worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/SimpleFilterBlock.java index 27cc60afd..a709f337a 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/SimpleFilterBlock.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/SimpleFilterBlock.java @@ -1,4 +1,4 @@ -package com.boydti.fawe.beta; +package com.boydti.fawe.beta.implementation.filter.block; import com.sk89q.worldedit.extent.Extent; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/SingleFilterBlock.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/SingleFilterBlock.java similarity index 90% rename from worldedit-core/src/main/java/com/boydti/fawe/beta/SingleFilterBlock.java rename to worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/SingleFilterBlock.java index 225aa3453..4c2e41244 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/SingleFilterBlock.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/SingleFilterBlock.java @@ -1,4 +1,4 @@ -package com.boydti.fawe.beta; +package com.boydti.fawe.beta.implementation.filter.block; import com.sk89q.worldedit.world.block.BaseBlock; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/VectorSingleFilterBlock.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/VectorSingleFilterBlock.java similarity index 91% rename from worldedit-core/src/main/java/com/boydti/fawe/beta/VectorSingleFilterBlock.java rename to worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/VectorSingleFilterBlock.java index 0e293ebf9..c96d714cc 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/VectorSingleFilterBlock.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/block/VectorSingleFilterBlock.java @@ -1,4 +1,4 @@ -package com.boydti.fawe.beta; +package com.boydti.fawe.beta.implementation.filter.block; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BaseBlock; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/ChunkPacket.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/packet/ChunkPacket.java similarity index 98% rename from worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/ChunkPacket.java rename to worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/packet/ChunkPacket.java index 7da7f129b..822b18a84 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/ChunkPacket.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/packet/ChunkPacket.java @@ -1,4 +1,4 @@ -package com.boydti.fawe.beta.implementation; +package com.boydti.fawe.beta.implementation.packet; import com.boydti.fawe.FaweCache; import com.boydti.fawe.beta.IBlocks; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/BatchProcessorHolder.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/BatchProcessorHolder.java similarity index 93% rename from worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/BatchProcessorHolder.java rename to worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/BatchProcessorHolder.java index e5469d224..07488154b 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/BatchProcessorHolder.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/BatchProcessorHolder.java @@ -1,4 +1,4 @@ -package com.boydti.fawe.beta.implementation; +package com.boydti.fawe.beta.implementation.processors; import com.boydti.fawe.beta.IBatchProcessor; import com.boydti.fawe.beta.IChunk; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/ChunkSendProcessor.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/ChunkSendProcessor.java similarity index 91% rename from worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/ChunkSendProcessor.java rename to worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/ChunkSendProcessor.java index aaf87a179..3aac986cb 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/ChunkSendProcessor.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/ChunkSendProcessor.java @@ -1,10 +1,10 @@ -package com.boydti.fawe.beta.implementation; +package com.boydti.fawe.beta.implementation.processors; import com.boydti.fawe.beta.IBatchProcessor; import com.boydti.fawe.beta.IChunk; import com.boydti.fawe.beta.IChunkGet; import com.boydti.fawe.beta.IChunkSet; -import com.google.common.base.Suppliers; +import com.boydti.fawe.beta.implementation.packet.ChunkPacket; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.world.World; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/EmptyBatchProcessor.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/EmptyBatchProcessor.java similarity index 91% rename from worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/EmptyBatchProcessor.java rename to worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/EmptyBatchProcessor.java index 297b50cfa..c68eadb5e 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/EmptyBatchProcessor.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/EmptyBatchProcessor.java @@ -1,4 +1,4 @@ -package com.boydti.fawe.beta.implementation; +package com.boydti.fawe.beta.implementation.processors; import com.boydti.fawe.beta.IBatchProcessor; import com.boydti.fawe.beta.IChunk; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/IBatchProcessorHolder.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/IBatchProcessorHolder.java similarity index 95% rename from worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/IBatchProcessorHolder.java rename to worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/IBatchProcessorHolder.java index 6712c5ec4..1a2770cd4 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/IBatchProcessorHolder.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/IBatchProcessorHolder.java @@ -1,4 +1,4 @@ -package com.boydti.fawe.beta.implementation; +package com.boydti.fawe.beta.implementation.processors; import com.boydti.fawe.beta.IBatchProcessor; import com.boydti.fawe.beta.IChunk; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/LimitExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/LimitExtent.java new file mode 100644 index 000000000..d7ec08ec5 --- /dev/null +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/LimitExtent.java @@ -0,0 +1,634 @@ +package com.boydti.fawe.beta.implementation.processors; + +import com.boydti.fawe.FaweCache; +import com.boydti.fawe.beta.Filter; +import com.boydti.fawe.beta.IBatchProcessor; +import com.boydti.fawe.beta.implementation.filter.block.ExtentFilterBlock; +import com.boydti.fawe.object.FaweLimit; +import com.boydti.fawe.object.changeset.FaweChangeSet; +import com.boydti.fawe.object.exception.FaweException; +import com.sk89q.jnbt.CompoundTag; +import com.sk89q.worldedit.MaxChangedBlocksException; +import com.sk89q.worldedit.WorldEditException; +import com.sk89q.worldedit.entity.BaseEntity; +import com.sk89q.worldedit.entity.Entity; +import com.sk89q.worldedit.extent.Extent; +import com.sk89q.worldedit.extent.PassthroughExtent; +import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; +import com.sk89q.worldedit.function.generator.GenBase; +import com.sk89q.worldedit.function.generator.Resource; +import com.sk89q.worldedit.function.mask.Mask; +import com.sk89q.worldedit.function.operation.Operation; +import com.sk89q.worldedit.function.pattern.Pattern; +import com.sk89q.worldedit.math.BlockVector2; +import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.regions.Region; +import com.sk89q.worldedit.session.ClipboardHolder; +import com.sk89q.worldedit.util.Countable; +import com.sk89q.worldedit.util.Location; +import com.sk89q.worldedit.world.biome.BiomeType; +import com.sk89q.worldedit.world.biome.BiomeTypes; +import com.sk89q.worldedit.world.block.BaseBlock; +import com.sk89q.worldedit.world.block.BlockState; +import com.sk89q.worldedit.world.block.BlockStateHolder; +import com.sk89q.worldedit.world.block.BlockType; +import com.sk89q.worldedit.world.block.BlockTypes; + +import javax.annotation.Nullable; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Set; +import java.util.UUID; + +public class LimitExtent extends PassthroughExtent { + private final FaweLimit limit; + + /** + * Create a new instance. + * + * @param extent the extent + */ + public LimitExtent(Extent extent, FaweLimit limit) { + super(extent); + this.limit = limit; + } + + public List getEntities(Region region) { + limit.THROW_MAX_CHECKS(region.getArea()); + try { + return getExtent().getEntities(region); + } catch (FaweException e) { + if (!limit.MAX_FAILS()) { + throw e; + } + return Collections.emptyList(); + } + } + + public List getEntities() { + limit.THROW_MAX_CHECKS(); + try { + return getExtent().getEntities(); + } catch (FaweException e) { + if (!limit.MAX_FAILS()) { + throw e; + } + return Collections.emptyList(); + } + } + + @Nullable + public Entity createEntity(Location location, BaseEntity entity) { + limit.THROW_MAX_CHANGES(); + limit.THROW_MAX_ENTITIES(); + try { + return getExtent().createEntity(location, entity); + } catch (FaweException e) { + if (!limit.MAX_FAILS()) { + throw e; + } + return null; + } + } + + @Override + @Nullable + public void removeEntity(int x, int y, int z, UUID uuid) { + limit.THROW_MAX_CHANGES(); + limit.THROW_MAX_ENTITIES(); + try { + getExtent().removeEntity(x, y, z, uuid); + } catch (FaweException e) { + if (!limit.MAX_FAILS()) { + throw e; + } + } + } + + @Override + public boolean regenerateChunk(int x, int z, @Nullable BiomeType type, @Nullable Long seed) { + limit.THROW_MAX_CHANGES(Character.MAX_VALUE); + try { + return getExtent().regenerateChunk(x, z, type, seed); + } catch (FaweException e) { + if (!limit.MAX_FAILS()) { + throw e; + } + return false; + } + } + + @Override + public int getHighestTerrainBlock(int x, int z, int minY, int maxY) { + limit.THROW_MAX_CHECKS(FaweCache.IMP.WORLD_HEIGHT); + try { + return getExtent().getHighestTerrainBlock(x, z, minY, maxY); + } catch (FaweException e) { + if (!limit.MAX_FAILS()) { + throw e; + } + return 0; + } + } + + @Override + public int getHighestTerrainBlock(int x, int z, int minY, int maxY, Mask filter) { + limit.THROW_MAX_CHECKS(FaweCache.IMP.WORLD_HEIGHT); + try { + return getExtent().getHighestTerrainBlock(x, z, minY, maxY, filter); + } catch (FaweException e) { + if (!limit.MAX_FAILS()) { + throw e; + } + return 0; + } + } + + @Override + public int getNearestSurfaceLayer(int x, int z, int y, int minY, int maxY) { + limit.THROW_MAX_CHECKS(FaweCache.IMP.WORLD_HEIGHT); + try { + return getExtent().getNearestSurfaceLayer(x, z, y, minY, maxY); + } catch (FaweException e) { + if (!limit.MAX_FAILS()) { + throw e; + } + return 0; + } + } + + @Override + public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, boolean ignoreAir) { + limit.THROW_MAX_CHECKS(FaweCache.IMP.WORLD_HEIGHT); + try { + return getExtent().getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, ignoreAir); + } catch (FaweException e) { + if (!limit.MAX_FAILS()) { + throw e; + } + return 0; + } + } + + @Override + public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY) { + limit.THROW_MAX_CHECKS(FaweCache.IMP.WORLD_HEIGHT); + try { + return getExtent().getNearestSurfaceTerrainBlock(x, z, y, minY, maxY); + } catch (FaweException e) { + if (!limit.MAX_FAILS()) { + throw e; + } + return 0; + } + } + + @Override + public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax) { + limit.THROW_MAX_CHECKS(FaweCache.IMP.WORLD_HEIGHT); + try { + return getExtent().getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax); + } catch (FaweException e) { + if (!limit.MAX_FAILS()) { + throw e; + } + return 0; + } + } + + @Override + public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax, Mask mask) { + limit.THROW_MAX_CHECKS(FaweCache.IMP.WORLD_HEIGHT); + try { + return getExtent().getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax, mask); + } catch (FaweException e) { + if (!limit.MAX_FAILS()) { + throw e; + } + return 0; + } + } + + @Override + public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax, boolean ignoreAir) { + limit.THROW_MAX_CHECKS(FaweCache.IMP.WORLD_HEIGHT); + try { + return getExtent().getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax, ignoreAir); + } catch (FaweException e) { + if (!limit.MAX_FAILS()) { + throw e; + } + return 0; + } + } + + @Override + public void addCaves(Region region) throws WorldEditException { + limit.THROW_MAX_CHECKS(region.getArea()); + limit.THROW_MAX_CHANGES(region.getArea()); + try { + getExtent().addCaves(region); + } catch (FaweException e) { + if (!limit.MAX_FAILS()) { + throw e; + } + } + } + + @Override + public void generate(Region region, GenBase gen) throws WorldEditException { + limit.THROW_MAX_CHECKS(region.getArea()); + limit.THROW_MAX_CHANGES(region.getArea()); + try { + getExtent().generate(region, gen); + } catch (FaweException e) { + if (!limit.MAX_FAILS()) { + throw e; + } + } + } + + @Override + public void addSchems(Region region, Mask mask, List clipboards, int rarity, boolean rotate) throws WorldEditException { + limit.THROW_MAX_CHECKS(region.getArea()); + limit.THROW_MAX_CHANGES(region.getArea()); + try { + getExtent().addSchems(region, mask, clipboards, rarity, rotate); + } catch (FaweException e) { + if (!limit.MAX_FAILS()) { + throw e; + } + } + } + + @Override + public void spawnResource(Region region, Resource gen, int rarity, int frequency) throws WorldEditException { + limit.THROW_MAX_CHECKS(region.getArea()); + limit.THROW_MAX_CHANGES(region.getArea()); + try { + getExtent().spawnResource(region, gen, rarity, frequency); + } catch (FaweException e) { + if (!limit.MAX_FAILS()) { + throw e; + } + } + } + + @Override + public void addOre(Region region, Mask mask, Pattern material, int size, int frequency, int rarity, int minY, int maxY) throws WorldEditException { + limit.THROW_MAX_CHECKS(region.getArea()); + limit.THROW_MAX_CHANGES(region.getArea()); + try { + getExtent().addOre(region, mask, material, size, frequency, rarity, minY, maxY); + } catch (FaweException e) { + if (!limit.MAX_FAILS()) { + throw e; + } + } + } + + @Override + public void addOres(Region region, Mask mask) throws WorldEditException { + limit.THROW_MAX_CHECKS(region.getArea()); + limit.THROW_MAX_CHANGES(region.getArea()); + try { + getExtent().addOres(region, mask); + } catch (FaweException e) { + if (!limit.MAX_FAILS()) { + throw e; + } + } + } + + @Override + public List> getBlockDistribution(Region region) { + limit.THROW_MAX_CHECKS(region.getArea()); + try { + return getExtent().getBlockDistribution(region); + } catch (FaweException e) { + if (!limit.MAX_FAILS()) { + throw e; + } + return Collections.emptyList(); + } + } + + @Override + public List> getBlockDistributionWithData(Region region) { + limit.THROW_MAX_CHECKS(region.getArea()); + try { + return getExtent().getBlockDistributionWithData(region); + } catch (FaweException e) { + if (!limit.MAX_FAILS()) { + throw e; + } + return Collections.emptyList(); + } + } + + @Override + public int countBlocks(Region region, Set searchBlocks) { + limit.THROW_MAX_CHECKS(region.getArea()); + try { + return getExtent().countBlocks(region, searchBlocks); + } catch (FaweException e) { + if (!limit.MAX_FAILS()) { + throw e; + } + return 0; + } + } + + @Override + public int countBlocks(Region region, Mask searchMask) { + limit.THROW_MAX_CHECKS(region.getArea()); + try { + return getExtent().countBlocks(region, searchMask); + } catch (FaweException e) { + if (!limit.MAX_FAILS()) { + throw e; + } + return 0; + } + } + + @Override + public > int setBlocks(Region region, B block) throws MaxChangedBlocksException { + limit.THROW_MAX_CHANGES(region.getArea()); + try { + return getExtent().setBlocks(region, block); + } catch (FaweException e) { + if (!limit.MAX_FAILS()) { + throw e; + } + return 0; + } + } + + @Override + public int setBlocks(Region region, Pattern pattern) throws MaxChangedBlocksException { + limit.THROW_MAX_CHANGES(region.getArea()); + try { + return getExtent().setBlocks(region, pattern); + } catch (FaweException e) { + if (!limit.MAX_FAILS()) { + throw e; + } + return 0; + } + } + + @Override + public > int replaceBlocks(Region region, Set filter, B replacement) throws MaxChangedBlocksException { + limit.THROW_MAX_CHECKS(region.getArea()); + limit.THROW_MAX_CHANGES(region.getArea()); + try { + return getExtent().replaceBlocks(region, filter, replacement); + } catch (FaweException e) { + if (!limit.MAX_FAILS()) { + throw e; + } + return 0; + } + } + + @Override + public int replaceBlocks(Region region, Set filter, Pattern pattern) throws MaxChangedBlocksException { + limit.THROW_MAX_CHECKS(region.getArea()); + limit.THROW_MAX_CHANGES(region.getArea()); + try { + return getExtent().replaceBlocks(region, filter, pattern); + } catch (FaweException e) { + if (!limit.MAX_FAILS()) { + throw e; + } + return 0; + } + } + + @Override + public int replaceBlocks(Region region, Mask mask, Pattern pattern) throws MaxChangedBlocksException { + limit.THROW_MAX_CHECKS(region.getArea()); + limit.THROW_MAX_CHANGES(region.getArea()); + try { + return getExtent().replaceBlocks(region, mask, pattern); + } catch (FaweException e) { + if (!limit.MAX_FAILS()) { + throw e; + } + return 0; + } + } + + @Override + public int center(Region region, Pattern pattern) throws MaxChangedBlocksException { + limit.THROW_MAX_CHECKS(region.getArea()); + limit.THROW_MAX_CHANGES(region.getArea()); + try { + return getExtent().center(region, pattern); + } catch (FaweException e) { + if (!limit.MAX_FAILS()) { + throw e; + } + return 0; + } + } + + @Override + public int setBlocks(Set vset, Pattern pattern) { + limit.THROW_MAX_CHANGES(vset.size()); + try { + return getExtent().setBlocks(vset, pattern); + } catch (FaweException e) { + if (!limit.MAX_FAILS()) { + throw e; + } + return 0; + } + } + + @Override + public T apply(Region region, T filter) { + limit.THROW_MAX_CHECKS(region.getArea()); + limit.THROW_MAX_CHANGES(region.getArea()); + try { + return getExtent().apply(region, filter); + } catch (FaweException e) { + if (!limit.MAX_FAILS()) { + throw e; + } + return filter; + } + } + + @Override + public T apply(Iterable positions, T filter) { + int size; + if (positions instanceof Collection) { + size = ((Collection) positions).size(); + } else if (positions instanceof Region) { + BlockVector3 dim = ((Region) positions).getDimensions(); + size = dim.getX() * dim.getY() * dim.getZ(); + } else if (positions instanceof Extent) { + BlockVector3 min = ((Extent) positions).getMinimumPoint(); + BlockVector3 max = ((Extent) positions).getMinimumPoint(); + BlockVector3 dim = max.subtract(min).add(BlockVector3.ONE); + size = dim.getX() * dim.getY() * dim.getZ(); + } else { + ExtentFilterBlock block = new ExtentFilterBlock(this); + for (BlockVector3 pos : positions) { + limit.THROW_MAX_CHECKS(); + filter.applyBlock(block.init(pos)); + } + return filter; + } + limit.THROW_MAX_CHECKS(size); + limit.THROW_MAX_CHANGES(size); + try { + return getExtent().apply(positions, filter); + } catch (FaweException e) { + if (!limit.MAX_FAILS()) { + throw e; + } + return filter; + } + } + + public BlockState getBlock(BlockVector3 position) { + limit.THROW_MAX_CHECKS(); + try { + return getExtent().getBlock(position); + } catch (FaweException e) { + if (!limit.MAX_FAILS()) { + throw e; + } + return BlockTypes.AIR.getDefaultState(); + } + } + + public BlockState getBlock(int x, int y, int z) { + limit.THROW_MAX_CHECKS(); + try { + return getExtent().getBlock(x, y, z); + } catch (FaweException e) { + if (!limit.MAX_FAILS()) { + throw e; + } + return BlockTypes.AIR.getDefaultState(); + } + } + + @Override + public BaseBlock getFullBlock(BlockVector3 position) { + limit.THROW_MAX_CHECKS(); + try { + return getExtent().getFullBlock(position); + } catch (FaweException e) { + if (!limit.MAX_FAILS()) { + throw e; + } + return BlockTypes.AIR.getDefaultState().toBaseBlock(); + } + } + + public BaseBlock getFullBlock(int x, int y, int z) { + limit.THROW_MAX_CHECKS(); + try { + return getExtent().getFullBlock(x, y, z); + } catch (FaweException e) { + if (!limit.MAX_FAILS()) { + throw e; + } + return BlockTypes.AIR.getDefaultState().toBaseBlock(); + } + } + + public BiomeType getBiome(BlockVector2 position) { + limit.THROW_MAX_CHECKS(); + try { + return getExtent().getBiome(position); + } catch (FaweException e) { + if (!limit.MAX_FAILS()) { + throw e; + } + return BiomeTypes.FOREST; + } + } + + public BiomeType getBiomeType(int x, int z) { + limit.THROW_MAX_CHECKS(); + try { + return getExtent().getBiomeType(x, z); + } catch (FaweException e) { + if (!limit.MAX_FAILS()) { + throw e; + } + return BiomeTypes.FOREST; + } + } + + @Deprecated + public > boolean setBlock(BlockVector3 position, T block) throws WorldEditException { + limit.THROW_MAX_CHANGES(); + if (block.hasNbtData()) limit.MAX_BLOCKSTATES(); + try { + return getExtent().setBlock(position, block); + } catch (FaweException e) { + if (!limit.MAX_FAILS()) { + throw e; + } + return false; + } + } + + public > boolean setBlock(int x, int y, int z, T block) throws WorldEditException { + limit.THROW_MAX_CHANGES(); + if (block.hasNbtData()) limit.MAX_BLOCKSTATES(); + try { + return getExtent().setBlock(x, y, z, block); + } catch (FaweException e) { + if (!limit.MAX_FAILS()) { + throw e; + } + return false; + } + } + + public boolean setTile(int x, int y, int z, CompoundTag tile) throws WorldEditException { + limit.THROW_MAX_CHANGES(); + limit.MAX_BLOCKSTATES(); + try { + return getExtent().setTile(x, y, z, tile); + } catch (FaweException e) { + if (!limit.MAX_FAILS()) { + throw e; + } + return false; + } + } + + public boolean setBiome(BlockVector2 position, BiomeType biome) { + limit.THROW_MAX_CHANGES(); + try { + return getExtent().setBiome(position, biome); + } catch (FaweException e) { + if (!limit.MAX_FAILS()) { + throw e; + } + return false; + } + } + + public boolean setBiome(int x, int y, int z, BiomeType biome) { + limit.THROW_MAX_CHANGES(); + try { + return getExtent().setBiome(x, y, z, biome); + } catch (FaweException e) { + if (!limit.MAX_FAILS()) { + throw e; + } + return false; + } + } +} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/LimitProcessor.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/LimitProcessor.java new file mode 100644 index 000000000..2485ba5c2 --- /dev/null +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/LimitProcessor.java @@ -0,0 +1,47 @@ +package com.boydti.fawe.beta.implementation.processors; + +import com.boydti.fawe.beta.IBatchProcessor; +import com.boydti.fawe.beta.IChunk; +import com.boydti.fawe.beta.IChunkGet; +import com.boydti.fawe.beta.IChunkSet; +import com.boydti.fawe.object.FaweLimit; +import com.boydti.fawe.object.exception.FaweException; +import com.sk89q.worldedit.extent.Extent; + +public class LimitProcessor implements IBatchProcessor { + private final FaweLimit limit; + private final IBatchProcessor parent; + public LimitProcessor(FaweLimit limit, IBatchProcessor parent) { + this.limit = limit; + this.parent = parent; + } + + @Override + public IChunkSet processSet(IChunk chunk, IChunkGet get, IChunkSet set) { + try { + return parent.processSet(chunk, get, set); + } catch (FaweException e) { + if (!limit.MAX_CHANGES()) { + throw e; + } + return null; + } + } + + @Override + public boolean processGet(int chunkX, int chunkZ) { + try { + return parent.processGet(chunkX, chunkZ); + } catch (FaweException e) { + if (!limit.MAX_CHECKS()) { + throw e; + } + return false; + } + } + + @Override + public Extent construct(Extent child) { + return new LimitExtent(parent.construct(child), limit); + } +} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/MultiBatchProcessor.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/MultiBatchProcessor.java similarity index 98% rename from worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/MultiBatchProcessor.java rename to worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/MultiBatchProcessor.java index 43a2de9ce..5cb13fd8f 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/MultiBatchProcessor.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/MultiBatchProcessor.java @@ -1,4 +1,4 @@ -package com.boydti.fawe.beta.implementation; +package com.boydti.fawe.beta.implementation.processors; import com.boydti.fawe.beta.IBatchProcessor; import com.boydti.fawe.beta.IChunk; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/NullProcessor.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/NullProcessor.java similarity index 90% rename from worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/NullProcessor.java rename to worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/NullProcessor.java index 18e9d6f37..7b3f54b25 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/NullProcessor.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/processors/NullProcessor.java @@ -1,4 +1,4 @@ -package com.boydti.fawe.beta.implementation; +package com.boydti.fawe.beta.implementation.processors; import com.boydti.fawe.beta.IBatchProcessor; import com.boydti.fawe.beta.IChunk; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/ParallelQueueExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/ParallelQueueExtent.java similarity index 96% rename from worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/ParallelQueueExtent.java rename to worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/ParallelQueueExtent.java index abeacd6b8..c890f3f40 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/ParallelQueueExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/ParallelQueueExtent.java @@ -1,11 +1,12 @@ -package com.boydti.fawe.beta.implementation; +package com.boydti.fawe.beta.implementation.queue; -import com.boydti.fawe.beta.ChunkFilterBlock; +import com.boydti.fawe.beta.IQueueWrapper; +import com.boydti.fawe.beta.implementation.filter.block.ChunkFilterBlock; import com.boydti.fawe.beta.Filter; -import com.boydti.fawe.beta.IChunk; import com.boydti.fawe.beta.IQueueExtent; -import com.boydti.fawe.beta.filters.CountFilter; -import com.boydti.fawe.beta.filters.DistrFilter; +import com.boydti.fawe.beta.implementation.filter.CountFilter; +import com.boydti.fawe.beta.implementation.filter.DistrFilter; +import com.boydti.fawe.beta.implementation.processors.BatchProcessorHolder; import com.boydti.fawe.config.Settings; import com.boydti.fawe.object.changeset.FaweChangeSet; import com.boydti.fawe.object.clipboard.WorldCopyClipboard; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/QueueHandler.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/QueueHandler.java similarity index 98% rename from worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/QueueHandler.java rename to worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/QueueHandler.java index 8997ff71d..9fb3d1815 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/QueueHandler.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/QueueHandler.java @@ -1,4 +1,4 @@ -package com.boydti.fawe.beta.implementation; +package com.boydti.fawe.beta.implementation.queue; import com.boydti.fawe.Fawe; import com.boydti.fawe.FaweCache; @@ -8,6 +8,8 @@ import com.boydti.fawe.beta.IChunkGet; import com.boydti.fawe.beta.IChunkSet; import com.boydti.fawe.beta.IQueueExtent; import com.boydti.fawe.beta.Trimable; +import com.boydti.fawe.beta.implementation.cache.ChunkCache; +import com.boydti.fawe.beta.IChunkCache; import com.boydti.fawe.config.Settings; import com.boydti.fawe.object.collection.CleanableThreadLocal; import com.boydti.fawe.util.MemUtil; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/SingleThreadQueueExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/SingleThreadQueueExtent.java similarity index 93% rename from worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/SingleThreadQueueExtent.java rename to worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/SingleThreadQueueExtent.java index 59763bc3a..6f06cb6d8 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/SingleThreadQueueExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/SingleThreadQueueExtent.java @@ -1,29 +1,28 @@ -package com.boydti.fawe.beta.implementation; +package com.boydti.fawe.beta.implementation.queue; import com.boydti.fawe.Fawe; -import com.boydti.fawe.FaweCache; -import com.boydti.fawe.beta.CharFilterBlock; -import com.boydti.fawe.beta.ChunkFilterBlock; +import com.boydti.fawe.beta.implementation.filter.block.CharFilterBlock; +import com.boydti.fawe.beta.implementation.filter.block.ChunkFilterBlock; import com.boydti.fawe.beta.IBatchProcessor; import com.boydti.fawe.beta.IChunk; import com.boydti.fawe.beta.IChunkGet; import com.boydti.fawe.beta.IChunkSet; import com.boydti.fawe.beta.IQueueExtent; +import com.boydti.fawe.beta.IChunkCache; +import com.boydti.fawe.beta.implementation.chunk.NullChunk; import com.boydti.fawe.beta.implementation.blocks.CharSetBlocks; -import com.boydti.fawe.beta.implementation.holder.ChunkHolder; -import com.boydti.fawe.beta.implementation.holder.ReferenceChunk; +import com.boydti.fawe.beta.implementation.chunk.ChunkHolder; +import com.boydti.fawe.beta.implementation.chunk.ReferenceChunk; +import com.boydti.fawe.beta.implementation.processors.BatchProcessorHolder; +import com.boydti.fawe.beta.implementation.processors.EmptyBatchProcessor; import com.boydti.fawe.config.Settings; import com.boydti.fawe.object.changeset.FaweChangeSet; -import com.boydti.fawe.object.exception.FaweException; import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.MemUtil; import com.google.common.util.concurrent.Futures; import com.sk89q.worldedit.extent.Extent; import it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; @@ -221,13 +220,15 @@ public class SingleThreadQueueExtent extends BatchProcessorHolder implements IQu @Override public final IChunk getOrCreateChunk(int x, int z) { - if (!processGet(x, z)) { - throw FaweCache.CHUNK; - } final long pair = (long) x << 32 | z & 0xffffffffL; if (pair == lastPair) { return lastChunk; } + if (!processGet(x, z)) { + lastPair = pair; + lastChunk = NullChunk.INSTANCE; + return NullChunk.INSTANCE; + } IChunk chunk = chunks.get(pair); if (chunk instanceof ReferenceChunk) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/command/CFICommands.java b/worldedit-core/src/main/java/com/boydti/fawe/command/CFICommands.java index 95eae94a8..71dce753a 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/command/CFICommands.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/command/CFICommands.java @@ -6,7 +6,7 @@ import static com.sk89q.worldedit.util.formatting.text.TextComponent.newline; import com.boydti.fawe.Fawe; import com.boydti.fawe.FaweAPI; -import com.boydti.fawe.beta.SingleFilterBlock; +import com.boydti.fawe.beta.implementation.filter.block.SingleFilterBlock; import com.boydti.fawe.config.BBC; import com.boydti.fawe.object.RunnableVal; import com.boydti.fawe.object.brush.visualization.cfi.HeightMapMCAGenerator; @@ -74,7 +74,6 @@ import java.util.function.Consumer; import java.util.function.Function; import java.util.stream.IntStream; import javax.imageio.ImageIO; -import javax.xml.soap.Text; import org.enginehub.piston.annotation.Command; import org.enginehub.piston.annotation.CommandContainer; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAFile.java b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAFile.java index 3229f60a2..6f3477332 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAFile.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAFile.java @@ -118,7 +118,7 @@ public class MCAFile implements Trimable { public MCAFile init(File file, int mcrX, int mcrZ) throws FileNotFoundException { if (raf != null) { - flush(pool); + flush(true); for (int i = 0; i < 4096; i++) { locations[i] = 0; } @@ -484,11 +484,11 @@ public class MCAFile implements Trimable { } } - public void close(ForkJoinPool pool) { + public void close() { if (raf == null) return; synchronized (raf) { if (raf != null) { - flush(pool); + flush(true); try { raf.close(); } catch (IOException e) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/mcatest/MCATest.java b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/mcatest/MCATest.java new file mode 100644 index 000000000..8c962316a --- /dev/null +++ b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/mcatest/MCATest.java @@ -0,0 +1,14 @@ +package com.boydti.fawe.jnbt.anvil.mcatest; + +import com.sk89q.worldedit.extent.clipboard.Clipboard; +import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats; + +import java.io.File; +import java.io.IOException; + +public class MCATest { + public MCATest() throws IOException { + File file = new File("plugins/FastAsyncWorldEdit/tobitower.schematic"); + Clipboard loaded = ClipboardFormats.findByFile(file).load(file); + } +} diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/FaweLimit.java b/worldedit-core/src/main/java/com/boydti/fawe/object/FaweLimit.java index bd8bec10b..87d2f84a0 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/FaweLimit.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/FaweLimit.java @@ -1,5 +1,7 @@ package com.boydti.fawe.object; +import com.boydti.fawe.FaweCache; + import java.util.Set; public class FaweLimit { @@ -51,6 +53,47 @@ public class FaweLimit { public boolean MAX_ITERATIONS() { return true; } + + @Override + public boolean isUnlimited() { + return true; + } + + public void THROW_MAX_CHANGES() { + } + + public void THROW_MAX_FAILS() { + } + + public void THROW_MAX_CHECKS() { + } + + public void THROW_MAX_ITERATIONS() { + } + + public void THROW_MAX_BLOCKSTATES() { + } + + public void THROW_MAX_ENTITIES() { + } + + public void THROW_MAX_CHANGES(int amt) { + } + + public void THROW_MAX_FAILS(int amt) { + } + + public void THROW_MAX_CHECKS(int amt) { + } + + public void THROW_MAX_ITERATIONS(int amt) { + } + + public void THROW_MAX_BLOCKSTATES(int amt) { + } + + public void THROW_MAX_ENTITIES(int amt) { + } }; MAX.SPEED_REDUCTION = 0; MAX.INVENTORY_MODE = 0; @@ -92,6 +135,54 @@ public class FaweLimit { return MAX_ENTITIES-- > 0; } + public void THROW_MAX_CHANGES() { + if (MAX_CHANGES-- <= 0) throw FaweCache.MAX_CHANGES; + } + + public void THROW_MAX_FAILS() { + if (MAX_FAILS-- <= 0) throw FaweCache.MAX_CHECKS; + } + + public void THROW_MAX_CHECKS() { + if (MAX_CHECKS-- <= 0) throw FaweCache.MAX_CHECKS; + } + + public void THROW_MAX_ITERATIONS() { + if (MAX_ITERATIONS-- <= 0) throw FaweCache.MAX_ITERATIONS; + } + + public void THROW_MAX_BLOCKSTATES() { + if (MAX_BLOCKSTATES-- <= 0) throw FaweCache.MAX_TILES; + } + + public void THROW_MAX_ENTITIES() { + if (MAX_ENTITIES-- <= 0) throw FaweCache.MAX_ENTITIES; + } + + public void THROW_MAX_CHANGES(int amt) { + if ((MAX_CHANGES -= amt) <= 0) throw FaweCache.MAX_CHANGES; + } + + public void THROW_MAX_FAILS(int amt) { + if ((MAX_FAILS -= amt) <= 0) throw FaweCache.MAX_CHECKS; + } + + public void THROW_MAX_CHECKS(int amt) { + if ((MAX_CHECKS -= amt) <= 0) throw FaweCache.MAX_CHECKS; + } + + public void THROW_MAX_ITERATIONS(int amt) { + if ((MAX_ITERATIONS -= amt) <= 0) throw FaweCache.MAX_ITERATIONS; + } + + public void THROW_MAX_BLOCKSTATES(int amt) { + if ((MAX_BLOCKSTATES -= amt) <= 0) throw FaweCache.MAX_TILES; + } + + public void THROW_MAX_ENTITIES(int amt) { + if ((MAX_ENTITIES -= amt) <= 0) throw FaweCache.MAX_ENTITIES; + } + public boolean isUnlimited() { return MAX_CHANGES == Integer.MAX_VALUE && MAX_FAILS == Integer.MAX_VALUE && diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/cfi/HeightMapMCAGenerator.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/cfi/HeightMapMCAGenerator.java index 42a537076..dea7f5b2a 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/cfi/HeightMapMCAGenerator.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/cfi/HeightMapMCAGenerator.java @@ -5,8 +5,8 @@ import com.boydti.fawe.FaweCache; import com.boydti.fawe.beta.IBlocks; import com.boydti.fawe.beta.IChunkGet; import com.boydti.fawe.beta.IChunkSet; -import com.boydti.fawe.beta.implementation.ChunkPacket; -import com.boydti.fawe.beta.implementation.FallbackChunkGet; +import com.boydti.fawe.beta.implementation.packet.ChunkPacket; +import com.boydti.fawe.beta.implementation.blocks.FallbackChunkGet; import com.boydti.fawe.jnbt.anvil.MCAChunk; import com.boydti.fawe.object.FaweInputStream; import com.boydti.fawe.object.FaweOutputStream; @@ -19,15 +19,12 @@ import com.boydti.fawe.object.collection.DifferentialBlockBuffer; import com.boydti.fawe.object.collection.LocalBlockVector2DSet; import com.boydti.fawe.object.collection.SummedAreaTable; import com.boydti.fawe.object.exception.FaweChunkLoadException; -import com.boydti.fawe.object.schematic.Schematic; import com.boydti.fawe.util.CachedTextureUtil; import com.boydti.fawe.util.RandomTextureUtil; import com.boydti.fawe.util.ReflectionUtils; -import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.util.TextureUtil; import com.boydti.fawe.util.image.Drawable; import com.boydti.fawe.util.image.ImageViewer; -import com.google.common.base.Suppliers; import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.LocalSession; @@ -626,12 +623,11 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr } } Clipboard clipboard = holder.getClipboard(); - Schematic schematic = new Schematic(clipboard); Transform transform = holder.getTransform(); if (transform.isIdentity()) { - schematic.paste(this, mutable, false); + clipboard.paste(this, mutable, false); } else { - schematic.paste(this, mutable, false, transform); + clipboard.paste(this, mutable, false, transform); } if (x + distance < getWidth()) { x += distance; @@ -675,12 +671,11 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr } } Clipboard clipboard = holder.getClipboard(); - Schematic schematic = new Schematic(clipboard); Transform transform = holder.getTransform(); if (transform.isIdentity()) { - schematic.paste(this, mutable, false); + clipboard.paste(this, mutable, false); } else { - schematic.paste(this, mutable, false, transform); + clipboard.paste(this, mutable, false, transform); } if (x + distance < getWidth()) { x += distance; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/LinearClipboard.java b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/LinearClipboard.java index 6effc0cfe..d7c4c32fe 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/LinearClipboard.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/LinearClipboard.java @@ -1,6 +1,6 @@ package com.boydti.fawe.object.clipboard; -import com.boydti.fawe.beta.AbstractFilterBlock; +import com.boydti.fawe.beta.implementation.filter.block.AbstractFilterBlock; import com.boydti.fawe.jnbt.streamer.IntValueReader; import com.google.common.collect.ForwardingIterator; import com.sk89q.jnbt.CompoundTag; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/RandomFullClipboardPattern.java b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/RandomFullClipboardPattern.java index 53a8f473e..049311906 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/RandomFullClipboardPattern.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/pattern/RandomFullClipboardPattern.java @@ -2,7 +2,6 @@ package com.boydti.fawe.object.pattern; import static com.google.common.base.Preconditions.checkNotNull; -import com.boydti.fawe.object.schematic.Schematic; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.clipboard.Clipboard; @@ -47,12 +46,11 @@ public class RandomFullClipboardPattern extends AbstractPattern { holder.setTransform(transform); } Clipboard clipboard = holder.getClipboard(); - Schematic schematic = new Schematic(clipboard); Transform newTransform = holder.getTransform(); if (newTransform.isIdentity()) { - schematic.paste(extent, set, false); + clipboard.paste(extent, set, false); } else { - schematic.paste(extent, set, false, newTransform); + clipboard.paste(extent, set, false, newTransform); } return true; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/Schematic.java b/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/Schematic.java deleted file mode 100644 index a06a8ace6..000000000 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/Schematic.java +++ /dev/null @@ -1,267 +0,0 @@ -package com.boydti.fawe.object.schematic; - -import static com.google.common.base.Preconditions.checkNotNull; - -import com.boydti.fawe.beta.Filter; -import com.boydti.fawe.beta.FilterBlock; -import com.boydti.fawe.object.clipboard.LinearClipboard; -import com.boydti.fawe.object.clipboard.ReadOnlyClipboard; -import com.boydti.fawe.util.EditSessionBuilder; -import com.boydti.fawe.util.MaskTraverser; -import com.sk89q.worldedit.EditSession; -import com.sk89q.worldedit.MaxChangedBlocksException; -import com.sk89q.worldedit.WorldEditException; -import com.sk89q.worldedit.entity.Entity; -import com.sk89q.worldedit.extent.Extent; -import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; -import com.sk89q.worldedit.extent.clipboard.Clipboard; -import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat; -import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter; -import com.sk89q.worldedit.extent.transform.BlockTransformExtent; -import com.sk89q.worldedit.function.RegionFunction; -import com.sk89q.worldedit.function.mask.ExistingBlockMask; -import com.sk89q.worldedit.function.mask.Mask; -import com.sk89q.worldedit.function.operation.ForwardExtentCopy; -import com.sk89q.worldedit.function.operation.Operation; -import com.sk89q.worldedit.function.operation.Operations; -import com.sk89q.worldedit.function.visitor.RegionVisitor; -import com.sk89q.worldedit.math.BlockVector2; -import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.MutableBlockVector2; -import com.sk89q.worldedit.math.transform.Transform; -import com.sk89q.worldedit.regions.CuboidRegion; -import com.sk89q.worldedit.regions.Region; -import com.sk89q.worldedit.util.Location; -import com.sk89q.worldedit.world.World; -import com.sk89q.worldedit.world.block.BlockState; -import com.sk89q.worldedit.world.block.BlockStateHolder; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import javax.annotation.Nullable; - -public class Schematic { - - private final Clipboard clipboard; - - public Schematic(Clipboard clipboard) { - checkNotNull(clipboard); - this.clipboard = clipboard; - } - - /** - * Get the schematic for a region - * - * @param region - */ - public Schematic(Region region) { - checkNotNull(region); - checkNotNull(region.getWorld(), - "World cannot be null (use the other constructor for the region)"); - EditSession session = new EditSessionBuilder(region.getWorld()).allowedRegionsEverywhere() - .autoQueue(false).build(); - this.clipboard = new BlockArrayClipboard(region, ReadOnlyClipboard.of(session, region)); - } - - @Nullable - public Clipboard getClipboard() { - return clipboard; - } - - /** - * Forwards to paste(world, to, true, true, null) - * - * @param world - * @param to - * @return - */ - public EditSession paste(World world, BlockVector3 to) { - return paste(world, to, true, true, null); - } - - public void save(File file, ClipboardFormat format) throws IOException { - checkNotNull(file); - checkNotNull(format); - if (!file.exists()) { - File parent = file.getParentFile(); - if (parent != null) { - parent.mkdirs(); - } - file.createNewFile(); - } - save(new FileOutputStream(file), format); - } - - /** - * Save this schematic to a stream - * - * @param stream - * @param format - * @throws IOException - */ - public void save(OutputStream stream, ClipboardFormat format) throws IOException { - checkNotNull(stream); - checkNotNull(format); - try (ClipboardWriter writer = format.getWriter(stream)) { - writer.write(clipboard); - } - } - - public EditSession paste(World world, BlockVector3 to, boolean allowUndo, boolean pasteAir, - @Nullable Transform transform) { - return paste(world, to, allowUndo, pasteAir, true, transform); - } - - /** - * Paste this schematic in a world - * - * @param world - * @param to - * @param allowUndo - * @param pasteAir - * @param transform - * @return - */ - public EditSession paste(World world, BlockVector3 to, boolean allowUndo, boolean pasteAir, - boolean copyEntities, @Nullable Transform transform) { - checkNotNull(world); - checkNotNull(to); - EditSession editSession; - if (world instanceof EditSession) { - editSession = (EditSession) world; - } else { - EditSessionBuilder builder = new EditSessionBuilder(world).autoQueue(true) - .checkMemory(false).allowedRegionsEverywhere().limitUnlimited(); - if (allowUndo) { - editSession = builder.build(); - } else { - editSession = builder.changeSetNull().fastmode(true).build(); - } - } - Extent extent = clipboard; - Mask sourceMask = editSession.getSourceMask(); - if (transform != null && !transform.isIdentity()) { - extent = new BlockTransformExtent(clipboard, transform); - } else if (sourceMask == null) { - paste(editSession, to, pasteAir); - editSession.flushQueue(); - return editSession; - } - ForwardExtentCopy copy = new ForwardExtentCopy(extent, clipboard.getRegion(), - clipboard.getOrigin(), editSession, to); - if (transform != null && !transform.isIdentity()) { - copy.setTransform(transform); - } - copy.setCopyingEntities(copyEntities); - if (sourceMask != null) { - new MaskTraverser(sourceMask).reset(extent); - copy.setSourceMask(sourceMask); - editSession.setSourceMask(null); - } - if (!pasteAir) { - copy.setSourceMask(new ExistingBlockMask(clipboard)); - } - try { - Operations.completeLegacy(copy); - } catch (MaxChangedBlocksException e) { - e.printStackTrace(); - } - editSession.flushQueue(); - return editSession; - } - - public void paste(Extent extent, BlockVector3 to, boolean pasteAir, @Nullable Transform transform) { - Extent source = clipboard; - if (transform != null && !transform.isIdentity()) { - source = new BlockTransformExtent(clipboard, transform); - } - ForwardExtentCopy copy = new ForwardExtentCopy(source, clipboard.getRegion(), clipboard.getOrigin(), extent, to); - if (transform != null) { - copy.setTransform(transform); - } - copy.setCopyingBiomes(clipboard.hasBiomes()); - if (extent instanceof EditSession) { - EditSession editSession = (EditSession) extent; - Mask sourceMask = editSession.getSourceMask(); - if (sourceMask != null) { - new MaskTraverser(sourceMask).reset(extent); - copy.setSourceMask(sourceMask); - editSession.setSourceMask(null); - } - } - if (!pasteAir) { - copy.setSourceMask(new ExistingBlockMask(clipboard)); - } - Operations.completeBlindly(copy); - } - - public void paste(Extent extent, BlockVector3 to, boolean pasteAir) { - Region region = clipboard.getRegion().clone(); - final BlockVector3 origin = clipboard.getOrigin(); - - final boolean copyBiomes = clipboard.hasBiomes(); - // To must be relative to the clipboard origin ( player location - clipboard origin ) (as the locations supplied are relative to the world origin) - final int relx = to.getBlockX() - origin.getBlockX(); - final int rely = to.getBlockY() - origin.getBlockY(); - final int relz = to.getBlockZ() - origin.getBlockZ(); - - clipboard.apply(clipboard, new Filter() { - @Override - public void applyBlock(FilterBlock block) { - - } - }); - - System.out.println("Rel " + relx + "," + rely + "," + relz + " | " + to + " | " + origin); - - System.out.println("TODO optimize paste using above apply"); - - Operation visitor = new RegionVisitor(region, new RegionFunction() { - // MutableBlockVector2 mpos2d_2 = new MutableBlockVector2(); - MutableBlockVector2 mpos2d = new MutableBlockVector2(); - - { - mpos2d.setComponents(Integer.MIN_VALUE, Integer.MIN_VALUE); - } - - @Override - public boolean apply(BlockVector3 mutable) throws WorldEditException { - BlockState block = clipboard.getBlock(mutable); - System.out.println("Pos " + mutable); - int xx = mutable.getBlockX() + relx; - int zz = mutable.getBlockZ() + relz; - if (copyBiomes && xx != mpos2d.getBlockX() && zz != mpos2d.getBlockZ()) { - mpos2d.setComponents(xx, zz); -// extent.setBiome(mpos2d, clipboard.getBiome(mpos2d_2.setComponents(mutable.getBlockX(), mutable.getBlockZ()))); - extent.setBiome(mpos2d, clipboard - .getBiome(BlockVector2.at(mutable.getBlockX(), mutable.getBlockZ()))); - } - if (!pasteAir && block.getBlockType().getMaterial().isAir()) { - return false; - } - extent.setBlock(xx, mutable.getBlockY() + rely, zz, block); - return false; - } - }); - Operations.completeBlindly(visitor); - // Entity offset is the paste location subtract the clipboard origin (entity's location is already relative to the world origin) - final int entityOffsetX = to.getBlockX() - origin.getBlockX(); - final int entityOffsetY = to.getBlockY() - origin.getBlockY(); - final int entityOffsetZ = to.getBlockZ() - origin.getBlockZ(); - // entities - for (Entity entity : clipboard.getEntities()) { - // skip players on pasting schematic - if (entity.getState() != null && entity.getState().getType().getId() - .equals("minecraft:player")) { - continue; - } - Location pos = entity.getLocation(); - Location newPos = new Location(pos.getExtent(), pos.getX() + entityOffsetX, - pos.getY() + entityOffsetY, pos.getZ() + entityOffsetZ, pos.getYaw(), - pos.getPitch()); - extent.createEntity(newPos, entity.getState()); - } - } -} - diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/EditSessionBuilder.java b/worldedit-core/src/main/java/com/boydti/fawe/util/EditSessionBuilder.java index 13c2860ca..b78fc6a0a 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/EditSessionBuilder.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/EditSessionBuilder.java @@ -3,8 +3,10 @@ package com.boydti.fawe.util; import com.boydti.fawe.Fawe; import com.boydti.fawe.FaweAPI; import com.boydti.fawe.FaweCache; +import com.boydti.fawe.beta.IBatchProcessor; import com.boydti.fawe.beta.IQueueExtent; -import com.boydti.fawe.beta.implementation.ParallelQueueExtent; +import com.boydti.fawe.beta.implementation.processors.LimitProcessor; +import com.boydti.fawe.beta.implementation.queue.ParallelQueueExtent; import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.Settings; import com.boydti.fawe.logging.LoggingChangeSet; @@ -18,7 +20,6 @@ import com.boydti.fawe.object.changeset.BlockBagChangeSet; import com.boydti.fawe.object.changeset.DiskStorageHistory; import com.boydti.fawe.object.changeset.FaweChangeSet; import com.boydti.fawe.object.changeset.MemoryOptimizedHistory; -import com.boydti.fawe.object.exception.FaweException; import com.boydti.fawe.object.extent.FaweRegionExtent; import com.boydti.fawe.object.extent.MultiRegionExtent; import com.boydti.fawe.object.extent.NullExtent; @@ -422,10 +423,14 @@ public class EditSessionBuilder { } else { // this.extent = new HeightBoundExtent(this.extent, this.limit, 0, maxY); } + IBatchProcessor limitProcessor = regionExtent; + if (limit != null && !limit.isUnlimited()) { + limitProcessor = new LimitProcessor(limit, limitProcessor); + } if (regionExtent != null && queue != null && combineStages) { - queue.addProcessor(regionExtent); + queue.addProcessor(limitProcessor); } else if (regionExtent != null) { - this.extent = regionExtent; + this.extent = limitProcessor.construct(regionExtent.getExtent()); } if (this.limit.STRIP_NBT != null && !this.limit.STRIP_NBT.isEmpty()) { System.out.println("TODO add batch processor for strip nbt"); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/TaskManager.java b/worldedit-core/src/main/java/com/boydti/fawe/util/TaskManager.java index 56fd8b979..3e3a78fc8 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/TaskManager.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/TaskManager.java @@ -1,9 +1,8 @@ package com.boydti.fawe.util; import com.boydti.fawe.Fawe; -import com.boydti.fawe.beta.implementation.QueueHandler; +import com.boydti.fawe.beta.implementation.queue.QueueHandler; import com.boydti.fawe.config.Settings; -import com.boydti.fawe.beta.IQueueExtent; import com.boydti.fawe.object.RunnableVal; import org.jetbrains.annotations.NotNull; @@ -13,7 +12,6 @@ import java.util.Collection; import java.util.Iterator; import java.util.concurrent.ExecutionException; import java.util.concurrent.ForkJoinPool; -import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Supplier; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/TextureUtil.java b/worldedit-core/src/main/java/com/boydti/fawe/util/TextureUtil.java index 22be512b7..63424cc74 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/TextureUtil.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/TextureUtil.java @@ -1,7 +1,7 @@ package com.boydti.fawe.util; import com.boydti.fawe.Fawe; -import com.boydti.fawe.beta.SingleFilterBlock; +import com.boydti.fawe.beta.implementation.filter.block.SingleFilterBlock; import com.boydti.fawe.config.Settings; import com.boydti.fawe.util.image.ImageUtil; import com.google.gson.Gson; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/task/TaskBuilder.java b/worldedit-core/src/main/java/com/boydti/fawe/util/task/TaskBuilder.java index 04d4b86be..9855bf49a 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/task/TaskBuilder.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/task/TaskBuilder.java @@ -2,7 +2,7 @@ package com.boydti.fawe.util.task; import com.boydti.fawe.Fawe; import com.boydti.fawe.beta.IQueueExtent; -import com.boydti.fawe.beta.implementation.QueueHandler; +import com.boydti.fawe.beta.implementation.queue.QueueHandler; import com.boydti.fawe.object.Metadatable; import com.boydti.fawe.object.RunnableVal; import com.boydti.fawe.util.TaskManager; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/wrappers/WorldWrapper.java b/worldedit-core/src/main/java/com/boydti/fawe/wrappers/WorldWrapper.java index e02b08b0b..4ebfde40a 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/wrappers/WorldWrapper.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/wrappers/WorldWrapper.java @@ -1,7 +1,7 @@ package com.boydti.fawe.wrappers; import com.boydti.fawe.beta.IChunkGet; -import com.boydti.fawe.beta.implementation.ChunkPacket; +import com.boydti.fawe.beta.implementation.packet.ChunkPacket; import com.boydti.fawe.object.RunnableVal; import com.boydti.fawe.util.ExtentTraverser; import com.boydti.fawe.util.TaskManager; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java index f768082ee..498764538 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java @@ -19,10 +19,6 @@ package com.sk89q.worldedit.command; -import static com.google.common.base.Preconditions.checkNotNull; -import static com.sk89q.worldedit.command.util.Logging.LogMode.PLACEMENT; -import static com.sk89q.worldedit.command.util.Logging.LogMode.REGION; - import com.boydti.fawe.FaweAPI; import com.boydti.fawe.FaweCache; import com.boydti.fawe.config.BBC; @@ -35,12 +31,9 @@ import com.boydti.fawe.object.clipboard.URIClipboardHolder; import com.boydti.fawe.object.clipboard.WorldCutClipboard; import com.boydti.fawe.object.exception.FaweException; import com.boydti.fawe.object.io.FastByteArrayOutputStream; -import com.boydti.fawe.object.schematic.Schematic; import com.boydti.fawe.util.ImgurUtility; import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.MaskTraverser; -import com.google.gson.Gson; -import com.google.gson.JsonObject; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalSession; @@ -77,6 +70,13 @@ import com.sk89q.worldedit.regions.RegionSelector; import com.sk89q.worldedit.regions.selector.CuboidRegionSelector; import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.world.World; +import org.enginehub.piston.annotation.Command; +import org.enginehub.piston.annotation.CommandContainer; +import org.enginehub.piston.annotation.param.Arg; +import org.enginehub.piston.annotation.param.ArgFlag; +import org.enginehub.piston.annotation.param.Switch; +import org.enginehub.piston.inject.InjectedValueAccess; + import java.io.File; import java.io.IOException; import java.io.OutputStream; @@ -88,12 +88,10 @@ import java.util.HashSet; import java.util.Set; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; -import org.enginehub.piston.annotation.Command; -import org.enginehub.piston.annotation.CommandContainer; -import org.enginehub.piston.annotation.param.Arg; -import org.enginehub.piston.annotation.param.ArgFlag; -import org.enginehub.piston.annotation.param.Switch; -import org.enginehub.piston.inject.InjectedValueAccess; + +import static com.google.common.base.Preconditions.checkNotNull; +import static com.sk89q.worldedit.command.util.Logging.LogMode.PLACEMENT; +import static com.sk89q.worldedit.command.util.Logging.LogMode.REGION; /** @@ -518,8 +516,7 @@ public class ClipboardCommands { final BlockVector3 to = atOrigin ? origin : session.getPlacementPosition(actor); checkPaste(actor, editSession, to, holder, clipboard); - Schematic schem = new Schematic(clipboard); - schem.paste(editSession, to, !ignoreAirBlocks); + clipboard.paste(editSession, to, !ignoreAirBlocks); Region region = clipboard.getRegion().clone(); if (selectPasted) { 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 216734789..2e0142c5c 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 @@ -31,8 +31,8 @@ import static com.sk89q.worldedit.regions.Regions.minimumBlockY; import com.boydti.fawe.FaweAPI; import com.boydti.fawe.FaweCache; -import com.boydti.fawe.beta.implementation.ChunkSendProcessor; -import com.boydti.fawe.beta.implementation.NullProcessor; +import com.boydti.fawe.beta.implementation.processors.ChunkSendProcessor; +import com.boydti.fawe.beta.implementation.processors.NullProcessor; import com.boydti.fawe.config.BBC; import com.boydti.fawe.object.FaweLimit; import com.sk89q.jnbt.CompoundTag; @@ -76,10 +76,8 @@ import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BlockStateHolder; import java.util.ArrayList; -import java.util.Collections; import java.util.Iterator; import java.util.List; -import java.util.function.Supplier; import java.util.stream.Stream; import com.sk89q.worldedit.world.block.BlockTypes; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/entity/Player.java b/worldedit-core/src/main/java/com/sk89q/worldedit/entity/Player.java index 9da5bb016..76a77c163 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/entity/Player.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/entity/Player.java @@ -20,7 +20,6 @@ package com.sk89q.worldedit.entity; import com.boydti.fawe.Fawe; -import com.boydti.fawe.beta.implementation.ChunkPacket; import com.boydti.fawe.config.Settings; import com.boydti.fawe.object.brush.visualization.VirtualWorld; import com.boydti.fawe.object.clipboard.DiskOptimizedClipboard; @@ -51,7 +50,6 @@ import com.sk89q.worldedit.world.gamemode.GameMode; import javax.annotation.Nullable; import java.io.File; -import java.util.function.Supplier; /** * Represents a player diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java index 8bbd89a97..25fd9e482 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java @@ -38,6 +38,7 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.regions.ConvexPolyhedralRegion; +import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.CylinderRegion; import com.sk89q.worldedit.regions.Polygonal2DRegion; import com.sk89q.worldedit.regions.Region; @@ -686,14 +687,16 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { * * @return an array of allowed regions */ - @Deprecated public Region[] getCurrentRegions() { - return WEManager.IMP.getMask(this); + return getCurrentRegions(FaweMaskManager.MaskType.MEMBER); } - @Deprecated public Region[] getCurrentRegions(FaweMaskManager.MaskType type) { - return WEManager.IMP.getMask(this, type); + BlockVector3 pos1 = BlockVector3.at(20, 20, 20); + BlockVector3 pos2 = BlockVector3.at(40, 40, 40); + Region[] regions = {new CuboidRegion(getWorld(), pos1, pos2)}; + return regions; +// return WEManager.IMP.getMask(this, type); } /** diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java index 6e4497b0f..6391c8c50 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java @@ -26,6 +26,7 @@ import com.boydti.fawe.command.CFICommands; import com.boydti.fawe.command.CFICommandsRegistration; import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.Settings; +import com.boydti.fawe.object.exception.FaweException; import com.boydti.fawe.object.task.ThrowableSupplier; import com.boydti.fawe.util.StringMan; import com.boydti.fawe.util.TaskManager; @@ -664,8 +665,7 @@ public final class PlatformCommandManager { MemoizingValueAccess context = initializeInjectedValues(event::getArguments, actor); - ThrowableSupplier task = - () -> commandManager.execute(context, ImmutableList.copyOf(split)); + ThrowableSupplier task = () -> commandManager.execute(context, ImmutableList.copyOf(split)); handleCommandTask(task, context, session, event); } @@ -699,6 +699,8 @@ public final class PlatformCommandManager { } else { actor.print(e.getRichMessage()); } + } catch (FaweException e) { + actor.printError("Edit cancelled: " + e.getMessage()); } catch (UsageException e) { actor.print(TextComponent.builder("") .color(TextColor.RED) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/Extent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/Extent.java index 417631377..a42d54d19 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/Extent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/Extent.java @@ -21,8 +21,7 @@ package com.sk89q.worldedit.extent; import static com.google.common.base.Preconditions.checkNotNull; -import com.boydti.fawe.beta.AbstractFilterBlock; -import com.boydti.fawe.beta.ExtentFilterBlock; +import com.boydti.fawe.beta.implementation.filter.block.ExtentFilterBlock; import com.boydti.fawe.beta.Filter; import com.boydti.fawe.beta.IBatchProcessor; import com.boydti.fawe.object.changeset.FaweChangeSet; @@ -68,7 +67,6 @@ import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; import java.util.ArrayList; import java.util.Collections; -import java.util.Iterator; import java.util.List; import java.util.Set; import java.util.UUID; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/Clipboard.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/Clipboard.java index 8d7bb89b4..5d8da7798 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/Clipboard.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/Clipboard.java @@ -24,26 +24,60 @@ import com.boydti.fawe.config.Settings; import com.boydti.fawe.object.clipboard.CPUOptimizedClipboard; import com.boydti.fawe.object.clipboard.DiskOptimizedClipboard; import com.boydti.fawe.object.clipboard.MemoryOptimizedClipboard; +import com.boydti.fawe.object.clipboard.ReadOnlyClipboard; +import com.boydti.fawe.util.EditSessionBuilder; +import com.boydti.fawe.util.MaskTraverser; +import com.sk89q.worldedit.EditSession; +import com.sk89q.worldedit.MaxChangedBlocksException; +import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.extent.Extent; +import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat; +import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter; +import com.sk89q.worldedit.extent.transform.BlockTransformExtent; +import com.sk89q.worldedit.function.RegionFunction; +import com.sk89q.worldedit.function.mask.ExistingBlockMask; +import com.sk89q.worldedit.function.mask.Mask; +import com.sk89q.worldedit.function.operation.ForwardExtentCopy; +import com.sk89q.worldedit.function.operation.Operation; +import com.sk89q.worldedit.function.operation.Operations; +import com.sk89q.worldedit.function.visitor.RegionVisitor; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.regions.CuboidRegion; +import com.sk89q.worldedit.math.MutableBlockVector2; +import com.sk89q.worldedit.math.transform.Transform; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Regions; import com.sk89q.worldedit.util.Location; +import com.sk89q.worldedit.world.World; +import com.sk89q.worldedit.world.block.BlockState; import javax.annotation.Nullable; import java.io.Closeable; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; import java.net.URI; import java.util.Iterator; import java.util.UUID; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Specifies an object that implements something suitable as a "clipboard." */ public interface Clipboard extends Extent, Iterable, Closeable { - static Clipboard create(BlockVector3 size, UUID uuid) { + public static Clipboard create(Region region) { + checkNotNull(region); + checkNotNull(region.getWorld(), + "World cannot be null (use the other constructor for the region)"); + EditSession session = new EditSessionBuilder(region.getWorld()).allowedRegionsEverywhere() + .autoQueue(false).build(); + return ReadOnlyClipboard.of(session, region); + } + + public static Clipboard create(BlockVector3 size, UUID uuid) { if (Settings.IMP.CLIPBOARD.USE_DISK) { return new DiskOptimizedClipboard(size, uuid); } else if (Settings.IMP.CLIPBOARD.COMPRESSION_LEVEL == 0) { @@ -150,4 +184,204 @@ public interface Clipboard extends Extent, Iterable, Closeable { default void close() { } + + + /* + Utility methods + */ + + /** + * Forwards to paste(world, to, true, true, null) + * + * @param world + * @param to + * @return + */ + default EditSession paste(World world, BlockVector3 to) { + return paste(world, to, true, true, null); + } + + default void save(File file, ClipboardFormat format) throws IOException { + checkNotNull(file); + checkNotNull(format); + if (!file.exists()) { + File parent = file.getParentFile(); + if (parent != null) { + parent.mkdirs(); + } + file.createNewFile(); + } + save(new FileOutputStream(file), format); + } + + /** + * Save this schematic to a stream + * + * @param stream + * @param format + * @throws IOException + */ + default void save(OutputStream stream, ClipboardFormat format) throws IOException { + checkNotNull(stream); + checkNotNull(format); + try (ClipboardWriter writer = format.getWriter(stream)) { + writer.write(this); + } + } + + default EditSession paste(World world, BlockVector3 to, boolean allowUndo, boolean pasteAir, + @Nullable Transform transform) { + return paste(world, to, allowUndo, pasteAir, true, transform); + } + + /** + * Paste this schematic in a world + * + * @param world + * @param to + * @param allowUndo + * @param pasteAir + * @param transform + * @return + */ + default EditSession paste(World world, BlockVector3 to, boolean allowUndo, boolean pasteAir, + boolean copyEntities, @Nullable Transform transform) { + checkNotNull(world); + checkNotNull(to); + EditSession editSession; + if (world instanceof EditSession) { + editSession = (EditSession) world; + } else { + EditSessionBuilder builder = new EditSessionBuilder(world).autoQueue(true) + .checkMemory(false).allowedRegionsEverywhere().limitUnlimited(); + if (allowUndo) { + editSession = builder.build(); + } else { + editSession = builder.changeSetNull().fastmode(true).build(); + } + } + Extent extent = this; + Mask sourceMask = editSession.getSourceMask(); + if (transform != null && !transform.isIdentity()) { + extent = new BlockTransformExtent(this, transform); + } else if (sourceMask == null) { + paste(editSession, to, pasteAir); + editSession.flushQueue(); + return editSession; + } + ForwardExtentCopy copy = new ForwardExtentCopy(extent, this.getRegion(), + this.getOrigin(), editSession, to); + if (transform != null && !transform.isIdentity()) { + copy.setTransform(transform); + } + copy.setCopyingEntities(copyEntities); + if (sourceMask != null) { + new MaskTraverser(sourceMask).reset(extent); + copy.setSourceMask(sourceMask); + editSession.setSourceMask(null); + } + if (!pasteAir) { + copy.setSourceMask(new ExistingBlockMask(this)); + } + try { + Operations.completeLegacy(copy); + } catch (MaxChangedBlocksException e) { + e.printStackTrace(); + } + editSession.flushQueue(); + return editSession; + } + + default void paste(Extent extent, BlockVector3 to, boolean pasteAir, @Nullable Transform transform) { + Extent source = this; + if (transform != null && !transform.isIdentity()) { + source = new BlockTransformExtent(this, transform); + } + ForwardExtentCopy copy = new ForwardExtentCopy(source, this.getRegion(), this.getOrigin(), extent, to); + if (transform != null) { + copy.setTransform(transform); + } + copy.setCopyingBiomes(this.hasBiomes()); + if (extent instanceof EditSession) { + EditSession editSession = (EditSession) extent; + Mask sourceMask = editSession.getSourceMask(); + if (sourceMask != null) { + new MaskTraverser(sourceMask).reset(extent); + copy.setSourceMask(sourceMask); + editSession.setSourceMask(null); + } + } + if (!pasteAir) { + copy.setSourceMask(new ExistingBlockMask(this)); + } + Operations.completeBlindly(copy); + } + + default void paste(Extent extent, BlockVector3 to, boolean pasteAir) { + Region region = this.getRegion().clone(); + final BlockVector3 origin = this.getOrigin(); + + final boolean copyBiomes = this.hasBiomes(); + // To must be relative to the clipboard origin ( player location - clipboard origin ) (as the locations supplied are relative to the world origin) + final int relx = to.getBlockX() - origin.getBlockX(); + final int rely = to.getBlockY() - origin.getBlockY(); + final int relz = to.getBlockZ() - origin.getBlockZ(); + +// this.apply(this, new Filter() { +// @Override +// public void applyBlock(FilterBlock block) { +// +// } +// }); + + System.out.println("Rel " + relx + "," + rely + "," + relz + " | " + to + " | " + origin); + + System.out.println("TODO optimize paste using above apply"); + + Operation visitor = new RegionVisitor(region, new RegionFunction() { + // MutableBlockVector2 mpos2d_2 = new MutableBlockVector2(); + MutableBlockVector2 mpos2d = new MutableBlockVector2(); + + { + mpos2d.setComponents(Integer.MIN_VALUE, Integer.MIN_VALUE); + } + + @Override + public boolean apply(BlockVector3 mutable) throws WorldEditException { + BlockState block = getBlock(mutable); + System.out.println("Pos " + mutable); + int xx = mutable.getBlockX() + relx; + int zz = mutable.getBlockZ() + relz; + if (copyBiomes && xx != mpos2d.getBlockX() && zz != mpos2d.getBlockZ()) { + mpos2d.setComponents(xx, zz); +// extent.setBiome(mpos2d, clipboard.getBiome(mpos2d_2.setComponents(mutable.getBlockX(), mutable.getBlockZ()))); + extent.setBiome(mpos2d, Clipboard.this + .getBiome(BlockVector2.at(mutable.getBlockX(), mutable.getBlockZ()))); + } + if (!pasteAir && block.getBlockType().getMaterial().isAir()) { + return false; + } + extent.setBlock(xx, mutable.getBlockY() + rely, zz, block); + return false; + } + }); + Operations.completeBlindly(visitor); + // Entity offset is the paste location subtract the clipboard origin (entity's location is already relative to the world origin) + final int entityOffsetX = to.getBlockX() - origin.getBlockX(); + final int entityOffsetY = to.getBlockY() - origin.getBlockY(); + final int entityOffsetZ = to.getBlockZ() - origin.getBlockZ(); + // entities + for (Entity entity : this.getEntities()) { + // skip players on pasting schematic + if (entity.getState() != null && entity.getState().getType().getId() + .equals("minecraft:player")) { + continue; + } + Location pos = entity.getLocation(); + Location newPos = new Location(pos.getExtent(), pos.getX() + entityOffsetX, + pos.getY() + entityOffsetY, pos.getZ() + entityOffsetZ, pos.getYaw(), + pos.getPitch()); + extent.createEntity(newPos, entity.getState()); + } + } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/ClipboardFormat.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/ClipboardFormat.java index 37f9ebec9..25e0ff743 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/ClipboardFormat.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/ClipboardFormat.java @@ -25,7 +25,6 @@ import com.boydti.fawe.config.Settings; import com.boydti.fawe.object.RunnableVal; import com.boydti.fawe.object.clipboard.URIClipboardHolder; import com.boydti.fawe.object.io.PGZIPOutputStream; -import com.boydti.fawe.object.schematic.Schematic; import com.boydti.fawe.util.MainUtil; import com.google.gson.Gson; import com.sk89q.worldedit.LocalSession; @@ -127,12 +126,12 @@ public interface ClipboardFormat { return holder; } - default Schematic load(File file) throws IOException { + default Clipboard load(File file) throws IOException { return load(new FileInputStream(file)); } - default Schematic load(InputStream stream) throws IOException { - return new Schematic(getReader(stream).read()); + default Clipboard load(InputStream stream) throws IOException { + return getReader(stream).read(); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/RegionFunction.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/RegionFunction.java index 7ff757bf0..a5b448aea 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/RegionFunction.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/RegionFunction.java @@ -20,7 +20,7 @@ package com.sk89q.worldedit.function; import com.boydti.fawe.beta.Filter; -import com.boydti.fawe.beta.FilterBlock; +import com.boydti.fawe.beta.implementation.filter.block.FilterBlock; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.math.BlockVector3; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/SchemGen.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/SchemGen.java index 018a907e5..3ff43d429 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/SchemGen.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/SchemGen.java @@ -1,6 +1,5 @@ package com.sk89q.worldedit.function.generator; -import com.boydti.fawe.object.schematic.Schematic; import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.Extent; @@ -45,12 +44,11 @@ public class SchemGen implements Resource { holder.setTransform(new AffineTransform().rotateY(ThreadLocalRandom.current().nextInt(4) * 90)); } Clipboard clipboard = holder.getClipboard(); - Schematic schematic = new Schematic(clipboard); Transform transform = holder.getTransform(); if (transform.isIdentity()) { - schematic.paste(extent, mutable, false); + clipboard.paste(extent, mutable, false); } else { - schematic.paste(extent, mutable, false, transform); + clipboard.paste(extent, mutable, false, transform); } mutable.mutY(y); return true; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/InverseMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/InverseMask.java index 4a22ef5fd..3999dfc44 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/InverseMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/InverseMask.java @@ -2,7 +2,6 @@ package com.sk89q.worldedit.function.mask; import javax.annotation.Nullable; -import com.boydti.fawe.beta.FilterBlock; import com.sk89q.worldedit.math.BlockVector3; public class InverseMask extends AbstractMask { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/InverseSingleBlockStateMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/InverseSingleBlockStateMask.java index 024a61812..2ea0b3027 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/InverseSingleBlockStateMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/InverseSingleBlockStateMask.java @@ -1,13 +1,9 @@ package com.sk89q.worldedit.function.mask; -import com.boydti.fawe.beta.FilterBlock; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; -import com.sk89q.worldedit.world.block.BlockTypes; - -import java.util.Arrays; public class InverseSingleBlockStateMask extends ABlockMask { private final char ordinal; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/Mask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/Mask.java index 43bb43346..c4dad4dc1 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/Mask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/Mask.java @@ -20,7 +20,7 @@ package com.sk89q.worldedit.function.mask; import com.boydti.fawe.beta.Filter; -import com.boydti.fawe.beta.FilterBlock; +import com.boydti.fawe.beta.implementation.filter.block.FilterBlock; import com.sk89q.worldedit.math.BlockVector3; import javax.annotation.Nullable; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskFilter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskFilter.java index 5e61405d5..6632ae17e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskFilter.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskFilter.java @@ -1,8 +1,8 @@ package com.sk89q.worldedit.function.mask; -import com.boydti.fawe.beta.DelegateFilter; +import com.boydti.fawe.beta.implementation.filter.block.DelegateFilter; import com.boydti.fawe.beta.Filter; -import com.boydti.fawe.beta.FilterBlock; +import com.boydti.fawe.beta.implementation.filter.block.FilterBlock; import java.util.function.Supplier; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SingleBlockStateMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SingleBlockStateMask.java index fa3655ccc..1ec097fcd 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SingleBlockStateMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SingleBlockStateMask.java @@ -1,13 +1,9 @@ package com.sk89q.worldedit.function.mask; -import com.boydti.fawe.beta.FilterBlock; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; -import com.sk89q.worldedit.world.block.BlockTypes; - -import java.util.Arrays; public class SingleBlockStateMask extends ABlockMask { private final char ordinal; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/Pattern.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/Pattern.java index 98e6bd271..8cb2800f0 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/Pattern.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/Pattern.java @@ -20,7 +20,7 @@ package com.sk89q.worldedit.function.pattern; import com.boydti.fawe.beta.Filter; -import com.boydti.fawe.beta.FilterBlock; +import com.boydti.fawe.beta.implementation.filter.block.FilterBlock; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector3; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/RandomPattern.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/RandomPattern.java index b9f2bc2ba..d5ecc2b44 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/RandomPattern.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/RandomPattern.java @@ -19,7 +19,6 @@ package com.sk89q.worldedit.function.pattern; -import com.boydti.fawe.beta.FilterBlock; import com.boydti.fawe.object.collection.RandomCollection; import com.boydti.fawe.object.random.SimpleRandom; import com.boydti.fawe.object.random.TrueRandom; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java index 58268c786..144506689 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java @@ -23,27 +23,22 @@ import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import com.boydti.fawe.FaweCache; -import com.boydti.fawe.beta.ChunkFilterBlock; +import com.boydti.fawe.beta.implementation.filter.block.ChunkFilterBlock; import com.boydti.fawe.beta.Filter; -import com.boydti.fawe.beta.IBatchProcessor; import com.boydti.fawe.beta.IChunk; import com.boydti.fawe.beta.IChunkGet; import com.boydti.fawe.beta.IChunkSet; import com.boydti.fawe.config.Settings; import com.boydti.fawe.object.collection.BlockVectorSet; -import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.MutableBlockVector2; import com.sk89q.worldedit.math.MutableBlockVector3; -import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.storage.ChunkStore; import java.util.AbstractSet; -import java.util.Arrays; import java.util.Iterator; -import java.util.Map; import java.util.NoSuchElementException; import java.util.Set; import org.jetbrains.annotations.NotNull; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CylinderRegion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CylinderRegion.java index 53f48baf9..c6f77597e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CylinderRegion.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/CylinderRegion.java @@ -21,7 +21,7 @@ package com.sk89q.worldedit.regions; import static com.google.common.base.Preconditions.checkNotNull; -import com.boydti.fawe.beta.ChunkFilterBlock; +import com.boydti.fawe.beta.implementation.filter.block.ChunkFilterBlock; import com.boydti.fawe.beta.Filter; import com.boydti.fawe.beta.IChunk; import com.boydti.fawe.beta.IChunkGet; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/EllipsoidRegion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/EllipsoidRegion.java index 4fbcc9577..896f3c701 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/EllipsoidRegion.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/EllipsoidRegion.java @@ -20,7 +20,7 @@ package com.sk89q.worldedit.regions; -import com.boydti.fawe.beta.ChunkFilterBlock; +import com.boydti.fawe.beta.implementation.filter.block.ChunkFilterBlock; import com.boydti.fawe.beta.Filter; import com.boydti.fawe.beta.IChunk; import com.boydti.fawe.beta.IChunkGet; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Region.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Region.java index 29c399199..4d3a15d17 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Region.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/Region.java @@ -19,8 +19,7 @@ package com.sk89q.worldedit.regions; -import com.boydti.fawe.FaweCache; -import com.boydti.fawe.beta.ChunkFilterBlock; +import com.boydti.fawe.beta.implementation.filter.block.ChunkFilterBlock; import com.boydti.fawe.beta.Filter; import com.boydti.fawe.beta.IBatchProcessor; import com.boydti.fawe.beta.IChunk; @@ -28,16 +27,13 @@ import com.boydti.fawe.beta.IChunkGet; import com.boydti.fawe.beta.IChunkSet; import com.boydti.fawe.object.FaweLimit; import com.boydti.fawe.object.extent.SingleRegionExtent; -import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.world.World; -import java.util.Iterator; import java.util.List; -import java.util.Map; import java.util.Set; import javax.annotation.Nullable; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/NullWorld.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/NullWorld.java index 9ad7325b2..d7dc007c5 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/NullWorld.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/NullWorld.java @@ -20,8 +20,8 @@ package com.sk89q.worldedit.world; import com.boydti.fawe.beta.IChunkGet; -import com.boydti.fawe.beta.implementation.ChunkPacket; -import com.boydti.fawe.beta.implementation.NullChunkGet; +import com.boydti.fawe.beta.implementation.packet.ChunkPacket; +import com.boydti.fawe.beta.implementation.blocks.NullChunkGet; import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.MaxChangedBlocksException; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/World.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/World.java index 1d3031a7d..95eb601ac 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/World.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/World.java @@ -20,8 +20,8 @@ package com.sk89q.worldedit.world; import com.boydti.fawe.beta.IChunkGet; -import com.boydti.fawe.beta.implementation.ChunkPacket; -import com.boydti.fawe.beta.implementation.IChunkCache; +import com.boydti.fawe.beta.implementation.packet.ChunkPacket; +import com.boydti.fawe.beta.IChunkCache; import com.boydti.fawe.object.extent.LightingExtent; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.MaxChangedBlocksException; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockState.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockState.java index b91f19510..ce313ae80 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockState.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockState.java @@ -19,7 +19,6 @@ package com.sk89q.worldedit.world.block; -import com.boydti.fawe.beta.FilterBlock; import com.boydti.fawe.command.SuggestInputParseException; import com.boydti.fawe.object.string.MutableCharSequence; import com.boydti.fawe.util.StringMan; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/ImmutableBaseBlock.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/ImmutableBaseBlock.java index bb86f0b65..08469e2c6 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/ImmutableBaseBlock.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/ImmutableBaseBlock.java @@ -1,6 +1,5 @@ package com.sk89q.worldedit.world.block; -import com.boydti.fawe.beta.FilterBlock; import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.Extent;