From be5541b61b53fa02335cf8f4355c69163f533855 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Fri, 5 Apr 2019 15:48:41 +1100 Subject: [PATCH] revert some changes --- .../worldedit/bukkit/BukkitBlockRegistry.java | 5 ++-- .../worldedit/command/RegionCommands.java | 2 +- .../worldedit/command/SelectionCommands.java | 2 +- .../sk89q/worldedit/command/ToolCommands.java | 2 +- .../worldedit/command/UtilityCommands.java | 2 +- .../command/tool/brush/CylinderBrush.java | 2 +- .../tool/brush/HollowCylinderBrush.java | 2 +- .../command/tool/brush/HollowSphereBrush.java | 2 +- .../command/tool/brush/SphereBrush.java | 2 +- .../pattern/BlockCategoryPatternParser.java | 4 ++-- .../pattern/RandomStatePatternParser.java | 2 +- .../pattern/SingleBlockPatternParser.java | 2 +- .../function/generator/FloraGenerator.java | 12 +++++----- .../generator/GardenPatchGenerator.java | 2 +- .../sk89q/worldedit/math/BlockVector2.java | 5 +--- .../sk89q/worldedit/math/BlockVector3.java | 6 +---- .../com/sk89q/worldedit/math/Vector2.java | 2 +- .../com/sk89q/worldedit/math/Vector3.java | 24 ++++--------------- 18 files changed, 29 insertions(+), 51 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockRegistry.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockRegistry.java index fcf2fd25d..62f95d000 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockRegistry.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockRegistry.java @@ -84,8 +84,9 @@ public class BukkitBlockRegistry extends BundledBlockRegistry { @Nullable @Override public Map> getProperties(BlockType blockType) { - if (WorldEditPlugin.getInstance().getBukkitImplAdapter() != null) { - return WorldEditPlugin.getInstance().getBukkitImplAdapter().getProperties(blockType); + BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter(); + if (adapter != null) { + return adapter.getProperties(blockType); } return super.getProperties(blockType); } 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 a01b9a8a0..ac132fe11 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 @@ -300,7 +300,7 @@ public class RegionCommands extends MethodCommands { @Command( aliases = { "/replace", "/re", "/rep" }, - usage = "[from-block] ", + usage = "[from-mask] ", desc = "Replace all blocks in the selection with another", flags = "f", min = 1, diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java index f32c823be..91c6e27eb 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java @@ -669,7 +669,7 @@ public class SelectionCommands { @Command( aliases = {"/count"}, - usage = "", + usage = "", desc = "Counts the number of a certain type of block", flags = "d", min = 1, diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolCommands.java index 0b2db093b..2d9e6c62e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolCommands.java @@ -104,7 +104,7 @@ public class ToolCommands { @Command( aliases = {"repl"}, - usage = "", + usage = "", desc = "Block replacer tool", min = 1, max = 1 diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java index 1d8e2b84d..27448953a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java @@ -372,7 +372,7 @@ public class UtilityCommands extends MethodCommands { @Command( aliases = {"/removenear", "removenear"}, - usage = " [size]", + usage = " [size]", desc = "Remove blocks near you.", min = 1, max = 2 diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/CylinderBrush.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/CylinderBrush.java index 12a663ed3..d1ef66637 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/CylinderBrush.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/CylinderBrush.java @@ -37,7 +37,7 @@ public class CylinderBrush implements Brush { @Override public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException { if (pattern == null) { - pattern = new BlockPattern(BlockTypes.COBBLESTONE.getDefaultState()); + pattern = (BlockTypes.COBBLESTONE.getDefaultState()); } editSession.makeCylinder(position, pattern, size, size, height, true); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/HollowCylinderBrush.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/HollowCylinderBrush.java index dbf959e1b..d96a44819 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/HollowCylinderBrush.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/HollowCylinderBrush.java @@ -37,7 +37,7 @@ public class HollowCylinderBrush implements Brush { @Override public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException { if (pattern == null) { - pattern = new BlockPattern(BlockTypes.COBBLESTONE.getDefaultState()); + pattern = (BlockTypes.COBBLESTONE.getDefaultState()); } editSession.makeCylinder(position, pattern, size, size, height, false); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/HollowSphereBrush.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/HollowSphereBrush.java index 0e89b3c16..bbba333b3 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/HollowSphereBrush.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/HollowSphereBrush.java @@ -31,7 +31,7 @@ public class HollowSphereBrush implements Brush { @Override public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException { if (pattern == null) { - pattern = new BlockPattern(BlockTypes.COBBLESTONE.getDefaultState()); + pattern = (BlockTypes.COBBLESTONE.getDefaultState()); } editSession.makeSphere(position, pattern, size, size, size, false); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/SphereBrush.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/SphereBrush.java index d8028f2ae..07e852da6 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/SphereBrush.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/SphereBrush.java @@ -31,7 +31,7 @@ public class SphereBrush implements Brush { @Override public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException { if (pattern == null) { - pattern = new BlockPattern(BlockTypes.COBBLESTONE.getDefaultState()); + pattern = (BlockTypes.COBBLESTONE.getDefaultState()); } editSession.makeSphere(position, pattern, size, size, size, true); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/BlockCategoryPatternParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/BlockCategoryPatternParser.java index b2e9672f5..9cc922368 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/BlockCategoryPatternParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/BlockCategoryPatternParser.java @@ -69,10 +69,10 @@ public class BlockCategoryPatternParser extends InputParser { if (anyState) { blocks.stream().flatMap(blockType -> blockType.getAllStates().stream()).forEach(state -> - randomPattern.add(new BlockPattern(state), 1.0)); + randomPattern.add((state), 1.0)); } else { for (BlockType blockType : blocks) { - randomPattern.add(new BlockPattern(blockType.getDefaultState()), 1.0); + randomPattern.add((blockType.getDefaultState()), 1.0); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/RandomStatePatternParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/RandomStatePatternParser.java index 9eb54eebe..f2d8ad383 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/RandomStatePatternParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/RandomStatePatternParser.java @@ -44,7 +44,7 @@ public class RandomStatePatternParser extends InputParser { context.setPreferringWildcard(wasFuzzy); if (block.getStates().size() == block.getBlockType().getPropertyMap().size()) { // they requested random with *, but didn't leave any states empty - simplify - return new BlockPattern(block); + return (block); } else { return null; // only should happen if parseLogic changes } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/SingleBlockPatternParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/SingleBlockPatternParser.java index e71530a2e..3ecf3a9ce 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/SingleBlockPatternParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/SingleBlockPatternParser.java @@ -34,7 +34,7 @@ public class SingleBlockPatternParser extends InputParser { @Override public Pattern parseFromInput(String input, ParserContext context) throws InputParseException { - return new BlockPattern(worldEdit.getBlockFactory().parseFromInput(input, context)); + return (worldEdit.getBlockFactory().parseFromInput(input, context)); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/FloraGenerator.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/FloraGenerator.java index 602c07f56..ef97efcae 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/FloraGenerator.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/FloraGenerator.java @@ -84,9 +84,9 @@ public class FloraGenerator implements RegionFunction { */ public static Pattern getDesertPattern() { RandomPattern pattern = new RandomPattern(); - pattern.add(new BlockPattern(BlockTypes.DEAD_BUSH.getDefaultState()), 30); - pattern.add(new BlockPattern(BlockTypes.CACTUS.getDefaultState()), 20); - pattern.add(new BlockPattern(BlockTypes.AIR.getDefaultState()), 300); + pattern.add((BlockTypes.DEAD_BUSH.getDefaultState()), 30); + pattern.add((BlockTypes.CACTUS.getDefaultState()), 20); + pattern.add((BlockTypes.AIR.getDefaultState()), 300); return pattern; } @@ -97,9 +97,9 @@ public class FloraGenerator implements RegionFunction { */ public static Pattern getTemperatePattern() { RandomPattern pattern = new RandomPattern(); - pattern.add(new BlockPattern(BlockTypes.GRASS.getDefaultState()), 300); - pattern.add(new BlockPattern(BlockTypes.POPPY.getDefaultState()), 5); - pattern.add(new BlockPattern(BlockTypes.DANDELION.getDefaultState()), 5); + pattern.add((BlockTypes.GRASS.getDefaultState()), 300); + pattern.add((BlockTypes.POPPY.getDefaultState()), 5); + pattern.add((BlockTypes.DANDELION.getDefaultState()), 5); return pattern; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/GardenPatchGenerator.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/GardenPatchGenerator.java index cec89ca16..da52bb416 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/GardenPatchGenerator.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/GardenPatchGenerator.java @@ -208,6 +208,6 @@ public class GardenPatchGenerator implements RegionFunction { * @return a melon pattern */ public static Pattern getMelonPattern() { - return new BlockPattern(BlockTypes.MELON.getDefaultState()); + return (BlockTypes.MELON.getDefaultState()); } } 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 c2e6cf904..4a6d8d27b 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 @@ -564,10 +564,7 @@ public class BlockVector2 { @Override public int hashCode() { - int hash = 17; - hash = 31 * hash + Integer.hashCode(x); - hash = 31 * hash + Integer.hashCode(z); - return hash; + return (x << 16) ^ z; } @Override 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 0d6447ceb..f465f4142 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 @@ -629,11 +629,7 @@ public class BlockVector3 { @Override public int hashCode() { - int hash = 17; - hash = 31 * hash + Integer.hashCode(x); - hash = 31 * hash + Integer.hashCode(y); - hash = 31 * hash + Integer.hashCode(z); - return hash; + return (x ^ (z << 12)) ^ (y << 24); } @Override 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 001fe15ce..86ff8857f 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 @@ -491,7 +491,7 @@ public class Vector2 { @Override public int hashCode() { - return ((int) getX() ^ ((int) getZ() << 16)); + return (((int) x) << 16) ^ ((int) z); } @Override 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 e5157e939..5d69f7c9d 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 @@ -40,21 +40,6 @@ public class Vector3 { public static final Vector3 ONE = new Vector3(1, 1, 1); public static Vector3 at(double x, double y, double z) { - // switch for efficiency on typical cases - // in MC y is rarely 0/1 on selections - int yTrunc = (int) y; - switch (yTrunc) { - case 0: - if (x == 0 && y == 0 && z == 0) { - return ZERO; - } - break; - case 1: - if (x == 1 && y == 1 && z == 1) { - return ONE; - } - break; - } return new Vector3(x, y, z); } @@ -647,15 +632,14 @@ public class Vector3 { @Override public int hashCode() { - int hash = 17; - hash = 31 * hash + Double.hashCode(x); - hash = 31 * hash + Double.hashCode(y); - hash = 31 * hash + Double.hashCode(z); - return hash; + return (((int) x) ^ (((int) z) << 12)) ^ (((int) y) << 24); } @Override public String toString() { + String x = (getX() == getBlockX() ? "" + getBlockX() : "" + getX()); + String y = (getY() == getBlockY() ? "" + getBlockY() : "" + getY()); + String z = (getZ() == getBlockZ() ? "" + getBlockZ() : "" + getZ()); return "(" + x + ", " + y + ", " + z + ")"; }