From 4a40c7d99caf8f8a0df4ffac02ef1b77c1f0e738 Mon Sep 17 00:00:00 2001 From: MattBDev <4009945+MattBDev@users.noreply.github.com> Date: Tue, 9 Jul 2019 15:50:13 -0400 Subject: [PATCH 1/4] Renaming and cleanup and a new method. --- .../sk89q/worldedit/bukkit/BukkitWorld.java | 11 +- .../main/java/com/boydti/fawe/FaweAPI.java | 9 +- .../main/java/com/boydti/fawe/FaweCache.java | 15 +- .../boydti/fawe/command/AnvilCommands.java | 121 ++++-- .../com/boydti/fawe/command/CFICommand.java | 71 ++-- .../com/boydti/fawe/command/CFICommands.java | 399 ++++++++++-------- .../fawe/command/FawePrimitiveBinding.java | 262 ++++++------ .../main/java/com/boydti/fawe/config/BBC.java | 2 +- .../com/boydti/fawe/example/NMSRelighter.java | 2 +- .../com/boydti/fawe/jnbt/NBTStreamer.java | 14 +- .../boydti/fawe/jnbt/SchematicStreamer.java | 20 +- .../fawe/jnbt/anvil/generator/OreGen.java | 23 +- .../fawe/jnbt/anvil/generator/Resource.java | 5 +- .../fawe/jnbt/anvil/generator/SchemGen.java | 2 +- .../fawe/object/brush/ShatterBrush.java | 60 ++- .../brush/visualization/VisualExtent.java | 29 +- .../AbstractDelegateFaweClipboard.java | 5 +- .../clipboard/CPUOptimizedClipboard.java | 11 +- .../clipboard/DiskOptimizedClipboard.java | 87 ++-- .../fawe/object/clipboard/FaweClipboard.java | 16 +- .../clipboard/MemoryOptimizedClipboard.java | 18 +- .../object/clipboard/OffsetFaweClipboard.java | 1 - .../object/clipboard/ReadOnlyClipboard.java | 6 +- .../object/clipboard/WorldCopyClipboard.java | 31 +- .../object/clipboard/WorldCutClipboard.java | 1 + .../clipboard/remap/RemappedClipboard.java | 72 ---- .../object/clipboard/remap/WikiScraper.java | 14 +- .../collection/FastRandomCollection.java | 2 +- .../collection/LocalBlockVector2DSet.java | 38 +- .../collection/LocalBlockVectorSet.java | 4 +- .../fawe/object/extent/MultiTransform.java | 2 +- .../boydti/fawe/object/extent/NullExtent.java | 106 ++--- .../fawe/object/extent/ProcessedWEExtent.java | 23 +- .../fawe/object/extent/StripNBTExtent.java | 4 +- .../boydti/fawe/object/mask/AngleMask.java | 7 - .../fawe/object/mask/BlockLightMask.java | 5 - .../fawe/object/mask/BrightnessMask.java | 9 +- .../com/boydti/fawe/object/mask/DataMask.java | 8 - .../boydti/fawe/object/mask/IdDataMask.java | 9 - .../com/boydti/fawe/object/mask/IdMask.java | 5 - .../boydti/fawe/object/mask/LightMask.java | 7 +- .../boydti/fawe/object/mask/OpacityMask.java | 5 - .../boydti/fawe/object/mask/PlaneMask.java | 5 - .../boydti/fawe/object/mask/RadiusMask.java | 5 - .../boydti/fawe/object/mask/SkyLightMask.java | 7 +- .../fawe/object/mask/SolidPlaneMask.java | 5 - .../boydti/fawe/object/mask/XAxisMask.java | 5 - .../boydti/fawe/object/mask/YAxisMask.java | 8 - .../boydti/fawe/object/mask/ZAxisMask.java | 5 - .../fawe/object/pattern/PatternExtent.java | 20 +- .../object/progress/ChatProgressTracker.java | 12 +- .../fawe/object/regions/PolyhedralRegion.java | 2 +- ...ureFormat.java => MinecraftStructure.java} | 40 +- .../fawe/object/visitor/FaweChunkVisitor.java | 10 +- .../fawe/regions/general/plot/PlotTrim.java | 23 +- .../boydti/fawe/wrappers/WorldWrapper.java | 8 +- .../java/com/sk89q/jnbt/NBTInputStream.java | 51 +-- .../java/com/sk89q/worldedit/EditSession.java | 123 +++--- .../com/sk89q/worldedit/LocalSession.java | 2 +- .../worldedit/command/ClipboardCommands.java | 39 +- .../worldedit/command/SchematicCommands.java | 8 +- .../worldedit/command/tool/BrushTool.java | 6 +- .../extent/clipboard/BlockArrayClipboard.java | 5 +- .../worldedit/extent/clipboard/Clipboard.java | 3 +- .../clipboard/io/BuiltInClipboardFormat.java | 37 +- .../transform/BlockTransformExtent.java | 30 +- .../function/mask/BlockCategoryMask.java | 8 - .../worldedit/function/mask/BlockMask.java | 7 - .../function/mask/BlockStateMask.java | 6 - .../function/mask/BlockTypeMask.java | 8 - .../function/mask/BoundedHeightMask.java | 9 - .../function/mask/ExistingBlockMask.java | 8 - .../worldedit/function/mask/RegionMask.java | 9 - .../function/mask/SolidBlockMask.java | 8 - .../sk89q/worldedit/math/MutableVector3.java | 3 - .../com/sk89q/worldedit/util/Location.java | 4 - .../sk89q/worldedit/world/AbstractWorld.java | 5 + .../sk89q/worldedit/world/SimpleWorld.java | 31 +- .../java/com/sk89q/worldedit/world/World.java | 13 + 79 files changed, 893 insertions(+), 1226 deletions(-) delete mode 100644 worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/remap/RemappedClipboard.java rename worldedit-core/src/main/java/com/boydti/fawe/object/schematic/{StructureFormat.java => MinecraftStructure.java} (92%) 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 887b48e7b..1a8769094 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 @@ -47,10 +47,12 @@ import org.bukkit.block.Chest; import org.bukkit.entity.Entity; import org.bukkit.inventory.DoubleChestInventory; import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.InventoryHolder; import org.slf4j.Logger; import javax.annotation.Nullable; import java.lang.ref.WeakReference; +import java.nio.file.Path; import java.util.ArrayList; import java.util.EnumMap; import java.util.HashMap; @@ -154,6 +156,11 @@ public class BukkitWorld extends AbstractWorld { return getWorld().getName(); } + @Override + public Path getStoragePath() { + return getWorld().getWorldFolder().toPath(); + } + @Override public int getBlockLightLevel(BlockVector3 pt) { return getWorld().getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).getLightLevel(); @@ -239,11 +246,11 @@ public class BukkitWorld extends AbstractWorld { return false; } BlockState state = block.getState(); - if (!(state instanceof org.bukkit.inventory.InventoryHolder)) { + if (!(state instanceof InventoryHolder)) { return false; } - org.bukkit.inventory.InventoryHolder chest = (org.bukkit.inventory.InventoryHolder) state; + InventoryHolder chest = (InventoryHolder) state; Inventory inven = chest.getInventory(); if (chest instanceof Chest) { inven = getBlockInventory((Chest) chest); 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 763b22c02..656a5c51b 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/FaweAPI.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/FaweAPI.java @@ -17,6 +17,7 @@ import com.boydti.fawe.util.SetQueue; import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.util.WEManager; import com.boydti.fawe.wrappers.WorldWrapper; + import com.google.common.collect.Sets; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.WorldEdit; @@ -36,24 +37,18 @@ import com.sk89q.worldedit.internal.registry.InputParser; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.util.Location; -import com.sk89q.worldedit.world.AbstractWorld; import com.sk89q.worldedit.world.World; -import org.jetbrains.annotations.NotNull; +import javax.annotation.Nullable; import java.io.File; import java.io.IOException; import java.lang.reflect.Field; import java.net.URL; import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Comparator; import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.UUID; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; /** * The FaweAPI class offers a few useful functions.
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 c3ed20bf8..cf345ef95 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/FaweCache.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/FaweCache.java @@ -1,12 +1,17 @@ package com.boydti.fawe; import com.boydti.fawe.object.collection.IterableThreadLocal; + import com.sk89q.jnbt.*; -import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BlockTypes; import java.lang.reflect.Field; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; public class FaweCache { public static final IterableThreadLocal BLOCK_TO_PALETTE = new IterableThreadLocal() { @@ -115,7 +120,7 @@ public class FaweCache { } else if (value instanceof String) { return asTag((String) value); } else if (value instanceof Map) { - return asTag((Map) value); + return asTag((Map) value); } else if (value instanceof Collection) { return asTag((Collection) value); } else if (value instanceof Object[]) { @@ -153,7 +158,7 @@ public class FaweCache { } public static ListTag asTag(Object... values) { - Class clazz = null; + Class clazz = null; List list = new ArrayList<>(values.length); for (Object value : values) { Tag tag = asTag(value); @@ -167,7 +172,7 @@ public class FaweCache { } public static ListTag asTag(Collection values) { - Class clazz = null; + Class clazz = null; List list = new ArrayList<>(values.size()); for (Object value : values) { Tag tag = asTag(value); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/command/AnvilCommands.java b/worldedit-core/src/main/java/com/boydti/fawe/command/AnvilCommands.java index c1430dab8..26e19a352 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/command/AnvilCommands.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/command/AnvilCommands.java @@ -1,10 +1,12 @@ package com.boydti.fawe.command; -import com.boydti.fawe.Fawe; import com.boydti.fawe.FaweAPI; -import com.boydti.fawe.FaweCache; import com.boydti.fawe.config.BBC; -import com.boydti.fawe.jnbt.anvil.*; +import com.boydti.fawe.jnbt.anvil.MCAClipboard; +import com.boydti.fawe.jnbt.anvil.MCAFile; +import com.boydti.fawe.jnbt.anvil.MCAFilter; +import com.boydti.fawe.jnbt.anvil.MCAFilterCounter; +import com.boydti.fawe.jnbt.anvil.MCAQueue; import com.boydti.fawe.jnbt.anvil.filters.*; import com.boydti.fawe.jnbt.anvil.history.IAnvilHistory; import com.boydti.fawe.jnbt.anvil.history.NullAnvilHistory; @@ -14,17 +16,18 @@ import com.boydti.fawe.object.RegionWrapper; import com.boydti.fawe.object.RunnableVal4; import com.boydti.fawe.object.changeset.AnvilHistory; import com.boydti.fawe.object.clipboard.remap.ClipboardRemapper; -import com.boydti.fawe.object.mask.FaweBlockMatcher; import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.SetQueue; -import com.boydti.fawe.util.StringMan; + +import static com.google.common.base.Preconditions.checkNotNull; import com.sk89q.minecraft.util.commands.Command; import com.sk89q.minecraft.util.commands.CommandPermissions; -import com.sk89q.worldedit.*; -import com.sk89q.worldedit.world.block.BlockState; +import com.sk89q.worldedit.EditSession; +import com.sk89q.worldedit.LocalSession; +import com.sk89q.worldedit.WorldEdit; +import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.function.pattern.Pattern; -import com.sk89q.worldedit.function.pattern.RandomPattern; import com.sk89q.worldedit.internal.annotation.Selection; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.CuboidRegion; @@ -36,17 +39,12 @@ import com.sk89q.worldedit.world.biome.BiomeType; import java.io.IOException; import java.io.RandomAccessFile; -import java.util.*; import java.util.function.Consumer; - -import static com.google.common.base.Preconditions.checkNotNull; - -@Command(aliases = {"/anvil"}, desc = "Manipulate billions of blocks: [More Info](https://github.com/boy0001/FastAsyncWorldedit/wiki/Anvil-API)") +@Command(aliases = {"/anvil"}, + desc = "Manipulate billions of blocks: [More Info](https://github.com/boy0001/FastAsyncWorldedit/wiki/Anvil-API)") public class AnvilCommands { - private final WorldEdit worldEdit; - /** * Create a new instance. * @@ -54,7 +52,6 @@ public class AnvilCommands { */ public AnvilCommands(WorldEdit worldEdit) { checkNotNull(worldEdit); - this.worldEdit = worldEdit; } /** @@ -170,19 +167,20 @@ public class AnvilCommands { ) @CommandPermissions("worldedit.anvil.remapall") public void remapall(Player player, String folder) throws WorldEditException { - ClipboardRemapper mapper; ClipboardRemapper.RemapPlatform from; ClipboardRemapper.RemapPlatform to; from = ClipboardRemapper.RemapPlatform.PE; to = ClipboardRemapper.RemapPlatform.PC; RemapFilter filter = new RemapFilter(from, to); RemapFilter result = runWithWorld(player, folder, filter, true); - if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal())); + if (result != null) { + player.print(BBC.VISITOR_BLOCK.format(result.getTotal())); + } } @Command( - aliases = {"deleteallunvisited", "delunvisited" }, + aliases = {"deleteallunvisited", "delunvisited"}, usage = " [file-age=60000]", desc = "Delete all chunks which haven't been occupied", help = "Delete all chunks which haven't been occupied for `age-ticks` (20t = 1s) and \n" + @@ -196,11 +194,13 @@ public class AnvilCommands { public void deleteAllUnvisited(Player player, String folder, int inhabitedTicks, @Optional("60000") int fileDurationMillis) throws WorldEditException { DeleteUninhabitedFilter filter = new DeleteUninhabitedFilter(fileDurationMillis, inhabitedTicks, fileDurationMillis); DeleteUninhabitedFilter result = runWithWorld(player, folder, filter, true); - if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal())); + if (result != null) { + player.print(BBC.VISITOR_BLOCK.format(result.getTotal())); + } } @Command( - aliases = {"deleteallunclaimed", "delallunclaimed" }, + aliases = {"deleteallunclaimed", "delallunclaimed"}, usage = " [file-age=60000]", desc = "(Supports: WG, P2, GP) Delete all chunks which haven't been occupied AND claimed", help = "(Supports: WG, P2, GP) Delete all chunks which aren't claimed AND haven't been occupied for `age-ticks` (20t = 1s) and \n" + @@ -211,12 +211,17 @@ public class AnvilCommands { max = 3 ) @CommandPermissions("worldedit.anvil.deleteallunclaimed") - public void deleteAllUnclaimed(Player player, int inhabitedTicks, @Optional("60000") int fileDurationMillis, @Switch('d') boolean debug) throws WorldEditException { + public void deleteAllUnclaimed(Player player, int inhabitedTicks, @Optional("60000") int fileDurationMillis, @Switch( + 'd') boolean debug) throws WorldEditException { String folder = player.getWorld().getName(); DeleteUnclaimedFilter filter = new DeleteUnclaimedFilter(player.getWorld(), fileDurationMillis, inhabitedTicks, fileDurationMillis); - if (debug) filter.enableDebug(); + if (debug) { + filter.enableDebug(); + } DeleteUnclaimedFilter result = runWithWorld(player, folder, filter, true); - if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal())); + if (result != null) { + player.print(BBC.VISITOR_BLOCK.format(result.getTotal())); + } } @Command( @@ -231,15 +236,20 @@ public class AnvilCommands { max = 3 ) @CommandPermissions("worldedit.anvil.deleteunclaimed") - public void deleteUnclaimed(Player player, EditSession editSession, @Selection Region selection, int inhabitedTicks, @Optional("60000") int fileDurationMillis, @Switch('d') boolean debug) throws WorldEditException { + public void deleteUnclaimed(Player player, EditSession editSession, @Selection Region selection, int inhabitedTicks, @Optional( + "60000") int fileDurationMillis, @Switch('d') boolean debug) throws WorldEditException { DeleteUnclaimedFilter filter = new DeleteUnclaimedFilter(player.getWorld(), fileDurationMillis, inhabitedTicks, fileDurationMillis); - if (debug) filter.enableDebug(); + if (debug) { + filter.enableDebug(); + } DeleteUnclaimedFilter result = runWithSelection(player, editSession, selection, filter); - if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal())); + if (result != null) { + player.print(BBC.VISITOR_BLOCK.format(result.getTotal())); + } } @Command( - aliases = {"deletealloldregions", "deloldreg" }, + aliases = {"deletealloldregions", "deloldreg"}, usage = "