From 699807665dbdfae390fd2e547043060694a41f30 Mon Sep 17 00:00:00 2001 From: Wizjany Date: Wed, 26 Oct 2011 16:50:46 -0400 Subject: [PATCH] Cleanup --- .../ConfigurationPermissionsResolver.java | 6 +- .../bukkit/migration/DinnerPermsResolver.java | 1 - .../util/commands/CommandContext.java | 3 +- .../java/com/sk89q/util/yaml/YAMLNode.java | 4 +- .../java/com/sk89q/worldedit/EditSession.java | 76 ++++++++++++++++--- .../com/sk89q/worldedit/LocalSession.java | 20 +++++ .../java/com/sk89q/worldedit/LocalWorld.java | 12 ++- .../bukkit/BukkitServerInterface.java | 4 +- .../sk89q/worldedit/bukkit/BukkitWorld.java | 33 +++++--- .../worldedit/commands/GeneralCommands.java | 30 ++++---- .../commands/GenerationCommands.java | 18 ++--- .../worldedit/commands/SelectionCommands.java | 3 +- .../worldedit/commands/ToolUtilCommands.java | 3 +- .../worldedit/expression/lexer/Lexer.java | 9 +-- .../worldedit/expression/parser/Parser.java | 12 +-- .../expression/parser/ParserProcessors.java | 35 +++------ .../expression/runtime/Function.java | 9 +-- .../expression/runtime/Operators.java | 4 +- .../expression/runtime/Sequence.java | 3 +- 19 files changed, 175 insertions(+), 110 deletions(-) diff --git a/src/main/java/com/sk89q/bukkit/migration/ConfigurationPermissionsResolver.java b/src/main/java/com/sk89q/bukkit/migration/ConfigurationPermissionsResolver.java index 0646998a9..97ee535ba 100644 --- a/src/main/java/com/sk89q/bukkit/migration/ConfigurationPermissionsResolver.java +++ b/src/main/java/com/sk89q/bukkit/migration/ConfigurationPermissionsResolver.java @@ -39,9 +39,9 @@ public class ConfigurationPermissionsResolver implements PermissionsResolver { "worldedit.reload", "worldedit.selection", "worlds.creative.worldedit.region"}); - section.setProperty("permissions.groups.admins.permissions", new String[]{"*"}); - section.setProperty("permissions.users.sk89q.permissions", new String[]{"worldedit"}); - section.setProperty("permissions.users.sk89q.groups", new String[]{"admins"}); + section.setProperty("permissions.groups.admins.permissions", new String[] {"*"}); + section.setProperty("permissions.users.sk89q.permissions", new String[] {"worldedit"}); + section.setProperty("permissions.users.sk89q.groups", new String[] {"admins"}); return section; } diff --git a/src/main/java/com/sk89q/bukkit/migration/DinnerPermsResolver.java b/src/main/java/com/sk89q/bukkit/migration/DinnerPermsResolver.java index 344db2352..2c042fdc6 100644 --- a/src/main/java/com/sk89q/bukkit/migration/DinnerPermsResolver.java +++ b/src/main/java/com/sk89q/bukkit/migration/DinnerPermsResolver.java @@ -38,7 +38,6 @@ public class DinnerPermsResolver implements PermissionsResolver { } public static PermissionsResolver factory(Server server, YAMLProcessor config) { - return new DinnerPermsResolver(server); } diff --git a/src/main/java/com/sk89q/minecraft/util/commands/CommandContext.java b/src/main/java/com/sk89q/minecraft/util/commands/CommandContext.java index 2895df8e0..d60fd527c 100644 --- a/src/main/java/com/sk89q/minecraft/util/commands/CommandContext.java +++ b/src/main/java/com/sk89q/minecraft/util/commands/CommandContext.java @@ -139,8 +139,7 @@ public class CommandContext { // If it is a value flag, read another argument and add it this.valueFlags.put(flagName, argList.get(nextArg++)); - } - else { + } else { booleanFlags.add(flagName); } } diff --git a/src/main/java/com/sk89q/util/yaml/YAMLNode.java b/src/main/java/com/sk89q/util/yaml/YAMLNode.java index 333c8b075..b1f94eea7 100644 --- a/src/main/java/com/sk89q/util/yaml/YAMLNode.java +++ b/src/main/java/com/sk89q/util/yaml/YAMLNode.java @@ -721,7 +721,7 @@ public class YAMLNode { return null; } else if (o instanceof Number) { return ((Number)o).intValue(); - } else { + } else { return null; } } @@ -737,7 +737,7 @@ public class YAMLNode { return null; } else if (o instanceof Number) { return ((Number)o).doubleValue(); - } else { + } else { return null; } } diff --git a/src/main/java/com/sk89q/worldedit/EditSession.java b/src/main/java/com/sk89q/worldedit/EditSession.java index f01f3f068..9b617db64 100644 --- a/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/src/main/java/com/sk89q/worldedit/EditSession.java @@ -100,6 +100,11 @@ public class EditSession { */ private boolean fastMode = false; + /** + * Use fast lighting as well if using fast mode. + */ + private boolean fastLighting = false; + /** * Block bag to use for getting blocks. */ @@ -209,13 +214,13 @@ public class EditSession { if (BlockType.usesData(type)) { if (fastMode) { - result = world.setTypeIdAndDataFast(pt, type, block.getData() > -1 ? block.getData() : 0); + result = world.setTypeIdAndDataFast(pt, type, block.getData() > -1 ? block.getData() : 0, fastLighting); } else { result = world.setTypeIdAndData(pt, type, block.getData() > -1 ? block.getData() : 0); } } else { if (fastMode) { - result = world.setBlockTypeFast(pt, type); + result = world.setBlockTypeFast(pt, type, fastLighting); } else { result = world.setBlockType(pt, type); } @@ -227,8 +232,7 @@ public class EditSession { if (blockBag == null) { world.copyToWorld(pt, block); } - } - else if (block instanceof TileEntityBlock) { + } else if (block instanceof TileEntityBlock) { world.copyToWorld(pt, block); } } @@ -522,12 +526,30 @@ public class EditSession { * Disable the queue. This will flush the queue. */ public void disableQueue() { - if (queued != false) { + if (queued) { flushQueue(); } queued = false; } + /** + * Set fast lighting. + * + * @param fastLighting + */ + public void setFastLighting(boolean fastLighting) { + this.fastLighting = fastLighting; + } + + /** + * Return fast lighting status. + * + * @return + */ + public boolean hasFastLighting() { + return fastLighting; + } + /** * Set fast mode. * @@ -561,7 +583,9 @@ public class EditSession { rawSetBlock(pt, (BaseBlock) entry.getValue()); // TODO: use ChunkStore.toChunk(pt) after optimizing it. - if (fastMode) dirtyChunks.add(new BlockVector2D(pt.getBlockX() >> 4, pt.getBlockZ() >> 4)); + if (fastMode) { + dirtyChunks.add(new BlockVector2D(pt.getBlockX() >> 4, pt.getBlockZ() >> 4)); + } } // We don't want to place these blocks if other blocks were missing @@ -629,7 +653,9 @@ public class EditSession { blocks.remove(pt); // TODO: use ChunkStore.toChunk(pt) after optimizing it. - if (fastMode) dirtyChunks.add(new BlockVector2D(pt.getBlockX() >> 4, pt.getBlockZ() >> 4)); + if (fastMode) { + dirtyChunks.add(new BlockVector2D(pt.getBlockX() >> 4, pt.getBlockZ() >> 4)); + } } } } @@ -1794,9 +1820,24 @@ public class EditSession { } /** - * Makes a sphere or ellipsoid. + * Makes a cylinder. * - * @param pos Center of the sphere or ellipsoid + * @param pos Center of the cylinder + * @param block The block pattern to use + * @param radius The cylinder's radius + * @param height The cylinder's up/down extent. If negative, extend downward. + * @param filled If false, only a shell will be generated. + * @return number of blocks changed + * @throws MaxChangedBlocksException + */ + public int makeCylinder(Vector pos, Pattern block, double radius, int height, boolean filled) throws MaxChangedBlocksException { + return makeCylinder(pos, block, radius, radius, height, filled); + } + + /** + * Makes a cylinder. + * + * @param pos Center of the cylinder * @param block The block pattern to use * @param radiusX The cylinder's largest north/south extent * @param radiusZ The cylinder's largest east/west extent @@ -1875,6 +1916,20 @@ public class EditSession { return affected; } + /** + * Makes a sphere. + * + * @param pos Center of the sphere or ellipsoid + * @param block The block pattern to use + * @param radius The sphere's radius + * @param filled If false, only a shell will be generated. + * @return number of blocks changed + * @throws MaxChangedBlocksException + */ + public int makeSphere(Vector pos, Pattern block, double radius, boolean filled) throws MaxChangedBlocksException { + return makeSphere(pos, block, radius, radius, radius, filled); + } + /** * Makes a sphere or ellipsoid. * @@ -2538,8 +2593,7 @@ public class EditSession { } /** - * @param blockBag - * the blockBag to set + * @param blockBag the blockBag to set */ public void setBlockBag(BlockBag blockBag) { this.blockBag = blockBag; diff --git a/src/main/java/com/sk89q/worldedit/LocalSession.java b/src/main/java/com/sk89q/worldedit/LocalSession.java index 8e5e0c0db..0873bed7f 100644 --- a/src/main/java/com/sk89q/worldedit/LocalSession.java +++ b/src/main/java/com/sk89q/worldedit/LocalSession.java @@ -73,6 +73,7 @@ public class LocalSession { private boolean beenToldVersion = false; private boolean hasCUISupport = false; private boolean fastMode = false; + private boolean fastLighting = false; private Mask mask; private TimeZone timezone = TimeZone.getDefault(); private Boolean jumptoBlock = true; @@ -644,6 +645,7 @@ public class LocalSession { new EditSession(player.getWorld(), getBlockChangeLimit(), blockBag); editSession.setFastMode(fastMode); + editSession.setFastLighting(fastLighting); editSession.setMask(mask); return editSession; @@ -667,6 +669,24 @@ public class LocalSession { this.fastMode = fastMode; } + /** + * Checks if the session has fast lighting enabled. + * + * @return + */ + public boolean hasFastLighting() { + return fastLighting; + } + + /** + * Set fast lighting. + * + * @param fastLighting + */ + public void setFastLighting(boolean fastLighting) { + this.fastLighting = fastLighting; + } + /** * Get the mask. * diff --git a/src/main/java/com/sk89q/worldedit/LocalWorld.java b/src/main/java/com/sk89q/worldedit/LocalWorld.java index adb57f8cb..8554b3823 100644 --- a/src/main/java/com/sk89q/worldedit/LocalWorld.java +++ b/src/main/java/com/sk89q/worldedit/LocalWorld.java @@ -63,6 +63,10 @@ public abstract class LocalWorld { return setBlockType(pt, type); } + public boolean setBlockTypeFast(Vector pt, int type, boolean fastLighting) { + return setBlockTypeFast(pt, type); + } + /** * Get block type. * @@ -100,7 +104,7 @@ public abstract class LocalWorld { setBlockData(pt, data); return ret; } - + /** * set block type & data * @param pt @@ -113,7 +117,11 @@ public abstract class LocalWorld { setBlockDataFast(pt, data); return ret; } - + + public boolean setTypeIdAndDataFast(Vector pt, int type, int data, boolean fastLighting) { + return setTypeIdAndDataFast(pt, type, data); + } + /** * Get block data. * diff --git a/src/main/java/com/sk89q/worldedit/bukkit/BukkitServerInterface.java b/src/main/java/com/sk89q/worldedit/bukkit/BukkitServerInterface.java index 32739e9f3..b36a770af 100644 --- a/src/main/java/com/sk89q/worldedit/bukkit/BukkitServerInterface.java +++ b/src/main/java/com/sk89q/worldedit/bukkit/BukkitServerInterface.java @@ -34,8 +34,8 @@ public class BukkitServerInterface extends ServerInterface { @Override public int resolveItem(String name) { - // TODO Auto-generated method stub - return 0; + Material mat = Material.matchMaterial(name); + return mat == null ? 0 : mat.getId(); } @Override diff --git a/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java b/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java index 78dfde4d9..a266705e8 100644 --- a/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java +++ b/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java @@ -111,8 +111,21 @@ public class BukkitWorld extends LocalWorld { */ @Override public boolean setBlockTypeFast(Vector pt, int type) { + return setBlockTypeFast(pt, type, false); + } + + /** + * Set block type. + * + * @param pt + * @param type + * @param fastLighting + * @return + */ + @Override + public boolean setBlockTypeFast(Vector pt, int type, boolean fastLighting) { final Block block = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()); - if (fastLightingAvailable) { + if (fastLightingAvailable && fastLighting) { type = type & 255; final int previousOpacity = Block_lightOpacity[type]; Block_lightOpacity[type] = 0; @@ -145,8 +158,13 @@ public class BukkitWorld extends LocalWorld { */ @Override public boolean setTypeIdAndDataFast(Vector pt, int type, int data){ + return setTypeIdAndDataFast(pt, type, data, false); + } + + @Override + public boolean setTypeIdAndDataFast(Vector pt, int type, int data, boolean fastLighting) { final Block block = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()); - if (fastLightingAvailable) { + if (fastLightingAvailable && fastLighting) { type = type & 255; final int previousOpacity = Block_lightOpacity[type]; Block_lightOpacity[type] = 0; @@ -157,7 +175,7 @@ public class BukkitWorld extends LocalWorld { return block.setTypeIdAndData(type, (byte) data, false); } - + /** * Get block type. * @@ -788,8 +806,7 @@ public class BukkitWorld extends LocalWorld { lightEmitters.add(chunk.getBlock(x, y, z).getState()); if (blockID == 20) { blocks[index] = 0; - } - else { + } else { blocks[index] = 20; } @@ -808,8 +825,7 @@ public class BukkitWorld extends LocalWorld { lightEmitter.update(true); } } - } - catch (Exception e) { + } catch (Exception e) { System.out.println("Fast Mode: Could not fix lighting. Probably an incompatible version of CraftBukkit."); e.printStackTrace(); } @@ -843,8 +859,7 @@ public class BukkitWorld extends LocalWorld { NibbleArray_ctor = Class.forName("net.minecraft.server.NibbleArray").getConstructor(int.class, int.class); fastLightingAvailable = true; - } - catch (Throwable e) { + } catch (Throwable e) { e.printStackTrace(); } } diff --git a/src/main/java/com/sk89q/worldedit/commands/GeneralCommands.java b/src/main/java/com/sk89q/worldedit/commands/GeneralCommands.java index 6fe824783..4802e8f60 100644 --- a/src/main/java/com/sk89q/worldedit/commands/GeneralCommands.java +++ b/src/main/java/com/sk89q/worldedit/commands/GeneralCommands.java @@ -63,6 +63,7 @@ public class GeneralCommands { @Command( aliases = { "/fast" }, + flags = "l", usage = "[on|off]", desc = "Toggle fast mode", min = 0, @@ -73,25 +74,24 @@ public class GeneralCommands { LocalSession session, LocalPlayer player, EditSession editSession) throws WorldEditException { + boolean light = args.hasFlag('f'); String newState = args.getString(0, null); - if (session.hasFastMode()) { - if ("on".equals(newState)) { - player.printError("Fast mode already enabled."); - return; - } + Boolean dir = newState.equals("on") ? true : newState.equals("off") ? false : null; - session.setFastMode(false); - player.print("Fast mode disabled."); - } - else { - if ("off".equals(newState)) { - player.printError("Fast mode already disabled."); - return; - } + boolean hadFast = session.hasFastMode(); + boolean hadLight = session.hasFastLighting(); - session.setFastMode(true); - player.print("Fast mode enabled. Lighting in the affected chunks may be wrong and/or you may need to rejoin to see changes."); + boolean setFast = dir == null ? !hadFast : dir; + boolean setLight = dir == null ? !hadLight : dir; + + session.setFastMode(setFast); + if (light) { + session.setFastLighting(setLight); } + + player.print("Fast mode " + (!setFast ? "disabled." : + ("enabled. You may need to rejoin to see changes" + + (setLight ? "and lighting in affected chunks may be wrong." : ".")))); } @Command( diff --git a/src/main/java/com/sk89q/worldedit/commands/GenerationCommands.java b/src/main/java/com/sk89q/worldedit/commands/GenerationCommands.java index 8d2e267b1..85fded4de 100644 --- a/src/main/java/com/sk89q/worldedit/commands/GenerationCommands.java +++ b/src/main/java/com/sk89q/worldedit/commands/GenerationCommands.java @@ -322,8 +322,7 @@ public class GenerationCommands { try { expression = Expression.compile(args.getJoinedStrings(1), "x", "y", "z"); expression.optimize(); - } - catch (ExpressionException e) { + } catch (ExpressionException e) { player.printError(e.getMessage()); return; } @@ -336,15 +335,13 @@ public class GenerationCommands { protected boolean isInside(double x, double y, double z) { try { return expression.evaluate(x, y, z) > 0; - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); return false; } } }; - } - else if (args.hasFlag('o')) { + } else if (args.hasFlag('o')) { final Vector placement = session.getPlacementPosition(player); final double placementX = placement.getX(); @@ -356,15 +353,13 @@ public class GenerationCommands { protected boolean isInside(double x, double y, double z) { try { return expression.evaluate(x - placementX, y - placementY, z - placementZ) > 0; - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); return false; } } }; - } - else { + } else { final Vector min = region.getMinimumPoint(); final Vector max = region.getMaximumPoint(); final Vector center = max.add(min).multiply(0.5); @@ -376,8 +371,7 @@ public class GenerationCommands { try { return expression.evaluate(scaled.getX(), scaled.getY(), scaled.getZ()) > 0; - } - catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); return false; } diff --git a/src/main/java/com/sk89q/worldedit/commands/SelectionCommands.java b/src/main/java/com/sk89q/worldedit/commands/SelectionCommands.java index 9be28a801..2b49c127e 100644 --- a/src/main/java/com/sk89q/worldedit/commands/SelectionCommands.java +++ b/src/main/java/com/sk89q/worldedit/commands/SelectionCommands.java @@ -194,8 +194,7 @@ public class SelectionCommands { player.print("Chunks selected: (" + min2D.getBlockX() + ", " + min2D.getBlockZ() + ") - (" + max2D.getBlockX() + ", " + max2D.getBlockZ() + ")"); - } - else { + } else { final Vector2D min2D = ChunkStore.toChunk(player.getBlockIn()); min = new Vector(min2D.getBlockX() * 16, 0, min2D.getBlockZ() * 16); diff --git a/src/main/java/com/sk89q/worldedit/commands/ToolUtilCommands.java b/src/main/java/com/sk89q/worldedit/commands/ToolUtilCommands.java index 17b5623f5..e3e209bd5 100644 --- a/src/main/java/com/sk89q/worldedit/commands/ToolUtilCommands.java +++ b/src/main/java/com/sk89q/worldedit/commands/ToolUtilCommands.java @@ -54,8 +54,7 @@ public class ToolUtilCommands { session.disableSuperPickAxe(); player.print("Super pick axe disabled."); - } - else { + } else { if ("off".equals(newState)) { player.printError("Super pick axe already disabled."); return; diff --git a/src/main/java/com/sk89q/worldedit/expression/lexer/Lexer.java b/src/main/java/com/sk89q/worldedit/expression/lexer/Lexer.java index a97f70bea..c2f9e170c 100644 --- a/src/main/java/com/sk89q/worldedit/expression/lexer/Lexer.java +++ b/src/main/java/com/sk89q/worldedit/expression/lexer/Lexer.java @@ -140,8 +140,7 @@ public class Lexer { if (!numberPart.isEmpty()) { try { tokens.add(new NumberToken(position, Double.parseDouble(numberPart))); - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { throw new LexerException(position, "Number parsing failed", e); } @@ -156,8 +155,7 @@ public class Lexer { if (!identifierPart.isEmpty()) { if (keywords.contains(identifierPart)) { tokens.add(new KeywordToken(position, identifierPart)); - } - else { + } else { tokens.add(new IdentifierToken(position, identifierPart)); } @@ -167,8 +165,7 @@ public class Lexer { } throw new LexerException(position, "Unknown character '" + ch + "'"); - } - while (position < expression.length()); + } while (position < expression.length()); return tokens; } diff --git a/src/main/java/com/sk89q/worldedit/expression/parser/Parser.java b/src/main/java/com/sk89q/worldedit/expression/parser/Parser.java index d84f49854..94bc16d93 100644 --- a/src/main/java/com/sk89q/worldedit/expression/parser/Parser.java +++ b/src/main/java/com/sk89q/worldedit/expression/parser/Parser.java @@ -100,8 +100,7 @@ public class Parser { final Token next = peek(); if (next.id() == '(') { halfProcessed.add(parseFunctionCall(identifierToken)); - } - else { + } else { RValue variable = variables.get(identifierToken.value); if (variable == null) { throw new ParserException(current.getPosition(), "Variable '" + identifierToken.value + "' not found"); @@ -130,8 +129,7 @@ public class Parser { case 'o': if (expressionStart) { halfProcessed.add(new PrefixOperator((OperatorToken) current)); - } - else { + } else { halfProcessed.add(current); } ++position; @@ -148,8 +146,7 @@ public class Parser { if (isStatement) { return ParserProcessors.processStatement(halfProcessed); - } - else { + } else { return ParserProcessors.processExpression(halfProcessed); } } @@ -195,8 +192,7 @@ public class Parser { } return Functions.getFunction(identifierToken.getPosition(), identifierToken.value, args.toArray(new RValue[args.size()])); - } - catch (NoSuchMethodException e) { + } catch (NoSuchMethodException e) { throw new ParserException(identifierToken.getPosition(), "Function not found", e); } } diff --git a/src/main/java/com/sk89q/worldedit/expression/parser/ParserProcessors.java b/src/main/java/com/sk89q/worldedit/expression/parser/ParserProcessors.java index 5a49ffaa1..872ad7bda 100644 --- a/src/main/java/com/sk89q/worldedit/expression/parser/ParserProcessors.java +++ b/src/main/java/com/sk89q/worldedit/expression/parser/ParserProcessors.java @@ -134,12 +134,10 @@ public final class ParserProcessors { for (Identifiable identifiable : input) { if (semicolonFound) { rhs.addLast(identifiable); - } - else { + } else { if (identifiable.id() == ';') { semicolonFound = true; - } - else { + } else { lhs.addLast(identifiable); } } @@ -151,12 +149,10 @@ public final class ParserProcessors { } return processExpression(lhs); - } - else if (lhs.isEmpty()) { + } else if (lhs.isEmpty()) { return processStatement(rhs); - } - else { - assert(semicolonFound); + } else { + assert (semicolonFound); RValue lhsInvokable = processExpression(lhs); RValue rhsInvokable = processStatement(rhs); @@ -193,8 +189,7 @@ public final class ParserProcessors { } rhs.removeFirst(); - } - else { + } else { lhs.addFirst(identifiable); } } @@ -206,8 +201,7 @@ public final class ParserProcessors { try { return Operators.getOperator(input.get(0).getPosition(), operator, lhsInvokable, rhsInvokable); - } - catch (NoSuchMethodException e) { + } catch (NoSuchMethodException e) { final Token operatorToken = (Token) input.get(lhs.size()); throw new ParserException(operatorToken.getPosition(), "Couldn't find operator '" + operator + "'"); } @@ -236,8 +230,7 @@ public final class ParserProcessors { } lhs.removeLast(); - } - else { + } else { rhs.addLast(identifiable); } } @@ -249,8 +242,7 @@ public final class ParserProcessors { try { return Operators.getOperator(input.get(0).getPosition(), operator, lhsInvokable, rhsInvokable); - } - catch (NoSuchMethodException e) { + } catch (NoSuchMethodException e) { final Token operatorToken = (Token) input.get(lhs.size()); throw new ParserException(operatorToken.getPosition(), "Couldn't find operator '" + operator + "'"); } @@ -280,19 +272,16 @@ public final class ParserProcessors { try { ret = Operators.getOperator(lastPosition, opName, ret); continue; - } - catch (NoSuchMethodException e) { + } catch (NoSuchMethodException e) { throw new ParserException(lastPosition, "No such prefix operator: " + operator); } } } if (last instanceof Token) { throw new ParserException(lastPosition, "Extra token found in expression: " + last); - } - else if (last instanceof RValue) { + } else if (last instanceof RValue) { throw new ParserException(lastPosition, "Extra expression found: " + last); - } - else { + } else { throw new ParserException(lastPosition, "Extra element found: " + last); } } diff --git a/src/main/java/com/sk89q/worldedit/expression/runtime/Function.java b/src/main/java/com/sk89q/worldedit/expression/runtime/Function.java index b9b13b78d..6aeeb08f6 100644 --- a/src/main/java/com/sk89q/worldedit/expression/runtime/Function.java +++ b/src/main/java/com/sk89q/worldedit/expression/runtime/Function.java @@ -49,14 +49,12 @@ public class Function extends RValue { public final double getValue() throws EvaluationException { try { return (Double) method.invoke(null, (Object[]) args); - } - catch (InvocationTargetException e) { + } catch (InvocationTargetException e) { if (e.getTargetException() instanceof EvaluationException) { throw (EvaluationException) e.getTargetException(); } throw new EvaluationException(-1, "Exception caught while evaluating expression", e.getTargetException()); - } - catch (IllegalAccessException e) { + } catch (IllegalAccessException e) { throw new EvaluationException(-1, "Internal error while evaluating expression", e); } } @@ -99,8 +97,7 @@ public class Function extends RValue { if (optimizable) { return new Constant(position, getValue()); - } - else { + } else { return new Function(position, method, optimizedArgs); } } diff --git a/src/main/java/com/sk89q/worldedit/expression/runtime/Operators.java b/src/main/java/com/sk89q/worldedit/expression/runtime/Operators.java index c28e092fc..20219872f 100644 --- a/src/main/java/com/sk89q/worldedit/expression/runtime/Operators.java +++ b/src/main/java/com/sk89q/worldedit/expression/runtime/Operators.java @@ -29,8 +29,8 @@ public final class Operators { if (lhs instanceof LValue) { try { return new Function(position, Operators.class.getMethod(name, LValue.class, RValue.class), lhs, rhs); + } catch (NoSuchMethodException e) { } - catch (NoSuchMethodException e) {} } return new Function(position, Operators.class.getMethod(name, RValue.class, RValue.class), lhs, rhs); } @@ -39,8 +39,8 @@ public final class Operators { if (argument instanceof LValue) { try { return new Function(position, Operators.class.getMethod(name, LValue.class), argument); + } catch (NoSuchMethodException e) { } - catch (NoSuchMethodException e) {} } return new Function(position, Operators.class.getMethod(name, RValue.class), argument); } diff --git a/src/main/java/com/sk89q/worldedit/expression/runtime/Sequence.java b/src/main/java/com/sk89q/worldedit/expression/runtime/Sequence.java index 8123cc9b7..cc700db22 100644 --- a/src/main/java/com/sk89q/worldedit/expression/runtime/Sequence.java +++ b/src/main/java/com/sk89q/worldedit/expression/runtime/Sequence.java @@ -75,8 +75,7 @@ public class Sequence extends RValue { for (RValue subInvokable : ((Sequence) invokable).sequence) { newSequence.add(subInvokable); } - } - else { + } else { newSequence.add(invokable); } }