From 7967ef4db48af8bf7f195a5ed4def975a8716a30 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Tue, 30 Jul 2019 07:39:18 +1000 Subject: [PATCH 1/3] ff586011 --- .../src/main/java/com/boydti/fawe/Fawe.java | 2 + .../com/boydti/fawe/command/CFICommands.java | 9 +-- .../com/boydti/fawe/command/FaweParser.java | 3 - .../fawe/object/brush/SplatterBrush.java | 2 +- .../brush/visualization/VisualQueue.java | 2 +- .../fawe/object/schematic/Schematic.java | 20 ++++--- .../sk89q/worldedit/command/ListFilters.java | 10 ++-- .../sk89q/worldedit/command/MaskCommands.java | 8 +-- .../platform/AbstractPlayerActor.java | 3 + .../platform/PlatformCommandManager.java | 3 +- .../clipboard/io/BuiltInClipboardFormat.java | 55 +++---------------- .../clipboard/io/SpongeSchematicReader.java | 4 ++ .../function/block/BlockReplace.java | 2 +- .../function/mask/ExistingBlockMask.java | 2 +- .../function/mask/SolidBlockMask.java | 7 --- .../function/operation/ChangeSetExecutor.java | 6 +- .../sk89q/worldedit/math/BlockVector2.java | 4 ++ .../sk89q/worldedit/math/BlockVector3.java | 2 + .../com/sk89q/worldedit/math/Vector2.java | 2 + .../com/sk89q/worldedit/math/Vector3.java | 2 + .../sk89q/worldedit/regions/CuboidRegion.java | 2 + .../worldedit/regions/CylinderRegion.java | 2 + .../registry/state/EnumProperty.java | 4 +- .../registry/state/IntegerProperty.java | 6 ++ .../sk89q/worldedit/session/PasteBuilder.java | 2 +- 25 files changed, 74 insertions(+), 90 deletions(-) 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 fe772decd..b2a4dd8df 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,7 @@ package com.boydti.fawe; import com.boydti.fawe.beta.implementation.QueueHandler; +import com.boydti.fawe.command.CFICommand; import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.Settings; import com.boydti.fawe.object.FawePlayer; @@ -18,6 +19,7 @@ import com.boydti.fawe.util.WEManager; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.extension.factory.DefaultTransformParser; import com.sk89q.worldedit.extension.platform.Actor; +import com.sk89q.worldedit.extension.platform.PlatformCommandManager; import com.sk89q.worldedit.session.request.Request; import java.io.BufferedReader; import java.io.File; 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 054ada577..bb7083f74 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 @@ -71,13 +71,14 @@ import java.util.function.Consumer; import java.util.function.Function; import java.util.stream.IntStream; import javax.imageio.ImageIO; -import org.checkerframework.checker.nullness.qual.NonNull; + 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.Switch; import org.enginehub.piston.exception.StopExecutionException; import org.enginehub.piston.inject.InjectedValueAccess; +import org.jetbrains.annotations.NotNull; @CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class) public class CFICommands { @@ -154,7 +155,7 @@ public class CFICommands { public void brush(FawePlayer fp) { CFISettings settings = assertSettings(fp); settings.popMessages(fp); - @NonNull Builder msg; + @NotNull Builder msg; if (settings.getGenerator().getImageViewer() != null) { msg = TextComponent.builder("CFI supports using brushes during creation").append(newline()) .append(" - Place the map on a wall of item frames").append(newline()) @@ -811,7 +812,7 @@ public class CFICommands { int biomePriority = gen.getBiomePriority(); //TODO fix this so it can execute commands and show tooltips. - @NonNull Builder builder = TextComponent.builder(">> Current Settings <<").append(newline()) + @NotNull Builder builder = TextComponent.builder(">> Current Settings <<").append(newline()) .append("Randomization ").append("[" + Boolean.toString(rand).toUpperCase() + "]")//.cmdTip("/cfi randomization " + (!rand)) .append(newline()) .append("Mask ").append("[" + mask + "]")//.cmdTip("/cfi mask") @@ -1020,7 +1021,7 @@ public class CFICommands { String snow = "/cfi snow"; //TODO - @NonNull Builder msg = TextComponent.builder(">> Current Settings <<").append(newline()) + @NotNull Builder msg = TextComponent.builder(">> Current Settings <<").append(newline()) .append("Mask ").append(TextComponent.of("[" + mask + "]") .hoverEvent(HoverEvent.showText(TextComponent.of("/cfi mask"))) .clickEvent(ClickEvent.runCommand("/cfi mask"))) diff --git a/worldedit-core/src/main/java/com/boydti/fawe/command/FaweParser.java b/worldedit-core/src/main/java/com/boydti/fawe/command/FaweParser.java index 337636a97..ba4f4b747 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/command/FaweParser.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/command/FaweParser.java @@ -5,7 +5,6 @@ import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extension.input.ParserContext; import com.sk89q.worldedit.internal.registry.InputParser; -import com.sk89q.worldedit.util.command.Dispatcher; import java.util.*; @@ -23,8 +22,6 @@ public abstract class FaweParser extends InputParser { } } - public abstract Dispatcher getDispatcher(); - protected static class ParseEntry { public boolean and; public String input; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SplatterBrush.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SplatterBrush.java index c6b4693d0..0d9fe33c5 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SplatterBrush.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/SplatterBrush.java @@ -41,7 +41,6 @@ public class SplatterBrush extends ScatterBrush { } final int size2 = (int) (size * size); SurfaceMask surface = new SurfaceMask(editSession); - final SolidBlockMask solid = new SolidBlockMask(editSession); RecursiveVisitor visitor = new RecursiveVisitor(vector -> { double dist = vector.distanceSq(position); @@ -51,6 +50,7 @@ public class SplatterBrush extends ScatterBrush { } return false; }, vector -> editSession.setBlock(vector, finalPattern), recursion); + visitor.setMaxBranch(2); visitor.setDirections(Arrays.asList(BreadthFirstSearch.DIAGONAL_DIRECTIONS)); visitor.visit(position); Operations.completeBlindly(visitor); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/VisualQueue.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/VisualQueue.java index de569c5b2..994e17270 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/VisualQueue.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/VisualQueue.java @@ -16,7 +16,7 @@ public class VisualQueue extends SingleThreadIntervalQueue { @Override public void operate(FawePlayer fp) { - LocalSession session = WorldEdit.getInstance().getSessionManager().get(fp.toWorldEditPlayer()); + LocalSession session = fp.getSession(); Player player = fp.getPlayer(); Tool tool = session.getTool(player); if (tool instanceof BrushTool) { 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 index bc58ae29e..29a9ab528 100644 --- 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 @@ -168,15 +168,17 @@ public class Schematic { return editSession; } - public void paste(Extent extent, BlockVector3 to, boolean pasteAir, Transform transform) { - checkNotNull(transform); - Extent source = new BlockTransformExtent(clipboard, transform); - ForwardExtentCopy copy = new ForwardExtentCopy(source, clipboard.getRegion(), - clipboard.getOrigin(), extent, to); - copy.setTransform(transform); - copy.setCopyingBiomes( - !(clipboard instanceof BlockArrayClipboard) || ((BlockArrayClipboard) clipboard).IMP - .hasBiomes()); + 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 instanceof BlockArrayClipboard) || ((BlockArrayClipboard) clipboard).IMP + .hasBiomes()); if (extent instanceof EditSession) { EditSession editSession = (EditSession) extent; Mask sourceMask = editSession.getSourceMask(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ListFilters.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ListFilters.java index 9c6113657..7924d9b49 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ListFilters.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ListFilters.java @@ -48,8 +48,8 @@ public class ListFilters { } @Command( - name = "private", - aliases = {"me", "mine", "local"}, + name = "local", + aliases = {"me", "mine", "private"}, desc = "List your personal schematics" ) public Filter local() { @@ -57,8 +57,8 @@ public class ListFilters { } @Command( - name = "public", - aliases = {"global"}, + name = "global", + aliases = {"public"}, desc = "List public schematics" ) public Filter global() { @@ -76,7 +76,7 @@ public class ListFilters { } @Command( - name = "*", //TODO originally this was left blank but doing so causes a major compilation error + name = "*", //TODO NOT IMPLEMENTED originally this was left blank but doing so causes a major compilation error desc = "wildcard" ) public Filter wildcard(Actor actor, File root, String arg) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/MaskCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/MaskCommands.java index b9bb4a190..89706f114 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/MaskCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/MaskCommands.java @@ -88,8 +88,8 @@ public class MaskCommands { } @Command( - name = "false", - aliases = {"#false"}, + name = "#false", + aliases = {"false"}, desc = "Always false" ) public Mask falseMask(Extent extent) { @@ -97,8 +97,8 @@ public class MaskCommands { } @Command( - name = "true", - aliases = {"#true"}, + name = "#true", + aliases = {"true"}, desc = "Always true" ) public Mask trueMask(Extent extent) { 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 f8b5971b9..30ecc7cef 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 @@ -428,7 +428,10 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { if (typeId.hasBlockType()) { return typeId.getBlockType().getDefaultState().toBaseBlock(); } else { + return BlockTypes.AIR.getDefaultState().toBaseBlock(); // FAWE returns air here + /* throw new NotABlockException(); + */ } } 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 270ddb3cd..4bdb38d74 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 @@ -81,6 +81,7 @@ import com.sk89q.worldedit.command.ToolCommandsRegistration; import com.sk89q.worldedit.command.ToolUtilCommands; import com.sk89q.worldedit.command.ToolUtilCommandsRegistration; import com.sk89q.worldedit.command.TransformCommands; +import com.sk89q.worldedit.command.TransformCommandsRegistration; import com.sk89q.worldedit.command.UtilityCommands; import com.sk89q.worldedit.command.UtilityCommandsRegistration; import com.sk89q.worldedit.command.WorldEditCommands; @@ -690,7 +691,7 @@ public final class PlatformCommandManager { // exceptions without writing a hook into every dispatcher, we need to unwrap these // exceptions and rethrow their converted form, if their is one. try { - task.get(); + Object result = task.get(); } catch (Throwable t) { // Use the exception converter to convert the exception if any of its causes // can be converted, otherwise throw the original exception diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/BuiltInClipboardFormat.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/BuiltInClipboardFormat.java index 9483f0d5b..5ff717636 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/BuiltInClipboardFormat.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/BuiltInClipboardFormat.java @@ -72,27 +72,13 @@ public enum BuiltInClipboardFormat implements ClipboardFormat { @Override public ClipboardWriter getWriter(OutputStream outputStream) throws IOException { - throw new IOException("This format does not support saving"); + throw new IOException("This format does not support saving, use `schem` or `sponge` as format"); // Is more helpful } @Override public boolean isFormat(File file) { - try (NBTInputStream str = new NBTInputStream(new GZIPInputStream(new FileInputStream(file)))) { - NamedTag rootTag = str.readNamedTag(); - if (!rootTag.getName().equals("Schematic")) { - return false; - } - CompoundTag schematicTag = (CompoundTag) rootTag.getTag(); - - // Check - Map schematic = schematicTag.getValue(); - if (!schematic.containsKey("Materials")) { - return false; - } - } catch (Exception e) { - return false; - } - return true; + String name = file.getName().toLowerCase(); + return name.endsWith(".schematic") || name.endsWith(".mcedit") || name.endsWith(".mce"); } }, SPONGE_SCHEMATIC("sponge", "schem") { @@ -127,23 +113,8 @@ public enum BuiltInClipboardFormat implements ClipboardFormat { @Override public boolean isFormat(File file) { - try (NBTInputStream str = new NBTInputStream(new GZIPInputStream(new FileInputStream(file)))) { - NamedTag rootTag = str.readNamedTag(); - if (!rootTag.getName().equals("Schematic")) { - return false; - } - CompoundTag schematicTag = (CompoundTag) rootTag.getTag(); - - // Check - Map schematic = schematicTag.getValue(); - if (!schematic.containsKey("Version")) { - return false; - } - } catch (Exception e) { - return false; - } - - return true; + String name = file.getName().toLowerCase(); + return name.endsWith(".schem") || name.endsWith(".sponge"); } }, @@ -175,20 +146,8 @@ public enum BuiltInClipboardFormat implements ClipboardFormat { @Override public boolean isFormat(File file) { - try (NBTInputStream str = new NBTInputStream(new GZIPInputStream(new FileInputStream(file)))) { - NamedTag rootTag = str.readNamedTag(); - CompoundTag structureTag = (CompoundTag) rootTag.getTag(); - - // Check - Map structure = structureTag.getValue(); - if (!structure.containsKey("DataVersion")) { - return false; - } - } catch (Exception e) { - return false; - } - - return true; + String name = file.getName().toLowerCase(); + return name.endsWith(".nbt"); } }, diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicReader.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicReader.java index f2195b37c..ae1b7a740 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicReader.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicReader.java @@ -280,6 +280,7 @@ public class SpongeSchematicReader extends NBTSchematicReader { return clipboard; } + /* private Clipboard readVersion2(BlockArrayClipboard version1, CompoundTag schematicTag) throws IOException { Map schematic = schematicTag.getValue(); if (schematic.containsKey("BiomeData")) { @@ -290,6 +291,7 @@ public class SpongeSchematicReader extends NBTSchematicReader { } return version1; } + */ private void readBiomes(BlockArrayClipboard clipboard, Map schematic) throws IOException { ByteArrayTag dataTag = requireTag(schematic, "BiomeData", ByteArrayTag.class); @@ -349,6 +351,7 @@ public class SpongeSchematicReader extends NBTSchematicReader { } } + /* private void readEntities(BlockArrayClipboard clipboard, Map schematic) throws IOException { List entList = requireTag(schematic, "Entities", ListTag.class).getValue(); if (entList.isEmpty()) { @@ -379,6 +382,7 @@ public class SpongeSchematicReader extends NBTSchematicReader { } } } + */ @Override public void close() throws IOException { inputStream.close(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/block/BlockReplace.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/block/BlockReplace.java index 00fbcd553..57f9d5aff 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/block/BlockReplace.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/block/BlockReplace.java @@ -50,7 +50,7 @@ public class BlockReplace implements RegionFunction { @Override public boolean apply(BlockVector3 position) throws WorldEditException { - return extent.setBlock(position, pattern.apply(position)); + return pattern.apply(extent, position, position); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExistingBlockMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExistingBlockMask.java index e2dd4eda3..9c10590d9 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExistingBlockMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/ExistingBlockMask.java @@ -40,7 +40,7 @@ public class ExistingBlockMask extends AbstractExtentMask { @Override public boolean test(BlockVector3 vector) { - return !getExtent().getBlock(vector).getBlockType().getMaterial().isAir(); + return !vector.getBlock(getExtent()).getMaterial().isAir(); } @Nullable diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SolidBlockMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SolidBlockMask.java index 44c5f8e66..40f691280 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SolidBlockMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/SolidBlockMask.java @@ -31,13 +31,6 @@ public class SolidBlockMask extends BlockMask { add(state -> state.getMaterial().isMovementBlocker()); } - @Override - public boolean test(BlockVector3 vector) { - Extent extent = getExtent(); - BlockState block = extent.getBlock(vector); - return block.getBlockType().getMaterial().isMovementBlocker(); - } - @Nullable @Override public Mask2D toMask2D() { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/ChangeSetExecutor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/ChangeSetExecutor.java index aecf1302a..65e56707c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/ChangeSetExecutor.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/ChangeSetExecutor.java @@ -66,11 +66,13 @@ public class ChangeSetExecutor implements Operation { @Override public Operation resume(RunContext run) throws WorldEditException { - while (iterator.hasNext()) { - Change change = iterator.next(); + Change change = iterator.next(); if (type == Type.UNDO) { + while (iterator.hasNext()) { change.undo(context); + } } else { + while (iterator.hasNext()) { change.redo(context); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector2.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector2.java index 3385bef50..507293cd4 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector2.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector2.java @@ -54,6 +54,7 @@ public class BlockVector2 { } public static BlockVector2 at(int x, int z) { + /* unnecessary switch (x) { case 0: if (z == 0) { @@ -66,11 +67,14 @@ public class BlockVector2 { } break; } + */ return new BlockVector2(x, z); } protected int x, z; + protected BlockVector2(){} + /** * Construct an instance. * diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector3.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector3.java index d87eafb60..77b5c7ba8 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector3.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector3.java @@ -48,6 +48,7 @@ public abstract class BlockVector3 { } public static BlockVector3 at(int x, int y, int z) { + /* unnecessary // switch for efficiency on typical cases // in MC y is rarely 0/1 on selections switch (y) { @@ -62,6 +63,7 @@ public abstract class BlockVector3 { } break; } + */ return new BlockVector3Imp(x, y, z); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/Vector2.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/Vector2.java index 8d5f61d23..6757e8766 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/Vector2.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/Vector2.java @@ -33,6 +33,7 @@ public class Vector2 { public static final Vector2 ONE = new Vector2(1, 1); public static Vector2 at(double x, double z) { + /* Unnecessary int xTrunc = (int) x; switch (xTrunc) { case 0: @@ -46,6 +47,7 @@ public class Vector2 { } break; } + */ return new Vector2(x, z); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/Vector3.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/Vector3.java index ede6a549b..c14cb7cd9 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/Vector3.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/Vector3.java @@ -39,6 +39,7 @@ public abstract class Vector3 { public static final Vector3 ONE = Vector3.at(1, 1, 1); public static Vector3 at(double x, double y, double z) { + /* Unnecessary // switch for efficiency on typical cases // in MC y is rarely 0/1 on selections int yTrunc = (int) y; @@ -54,6 +55,7 @@ public abstract class Vector3 { } break; } + */ return new Vector3Impl(x, y, z); } 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 1f2f328c0..ac268256c 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 @@ -392,6 +392,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { return chunks; } + /* Slow and unnecessary @Override public boolean contains(BlockVector3 position) { BlockVector3 min = getMinimumPoint(); @@ -399,6 +400,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { return position.containedWithin(min, max); } + */ @Override public boolean contains(int x, int y, int z) { 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 754aaf4d3..4e3a9a6e0 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 @@ -296,6 +296,7 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion { /** * Checks to see if a point is inside this region. */ + /* Slow and unnecessary @Override public boolean contains(BlockVector3 position) { final int blockY = position.getBlockY(); @@ -305,6 +306,7 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion { return position.toBlockVector2().subtract(center).toVector2().divide(radius).lengthSq() <= 1; } + */ /** * Checks to see if a point is inside this region. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/EnumProperty.java b/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/EnumProperty.java index ba95e10d0..668424034 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/EnumProperty.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/EnumProperty.java @@ -26,7 +26,7 @@ import javax.annotation.Nullable; public class EnumProperty extends AbstractProperty { - private Map offsets = new HashMap<>(); + private Map offsets = new HashMap<>(); public EnumProperty(final String name, final List values) { this(name, values, 0); @@ -48,7 +48,7 @@ public class EnumProperty extends AbstractProperty { @Override public int getIndexFor(CharSequence string) throws IllegalArgumentException { - Integer value = offsets.get(string.toString()); + Integer value = offsets.get(string); return value == null ? -1 : value; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/IntegerProperty.java b/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/IntegerProperty.java index ad0095b00..225846eff 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/IntegerProperty.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/IntegerProperty.java @@ -67,10 +67,16 @@ public class IntegerProperty extends AbstractProperty { public Integer getValueFor(String string) { try { int val = Integer.parseInt(string); + /* //It shouldn't matter if this check is slow. It's an important check if (!getValues().contains(val)) { throw new IllegalArgumentException("Invalid int value: " + string + ". Must be in " + getValues().toString()); } + */ + // An exception will get thrown anyway if the property doesn't exist, so it's not really that important. Anyway, we can check the array instead of the string list + if (val > 0 && val >= map.length) { + throw new IllegalArgumentException("Invalid int value: " + string + ". Must be in " + getValues().toString()); + } return val; } catch (NumberFormatException e) { throw new IllegalArgumentException("Invalid int value: " + string + ". Not an int."); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/session/PasteBuilder.java b/worldedit-core/src/main/java/com/sk89q/worldedit/session/PasteBuilder.java index 28cc64520..91cb29b06 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/session/PasteBuilder.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/session/PasteBuilder.java @@ -151,7 +151,7 @@ public class PasteBuilder { copy.setFilterFunction(this.canApply); } if (ignoreAirBlocks) { - sourceMask = new MaskIntersection(sourceMask, new ExistingBlockMask(clipboard)); + sourceMask = MaskIntersection.of(sourceMask, new ExistingBlockMask(clipboard)); } if (targetExtent instanceof EditSession) { Mask esSourceMask = ((EditSession) targetExtent).getSourceMask(); From cdb9abc1176813c0225b2f60133f2aaab76cf551 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Tue, 30 Jul 2019 07:44:19 +1000 Subject: [PATCH 2/3] 9a4473b73f3f5be9585a339c05912fef9868a0b9 --- .../fawe/bukkit/beta/BukkitChunkHolder.java | 4 ++-- .../com/boydti/fawe/beta/ChunkFilterBlock.java | 2 +- .../main/java/com/boydti/fawe/beta/Flood.java | 18 +++++++++--------- .../implementation/holder/ChunkHolder.java | 18 +++++++++--------- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/beta/BukkitChunkHolder.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/beta/BukkitChunkHolder.java index ccdd3da81..64c0fdc87 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/beta/BukkitChunkHolder.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/beta/BukkitChunkHolder.java @@ -41,8 +41,8 @@ import java.util.concurrent.Future; public class BukkitChunkHolder> extends ChunkHolder { @Override - public void init(final IQueueExtent extent, final int x, final int z) { - super.init(extent, x, z); + public void init(final IQueueExtent extent, final int chunkX, final int chunkZ) { + super.init(extent, chunkX, chunkZ); } @Override diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/ChunkFilterBlock.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/ChunkFilterBlock.java index f34d6a3a6..2e0de38c4 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/ChunkFilterBlock.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/ChunkFilterBlock.java @@ -8,7 +8,7 @@ public abstract class ChunkFilterBlock extends SimpleFilterBlock { super(extent); } - public abstract ChunkFilterBlock init(int x, int z, IChunkGet chunk); + public abstract ChunkFilterBlock init(int chunkX, int chunkZ, IChunkGet chunk); public abstract ChunkFilterBlock init(final IChunkGet iget, final IChunkSet iset, final int layer); 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 e8773e5c5..377edfa34 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 @@ -20,9 +20,9 @@ public class Flood { private int[][] queues; private long[][] visits; - private int x; - private int y; - private int z; + private int chunkX; + private int chunkYLayer; + private int chunkZ; private ConcurrentLinkedQueue queuePool = new ConcurrentLinkedQueue<>(); private final Long2ObjectLinkedOpenHashMap chunkVisits; @@ -52,10 +52,10 @@ public class Flood { } } - private void init(int x, int y, int z) { - this.x = x; - this.y = y; - this.z = z; + private void init(int chunkX, int chunkYLayer, int chunkZ) { + this.chunkX = chunkX; + this.chunkYLayer = chunkYLayer; + this.chunkZ = chunkZ; } public void start(int x, int y, int z) { @@ -154,8 +154,8 @@ public class Flood { visit = visits[sectionIndex]; queue = queues[sectionIndex]; if (visit == null || queue == null) { - long pair = MathMan.pairInt(this.x + nextX, this.z + nextZ); - int layer = this.y + nextY; + long pair = MathMan.pairInt(this.chunkX + nextX, this.chunkZ + nextZ); + int layer = this.chunkYLayer + nextY; if (layer < 0 || layer > 15) { continue; } 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/holder/ChunkHolder.java index dd889fd80..2e8c320cb 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/holder/ChunkHolder.java @@ -28,8 +28,8 @@ public abstract class ChunkHolder implements IChunk, Supplier { private IChunkSet set; private IBlockDelegate delegate; private IQueueExtent extent; - private int x; - private int z; + private int chunkX; + private int chunkZ; public ChunkHolder() { this.delegate = NULL; @@ -62,7 +62,7 @@ public abstract class ChunkHolder implements IChunk, Supplier { if (region != null) { region.filter(this, filter, block, get, set); } else { - block = block.init(x, z, get); + block = block.init(chunkX, chunkZ, get); for (int layer = 0; layer < 16; layer++) { if (!get.hasSection(layer) || !filter.appliesLayer(this, layer)) continue; block.init(get, set, layer); @@ -119,7 +119,7 @@ public abstract class ChunkHolder implements IChunk, Supplier { private IChunkGet newGet() { if (extent instanceof SingleThreadQueueExtent) { - IChunkGet newGet = extent.getCachedGet(x, z, this); + IChunkGet newGet = extent.getCachedGet(chunkX, chunkZ, this); if (newGet != null) { return newGet; } @@ -128,10 +128,10 @@ public abstract class ChunkHolder implements IChunk, Supplier { } @Override - public void init(final IQueueExtent extent, final int x, final int z) { + public void init(final IQueueExtent extent, final int chunkX, final int chunkZ) { this.extent = extent; - this.x = x; - this.z = z; + this.chunkX = chunkX; + this.chunkZ = chunkZ; if (set != null) { set.reset(); delegate = SET; @@ -147,12 +147,12 @@ public abstract class ChunkHolder implements IChunk, Supplier { @Override public int getX() { - return x; + return chunkX; } @Override public int getZ() { - return z; + return chunkZ; } @Override From accc62c10bb08a4fcfcd00e12fa9532a9e434be2 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Tue, 30 Jul 2019 07:48:19 +1000 Subject: [PATCH 3/3] 7963b2c9 --- .../java/com/boydti/fawe/beta/CharFilterBlock.java | 10 +++++----- .../main/java/com/boydti/fawe/beta/IDelegateChunk.java | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/CharFilterBlock.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/CharFilterBlock.java index 960b8502a..ea236d5a4 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/CharFilterBlock.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/CharFilterBlock.java @@ -28,12 +28,12 @@ public class CharFilterBlock extends ChunkFilterBlock { } @Override - public final ChunkFilterBlock init(final int x, final int z, final IChunkGet chunk) { + public final ChunkFilterBlock init(final int chunkX, final int chunkZ, final IChunkGet chunk) { this.get = (CharGetBlocks) chunk; - this.X = x; - this.Z = z; - this.xx = x << 4; - this.zz = z << 4; + this.X = chunkX; + this.Z = chunkZ; + this.xx = chunkX << 4; + this.zz = chunkZ << 4; return this; } 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 e4bf6237f..d88896ee8 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 @@ -73,8 +73,8 @@ public interface IDelegateChunk extends IChunk { } @Override - default void init(final IQueueExtent extent, final int x, final int z) { - getParent().init(extent, x, z); + default void init(final IQueueExtent extent, final int chunkX, final int chunkZ) { + getParent().init(extent, chunkX, chunkZ); } @Override