From b5b55a27750b84d13915fb7cef918f95584907cc Mon Sep 17 00:00:00 2001 From: Wizjany Date: Sat, 24 Sep 2011 15:24:10 -0400 Subject: [PATCH] Cleanup and a few bugfixes --- .../bukkit/migration/DinnerPermsResolver.java | 20 ++++-- .../migration/NijiPermissionsResolver.java | 9 ++- .../migration/PermissionsExResolver.java | 3 +- .../migration/PermissionsResolverManager.java | 4 +- .../util/commands/CommandContext.java | 12 ++-- .../util/commands/CommandsManager.java | 3 +- .../java/com/sk89q/worldedit/EditSession.java | 1 + .../java/com/sk89q/worldedit/HeightMap.java | 3 +- .../java/com/sk89q/worldedit/LocalPlayer.java | 12 ++-- .../com/sk89q/worldedit/LocalSession.java | 17 +---- .../java/com/sk89q/worldedit/LocalWorld.java | 8 +-- src/main/java/com/sk89q/worldedit/Vector.java | 2 +- .../java/com/sk89q/worldedit/Vector2D.java | 6 +- .../java/com/sk89q/worldedit/WorldEdit.java | 21 +++--- .../com/sk89q/worldedit/blocks/BaseBlock.java | 20 +++--- .../sk89q/worldedit/bukkit/BukkitUtil.java | 1 + .../sk89q/worldedit/bukkit/BukkitWorld.java | 30 ++++---- .../worldedit/commands/ChunkCommands.java | 9 ++- .../worldedit/commands/RegionCommands.java | 6 +- .../worldedit/commands/ScriptingCommands.java | 17 +++-- .../worldedit/commands/SelectionCommands.java | 9 +-- .../worldedit/commands/UtilityCommands.java | 16 ++--- .../worldedit/cui/CUIPointBasedRegion.java | 1 - .../worldedit/cui/SelectionMinMaxEvent.java | 2 - .../com/sk89q/worldedit/data/BlockData.java | 72 +++++++------------ .../regions/CuboidRegionSelector.java | 24 +++---- .../regions/Polygonal2DRegionSelector.java | 16 ++--- .../scripting/RhinoCraftScriptEngine.java | 6 +- .../scripting/java/RhinoScriptEngine.java | 8 +-- .../tools/brushes/ClipboardBrush.java | 3 +- 30 files changed, 170 insertions(+), 191 deletions(-) diff --git a/src/main/java/com/sk89q/bukkit/migration/DinnerPermsResolver.java b/src/main/java/com/sk89q/bukkit/migration/DinnerPermsResolver.java index c58d71d36..6ed5f3281 100644 --- a/src/main/java/com/sk89q/bukkit/migration/DinnerPermsResolver.java +++ b/src/main/java/com/sk89q/bukkit/migration/DinnerPermsResolver.java @@ -41,14 +41,17 @@ public class DinnerPermsResolver implements PermissionsResolver { public boolean hasPermission(String name, String permission) { Player player = server.getPlayer(name); - if (player == null) + if (player == null) { return false; // Permissions are only registered for online players - if ( player.hasPermission("*") || player.hasPermission(permission)) + } + if ( player.hasPermission("*") || player.hasPermission(permission)) { return true; + } int dotPos = permission.lastIndexOf("."); while (dotPos > -1) { - if (player.hasPermission(permission.substring(0, dotPos + 1) + "*")) + if (player.hasPermission(permission.substring(0, dotPos + 1) + "*")) { return true; + } dotPos = permission.lastIndexOf(".", dotPos - 1); } return false; @@ -60,22 +63,25 @@ public class DinnerPermsResolver implements PermissionsResolver { public boolean inGroup(String name, String group) { Player player = server.getPlayer(name); - if (player == null) + if (player == null) { return false; + } return player.hasPermission(GROUP_PREFIX + group); } public String[] getGroups(String name) { Player player = server.getPlayer(name); - if (player == null) + if (player == null) { return new String[0]; + } List groupNames = new ArrayList(); for (PermissionAttachmentInfo permAttach : player.getEffectivePermissions()) { String perm = permAttach.getPermission(); - if (!(perm.startsWith(GROUP_PREFIX) && permAttach.getValue())) + if (!(perm.startsWith(GROUP_PREFIX) && permAttach.getValue())) { continue; + } groupNames.add(perm.substring(GROUP_PREFIX.length(), perm.length())); } - return groupNames.toArray(new String[0]); + return groupNames.toArray(new String[groupNames.size()]); } } diff --git a/src/main/java/com/sk89q/bukkit/migration/NijiPermissionsResolver.java b/src/main/java/com/sk89q/bukkit/migration/NijiPermissionsResolver.java index 03d096808..954585b2e 100644 --- a/src/main/java/com/sk89q/bukkit/migration/NijiPermissionsResolver.java +++ b/src/main/java/com/sk89q/bukkit/migration/NijiPermissionsResolver.java @@ -45,8 +45,9 @@ public class NijiPermissionsResolver implements PermissionsResolver { if (plugin == null) { throw new MissingPluginException(); } - if (!checkRealNijiPerms(ignoreBridges)) + if (!checkRealNijiPerms(ignoreBridges)) { throw new MissingPluginException(); + } try { api = (Permissions)plugin; @@ -129,11 +130,13 @@ public class NijiPermissionsResolver implements PermissionsResolver { } public static boolean checkRealNijiPerms(boolean ignoreBridges) { - if (!ignoreBridges) + if (!ignoreBridges) { return true; + } PluginCommand permsCommand = Bukkit.getServer().getPluginCommand("permissions"); - if (permsCommand == null) + if (permsCommand == null) { return false; + } return permsCommand.getPlugin().getDescription().getName().equals("Permissions"); } } diff --git a/src/main/java/com/sk89q/bukkit/migration/PermissionsExResolver.java b/src/main/java/com/sk89q/bukkit/migration/PermissionsExResolver.java index 1bbb1f70b..d7e901f24 100644 --- a/src/main/java/com/sk89q/bukkit/migration/PermissionsExResolver.java +++ b/src/main/java/com/sk89q/bukkit/migration/PermissionsExResolver.java @@ -34,8 +34,9 @@ public class PermissionsExResolver implements PermissionsResolver { public PermissionsExResolver(Server server) throws MissingPluginException { this.server = server; manager = server.getServicesManager().load(PermissionManager.class); - if (manager == null) + if (manager == null) { throw new MissingPluginException(); + } } public void load() { diff --git a/src/main/java/com/sk89q/bukkit/migration/PermissionsResolverManager.java b/src/main/java/com/sk89q/bukkit/migration/PermissionsResolverManager.java index 4c318daca..fdfb2015b 100644 --- a/src/main/java/com/sk89q/bukkit/migration/PermissionsResolverManager.java +++ b/src/main/java/com/sk89q/bukkit/migration/PermissionsResolverManager.java @@ -76,6 +76,7 @@ public class PermissionsResolverManager implements PermissionsResolver { loadConfig(new File("wepif.yml")); findResolver(); } + public void findResolver() { if (tryPluginPermissionsResolver()) return; if (tryNijiPermissions()) return; @@ -132,8 +133,9 @@ public class PermissionsResolverManager implements PermissionsResolver { } private boolean tryDinnerPerms() { - if (!permsConfig.getBoolean("dinnerperms", true)) + if (!permsConfig.getBoolean("dinnerperms", true)) { return false; + } perms = new DinnerPermsResolver(server); logger.info(name + ": Using the Bukkit Permissions API."); return true; 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 7cbdfa7ea..17015f664 100644 --- a/src/main/java/com/sk89q/minecraft/util/commands/CommandContext.java +++ b/src/main/java/com/sk89q/minecraft/util/commands/CommandContext.java @@ -133,8 +133,9 @@ public class CommandContext { throw new CommandException("Value flag '" + flagName + "' already given"); } - if (nextArg >= argList.size()) + if (nextArg >= argList.size()) { throw new CommandException("No value specified for the '-"+flagName+"' flag."); + } // If it is a value flag, read another argument and add it this.valueFlags.put(flagName, argList.get(nextArg++)); @@ -217,8 +218,9 @@ public class CommandContext { public String getFlag(char ch, String def) { final String value = valueFlags.get(ch); - if (value == null) + if (value == null) { return def; + } return value; } @@ -229,8 +231,9 @@ public class CommandContext { public int getFlagInteger(char ch, int def) throws NumberFormatException { final String value = valueFlags.get(ch); - if (value == null) + if (value == null) { return def; + } return Integer.parseInt(value); } @@ -241,8 +244,9 @@ public class CommandContext { public double getFlagDouble(char ch, double def) throws NumberFormatException { final String value = valueFlags.get(ch); - if (value == null) + if (value == null) { return def; + } return Double.parseDouble(value); } diff --git a/src/main/java/com/sk89q/minecraft/util/commands/CommandsManager.java b/src/main/java/com/sk89q/minecraft/util/commands/CommandsManager.java index f384b64ea..ce9aa7660 100644 --- a/src/main/java/com/sk89q/minecraft/util/commands/CommandsManager.java +++ b/src/main/java/com/sk89q/minecraft/util/commands/CommandsManager.java @@ -422,7 +422,8 @@ public abstract class CommandsManager { } } - public void invokeMethod(Method parent, String[] args, T player, Method method, Object instance, Object[] methodArgs, int level) throws CommandException { + public void invokeMethod(Method parent, String[] args, T player, Method method, + Object instance, Object[] methodArgs, int level) throws CommandException { try { method.invoke(instance, methodArgs); } catch (IllegalArgumentException e) { diff --git a/src/main/java/com/sk89q/worldedit/EditSession.java b/src/main/java/com/sk89q/worldedit/EditSession.java index d56e8fff7..4d380e5a8 100644 --- a/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/src/main/java/com/sk89q/worldedit/EditSession.java @@ -2386,6 +2386,7 @@ public class EditSession { setBlockIfAir(pos.add(-1, h, -1), log); } setBlockIfAir(pos.add(-1, 0, -1), pumpkin); + break; } } diff --git a/src/main/java/com/sk89q/worldedit/HeightMap.java b/src/main/java/com/sk89q/worldedit/HeightMap.java index c3db61195..74aeae182 100644 --- a/src/main/java/com/sk89q/worldedit/HeightMap.java +++ b/src/main/java/com/sk89q/worldedit/HeightMap.java @@ -89,8 +89,9 @@ public class HeightMap { int[] newData = new int[data.length]; System.arraycopy(data, 0, newData, 0, data.length); - for (int i = 0; i < iterations; ++i) + for (int i = 0; i < iterations; ++i) { newData = filter.filter(newData, width, height); + } return apply(newData); } diff --git a/src/main/java/com/sk89q/worldedit/LocalPlayer.java b/src/main/java/com/sk89q/worldedit/LocalPlayer.java index 0765a76ba..52e55bdc6 100644 --- a/src/main/java/com/sk89q/worldedit/LocalPlayer.java +++ b/src/main/java/com/sk89q/worldedit/LocalPlayer.java @@ -240,8 +240,7 @@ public abstract class LocalPlayer { // Found a ceiling! if (!BlockType.canPassThrough(world.getBlockType(new Vector(x, y, z)))) { int platformY = Math.max(initialY, y - 3 - clearance); - world.setBlockType(new Vector(x, platformY, z), - BlockID.GLASS); + world.setBlockType(new Vector(x, platformY, z), BlockID.GLASS); setPosition(new Vector(x + 0.5, platformY + 1, z + 0.5)); return true; } @@ -273,8 +272,7 @@ public abstract class LocalPlayer { } else if (y > maxY + 1) { break; } else if (y == maxY + 1) { - world.setBlockType(new Vector(x, y - 2, z), - BlockID.GLASS); + world.setBlockType(new Vector(x, y - 2, z), BlockID.GLASS); setPosition(new Vector(x + 0.5, y - 1, z + 0.5)); return true; } @@ -351,10 +349,12 @@ public abstract class LocalPlayer { * @return */ public PlayerDirection getCardinalDirection() { - if (getPitch() > 67.5) + if (getPitch() > 67.5) { return PlayerDirection.DOWN; - if (getPitch() < -67.5) + } + if (getPitch() < -67.5) { return PlayerDirection.UP; + } // From hey0's code double rot = (getYaw() - 90) % 360; diff --git a/src/main/java/com/sk89q/worldedit/LocalSession.java b/src/main/java/com/sk89q/worldedit/LocalSession.java index fb2bebe25..c6e6221dd 100644 --- a/src/main/java/com/sk89q/worldedit/LocalSession.java +++ b/src/main/java/com/sk89q/worldedit/LocalSession.java @@ -36,7 +36,6 @@ import com.sk89q.worldedit.tools.Tool; import com.sk89q.worldedit.bags.BlockBag; import com.sk89q.worldedit.cui.CUIPointBasedRegion; import com.sk89q.worldedit.cui.CUIEvent; -import com.sk89q.worldedit.cui.SelectionPointEvent; import com.sk89q.worldedit.cui.SelectionShapeEvent; import com.sk89q.worldedit.masks.Mask; import com.sk89q.worldedit.regions.CuboidRegionSelector; @@ -66,8 +65,7 @@ public class LocalSession { private boolean toolControl = true; private boolean superPickaxe = false; private BlockTool pickaxeMode = new SinglePickaxe(); - private Map tools - = new HashMap(); + private Map tools = new HashMap(); private int maxBlocksChanged = -1; private boolean useInventory; private Snapshot snapshot; @@ -122,7 +120,7 @@ public class LocalSession { */ public void remember(EditSession editSession) { // Don't store anything if no changes were made - if (editSession.size() == 0) { return; } + if (editSession.size() == 0) return; // Destroy any sessions after this undo point while (historyPointer < history.size()) { @@ -480,10 +478,6 @@ public class LocalSession { public void setTool(int item, Tool tool) throws InvalidToolBindException { if (item > 0 && item < 255) { throw new InvalidToolBindException(item, "Blocks can't be used"); - /* } else if (item == ItemType.COAL.getID() || item == ItemType.LIGHTSTONE_DUST.getID()) { - throw new InvalidToolBindException(item, "Item is not usuable"); - // let people deal with craftbook themselves, not everyone uses it - */ } else if (item == config.wandItem) { throw new InvalidToolBindException(item, "Already used for the wand"); } else if (item == config.navigationWand) { @@ -562,10 +556,6 @@ public class LocalSession { * @param player */ public void dispatchCUISetup(LocalPlayer player) { - if (!hasCUISupport) { - return; - } - if (selector != null) { dispatchCUISelection(player); } @@ -581,8 +571,7 @@ public class LocalSession { return; } - player.dispatchCUIEvent( - new SelectionShapeEvent(selector.getTypeId())); + player.dispatchCUIEvent(new SelectionShapeEvent(selector.getTypeId())); if (selector instanceof CUIPointBasedRegion) { ((CUIPointBasedRegion) selector).describeCUI(player); diff --git a/src/main/java/com/sk89q/worldedit/LocalWorld.java b/src/main/java/com/sk89q/worldedit/LocalWorld.java index 284e6bad0..33f1f4544 100644 --- a/src/main/java/com/sk89q/worldedit/LocalWorld.java +++ b/src/main/java/com/sk89q/worldedit/LocalWorld.java @@ -206,8 +206,8 @@ public abstract class LocalWorld { * @return * @throws MaxChangedBlocksException */ - public abstract boolean generateRedwoodTree(EditSession editSession, - Vector pt) throws MaxChangedBlocksException; + public abstract boolean generateRedwoodTree(EditSession editSession, Vector pt) + throws MaxChangedBlocksException; /** * Generate a tall redwood tree at a location. @@ -217,8 +217,8 @@ public abstract class LocalWorld { * @return * @throws MaxChangedBlocksException */ - public abstract boolean generateTallRedwoodTree(EditSession editSession, - Vector pt) throws MaxChangedBlocksException; + public abstract boolean generateTallRedwoodTree(EditSession editSession, Vector pt) + throws MaxChangedBlocksException; /** * Drop an item. diff --git a/src/main/java/com/sk89q/worldedit/Vector.java b/src/main/java/com/sk89q/worldedit/Vector.java index ade2ec793..949901ae0 100644 --- a/src/main/java/com/sk89q/worldedit/Vector.java +++ b/src/main/java/com/sk89q/worldedit/Vector.java @@ -573,7 +573,7 @@ public class Vector { if (!(obj instanceof Vector)) { return false; } - Vector other = (Vector)obj; + Vector other = (Vector) obj; return other.getX() == this.x && other.getY() == this.y && other.getZ() == this.z; } diff --git a/src/main/java/com/sk89q/worldedit/Vector2D.java b/src/main/java/com/sk89q/worldedit/Vector2D.java index b9e343a08..64d4bd343 100644 --- a/src/main/java/com/sk89q/worldedit/Vector2D.java +++ b/src/main/java/com/sk89q/worldedit/Vector2D.java @@ -88,7 +88,7 @@ public class Vector2D { * @return the x */ public int getBlockX() { - return (int)Math.round(x); + return (int) Math.round(x); } /** @@ -122,7 +122,7 @@ public class Vector2D { * @return the z */ public int getBlockZ() { - return (int)Math.round(z); + return (int) Math.round(z); } /** @@ -165,7 +165,7 @@ public class Vector2D { if (!(obj instanceof Vector2D)) { return false; } - Vector other = (Vector)obj; + Vector other = (Vector) obj; return other.x == this.x && other.z == this.z; } diff --git a/src/main/java/com/sk89q/worldedit/WorldEdit.java b/src/main/java/com/sk89q/worldedit/WorldEdit.java index 87eeaefe8..b94d8e76f 100644 --- a/src/main/java/com/sk89q/worldedit/WorldEdit.java +++ b/src/main/java/com/sk89q/worldedit/WorldEdit.java @@ -79,8 +79,7 @@ public class WorldEdit { * without any WorldEdit abilities or never use WorldEdit in a session will * not have a session object generated for them. */ - private HashMap sessions = - new HashMap(); + private HashMap sessions = new HashMap(); /** * Initialize statically. @@ -113,13 +112,14 @@ public class WorldEdit { final Logging loggingAnnotation = method.getAnnotation(Logging.class); final Logging.LogMode logMode; - if (loggingAnnotation == null) + if (loggingAnnotation == null) { logMode = null; - else + } else { logMode = loggingAnnotation.value(); + } - String msg = "WorldEdit: " + player.getName() + "(in " + player.getWorld().getName() + ")" - + ": " + StringUtil.joinString(args, " "); + String msg = "WorldEdit: " + player.getName() + " (in \"" + player.getWorld().getName() + + "\")" + ": " + StringUtil.joinString(args, " "); if (logMode != null) { Vector position = player.getPosition(); final LocalSession session = getSession(player); @@ -690,8 +690,7 @@ public class WorldEdit { } if (!filename.matches("^[A-Za-z0-9_\\- \\./\\\\'\\$@~!%\\^\\*\\(\\)\\[\\]\\+\\{\\},\\?]+\\.[A-Za-z0-9]+$")) { - throw new InvalidFilenameException(filename, - "Invalid characters or extension missing"); + throw new InvalidFilenameException(filename, "Invalid characters or extension missing"); } f = new File(dir, filename); @@ -749,7 +748,7 @@ public class WorldEdit { * @return */ public static int divisorMod(int a, int n) { - return (int)(a - n * Math.floor(Math.floor(a) / (double)n)); + return (int) (a - n * Math.floor(Math.floor(a) / (double) n)); } /** @@ -1044,6 +1043,7 @@ public class WorldEdit { && player.hasPermission("worldedit.navigation.jumpto")) { // Bug workaround // Blocks this from being used after the thru function + // @TODO do this right or make craftbukkit do it right if (!session.canUseJumpto()){ session.toggleJumptoBlock(); return false; @@ -1085,8 +1085,9 @@ public class WorldEdit { } // Bug workaround, so it wont do the Jumpto compass function // Right after this teleport - if (session.canUseJumpto()) + if (session.canUseJumpto()) { session.toggleJumptoBlock(); + } return true; } diff --git a/src/main/java/com/sk89q/worldedit/blocks/BaseBlock.java b/src/main/java/com/sk89q/worldedit/blocks/BaseBlock.java index d29a65c65..ae4aeaad9 100644 --- a/src/main/java/com/sk89q/worldedit/blocks/BaseBlock.java +++ b/src/main/java/com/sk89q/worldedit/blocks/BaseBlock.java @@ -43,7 +43,7 @@ public class BaseBlock { * @param type */ public BaseBlock(int type) { - this.type = (short)type; + this.type = (short) type; } /** @@ -53,22 +53,22 @@ public class BaseBlock { * @param data */ public BaseBlock(int type, int data) { - this.type = (short)type; - this.data = (byte)data; + this.type = (short) type; + this.data = (byte) data; } /** * @return the type */ public int getType() { - return (int)type; + return (int) type; } /** * @param type the type to set */ public void setType(int type) { - this.type = (short)type; + this.type = (short) type; } /** @@ -82,7 +82,7 @@ public class BaseBlock { * @param data the data to set */ public void setData(int data) { - this.data = (byte)data; + this.data = (byte) data; } /** @@ -98,14 +98,14 @@ public class BaseBlock { * Rotate this block 90 degrees. */ public void rotate90() { - data = (byte)BlockData.rotate90(type, data); + data = (byte) BlockData.rotate90(type, data); } /** * Rotate this block -90 degrees. */ public void rotate90Reverse() { - data = (byte)BlockData.rotate90Reverse(type, data); + data = (byte) BlockData.rotate90Reverse(type, data); } /** @@ -129,8 +129,8 @@ public class BaseBlock { if (!(o instanceof BaseBlock)) { return false; } - return (type == ((BaseBlock)o).type) - && (data == ((BaseBlock)o).data || data == -1 || ((BaseBlock)o).data == -1); + return (type == ((BaseBlock) o).type) + && (data == ((BaseBlock) o).data || data == -1 || ((BaseBlock) o).data == -1); } @Override diff --git a/src/main/java/com/sk89q/worldedit/bukkit/BukkitUtil.java b/src/main/java/com/sk89q/worldedit/bukkit/BukkitUtil.java index 3e2647422..77deb2750 100644 --- a/src/main/java/com/sk89q/worldedit/bukkit/BukkitUtil.java +++ b/src/main/java/com/sk89q/worldedit/bukkit/BukkitUtil.java @@ -34,6 +34,7 @@ public class BukkitUtil { } private static final Map wlw = new HashMap(); + public static LocalWorld getLocalWorld(World w) { LocalWorld lw = wlw.get(w); if (lw == null) { diff --git a/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java b/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java index 3da9d699e..d0cef0d84 100644 --- a/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java +++ b/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java @@ -304,7 +304,7 @@ public class BukkitWorld extends LocalWorld { public boolean copyFromWorld(Vector pt, BaseBlock block) { // Signs if (block instanceof SignBlock) { - ((SignBlock)block).setText(getSignText(pt)); + ((SignBlock) block).setText(getSignText(pt)); return true; // Furnaces @@ -313,16 +313,16 @@ public class BukkitWorld extends LocalWorld { if (bukkitBlock == null) return false; BlockState state = bukkitBlock.getState(); if (!(state instanceof Furnace)) return false; - Furnace bukkit = (Furnace)state; - FurnaceBlock we = (FurnaceBlock)block; + Furnace bukkit = (Furnace) state; + FurnaceBlock we = (FurnaceBlock) block; we.setBurnTime(bukkit.getBurnTime()); we.setCookTime(bukkit.getCookTime()); - ((ContainerBlock)block).setItems(getContainerBlockContents(pt)); + ((ContainerBlock) block).setItems(getContainerBlockContents(pt)); return true; // Chests/dispenser } else if (block instanceof ContainerBlock) { - ((ContainerBlock)block).setItems(getContainerBlockContents(pt)); + ((ContainerBlock) block).setItems(getContainerBlockContents(pt)); return true; // Mob spawners @@ -331,10 +331,10 @@ public class BukkitWorld extends LocalWorld { if (bukkitBlock == null) return false; BlockState state = bukkitBlock.getState(); if (!(state instanceof CreatureSpawner)) return false; - CreatureSpawner bukkit = (CreatureSpawner)state; - MobSpawnerBlock we = (MobSpawnerBlock)block; + CreatureSpawner bukkit = (CreatureSpawner) state; + MobSpawnerBlock we = (MobSpawnerBlock) block; we.setMobType(bukkit.getCreatureTypeId()); - we.setDelay((short)bukkit.getDelay()); + we.setDelay((short) bukkit.getDelay()); return true; // Note block @@ -344,7 +344,7 @@ public class BukkitWorld extends LocalWorld { BlockState state = bukkitBlock.getState(); if (!(state instanceof org.bukkit.block.NoteBlock)) return false; org.bukkit.block.NoteBlock bukkit = (org.bukkit.block.NoteBlock)state; - NoteBlock we = (NoteBlock)block; + NoteBlock we = (NoteBlock) block; we.setNote(bukkit.getRawNote()); } @@ -442,7 +442,7 @@ public class BukkitWorld extends LocalWorld { @Override public void dropItem(Vector pt, BaseItemStack item) { ItemStack bukkitItem = new ItemStack(item.getType(), item.getAmount(), - (byte)item.getDamage()); + (byte) item.getDamage()); world.dropItemNaturally(toLocation(pt), bukkitItem); } @@ -563,7 +563,7 @@ public class BukkitWorld extends LocalWorld { if (block == null) return false; BlockState state = block.getState(); if (state == null || !(state instanceof Sign)) return false; - Sign sign = (Sign)state; + Sign sign = (Sign) state; sign.setLine(0, text[0]); sign.setLine(1, text[1]); sign.setLine(2, text[2]); @@ -583,7 +583,7 @@ public class BukkitWorld extends LocalWorld { if (block == null) return new String[] { "", "", "", "" }; BlockState state = block.getState(); if (state == null || !(state instanceof Sign)) return new String[] { "", "", "", "" }; - Sign sign = (Sign)state; + Sign sign = (Sign) state; String line0 = sign.getLine(0); String line1 = sign.getLine(1); String line2 = sign.getLine(2); @@ -612,7 +612,7 @@ public class BukkitWorld extends LocalWorld { return new BaseItemStack[0]; } - org.bukkit.block.ContainerBlock container = (org.bukkit.block.ContainerBlock)state; + org.bukkit.block.ContainerBlock container = (org.bukkit.block.ContainerBlock) state; Inventory inven = container.getInventory(); int size = inven.getSize(); BaseItemStack[] contents = new BaseItemStack[size]; @@ -659,7 +659,7 @@ public class BukkitWorld extends LocalWorld { if (contents[i] != null) { inven.setItem(i, new ItemStack(contents[i].getType(), contents[i].getAmount(), - (byte)contents[i].getDamage())); + (byte) contents[i].getDamage())); } else { inven.setItem(i, null); } @@ -692,7 +692,7 @@ public class BukkitWorld extends LocalWorld { return false; } - return ((BukkitWorld)other).world.equals(world); + return ((BukkitWorld) other).world.equals(world); } @Override diff --git a/src/main/java/com/sk89q/worldedit/commands/ChunkCommands.java b/src/main/java/com/sk89q/worldedit/commands/ChunkCommands.java index 58bbee869..781e6735d 100644 --- a/src/main/java/com/sk89q/worldedit/commands/ChunkCommands.java +++ b/src/main/java/com/sk89q/worldedit/commands/ChunkCommands.java @@ -49,8 +49,8 @@ public class ChunkCommands { throws WorldEditException { Vector pos = player.getBlockIn(); - int chunkX = (int)Math.floor(pos.getBlockX() / 16.0); - int chunkZ = (int)Math.floor(pos.getBlockZ() / 16.0); + int chunkX = (int) Math.floor(pos.getBlockX() / 16.0); + int chunkZ = (int) Math.floor(pos.getBlockZ() / 16.0); String folder1 = Integer.toString(WorldEdit.divisorMod(chunkX, 64), 36); String folder2 = Integer.toString(WorldEdit.divisorMod(chunkZ, 64), 36); @@ -159,7 +159,10 @@ public class ChunkCommands { player.printError("Error occurred: " + e.getMessage()); } finally { if (out != null) { - try { out.close(); } catch (IOException ie) {} + try { + out.close(); + } catch (IOException ie) { + } } } } else { diff --git a/src/main/java/com/sk89q/worldedit/commands/RegionCommands.java b/src/main/java/com/sk89q/worldedit/commands/RegionCommands.java index 8641596ad..24aa75454 100644 --- a/src/main/java/com/sk89q/worldedit/commands/RegionCommands.java +++ b/src/main/java/com/sk89q/worldedit/commands/RegionCommands.java @@ -61,7 +61,7 @@ public class RegionCommands { if (pattern instanceof SingleBlockPattern) { affected = editSession.setBlocks(session.getSelection(player.getWorld()), - ((SingleBlockPattern)pattern).getBlock()); + ((SingleBlockPattern) pattern).getBlock()); } else { affected = editSession.setBlocks(session.getSelection(player.getWorld()), pattern); } @@ -96,7 +96,7 @@ public class RegionCommands { int affected = 0; if (to instanceof SingleBlockPattern) { affected = editSession.replaceBlocks(session.getSelection(player.getWorld()), from, - ((SingleBlockPattern)to).getBlock()); + ((SingleBlockPattern) to).getBlock()); } else { affected = editSession.replaceBlocks(session.getSelection(player.getWorld()), from, to); } @@ -123,7 +123,7 @@ public class RegionCommands { int affected = 0; if (pat instanceof SingleBlockPattern) { affected = editSession.overlayCuboidBlocks(region, - ((SingleBlockPattern)pat).getBlock()); + ((SingleBlockPattern) pat).getBlock()); } else { affected = editSession.overlayCuboidBlocks(region, pat); } diff --git a/src/main/java/com/sk89q/worldedit/commands/ScriptingCommands.java b/src/main/java/com/sk89q/worldedit/commands/ScriptingCommands.java index c654c4468..143315777 100644 --- a/src/main/java/com/sk89q/worldedit/commands/ScriptingCommands.java +++ b/src/main/java/com/sk89q/worldedit/commands/ScriptingCommands.java @@ -45,14 +45,19 @@ public class ScriptingCommands { public static void execute(CommandContext args, WorldEdit we, LocalSession session, LocalPlayer player, EditSession editSession) throws WorldEditException { - // @TODO: Check for worldedit.scripting.execute.