From 699783ba725bd40365d53457896384af3f5007a9 Mon Sep 17 00:00:00 2001 From: matt <4009945+MattBDev@users.noreply.github.com> Date: Thu, 28 Mar 2019 15:02:37 -0400 Subject: [PATCH] Another selective merge --- .../src/main/java/com/boydti/fawe/IFawe.java | 43 +- .../com/boydti/fawe/util/chat/Message.java | 2 +- .../boydti/fawe/util/chat/UsageMessage.java | 12 +- .../com/boydti/fawe/util/gui/FormBuilder.java | 31 -- .../java/com/sk89q/worldedit/EditSession.java | 310 +++++++-------- .../worldedit/command/ClipboardCommands.java | 14 +- .../worldedit/command/SchematicCommands.java | 2 +- .../worldedit/command/UtilityCommands.java | 368 +++--------------- .../extension/platform/CommandManager.java | 47 +-- .../function/pattern/BlockPattern.java | 20 +- .../parametric/AParametricCallable.java | 2 - .../worldedit/world/block/BaseBlock.java | 14 +- .../worldedit/world/block/BlockState.java | 7 - .../world/block/BlockStateHolder.java | 14 +- 14 files changed, 260 insertions(+), 626 deletions(-) delete mode 100644 worldedit-core/src/main/java/com/boydti/fawe/util/gui/FormBuilder.java 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 5708ee912..ecba46a2f 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/IFawe.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/IFawe.java @@ -6,63 +6,60 @@ import com.boydti.fawe.object.FaweQueue; import com.boydti.fawe.regions.FaweMaskManager; import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.util.cui.CUI; -import com.boydti.fawe.util.gui.FormBuilder; import com.boydti.fawe.util.image.ImageViewer; import com.sk89q.worldedit.world.World; + import java.io.File; import java.util.Collection; import java.util.UUID; public interface IFawe { - public void debug(final String s); + void debug(final String s); - public File getDirectory(); + File getDirectory(); - public void setupCommand(final String label, final FaweCommand cmd); + void setupCommand(final String label, final FaweCommand cmd); - public FawePlayer wrap(final Object obj); + FawePlayer wrap(final Object obj); - public void setupVault(); + void setupVault(); - public TaskManager getTaskManager(); + TaskManager getTaskManager(); - public FaweQueue getNewQueue(World world, boolean fast); + FaweQueue getNewQueue(World world, boolean fast); - public FaweQueue getNewQueue(String world, boolean fast); + FaweQueue getNewQueue(String world, boolean fast); - public String getWorldName(World world); + String getWorldName(World world); - public Collection getMaskManagers(); + Collection getMaskManagers(); - public void startMetrics(); + void startMetrics(); default CUI getCUI(FawePlayer player) { return null; } default ImageViewer getImageViewer(FawePlayer player) { return null; } - public default void registerPacketListener() {} + default void registerPacketListener() {} default int getPlayerCount() { return Fawe.get().getCachedPlayers().size(); } - public String getPlatformVersion(); + String getPlatformVersion(); - public boolean isOnlineMode(); + boolean isOnlineMode(); - public String getPlatform(); + String getPlatform(); - public UUID getUUID(String name); + UUID getUUID(String name); - public String getName(UUID uuid); + String getName(UUID uuid); - public Object getBlocksHubApi(); + Object getBlocksHubApi(); - public default String getDebugInfo() { + default String getDebugInfo() { return ""; } - public default FormBuilder getFormBuilder() { - return null; - } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/chat/Message.java b/worldedit-core/src/main/java/com/boydti/fawe/util/chat/Message.java index b96444ac6..46a74b7f1 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/chat/Message.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/chat/Message.java @@ -55,7 +55,7 @@ public class Message { return text(caption.format(args)); } - public Message text(Object text) { + public Message text(java.io.Serializable text) { Fawe.get().getChatManager().text(this, BBC.color(Objects.toString(text))); return this; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/chat/UsageMessage.java b/worldedit-core/src/main/java/com/boydti/fawe/util/chat/UsageMessage.java index 3c187360d..313bb6275 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/chat/UsageMessage.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/chat/UsageMessage.java @@ -17,7 +17,6 @@ import com.sk89q.worldedit.util.command.binding.Range; import com.sk89q.worldedit.util.command.parametric.ParameterData; import java.lang.reflect.Type; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import javax.annotation.Nullable; @@ -58,7 +57,7 @@ public class UsageMessage extends Message { String prefix = !commandString.isEmpty() ? commandString + " " : ""; List list = new ArrayList<>(dispatcher.getCommands()); - Collections.sort(list, new PrimaryAliasComparator(CommandManager.COMMAND_CLEAN_PATTERN)); + list.sort(new PrimaryAliasComparator(CommandManager.COMMAND_CLEAN_PATTERN)); for (CommandMapping mapping : list) { boolean perm = locals == null || mapping.getCallable().testPermission(locals); @@ -110,7 +109,6 @@ public class UsageMessage extends Message { StringBuilder tooltip = new StringBuilder(); String command = null; - String webpage = null; tooltip.append("Name: " + param.getName()); if (param instanceof ParameterData) { @@ -129,23 +127,21 @@ public class UsageMessage extends Message { if (type instanceof Class) { Link link = (Link) ((Class) type).getAnnotation(Link.class); if (link != null) { - if (link.value().startsWith("http")) webpage = link.value(); - else command = Commands.getAlias(link.clazz(), link.value()); + command = Commands.getAlias(link.clazz(), link.value()); } } } tooltip.append("\nOptional: " + (param.isOptional() || param.isValueFlag())); - if (param.getDefaultValue() != null && param.getDefaultValue().length >= 0) { + if (param.getDefaultValue() != null) { tooltip.append("\nDefault: " + param.getDefaultValue()[0]); } else if (argStr.contains("=")) { tooltip.append("\nDefault: " + argStr.split("[=|\\]|>]")[1]); } - if (command != null || webpage != null) { + if (command != null) { tooltip.append("\nClick for more info"); } tooltip(tooltip.toString()); if (command != null) command(command); - if (webpage != null) link(webpage); } newline(); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/gui/FormBuilder.java b/worldedit-core/src/main/java/com/boydti/fawe/util/gui/FormBuilder.java deleted file mode 100644 index 8897d558c..000000000 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/gui/FormBuilder.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.boydti.fawe.util.gui; - -import com.boydti.fawe.object.FawePlayer; -import java.net.URL; -import java.util.Map; -import java.util.function.Consumer; -import javax.annotation.Nullable; - -public interface FormBuilder { - FormBuilder setTitle(String text); - - FormBuilder setIcon(URL icon); - - FormBuilder addButton(String text, @Nullable URL image); - - FormBuilder addDropdown(String text, int def, String... options); - - FormBuilder addInput(String text, String placeholder, String def); - - FormBuilder addLabel(String text); - - FormBuilder addSlider(String text, double min, double max, int step, double def); - - FormBuilder addStepSlider(String text, int def, String... options); - - FormBuilder addToggle(String text, boolean def); - - FormBuilder setResponder(Consumer> handler); - - void display(FawePlayer fp); -} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java index 2b2343408..a445423a0 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java @@ -543,7 +543,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, * @return the world */ public World getWorld() { - return this.world; + return world; } /** @@ -612,6 +612,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, * * @return whether the queue is enabled */ + @Deprecated public boolean isQueueEnabled() { return true; } @@ -619,12 +620,14 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, /** * Queue certain types of block for better reproduction of those blocks. */ + @Deprecated public void enableQueue() { } /** * Disable the queue. This will close the queue. */ + @Deprecated public void disableQueue() { if (this.isQueueEnabled()) { this.flushQueue(); @@ -967,10 +970,25 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, } public int getHighestTerrainBlock(int x, int z, int minY, int maxY) { + return getHighestTerrainBlock(x, z, minY, maxY, null); + } + + /** + * Returns the highest solid 'terrain' block. + * + * @param x the X coordinate + * @param z the Z coordinate + * @param minY minimal height + * @param maxY maximal height + * @param filter a mask of blocks to consider, or null to consider any solid (movement-blocking) block + * @return height of highest block found or 'minY' + */ + public int getHighestTerrainBlock(int x, int z, int minY, int maxY, Mask filter) { for (int y = maxY; y >= minY; --y) { BlockVector3 pt = BlockVector3.at(x, y, z); - BlockState block = getBlock(pt); - if (block.getBlockType().getMaterial().isMovementBlocker()) { + if (filter == null + ? getBlock(pt).getBlockType().getMaterial().isMovementBlocker() + : filter.test(pt)) { return y; } } @@ -1008,10 +1026,17 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, throw new RuntimeException("New enum entry added that is unhandled here"); } + /** + * Set a block, bypassing both history and block re-ordering. + * + * @param position the position to set the block at + * @param block the block + * @return whether the block changed + */ public > boolean rawSetBlock(BlockVector3 position, B block) { try { return this.bypassAll.setBlock(position, block); - } catch (final WorldEditException e) { + } catch (WorldEditException e) { throw new RuntimeException("Unexpected exception", e); } } @@ -1183,7 +1208,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, * @return the number of changes */ public int size() { - return this.getBlockChangeCount(); + return getBlockChangeCount(); } public void setSize(int size) { @@ -1426,9 +1451,8 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, * @return number of blocks affected * @throws MaxChangedBlocksException thrown if too many blocks are changed */ - @SuppressWarnings("deprecation") - public int fillXZ(final BlockVector3 origin, final BaseBlock block, final double radius, final int depth, final boolean recursive) { - return this.fillXZ(origin, (Pattern) block, radius, depth, recursive); + public int fillXZ(final BlockVector3 origin, BaseBlock block, double radius, int depth, boolean recursive) throws MaxChangedBlocksException { + return fillXZ(origin, (Pattern) block, radius, depth, recursive); } /** * Fills an area recursively in the X/Z directions. @@ -1441,8 +1465,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, * @return number of blocks affected * @throws MaxChangedBlocksException thrown if too many blocks are changed */ - @SuppressWarnings("deprecation") - public int fillXZ(final BlockVector3 origin, final Pattern pattern, final double radius, final int depth, final boolean recursive) { + public int fillXZ(BlockVector3 origin, Pattern pattern, double radius, int depth, boolean recursive) throws MaxChangedBlocksException { checkNotNull(origin); checkNotNull(pattern); checkArgument(radius >= 0, "radius >= 0"); @@ -1457,7 +1480,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, // Masks.negate(new ExistingBlockMask(this))); // Want to replace blocks - final BlockReplace replace = new BlockReplace(EditSession.this, pattern); + BlockReplace replace = new BlockReplace(this, pattern); // Pick how we're going to visit blocks RecursiveVisitor visitor; @@ -1524,7 +1547,6 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, * @return number of blocks affected * @throws MaxChangedBlocksException thrown if too many blocks are changed */ - @SuppressWarnings("deprecation") public int removeNear(final BlockVector3 position, Mask mask, final int apothem) { checkNotNull(position); checkArgument(apothem >= 1, "apothem >= 1"); @@ -1589,8 +1611,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, * @return number of blocks affected * @throws MaxChangedBlocksException thrown if too many blocks are changed */ - @SuppressWarnings("deprecation") - public > int setBlocks(final Region region, final B block) { + public > int setBlocks(final Region region, final B block) throws MaxChangedBlocksException { checkNotNull(region); checkNotNull(block); boolean hasNbt = block instanceof BaseBlock && ((BaseBlock)block).hasNbtData(); @@ -1625,8 +1646,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, * @return number of blocks affected * @throws MaxChangedBlocksException thrown if too many blocks are changed */ - @SuppressWarnings("deprecation") - public int setBlocks(final Region region, final Pattern pattern) { + public int setBlocks(Region region, Pattern pattern) throws MaxChangedBlocksException { checkNotNull(region); checkNotNull(pattern); if (pattern instanceof BlockPattern) { @@ -1844,7 +1864,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, */ public > int overlayCuboidBlocks(Region region, B block) throws MaxChangedBlocksException { checkNotNull(block); - return this.overlayCuboidBlocks(region, (Pattern) (block)); + return overlayCuboidBlocks(region, new BlockPattern(block)); } /** @@ -2100,8 +2120,8 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, * @return number of blocks changed * @throws MaxChangedBlocksException thrown if too many blocks are changed */ - public int makeCylinder(final BlockVector3 pos, final Pattern block, final double radius, final int height, final boolean filled) { - return this.makeCylinder(pos, block, radius, radius, height, filled); + public int makeCylinder(BlockVector3 pos, Pattern block, double radius, int height, boolean filled) throws MaxChangedBlocksException { + return makeCylinder(pos, block, radius, radius, height, filled); } /** @@ -2425,18 +2445,28 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, * @return number of blocks changed * @throws MaxChangedBlocksException thrown if too many blocks are changed */ - public int makePyramid(final BlockVector3 position, final Pattern block, int size, final boolean filled) { - final int height = size; + public int makePyramid(BlockVector3 position, Pattern block, int size, boolean filled) throws MaxChangedBlocksException { + int affected = 0; + int height = size; for (int y = 0; y <= height; ++y) { size--; for (int x = 0; x <= size; ++x) { for (int z = 0; z <= size; ++z) { - if ((filled && (z <= size) && (x <= size)) || (z == size) || (x == size)) { - this.setBlock(position.add(x, y, z), block); - this.setBlock(position.add(-x, y, z), block); - this.setBlock(position.add(x, y, -z), block); - this.setBlock(position.add(-x, y, -z), block); + if ((filled && z <= size && x <= size) || z == size || x == size) { + + if (setBlock(position.add(x, y, z), block)) { + ++affected; + } + if (setBlock(position.add(-x, y, z), block)) { + ++affected; + } + if (setBlock(position.add(x, y, -z), block)) { + ++affected; + } + if (setBlock(position.add(-x, y, -z), block)) { + ++affected; + } } } } @@ -2453,60 +2483,36 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, * @return number of blocks affected * @throws MaxChangedBlocksException thrown if too many blocks are changed */ - public int thaw(BlockVector3 position, final double radius) + public int thaw(BlockVector3 position, double radius) throws MaxChangedBlocksException { int affected = 0; double radiusSq = radius * radius; - final int ox = position.getBlockX(); - final int oy = position.getBlockY(); - final int oz = position.getBlockZ(); - final int ceilRadius = (int) Math.ceil(radius); - for (int x = ox - ceilRadius; x <= (ox + ceilRadius); ++x) { - int dx = x - ox; - int dx2 = dx * dx; - for (int z = oz - ceilRadius; z <= (oz + ceilRadius); ++z) { - int dz = z - oz; - int dz2 = dz * dz; - if (dx2 + dz2 > radiusSq) { + int ox = position.getBlockX(); + int oy = position.getBlockY(); + int oz = position.getBlockZ(); + BlockState air = BlockTypes.AIR.getDefaultState(); + BlockState water = BlockTypes.WATER.getDefaultState(); + int ceilRadius = (int) Math.ceil(radius); + for (int x = ox - ceilRadius; x <= ox + ceilRadius; ++x) { + for (int z = oz - ceilRadius; z <= oz + ceilRadius; ++z) { + if ((BlockVector3.at(x, oy, z)).distanceSq(position) > radiusSq) { continue; } - for (int y = maxY; y >= 1; --y) { - final BlockType type = getBlockType(x, y, z); - switch (type.getResource().toUpperCase()) { - case "ICE": - this.setBlock(x, y, z, BlockTypes.WATER.getDefaultState()); - break; - case "SNOW": - this.setBlock(x, y, z, BlockTypes.AIR.getDefaultState()); - break; - case "CAVE_AIR": - case "VOID_AIR": - case "AIR": + for (int y = world.getMaxY(); y >= 1; --y) { + BlockVector3 pt = BlockVector3.at(x, y, z); + BlockType id = getBlock(pt).getBlockType(); + + if (id == BlockTypes.ICE) { + if (setBlock(pt, water)) { + ++affected; + } + } else if (id == BlockTypes.SNOW) { + if (setBlock(pt, air)) { + ++affected; + } + } else if (id.getMaterial().isAir()) { continue; - default: - break; -// int ceilRadius = (int) Math.ceil(radius); -// for (int x = ox - ceilRadius; x <= ox + ceilRadius; ++x) { -// for (int z = oz - ceilRadius; z <= oz + ceilRadius; ++z) { -// if ((BlockVector3.at(x, oy, z)).distanceSq(position) > radiusSq) { -// continue; -// } -// -// for (int y = world.getMaxY(); y >= 1; --y) { -// BlockVector3 pt = BlockVector3.at(x, y, z); -// BlockType id = getBlock(pt).getBlockType(); -// -// if (id == BlockTypes.ICE) { -// if (setBlock(pt, water)) { -// ++affected; -// } -// } else if (id == BlockTypes.SNOW) { -// if (setBlock(pt, air)) { -// ++affected; -// } -// } else if (id.getMaterial().isAir()) { -// continue; } break; } @@ -2524,83 +2530,55 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, * @return number of blocks affected * @throws MaxChangedBlocksException thrown if too many blocks are changed */ - public int simulateSnow(final BlockVector3 position, final double radius) { + public int simulateSnow(BlockVector3 position, double radius) throws MaxChangedBlocksException { + int affected = 0; + double radiusSq = radius * radius; - final double radiusSq = radius * radius; + int ox = position.getBlockX(); + int oy = position.getBlockY(); + int oz = position.getBlockZ(); - final int ox = position.getBlockX(); - final int oy = position.getBlockY(); - final int oz = position.getBlockZ(); + BlockState ice = BlockTypes.ICE.getDefaultState(); + BlockState snow = BlockTypes.SNOW.getDefaultState(); - final int ceilRadius = (int) Math.ceil(radius); - for (int x = ox - ceilRadius; x <= (ox + ceilRadius); ++x) { - int dx = x - ox; - int dx2 = dx * dx; - for (int z = oz - ceilRadius; z <= (oz + ceilRadius); ++z) { - int dz = z - oz; - int dz2 = dz * dz; - if (dx2 + dz2 > radiusSq) { + int ceilRadius = (int) Math.ceil(radius); + for (int x = ox - ceilRadius; x <= ox + ceilRadius; ++x) { + for (int z = oz - ceilRadius; z <= oz + ceilRadius; ++z) { + if ((BlockVector3.at(x, oy, z)).distanceSq(position) > radiusSq) { continue; } - outer: - for (int y = maxY; y >= 1; --y) { - BlockType type = getBlockType(x, y, z); - switch (type.getResource().toUpperCase()) { - case "AIR": - case "CAVE_AIR": - case "VOID_AIR": - continue; - case "WATER": - this.setBlock(x, y, z, BlockTypes.ICE.getDefaultState()); - break outer; - case "ACACIA_LEAVES": // TODO FIXME get leaves dynamically - case "BIRCH_LEAVES": - case "DARK_OAK_LEAVES": - case "JUNGLE_LEAVES": - case "OAK_LEAVES": - case "SPRUCE_LEAVES": -// int ceilRadius = (int) Math.ceil(radius); -// for (int x = ox - ceilRadius; x <= ox + ceilRadius; ++x) { -// for (int z = oz - ceilRadius; z <= oz + ceilRadius; ++z) { -// if ((BlockVector3.at(x, oy, z)).distanceSq(position) > radiusSq) { -// continue; -// } -// -// for (int y = world.getMaxY(); y >= 1; --y) { -// BlockVector3 pt = BlockVector3.at(x, y, z); -// BlockType id = getBlock(pt).getBlockType(); -// -// if (id.getMaterial().isAir()) { -// continue; -// } -// -// // Ice! -// if (id == BlockTypes.WATER) { -// if (setBlock(pt, ice)) { -// ++affected; -// } -// break; -// } -// -// // Snow should not cover these blocks -// if (id.getMaterial().isTranslucent()) { -// // Add snow on leaves -// if (!BlockCategories.LEAVES.contains(id)) { + for (int y = world.getMaxY(); y >= 1; --y) { + BlockVector3 pt = BlockVector3.at(x, y, z); + BlockType id = getBlock(pt).getBlockType(); + if (id.getMaterial().isAir()) { + continue; + } + // Ice! + if (id == BlockTypes.WATER) { + if (setBlock(pt, ice)) { + ++affected; + } + break; + } + + // Snow should not cover these blocks + if (id.getMaterial().isTranslucent()) { + // Add snow on leaves + if (!BlockCategories.LEAVES.contains(id)) { break; - default: - if (type.getMaterial().isTranslucent()) { - break outer; } } // Too high? - if (y == maxY) { - break outer; + if (y == world.getMaxY()) { + break; } // add snow cover - this.setBlock(x, y + 1, z, BlockTypes.SNOW.getDefaultState()); - break outer; + if (setBlock(pt.add(0, 1, 0), snow)) { + ++affected; + } + break; } } } @@ -3030,22 +3008,22 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, for (int x = minX; x <= maxX; ++x) { for (int y = minY; y <= maxY; ++y) { - this.recurseHollow(region, BlockVector3.at(x, y, minZ), outside); - this.recurseHollow(region, BlockVector3.at(x, y, maxZ), outside); + recurseHollow(region, BlockVector3.at(x, y, minZ), outside); + recurseHollow(region, BlockVector3.at(x, y, maxZ), outside); } } for (int y = minY; y <= maxY; ++y) { for (int z = minZ; z <= maxZ; ++z) { - this.recurseHollow(region, BlockVector3.at(minX, y, z), outside); - this.recurseHollow(region, BlockVector3.at(maxX, y, z), outside); + recurseHollow(region, BlockVector3.at(minX, y, z), outside); + recurseHollow(region, BlockVector3.at(maxX, y, z), outside); } } for (int z = minZ; z <= maxZ; ++z) { for (int x = minX; x <= maxX; ++x) { - this.recurseHollow(region, BlockVector3.at(x, minY, z), outside); - this.recurseHollow(region, BlockVector3.at(x, maxY, z), outside); + recurseHollow(region, BlockVector3.at(x, minY, z), outside); + recurseHollow(region, BlockVector3.at(x, maxY, z), outside); } } @@ -3101,44 +3079,47 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, LocalBlockVectorSet vset = new LocalBlockVectorSet(); boolean notdrawn = true; - final int x1 = pos1.getBlockX(), y1 = pos1.getBlockY(), z1 = pos1.getBlockZ(); - final int x2 = pos2.getBlockX(), y2 = pos2.getBlockY(), z2 = pos2.getBlockZ(); + int x1 = pos1.getBlockX(), y1 = pos1.getBlockY(), z1 = pos1.getBlockZ(); + int x2 = pos2.getBlockX(), y2 = pos2.getBlockY(), z2 = pos2.getBlockZ(); int tipx = x1, tipy = y1, tipz = z1; - final int dx = Math.abs(x2 - x1), dy = Math.abs(y2 - y1), dz = Math.abs(z2 - z1); + int dx = Math.abs(x2 - x1), dy = Math.abs(y2 - y1), dz = Math.abs(z2 - z1); - if ((dx + dy + dz) == 0) { - vset.add(tipx, tipy, tipz); + if (dx + dy + dz == 0) { + vset.add(BlockVector3.at(tipx, tipy, tipz)); notdrawn = false; } - if ((Math.max(Math.max(dx, dy), dz) == dx) && notdrawn) { + if (Math.max(Math.max(dx, dy), dz) == dx && notdrawn) { for (int domstep = 0; domstep <= dx; domstep++) { - tipx = x1 + (domstep * ((x2 - x1) > 0 ? 1 : -1)); - tipy = (int) Math.round(y1 + (((domstep * ((double) dy)) / (dx)) * ((y2 - y1) > 0 ? 1 : -1))); - tipz = (int) Math.round(z1 + (((domstep * ((double) dz)) / (dx)) * ((z2 - z1) > 0 ? 1 : -1))); - vset.add(tipx, tipy, tipz); + tipx = x1 + domstep * (x2 - x1 > 0 ? 1 : -1); + tipy = (int) Math.round(y1 + domstep * ((double) dy) / ((double) dx) * (y2 - y1 > 0 ? 1 : -1)); + tipz = (int) Math.round(z1 + domstep * ((double) dz) / ((double) dx) * (z2 - z1 > 0 ? 1 : -1)); + + vset.add(BlockVector3.at(tipx, tipy, tipz)); } notdrawn = false; } - if ((Math.max(Math.max(dx, dy), dz) == dy) && notdrawn) { + if (Math.max(Math.max(dx, dy), dz) == dy && notdrawn) { for (int domstep = 0; domstep <= dy; domstep++) { - tipy = y1 + (domstep * ((y2 - y1) > 0 ? 1 : -1)); - tipx = (int) Math.round(x1 + (((domstep * ((double) dx)) / (dy)) * ((x2 - x1) > 0 ? 1 : -1))); - tipz = (int) Math.round(z1 + (((domstep * ((double) dz)) / (dy)) * ((z2 - z1) > 0 ? 1 : -1))); + tipy = y1 + domstep * (y2 - y1 > 0 ? 1 : -1); + tipx = (int) Math.round(x1 + domstep * ((double) dx) / ((double) dy) * (x2 - x1 > 0 ? 1 : -1)); + tipz = (int) Math.round(z1 + domstep * ((double) dz) / ((double) dy) * (z2 - z1 > 0 ? 1 : -1)); - vset.add(tipx, tipy, tipz); + vset.add(BlockVector3.at(tipx, tipy, tipz)); } notdrawn = false; } - if ((Math.max(Math.max(dx, dy), dz) == dz) && notdrawn) { + if (Math.max(Math.max(dx, dy), dz) == dz && notdrawn) { for (int domstep = 0; domstep <= dz; domstep++) { - tipz = z1 + (domstep * ((z2 - z1) > 0 ? 1 : -1)); - tipy = (int) Math.round(y1 + (((domstep * ((double) dy)) / (dz)) * ((y2 - y1) > 0 ? 1 : -1))); - tipx = (int) Math.round(x1 + (((domstep * ((double) dx)) / (dz)) * ((x2 - x1) > 0 ? 1 : -1))); - vset.add(tipx, tipy, tipz); + tipz = z1 + domstep * (z2 - z1 > 0 ? 1 : -1); + tipy = (int) Math.round(y1 + domstep * ((double) dy) / ((double) dz) * (y2-y1>0 ? 1 : -1)); + tipx = (int) Math.round(x1 + domstep * ((double) dx) / ((double) dz) * (x2-x1>0 ? 1 : -1)); + + vset.add(BlockVector3.at(tipx, tipy, tipz)); } + notdrawn = false; } Set newVset; if (flat) { @@ -3283,7 +3264,8 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, while (!queue.isEmpty()) { final BlockVector3 current = queue.removeFirst(); - if (this.getBlockType(current).getMaterial().isMovementBlocker()) { + final BlockState block = getBlock(current); + if (block.getBlockType().getMaterial().isMovementBlocker()) { continue; } 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 88d81278d..d5e63ba85 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 @@ -36,8 +36,6 @@ 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.boydti.fawe.util.gui.FormBuilder; -import com.boydti.fawe.wrappers.FakePlayer; import com.sk89q.minecraft.util.commands.*; import com.sk89q.worldedit.*; import static com.google.common.base.Preconditions.checkNotNull; @@ -393,17 +391,7 @@ public class ClipboardCommands extends MethodCommands { e.printStackTrace(); } } - if (Fawe.imp().getPlatform().equalsIgnoreCase("nukkit")) { - FormBuilder form = Fawe.imp().getFormBuilder(); - FawePlayer fp = FawePlayer.wrap(player); - if (form != null && fp != FakePlayer.getConsole().toFawePlayer()) { - form.setTitle("Download Clipboard"); - form.addInput("url:", urlText, urlText); - form.display(fp); - return; - } - } - BBC.DOWNLOAD_LINK.send(player, urlText); + BBC.DOWNLOAD_LINK.send(player, urlText); } } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java index 702c8b516..2ce053148 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java @@ -176,7 +176,7 @@ public class SchematicCommands extends MethodCommands { @CommandPermissions({"worldedit.schematic.remap"}) public void remap(final Player player, final LocalSession session) throws WorldEditException { ClipboardRemapper remapper; - if (Fawe.imp().getPlatform().equalsIgnoreCase("nukkit")) { + if (false) { remapper = new ClipboardRemapper(ClipboardRemapper.RemapPlatform.PC, ClipboardRemapper.RemapPlatform.PE); } else { remapper = new ClipboardRemapper(ClipboardRemapper.RemapPlatform.PE, ClipboardRemapper.RemapPlatform.PC); 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 61f007404..ad3314995 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 @@ -28,22 +28,17 @@ import com.boydti.fawe.config.Settings; import com.boydti.fawe.object.DelegateConsumer; import com.boydti.fawe.object.FaweLimit; import com.boydti.fawe.object.FawePlayer; -import com.boydti.fawe.object.RunnableVal; import com.boydti.fawe.object.RunnableVal3; import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.StringMan; import com.boydti.fawe.util.chat.Message; import com.boydti.fawe.util.chat.UsageMessage; -import com.boydti.fawe.util.gui.FormBuilder; import com.boydti.fawe.util.image.ImageUtil; import com.sk89q.minecraft.util.commands.*; -import com.sk89q.worldedit.*; -import com.sk89q.worldedit.world.block.BlockState; import static com.sk89q.minecraft.util.commands.Logging.LogMode.PLACEMENT; -import com.google.common.base.Joiner; import com.sk89q.minecraft.util.commands.Command; import com.sk89q.minecraft.util.commands.CommandContext; import com.sk89q.minecraft.util.commands.CommandException; @@ -201,33 +196,30 @@ public class UtilityCommands extends MethodCommands { File maxImages = new File(webSrc, "images" + File.separator + "max"); final int sub = srcFolder.getAbsolutePath().length(); List images = new ArrayList<>(); - MainUtil.iterateFiles(srcFolder, new Consumer() { - @Override - public void accept(File file) { - switch (file.getName().substring(file.getName().lastIndexOf('.')).toLowerCase()) { - case ".png": - case ".jpeg": - break; - default: - return; - } - try { - String name = file.getAbsolutePath().substring(sub); - if (name.startsWith(File.separator)) name = name.replaceFirst(java.util.regex.Pattern.quote(File.separator), ""); - BufferedImage img = MainUtil.readImage(file); - BufferedImage minImg = ImageUtil.getScaledInstance(img, min, min, RenderingHints.VALUE_INTERPOLATION_BILINEAR, true); - BufferedImage maxImg = max == -1 ? img : ImageUtil.getScaledInstance(img, max, max, RenderingHints.VALUE_INTERPOLATION_BILINEAR, true); - player.sendMessage("Writing " + name); - File minFile = new File(minImages, name); - File maxFile = new File(maxImages, name); - minFile.getParentFile().mkdirs(); - maxFile.getParentFile().mkdirs(); - ImageIO.write(minImg, "png", minFile); - ImageIO.write(maxImg, "png", maxFile); - images.add(name); - } catch (IOException e) { - throw new RuntimeException(e); - } + MainUtil.iterateFiles(srcFolder, file -> { + switch (file.getName().substring(file.getName().lastIndexOf('.')).toLowerCase()) { + case ".png": + case ".jpeg": + break; + default: + return; + } + try { + String name = file.getAbsolutePath().substring(sub); + if (name.startsWith(File.separator)) name = name.replaceFirst(java.util.regex.Pattern.quote(File.separator), ""); + BufferedImage img = MainUtil.readImage(file); + BufferedImage minImg = ImageUtil.getScaledInstance(img, min, min, RenderingHints.VALUE_INTERPOLATION_BILINEAR, true); + BufferedImage maxImg = max == -1 ? img : ImageUtil.getScaledInstance(img, max, max, RenderingHints.VALUE_INTERPOLATION_BILINEAR, true); + player.sendMessage("Writing " + name); + File minFile = new File(minImages, name); + File maxFile = new File(maxImages, name); + minFile.getParentFile().mkdirs(); + maxFile.getParentFile().mkdirs(); + ImageIO.write(minImg, "png", minFile); + ImageIO.write(maxImg, "png", maxFile); + images.add(name); + } catch (IOException e) { + throw new RuntimeException(e); } }); StringBuilder config = new StringBuilder(); @@ -666,20 +658,12 @@ public class UtilityCommands extends MethodCommands { final Expression expression = Expression.compile(input); ExecutorService executor = Executors.newSingleThreadExecutor(); - Future futureResult = executor.submit(new Callable() { - @Override - public Double call() throws Exception { - - return expression.evaluate(); - } - }); + Future futureResult = executor.submit((Callable) expression::evaluate); Double result = Double.NaN; try { result = futureResult.get(limit.MAX_EXPRESSION_MS, TimeUnit.MILLISECONDS); - } catch (InterruptedException e) { - e.printStackTrace(); - } catch (ExecutionException e) { + } catch (InterruptedException | ExecutionException e) { e.printStackTrace(); } catch (TimeoutException e) { futureResult.cancel(true); @@ -780,26 +764,25 @@ public class UtilityCommands extends MethodCommands { final int sortType = args.hasFlag('d') ? -1 : args.hasFlag('n') ? 1 : 0; // cleanup file list - Collections.sort(fileList, new Comparator() { - @Override - public int compare(File f1, File f2) { - boolean dir1 = f1.isDirectory(); - boolean dir2 = f2.isDirectory(); - if (dir1 != dir2) return dir1 ? -1 : 1; - int res; - if (sortType == 0) { // use name by default - int p = f1.getParent().compareTo(f2.getParent()); - if (p == 0) { // same parent, compare names - res = f1.getName().compareTo(f2.getName()); - } else { // different parent, sort by that - res = p; - } - } else { - res = Long.valueOf(f1.lastModified()).compareTo(f2.lastModified()); // use date if there is a flag - if (sortType == 1) res = -res; // flip date for newest first instead of oldest first + fileList.sort((f1, f2) -> { + boolean dir1 = f1.isDirectory(); + boolean dir2 = f2.isDirectory(); + if (dir1 != dir2) + return dir1 ? -1 : 1; + int res; + if (sortType == 0) { // use name by default + int p = f1.getParent().compareTo(f2.getParent()); + if (p == 0) { // same parent, compare names + res = f1.getName().compareTo(f2.getName()); + } else { // different parent, sort by that + res = p; } - return res; + } else { + res = Long.compare(f1.lastModified(), f2.lastModified()); // use date if there is a flag + if (sortType == 1) + res = -res; // flip date for newest first instead of oldest first } + return res; }); int offset = (page - 1) * perPage; @@ -891,7 +874,7 @@ public class UtilityCommands extends MethodCommands { UUID uuid = UUID.fromString(f.getName()); return false; } - } catch (IllegalArgumentException exception) {} + } catch (IllegalArgumentException ignored) {} return true; }; @@ -1031,269 +1014,6 @@ public class UtilityCommands extends MethodCommands { help(args, we, actor, "/", null); } - @Command( - aliases = {"/gui"}, - desc = "Open the GUI" - ) - @Logging(PLACEMENT) - public void gui(Actor actor, FawePlayer fp, LocalSession session, CommandContext args) throws WorldEditException, CommandException { - FormBuilder gui = Fawe.imp().getFormBuilder(); - if (gui == null) throw new CommandException("Only supported on Pocket Edition"); - - Dispatcher callable = worldEdit.getPlatformManager().getCommandManager().getDispatcher(); - CommandLocals locals = args.getLocals(); - - String prefix = Commands.getAlias(UtilityCommands.class, "/gui"); - - // TODO sort commands by most used - - new HelpBuilder(callable, args, prefix, Integer.MAX_VALUE) { - @Override - public void displayFailure(String message) { - gui.setTitle("Error"); - gui.addLabel(message); - } - - @Override - public void displayUsage(CommandCallable callable, String commandString) { - gui.setTitle(commandString); - - if (callable instanceof Dispatcher) { - Dispatcher dispathcer = (Dispatcher) callable; - dispathcer.getCommands(); - gui.addLabel("Dispatcher not implemented for " + commandString); - } else { - Description cmdDesc = callable.getDescription(); - - - - List params = cmdDesc.getParameters(); - String[] suggested = new String[params.size()]; - if (cmdDesc.getUsage() != null) { - String[] usageArgs = cmdDesc.getUsage().split(" ", params.size()); - for (int i = 0; i < usageArgs.length; i++) { - String arg = usageArgs[i]; - String[] splitSug = arg.split("="); - if (splitSug.length == 2) { - suggested[i] = splitSug[1]; - } - } - } - for (int i = 0 ; i < params.size(); i++) { - String[] def = params.get(i).getDefaultValue(); - if (def != null && def.length != 0) { - suggested[i] = def[0]; - } - } - - String help = cmdDesc.getHelp(); - if (help == null || help.isEmpty()) help = cmdDesc.getDescription(); - - gui.addLabel(BBC.color("&2" + help + "\n")); - - List flags = new ArrayList<>(); - - for (int i = 0; i < params.size(); i++) { - Parameter param = params.get(i); - String name = param.getName(); - boolean optional = param.isValueFlag() || param.isOptional(); - String[] def = param.getDefaultValue(); - - if (param.getFlag() != null) { - flags.add("-" + param.getFlag() + " "); - } else { - flags.add(""); - } - - if (param instanceof ParameterData) { - ParameterData pd = (ParameterData) param; - Type type = pd.getType(); - String suggestion = suggested[i]; - - String color = optional ? "3" : "c"; - StringBuilder label = new StringBuilder(BBC.color("&" + color + name + ": ")); -// if (suggested[i] != null) label.append(" e.g. " + suggestion); - Range range = MainUtil.getOf(pd.getModifiers(), Range.class); - double min = 0; - double max = 100; - if (range != null) { - min = range.min(); - max = range.max(); - } else { - SuggestedRange suggestedRange = MainUtil.getOf(pd.getModifiers(), SuggestedRange.class); - if (suggestedRange != null) { - min = suggestedRange.min(); - max = suggestedRange.max(); - } else if (name.equalsIgnoreCase("radius") || name.equalsIgnoreCase("size")) { - max = WorldEdit.getInstance().getConfiguration().maxBrushRadius; - } - } - int step = 1; - Step stepSizeAnn = MainUtil.getOf(pd.getModifiers(), Step.class); - if (stepSizeAnn != null) { - double stepVal = stepSizeAnn.value(); - step = Math.max(1, (int) stepVal); - } - /* - BaseBiome - Vector - Vector2D - */ - - switch (type.getTypeName()) { - case "double": - case "java.lang.Double": { - double value = suggestion != null ? Double.parseDouble(suggestion) : min; - gui.addSlider("\n" + label.toString(), min, max, 1, value); - break; - } - case "int": - case "java.lang.Integer": { - int value = suggestion != null ? Integer.parseInt(suggestion) : (int) min; - gui.addSlider("\n" + label.toString(), min, max, 1, value); - break; - } - case "boolean": - case "java.lang.Boolean": { - boolean value = suggestion != null ? Boolean.parseBoolean(suggestion) : false; - gui.addToggle(label.toString(), value); - break; - } - case "com.sk89q.worldedit.patterns.Pattern": { - gui.addInput("\n" + label.toString(), "stone", "wood"); - break; - } - case "com.sk89q.worldedit.blocks.BaseBlock": { - gui.addInput("\n" + label.toString(), "stone", "wood"); - break; - } - case "com.sk89q.worldedit.function.mask.Mask": { - gui.addInput("\n" + label.toString(), "stone", "wood"); - break; - } - default: - case "java.lang.String": { - // TODO - // clipboard - // schematic - // image - if (suggestion == null) suggestion = ""; - gui.addInput("\n" + label.toString(), suggestion, suggestion); - break; - } - } - } else { - throw new UnsupportedOperationException("Unsupported callable: " + callable.getClass() + " | " + param.getClass()); - } - } - - gui.setResponder(new Consumer>() { - @Override - public void accept(Map response) { - int index = 0; - StringBuilder command = new StringBuilder(commandString); - for (Map.Entry arg : response.entrySet()) { - String argValue = arg.getValue().toString(); - String flag = flags.get(index); - if (!flag.isEmpty()) { - if (argValue.equalsIgnoreCase("false")) continue; - if (argValue.equalsIgnoreCase("true")) argValue = ""; - } - command.append(" " + flag + argValue); - index++; - } - CommandEvent event = new CommandEvent(actor, command.toString()); - CommandManager.getInstance().handleCommand(event); - } - }); - } - } - - @Override - public void displayCategories(Map> categories) { - gui.setTitle(BBC.HELP_HEADER_CATEGORIES.s()); - List categoryList = new ArrayList<>(); - for (Map.Entry> categoryEntry : categories.entrySet()) { - String category = categoryEntry.getKey(); - categoryList.add(category); - Map commandMap = categoryEntry.getValue(); - int size = commandMap.size(); - - String plural = size == 1 ? "command" : "commands"; - gui.addButton(BBC.HELP_ITEM_ALLOWED.f(category, "(" + size + " " + plural + ")"), null); - } - - gui.setResponder(new Consumer>() { - @Override - public void accept(Map response) { - if (response.isEmpty()) { - // ?? - throw new IllegalArgumentException("No response for categories"); - } else { - Map.Entry clicked = response.entrySet().iterator().next(); - String category = categoryList.get(clicked.getKey()); - String arguments = prefix + " " + category; - CommandEvent event = new CommandEvent(actor, arguments); - CommandManager.getInstance().handleCommand(event); - } - } - }); - } - - @Override - public void displayCommands(Map commandMap, String visited, int page, int pageTotal, int effectiveLength) { - gui.setTitle(BBC.HELP_HEADER_SUBCOMMANDS.s()); - - String baseCommand = prefix; - if (effectiveLength > 0) baseCommand += " " + args.getString(0, effectiveLength - 1); - - CommandLocals locals = args.getLocals(); - if (!visited.isEmpty()) { - visited = visited + " "; - } - - List commands = new ArrayList<>(); - - for (Map.Entry cmdEntry : commandMap.entrySet()) { - CommandMapping mapping = cmdEntry.getKey(); - String subPrefix = cmdEntry.getValue(); - - StringBuilder helpCmd = new StringBuilder(); - helpCmd.append(prefix); - helpCmd.append(" "); - helpCmd.append(subPrefix); - CommandCallable c = mapping.getCallable(); - helpCmd.append(visited); - helpCmd.append(mapping.getPrimaryAlias()); - String s2 = mapping.getDescription().getDescription(); - if (c.testPermission(locals)) { -// gui.addLabel(s2); - gui.addButton(helpCmd.toString(), null); - commands.add(helpCmd.toString()); - } - } - - gui.setResponder(new Consumer>() { - @Override - public void accept(Map response) { - if (response.isEmpty()) { - // ?? - throw new IllegalArgumentException("No response for command list: " + prefix); - } else { - Map.Entry clicked = response.entrySet().iterator().next(); - int index = clicked.getKey(); - String cmd = commands.get(index); - CommandEvent event = new CommandEvent(actor, cmd); - CommandManager.getInstance().handleCommand(event); - } - } - }); - } - }.run(); - - gui.display(fp); - } - public static void help(CommandContext args, WorldEdit we, Actor actor, String prefix, CommandCallable callable) { final int perPage = actor instanceof Player ? 12 : 20; // More pages for console diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/CommandManager.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/CommandManager.java index f0b547cc2..8ecbef23c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/CommandManager.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/CommandManager.java @@ -359,7 +359,7 @@ public final class CommandManager { return split; } - public void handleCommandOnCurrentThread(final CommandEvent event) { + public void handleCommandOnCurrentThread(CommandEvent event) { Actor actor = platformManager.createProxyActor(event.getActor()); final String args = event.getArguments(); final String[] split = commandDetection(args.split(" ")); @@ -408,12 +408,8 @@ public final class CommandManager { final Actor finalActor = actor; locals.put("arguments", args); - ThrowableSupplier task = new ThrowableSupplier() { - @Override - public Object get() throws Throwable { - return dispatcher.call(Joiner.on(" ").join(split), locals, new String[0]); - } - }; + ThrowableSupplier task = + () -> dispatcher.call(Joiner.on(" ").join(split), locals, new String[0]); handleCommandTask(task, locals, actor, session, failedPermissions, fp); } @@ -517,29 +513,21 @@ public final class CommandManager { String args = event.getArguments(); CommandEvent finalEvent = new CommandEvent(actor, args); final FawePlayer fp = FawePlayer.wrap(actor); - TaskManager.IMP.taskNow(new Runnable() { - @Override - public void run() { - int space0 = args.indexOf(' '); - String arg0 = space0 == -1 ? args : args.substring(0, space0); - CommandMapping cmd = dispatcher.get(arg0); - if (cmd != null && cmd.getCallable() instanceof AParametricCallable) { - Command info = ((AParametricCallable) cmd.getCallable()).getDefinition(); - if (!info.queued()) { - handleCommandOnCurrentThread(finalEvent); - return; - } + TaskManager.IMP.taskNow(() -> { + int space0 = args.indexOf(' '); + String arg0 = space0 == -1 ? args : args.substring(0, space0); + CommandMapping cmd = dispatcher.get(arg0); + if (cmd != null && cmd.getCallable() instanceof AParametricCallable) { + Command info = ((AParametricCallable) cmd.getCallable()).getDefinition(); + if (!info.queued()) { + handleCommandOnCurrentThread(finalEvent); + return; } - if (!fp.runAction(new Runnable() { - @Override - public void run() { - handleCommandOnCurrentThread(finalEvent); - } - }, false, true)) { - BBC.WORLDEDIT_COMMAND_LIMIT.send(fp); - } - finalEvent.setCancelled(true); } + if (!fp.runAction(() -> handleCommandOnCurrentThread(finalEvent), false, true)) { + BBC.WORLDEDIT_COMMAND_LIMIT.send(fp); + } + finalEvent.setCancelled(true); }, Fawe.isMainThread()); } @@ -548,6 +536,7 @@ public final class CommandManager { try { CommandLocals locals = new CommandLocals(); locals.put(Actor.class, event.getActor()); + locals.put("arguments", event.getArguments()); event.setSuggestions(dispatcher.getSuggestions(event.getArguments(), locals)); } catch (CommandException e) { event.getActor().printError(e.getMessage()); @@ -568,4 +557,4 @@ public final class CommandManager { } -} \ No newline at end of file +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/BlockPattern.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/BlockPattern.java index 947ed20db..7a41cc062 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/BlockPattern.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/BlockPattern.java @@ -1,3 +1,21 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ package com.sk89q.worldedit.function.pattern; import static com.google.common.base.Preconditions.checkNotNull; @@ -7,7 +25,7 @@ import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockStateHolder; /** - * @deprecated Just use BaseBlock directly + * A pattern that returns the same {@link BaseBlock} each time. */ @Deprecated public class BlockPattern implements Pattern { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/parametric/AParametricCallable.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/parametric/AParametricCallable.java index 3d6e13013..64964d07c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/parametric/AParametricCallable.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/parametric/AParametricCallable.java @@ -2,9 +2,7 @@ package com.sk89q.worldedit.util.command.parametric; import com.boydti.fawe.command.SuggestInputParseException; import com.boydti.fawe.config.BBC; -import com.boydti.fawe.util.chat.UsageMessage; import com.sk89q.minecraft.util.commands.*; -import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.util.command.*; import java.lang.reflect.InvocationTargetException; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BaseBlock.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BaseBlock.java index e106ed3ed..31b424422 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BaseBlock.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BaseBlock.java @@ -26,16 +26,9 @@ import com.sk89q.jnbt.StringTag; import com.sk89q.jnbt.Tag; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.Extent; -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 com.sk89q.worldedit.world.registry.BlockMaterial; import com.sk89q.worldedit.world.registry.LegacyMapper; import com.sk89q.worldedit.blocks.TileEntityBlock; -import com.sk89q.worldedit.function.mask.Mask; -import com.sk89q.worldedit.function.mask.SingleBlockStateMask; -import com.sk89q.worldedit.function.mask.SingleBlockTypeMask; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.registry.state.PropertyKey; @@ -271,12 +264,7 @@ public class BaseBlock implements BlockStateHolder, TileEntityBlock { return toImmutableState().getInternalPropertiesId(); } - @Override - public Mask toMask(Extent extent) { - return new SingleBlockStateMask(extent, toImmutableState()); - } - - @Override + @Override public BaseBlock with(Property property, V value) { return toImmutableState().with(property, value).toBaseBlock(getNbtData()); } 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 835942bea..f007ad5db 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 @@ -27,8 +27,6 @@ import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extent.Extent; -import com.sk89q.worldedit.function.mask.Mask; -import com.sk89q.worldedit.function.mask.SingleBlockStateMask; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.registry.state.AbstractProperty; import com.sk89q.worldedit.registry.state.Property; @@ -225,11 +223,6 @@ public class BlockState implements BlockStateHolder { return getBlockType().withPropertyId(propertyId); } - @Override - public Mask toMask(Extent extent) { - return new SingleBlockStateMask(extent, this); - } - @Override public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException { return extent.setBlock(set, this); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockStateHolder.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockStateHolder.java index ee4fe1eea..598cdba5a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockStateHolder.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockStateHolder.java @@ -19,8 +19,6 @@ package com.sk89q.worldedit.world.block; -import com.sk89q.worldedit.extent.Extent; -import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.pattern.FawePattern; import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.registry.state.Property; @@ -30,7 +28,7 @@ import com.sk89q.worldedit.world.registry.BlockMaterial; import java.util.Map; import java.util.stream.Collectors; -public interface BlockStateHolder> extends FawePattern { +public interface BlockStateHolder> extends FawePattern { /** * Get the block type @@ -45,7 +43,7 @@ public interface BlockStateHolder> extends FawePat * @return */ @Deprecated - T withPropertyId(int propertyId); + B withPropertyId(int propertyId); /** * Get combined id (legacy uses) @@ -72,16 +70,14 @@ public interface BlockStateHolder> extends FawePat @Deprecated int getInternalPropertiesId(); - Mask toMask(Extent extent); - /** - * Returns a BlockStateHolder with the given state and value applied. + * Returns a BlockState with the given state and value applied. * * @param property The state * @param value The value * @return The modified state, or same if could not be applied */ - T with(final Property property, final V value); + B with(final Property property, final V value); /** * Returns a BlockStateHolder with the given state and value applied. @@ -90,7 +86,7 @@ public interface BlockStateHolder> extends FawePat * @param value The value * @return The modified state, or same if could not be applied */ - T with(final PropertyKey property, final V value); + B with(final PropertyKey property, final V value); /** * Gets the value at the given state