From 1dc84d25113489523b6390b6f4bb2282713ba8ce Mon Sep 17 00:00:00 2001 From: sk89q Date: Tue, 29 Jul 2014 11:04:04 -0700 Subject: [PATCH] Fix Javadocs and code issues. --- .../sk89q/wepif/TestOfflinePermissible.java | 25 +++ .../worldedit/bukkit/BukkitWorldTest.java | 5 +- .../com/sk89q/bukkit/util/CommandInfo.java | 5 +- .../bukkit/util/CommandRegistration.java | 16 +- .../util/CommandsManagerRegistration.java | 7 +- .../util/DynamicPluginCommandHelpTopic.java | 6 +- .../util/FallbackRegistrationListener.java | 4 +- .../ConfigurationPermissionsResolver.java | 16 +- .../com/sk89q/wepif/DinnerPermsResolver.java | 10 ++ .../wepif/FlatFilePermissionsResolver.java | 47 +++--- .../com/sk89q/wepif/GroupManagerResolver.java | 10 ++ .../sk89q/wepif/NijiPermissionsResolver.java | 25 ++- .../sk89q/wepif/PermissionsExResolver.java | 6 + .../wepif/PermissionsResolverManager.java | 21 ++- .../wepif/PluginPermissionsResolver.java | 10 ++ .../sk89q/wepif/WEPIFRuntimeException.java | 5 +- .../com/sk89q/wepif/bPermissionsResolver.java | 14 +- .../bukkit/BukkitPlayerBlockBag.java | 35 +--- .../worldedit/bukkit/CUIChannelListener.java | 5 +- .../EditSessionBlockChangeDelegate.java | 11 +- .../sk89q/worldedit/bukkit/WorldEditAPI.java | 10 +- .../worldedit/bukkit/WorldEditListener.java | 4 +- .../worldedit/bukkit/WorldEditPlugin.java | 61 +++---- .../worldedit/bukkit/entity/BukkitEntity.java | 5 +- .../worldedit/bukkit/entity/BukkitExpOrb.java | 5 +- .../worldedit/bukkit/entity/BukkitItem.java | 5 +- .../bukkit/entity/BukkitPainting.java | 15 +- .../selections/Polygonal2DSelection.java | 1 - .../bukkit/selections/RegionSelection.java | 17 +- .../bukkit/selections/Selection.java | 18 ++- .../com/sk89q/worldedit/forge/ForgeUtil.java | 10 +- .../worldedit/forge/TileEntityUtils.java | 5 +- .../worldedit/forge/WECUIPacketHandler.java | 1 + .../com/sk89q/worldedit/bags/BlockBag.java | 38 +++-- .../worldedit/bags/BlockBagException.java | 2 +- .../worldedit/bags/OutOfBlocksException.java | 2 +- .../worldedit/bags/OutOfSpaceException.java | 7 +- .../bags/UnplaceableBlockException.java | 1 - .../sk89q/worldedit/blocks/ChestBlock.java | 3 +- .../worldedit/blocks/ContainerBlock.java | 19 ++- .../worldedit/blocks/DispenserBlock.java | 3 +- .../sk89q/worldedit/blocks/FurnaceBlock.java | 3 +- .../com/sk89q/worldedit/blocks/LazyBlock.java | 12 +- .../worldedit/blocks/MobSpawnerBlock.java | 4 +- .../com/sk89q/worldedit/blocks/NoteBlock.java | 3 +- .../com/sk89q/worldedit/blocks/SignBlock.java | 3 +- .../com/sk89q/worldedit/masks/BlockMask.java | 4 +- .../sk89q/worldedit/masks/BlockTypeMask.java | 8 +- .../sk89q/worldedit/masks/CombinedMask.java | 4 +- .../worldedit/masks/DynamicRegionMask.java | 4 +- .../worldedit/masks/ExistingBlockMask.java | 4 +- .../sk89q/worldedit/masks/FuzzyBlockMask.java | 9 +- .../masks/InvertedBlockTypeMask.java | 17 +- .../sk89q/worldedit/masks/InvertedMask.java | 5 +- .../java/com/sk89q/worldedit/masks/Mask.java | 13 +- .../com/sk89q/worldedit/masks/RandomMask.java | 2 +- .../com/sk89q/worldedit/masks/RegionMask.java | 4 +- .../sk89q/worldedit/masks/SolidBlockMask.java | 4 +- .../worldedit/masks/UnderOverlayMask.java | 4 +- .../sk89q/worldedit/patterns/BlockChance.java | 12 +- .../worldedit/patterns/ClipboardPattern.java | 32 +--- .../com/sk89q/worldedit/patterns/Pattern.java | 24 +-- .../worldedit/patterns/RandomFillPattern.java | 20 +-- .../patterns/SingleBlockPattern.java | 33 ++-- src/main/java/com/sk89q/jnbt/EndTag.java | 5 +- src/main/java/com/sk89q/jnbt/IntArrayTag.java | 2 +- src/main/java/com/sk89q/jnbt/ListTag.java | 7 +- .../java/com/sk89q/jnbt/NBTConstants.java | 3 - .../java/com/sk89q/jnbt/NBTInputStream.java | 13 +- .../java/com/sk89q/jnbt/NBTOutputStream.java | 51 +++--- src/main/java/com/sk89q/jnbt/NBTUtils.java | 11 +- .../minecraft/util/commands/Command.java | 10 +- .../minecraft/util/commands/CommandAlias.java | 5 +- .../util/commands/CommandContext.java | 4 +- .../util/commands/CommandException.java | 3 +- .../util/commands/CommandPermissions.java | 4 +- .../commands/CommandPermissionsException.java | 4 +- .../util/commands/CommandUsageException.java | 1 - .../util/commands/CommandsManager.java | 128 ++++++++------- .../minecraft/util/commands/Console.java | 3 +- .../minecraft/util/commands/Logging.java | 4 +- .../MissingNestedCommandException.java | 1 - .../util/commands/NestedCommand.java | 4 +- .../util/commands/SimpleInjector.java | 17 +- .../commands/UnhandledCommandException.java | 1 - .../commands/WrappedCommandException.java | 2 +- .../java/com/sk89q/util/ReflectionUtil.java | 7 +- src/main/java/com/sk89q/util/StringUtil.java | 84 +++++----- .../java/com/sk89q/util/yaml/YAMLNode.java | 53 ++++--- .../com/sk89q/util/yaml/YAMLProcessor.java | 34 ++-- .../util/yaml/YAMLProcessorException.java | 4 +- .../com/sk89q/worldedit/CuboidClipboard.java | 5 +- .../java/com/sk89q/worldedit/EditSession.java | 140 ++++++++-------- .../java/com/sk89q/worldedit/Location.java | 2 +- .../com/sk89q/worldedit/PlayerDirection.java | 6 +- .../java/com/sk89q/worldedit/VectorFace.java | 6 +- .../java/com/sk89q/worldedit/WorldEdit.java | 5 +- .../java/com/sk89q/worldedit/WorldVector.java | 53 +++---- .../com/sk89q/worldedit/WorldVector2D.java | 6 - .../com/sk89q/worldedit/WorldVectorFace.java | 47 +----- .../com/sk89q/worldedit/blocks/BlockData.java | 5 +- .../com/sk89q/worldedit/blocks/BlockType.java | 4 +- .../worldedit/blocks/metadata/MobType.java | 3 +- .../worldedit/command/GeneralCommands.java | 2 +- .../InsufficientArgumentsException.java | 6 +- .../worldedit/command/SelectionCommands.java | 3 +- .../worldedit/command/SnapshotCommands.java | 6 +- .../command/SnapshotUtilCommands.java | 2 +- .../sk89q/worldedit/command/ToolCommands.java | 1 - .../worldedit/command/ToolUtilCommands.java | 2 +- .../worldedit/command/UtilityCommands.java | 4 +- .../worldedit/command/tool/BrushTool.java | 27 ++-- .../tool/InvalidToolBindException.java | 2 +- .../sk89q/worldedit/command/tool/Tool.java | 2 +- .../worldedit/command/tool/brush/Brush.java | 16 +- .../command/tool/brush/ButcherBrush.java | 4 +- .../command/tool/brush/ClipboardBrush.java | 4 +- .../command/tool/brush/CylinderBrush.java | 5 +- .../command/tool/brush/GravityBrush.java | 10 +- .../tool/brush/HollowCylinderBrush.java | 4 +- .../command/tool/brush/HollowSphereBrush.java | 4 +- .../command/tool/brush/SmoothBrush.java | 8 +- .../command/tool/brush/SphereBrush.java | 4 +- .../java/com/sk89q/worldedit/event/Event.java | 2 - .../extension/platform/AbstractPlatform.java | 3 - .../extension/platform/Platform.java | 35 ++-- .../extent/buffer/ForgetfulExtentBuffer.java | 4 +- .../worldedit/extent/clipboard/Clipboard.java | 4 +- .../extent/clipboard/io/SchematicReader.java | 2 - .../extent/inventory/BlockBagExtent.java | 3 - .../extent/world/FastModeExtent.java | 2 +- .../worldedit/function/mask/BlockMask.java | 6 +- .../sk89q/worldedit/function/mask/Masks.java | 4 +- .../function/visitor/BreadthFirstSearch.java | 6 +- .../command/CommandLoggingHandler.java | 8 +- .../internal/expression/Expression.java | 2 - .../expression/parser/ParserProcessors.java | 6 +- .../internal/expression/runtime/Function.java | 2 +- .../expression/runtime/SimpleFor.java | 2 +- .../internal/expression/runtime/Switch.java | 4 +- .../regions/ConvexPolyhedralRegion.java | 10 +- .../sk89q/worldedit/regions/CuboidRegion.java | 8 +- .../worldedit/regions/CylinderRegion.java | 9 +- .../worldedit/regions/EllipsoidRegion.java | 4 +- .../sk89q/worldedit/regions/NullRegion.java | 2 +- .../worldedit/regions/Polygonal2DRegion.java | 149 +++++++----------- .../com/sk89q/worldedit/regions/Region.java | 39 +++-- .../worldedit/regions/RegionIntersection.java | 19 ++- .../regions/RegionOperationException.java | 2 +- .../com/sk89q/worldedit/regions/Regions.java | 6 +- .../worldedit/regions/TransformRegion.java | 4 +- .../schematic/MCEditSchematicFormat.java | 33 ++-- .../scripting/CraftScriptContext.java | 83 +++++----- .../scripting/RhinoContextFactory.java | 4 +- .../scripting/RhinoCraftScriptEngine.java | 5 +- .../scripting/java/RhinoScriptEngine.java | 4 + .../java/RhinoScriptEngineFactory.java | 12 ++ .../sk89q/worldedit/session/PasteBuilder.java | 4 +- .../sk89q/worldedit/session/SessionOwner.java | 1 - .../session/request/RequestSelection.java | 10 +- .../com/sk89q/worldedit/util/Countable.java | 35 +--- .../sk89q/worldedit/util/FileDialogUtil.java | 2 +- .../com/sk89q/worldedit/util/Location.java | 12 +- .../util/PropertiesConfiguration.java | 70 ++++---- .../com/sk89q/worldedit/util/TargetBlock.java | 12 +- .../sk89q/worldedit/util/TreeGenerator.java | 87 +++++----- .../worldedit/util/YAMLConfiguration.java | 13 +- .../util/collection/DoubleArrayList.java | 48 +++--- .../util/collection/FastListIterator.java | 6 +- .../util/command/CommandCallable.java | 5 +- .../worldedit/util/command/Description.java | 2 +- .../util/command/InvalidUsageException.java | 14 +- .../command/MissingParameterException.java | 2 - .../util/command/SimpleDescription.java | 2 +- .../command/UnconsumedParameterException.java | 2 - .../util/command/binding/Switch.java | 2 +- .../command/parametric/BindingBehavior.java | 2 +- .../command/parametric/BindingHelper.java | 2 +- .../parametric/ExceptionConverterHelper.java | 2 +- .../parametric/ParameterException.java | 2 - .../command/parametric/ParametricBuilder.java | 4 +- .../parametric/ParametricException.java | 2 - .../eventbus/AnnotatedSubscriberFinder.java | 4 +- .../worldedit/util/eventbus/EventBus.java | 13 +- .../worldedit/util/eventbus/EventHandler.java | 8 +- .../util/eventbus/HierarchyCache.java | 8 +- .../worldedit/util/eventbus/Subscribe.java | 2 +- .../util/formatting/ColorCodeBuilder.java | 8 +- .../worldedit/util/formatting/Style.java | 6 +- .../worldedit/util/formatting/StyleSet.java | 8 +- .../util/formatting/StyledFragment.java | 2 +- .../util/function/LevenshteinDistance.java | 8 +- .../file/FileSelectionAbortedException.java | 2 +- .../util/io/file/FilenameException.java | 2 +- .../io/file/FilenameResolutionException.java | 2 +- .../io/file/InvalidFilenameException.java | 2 +- .../worldedit/util/logging/LogFormat.java | 2 +- .../sk89q/worldedit/world/AbstractWorld.java | 3 +- .../sk89q/worldedit/world/DataException.java | 4 +- .../com/sk89q/worldedit/world/NbtValued.java | 22 +-- .../java/com/sk89q/worldedit/world/World.java | 23 +-- .../worldedit/world/chunk/AnvilChunk.java | 75 +++++---- .../sk89q/worldedit/world/chunk/Chunk.java | 28 ++-- .../sk89q/worldedit/world/chunk/OldChunk.java | 66 ++++---- .../world/registry/EntityRegistry.java | 2 - .../snapshot/InvalidSnapshotException.java | 5 - .../snapshot/ModificationTimerParser.java | 1 + .../worldedit/world/snapshot/Snapshot.java | 37 ++--- .../world/snapshot/SnapshotDateParser.java | 8 +- .../world/snapshot/SnapshotRepository.java | 81 +++++----- .../world/snapshot/SnapshotRestore.java | 38 ++--- .../world/snapshot/YYMMDDHHIISSParser.java | 1 + .../worldedit/world/storage/BlockData.java | 46 +++--- .../worldedit/world/storage/ChunkStore.java | 47 +++--- .../world/storage/ChunkStoreException.java | 6 +- .../world/storage/FileLegacyChunkStore.java | 22 ++- .../world/storage/FileMcRegionChunkStore.java | 17 +- .../world/storage/InvalidFormatException.java | 6 +- .../world/storage/LegacyChunkStore.java | 58 +++---- .../world/storage/McRegionChunkStore.java | 46 +++--- .../world/storage/McRegionReader.java | 42 +++-- .../world/storage/MissingChunkException.java | 15 +- .../world/storage/MissingWorldException.java | 24 +-- .../storage/TrueZipLegacyChunkStore.java | 67 +++----- .../storage/TrueZipMcRegionChunkStore.java | 64 +++----- .../world/storage/ZippedLegacyChunkStore.java | 52 ++---- .../storage/ZippedMcRegionChunkStore.java | 52 ++---- .../util/commands/CommandContextTest.java | 24 +-- .../sk89q/worldedit/blocks/BlockDataTest.java | 15 +- .../internal/expression/ExpressionTest.java | 17 +- 230 files changed, 1646 insertions(+), 1882 deletions(-) diff --git a/src/bukkit-test/java/com/sk89q/wepif/TestOfflinePermissible.java b/src/bukkit-test/java/com/sk89q/wepif/TestOfflinePermissible.java index b309927cf..81e41e9d7 100644 --- a/src/bukkit-test/java/com/sk89q/wepif/TestOfflinePermissible.java +++ b/src/bukkit-test/java/com/sk89q/wepif/TestOfflinePermissible.java @@ -36,22 +36,27 @@ public class TestOfflinePermissible implements OfflinePlayer, Permissible { private final Map assignedPermissions = new HashMap(); + @Override public boolean isOp() { return op; } + @Override public void setOp(boolean b) { this.op = b; } + @Override public boolean isPermissionSet(String s) { return assignedPermissions.containsKey(s.toLowerCase()); } + @Override public boolean isPermissionSet(Permission permission) { return isPermissionSet(permission.getName()); } + @Override public boolean hasPermission(String s) { if (isPermissionSet(s)) { return assignedPermissions.get(s.toLowerCase()); @@ -59,34 +64,42 @@ public class TestOfflinePermissible implements OfflinePlayer, Permissible { return false; } + @Override public boolean hasPermission(Permission permission) { return hasPermission(permission.getName()); } + @Override public PermissionAttachment addAttachment(Plugin plugin, String s, boolean b) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public PermissionAttachment addAttachment(Plugin plugin) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public PermissionAttachment addAttachment(Plugin plugin, String s, boolean b, int i) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public PermissionAttachment addAttachment(Plugin plugin, int i) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public void removeAttachment(PermissionAttachment permissionAttachment) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public void recalculatePermissions() { throw new UnsupportedOperationException("Not supported yet."); } + @Override public Set getEffectivePermissions() { Set ret = new HashSet(); for (Map.Entry entry : assignedPermissions.entrySet()) { @@ -109,10 +122,12 @@ public class TestOfflinePermissible implements OfflinePlayer, Permissible { // -- Unneeded OfflinePlayer methods + @Override public boolean isOnline() { return false; } + @Override public String getName() { return "Tester"; } @@ -121,42 +136,52 @@ public class TestOfflinePermissible implements OfflinePlayer, Permissible { return randomUuid; } + @Override public boolean isBanned() { throw new UnsupportedOperationException("Not supported yet."); } + @Override public void setBanned(boolean b) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public boolean isWhitelisted() { throw new UnsupportedOperationException("Not supported yet."); } + @Override public void setWhitelisted(boolean b) { throw new UnsupportedOperationException("Not supported yet."); } + @Override public Player getPlayer() { throw new UnsupportedOperationException("Not supported yet."); } + @Override public long getFirstPlayed() { throw new UnsupportedOperationException("Not supported yet."); } + @Override public long getLastPlayed() { throw new UnsupportedOperationException("Not supported yet."); } + @Override public boolean hasPlayedBefore() { throw new UnsupportedOperationException("Not supported yet."); } + @Override public Location getBedSpawnLocation() { throw new UnsupportedOperationException("Not supported yet."); } + @Override public Map serialize() { throw new UnsupportedOperationException("Not supported yet."); } diff --git a/src/bukkit-test/java/com/sk89q/worldedit/bukkit/BukkitWorldTest.java b/src/bukkit-test/java/com/sk89q/worldedit/bukkit/BukkitWorldTest.java index def2018d6..cf627e393 100644 --- a/src/bukkit-test/java/com/sk89q/worldedit/bukkit/BukkitWorldTest.java +++ b/src/bukkit-test/java/com/sk89q/worldedit/bukkit/BukkitWorldTest.java @@ -23,14 +23,13 @@ import com.sk89q.worldedit.util.TreeGenerator; import org.junit.Assert; import org.junit.Test; -/** - * @author zml2008 - */ public class BukkitWorldTest { + @Test public void testTreeTypeMapping() { for (TreeGenerator.TreeType type : TreeGenerator.TreeType.values()) { Assert.assertFalse("No mapping for: " + type, BukkitWorld.toBukkitTreeType(type) == null); } } + } diff --git a/src/bukkit/java/com/sk89q/bukkit/util/CommandInfo.java b/src/bukkit/java/com/sk89q/bukkit/util/CommandInfo.java index 2a87c3215..5fad6c1b2 100644 --- a/src/bukkit/java/com/sk89q/bukkit/util/CommandInfo.java +++ b/src/bukkit/java/com/sk89q/bukkit/util/CommandInfo.java @@ -19,10 +19,8 @@ package com.sk89q.bukkit.util; -/** - * @author zml2008 - */ public class CommandInfo { + private final String[] aliases; private final Object registeredWith; private final String usage, desc; @@ -63,4 +61,5 @@ public class CommandInfo { public Object getRegisteredWith() { return registeredWith; } + } diff --git a/src/bukkit/java/com/sk89q/bukkit/util/CommandRegistration.java b/src/bukkit/java/com/sk89q/bukkit/util/CommandRegistration.java index 698f33f03..2417b2ced 100644 --- a/src/bukkit/java/com/sk89q/bukkit/util/CommandRegistration.java +++ b/src/bukkit/java/com/sk89q/bukkit/util/CommandRegistration.java @@ -19,12 +19,6 @@ package com.sk89q.bukkit.util; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; - import com.sk89q.util.ReflectionUtil; import org.bukkit.Bukkit; import org.bukkit.command.CommandExecutor; @@ -32,9 +26,12 @@ import org.bukkit.command.CommandMap; import org.bukkit.command.SimpleCommandMap; import org.bukkit.plugin.Plugin; -/** - * @author zml2008 - */ +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + public class CommandRegistration { static { @@ -109,4 +106,5 @@ public class CommandRegistration { } return true; } + } diff --git a/src/bukkit/java/com/sk89q/bukkit/util/CommandsManagerRegistration.java b/src/bukkit/java/com/sk89q/bukkit/util/CommandsManagerRegistration.java index 508d518be..175c51c6d 100644 --- a/src/bukkit/java/com/sk89q/bukkit/util/CommandsManagerRegistration.java +++ b/src/bukkit/java/com/sk89q/bukkit/util/CommandsManagerRegistration.java @@ -31,10 +31,8 @@ import java.util.Arrays; import java.util.List; import java.util.Map; -/** - * @author zml2008 - */ public class CommandsManagerRegistration extends CommandRegistration { + protected CommandsManager commands; public CommandsManagerRegistration(Plugin plugin, CommandsManager commands) { @@ -60,7 +58,7 @@ public class CommandsManagerRegistration extends CommandRegistration { if (cmdMethod != null && cmdMethod.isAnnotationPresent(CommandPermissions.class)) { permissions = Arrays.asList(cmdMethod.getAnnotation(CommandPermissions.class).value()); - } else if (cmdMethod != null && childMethods != null && childMethods.size() > 0) { + } else if (cmdMethod != null && childMethods != null && !childMethods.isEmpty()) { permissions = new ArrayList(); for (Method m : childMethods.values()) { if (m.isAnnotationPresent(CommandPermissions.class)) { @@ -74,4 +72,5 @@ public class CommandsManagerRegistration extends CommandRegistration { return register(toRegister); } + } diff --git a/src/bukkit/java/com/sk89q/bukkit/util/DynamicPluginCommandHelpTopic.java b/src/bukkit/java/com/sk89q/bukkit/util/DynamicPluginCommandHelpTopic.java index fda92fc40..6f4cec526 100644 --- a/src/bukkit/java/com/sk89q/bukkit/util/DynamicPluginCommandHelpTopic.java +++ b/src/bukkit/java/com/sk89q/bukkit/util/DynamicPluginCommandHelpTopic.java @@ -30,10 +30,8 @@ import org.bukkit.help.HelpTopicFactory; import java.util.Map; -/** - * @author zml2008 - */ public class DynamicPluginCommandHelpTopic extends HelpTopic { + private final DynamicPluginCommand cmd; public DynamicPluginCommandHelpTopic(DynamicPluginCommand cmd) { @@ -140,10 +138,10 @@ public class DynamicPluginCommandHelpTopic extends HelpTopic { } public static class Factory implements HelpTopicFactory { - @Override public HelpTopic createTopic(DynamicPluginCommand command) { return new DynamicPluginCommandHelpTopic(command); } } + } diff --git a/src/bukkit/java/com/sk89q/bukkit/util/FallbackRegistrationListener.java b/src/bukkit/java/com/sk89q/bukkit/util/FallbackRegistrationListener.java index 1f1b680cc..73ee10759 100644 --- a/src/bukkit/java/com/sk89q/bukkit/util/FallbackRegistrationListener.java +++ b/src/bukkit/java/com/sk89q/bukkit/util/FallbackRegistrationListener.java @@ -24,9 +24,6 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerCommandPreprocessEvent; -/** -* @author zml2008 -*/ public class FallbackRegistrationListener implements Listener { private final CommandMap commandRegistration; @@ -41,4 +38,5 @@ public class FallbackRegistrationListener implements Listener { event.setCancelled(true); } } + } diff --git a/src/bukkit/java/com/sk89q/wepif/ConfigurationPermissionsResolver.java b/src/bukkit/java/com/sk89q/wepif/ConfigurationPermissionsResolver.java index 9aa103e3a..75beabdf2 100644 --- a/src/bukkit/java/com/sk89q/wepif/ConfigurationPermissionsResolver.java +++ b/src/bukkit/java/com/sk89q/wepif/ConfigurationPermissionsResolver.java @@ -50,6 +50,7 @@ public class ConfigurationPermissionsResolver implements PermissionsResolver { return section; } + @Override public void load() { userGroups = new HashMap>(); userPermissionsCache = new HashMap>(); @@ -64,7 +65,7 @@ public class ConfigurationPermissionsResolver implements PermissionsResolver { List permissions = config.getStringList("permissions.groups." + key + ".permissions", null); - if (permissions.size() > 0) { + if (!permissions.isEmpty()) { Set groupPerms = new HashSet(permissions); userGroupPermissions.put(key, groupPerms); @@ -84,7 +85,7 @@ public class ConfigurationPermissionsResolver implements PermissionsResolver { List permissions = config.getStringList("permissions.users." + key + ".permissions", null); - if (permissions.size() > 0) { + if (!permissions.isEmpty()) { permsCache.addAll(permissions); } @@ -92,7 +93,7 @@ public class ConfigurationPermissionsResolver implements PermissionsResolver { config.getStringList("permissions.users." + key + ".groups", null); groups.add("default"); - if (groups.size() > 0) { + if (!groups.isEmpty()) { for (String group : groups) { Set groupPerms = userGroupPermissions.get(group); if (groupPerms != null) { @@ -107,6 +108,7 @@ public class ConfigurationPermissionsResolver implements PermissionsResolver { } } + @Override public boolean hasPermission(String player, String permission) { int dotPos = permission.lastIndexOf("."); if (dotPos > -1) { @@ -124,11 +126,13 @@ public class ConfigurationPermissionsResolver implements PermissionsResolver { return perms.contains("*") || perms.contains(permission); } + @Override public boolean hasPermission(String worldName, String player, String permission) { return hasPermission(player, "worlds." + worldName + "." + permission) || hasPermission(player, permission); } + @Override public boolean inGroup(String player, String group) { Set groups = userGroups.get(player.toLowerCase()); if (groups == null) { @@ -138,6 +142,7 @@ public class ConfigurationPermissionsResolver implements PermissionsResolver { return groups.contains(group); } + @Override public String[] getGroups(String player) { Set groups = userGroups.get(player.toLowerCase()); if (groups == null) { @@ -147,22 +152,27 @@ public class ConfigurationPermissionsResolver implements PermissionsResolver { return groups.toArray(new String[groups.size()]); } + @Override public boolean hasPermission(OfflinePlayer player, String permission) { return hasPermission(player.getName(), permission); } + @Override public boolean hasPermission(String worldName, OfflinePlayer player, String permission) { return hasPermission(worldName, player.getName(), permission); } + @Override public boolean inGroup(OfflinePlayer player, String group) { return inGroup(player.getName(), group); } + @Override public String[] getGroups(OfflinePlayer player) { return getGroups(player.getName()); } + @Override public String getDetectionMessage() { return "No known permissions plugin detected. Using configuration file for permissions."; } diff --git a/src/bukkit/java/com/sk89q/wepif/DinnerPermsResolver.java b/src/bukkit/java/com/sk89q/wepif/DinnerPermsResolver.java index 57e40e1c2..4e8199f9b 100644 --- a/src/bukkit/java/com/sk89q/wepif/DinnerPermsResolver.java +++ b/src/bukkit/java/com/sk89q/wepif/DinnerPermsResolver.java @@ -43,25 +43,31 @@ public class DinnerPermsResolver implements PermissionsResolver { return new DinnerPermsResolver(server); } + @Override public void load() { } + @Override public boolean hasPermission(String name, String permission) { return hasPermission(server.getOfflinePlayer(name), permission); } + @Override public boolean hasPermission(String worldName, String name, String permission) { return hasPermission(worldName, server.getOfflinePlayer(name), permission); } + @Override public boolean inGroup(String name, String group) { return inGroup(server.getOfflinePlayer(name), group); } + @Override public String[] getGroups(String name) { return getGroups(server.getOfflinePlayer(name)); } + @Override public boolean hasPermission(OfflinePlayer player, String permission) { Permissible perms = getPermissible(player); if (perms == null) { @@ -86,10 +92,12 @@ public class DinnerPermsResolver implements PermissionsResolver { return internalHasPermission(perms, "*") == 1; } + @Override public boolean hasPermission(String worldName, OfflinePlayer player, String permission) { return hasPermission(player, permission); // no per-world ability to check permissions in dinnerperms } + @Override public boolean inGroup(OfflinePlayer player, String group) { final Permissible perms = getPermissible(player); if (perms == null) { @@ -100,6 +108,7 @@ public class DinnerPermsResolver implements PermissionsResolver { return perms.isPermissionSet(perm) && perms.hasPermission(perm); } + @Override public String[] getGroups(OfflinePlayer player) { Permissible perms = getPermissible(player); if (perms == null) { @@ -149,6 +158,7 @@ public class DinnerPermsResolver implements PermissionsResolver { } } + @Override public String getDetectionMessage() { return "Using the Bukkit Permissions API."; } diff --git a/src/bukkit/java/com/sk89q/wepif/FlatFilePermissionsResolver.java b/src/bukkit/java/com/sk89q/wepif/FlatFilePermissionsResolver.java index 007d0d644..6caa45207 100644 --- a/src/bukkit/java/com/sk89q/wepif/FlatFilePermissionsResolver.java +++ b/src/bukkit/java/com/sk89q/wepif/FlatFilePermissionsResolver.java @@ -19,27 +19,32 @@ package com.sk89q.wepif; +import com.sk89q.util.yaml.YAMLProcessor; +import org.bukkit.OfflinePlayer; +import org.bukkit.Server; + import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.util.Arrays; +import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; -import java.util.HashMap; - -import com.sk89q.util.yaml.YAMLProcessor; -import org.bukkit.OfflinePlayer; -import org.bukkit.Server; +import java.util.logging.Level; +import java.util.logging.Logger; public class FlatFilePermissionsResolver implements PermissionsResolver { + + private static final Logger log = Logger.getLogger(FlatFilePermissionsResolver.class.getCanonicalName()); + private Map> userPermissionsCache; private Set defaultPermissionsCache; private Map> userGroups; - protected File groupFile; - protected File userFile; + private final File groupFile; + private final File userFile; public static PermissionsResolver factory(Server server, YAMLProcessor config) { File groups = new File("perms_groups.txt"); @@ -80,7 +85,7 @@ public class FlatFilePermissionsResolver implements PermissionsResolver { line = line.trim(); // Blank line - if (line.length() == 0) { + if (line.isEmpty()) { continue; } else if (line.charAt(0) == ';' || line.charAt(0) == '#') { continue; @@ -98,19 +103,20 @@ public class FlatFilePermissionsResolver implements PermissionsResolver { } } } catch (IOException e) { - e.printStackTrace(); + log.log(Level.WARNING, "Failed to load permissions", e); } finally { try { if (buff != null) { buff.close(); } - } catch (IOException e2) { + } catch (IOException ignored) { } } return userGroupPermissions; } + @Override public void load() { userGroups = new HashMap>(); userPermissionsCache = new HashMap>(); @@ -135,7 +141,7 @@ public class FlatFilePermissionsResolver implements PermissionsResolver { line = line.trim(); // Blank line - if (line.length() == 0) { + if (line.isEmpty()) { continue; } else if (line.charAt(0) == ';' || line.charAt(0) == '#') { continue; @@ -163,17 +169,18 @@ public class FlatFilePermissionsResolver implements PermissionsResolver { } } } catch (IOException e) { - e.printStackTrace(); + log.log(Level.WARNING, "Failed to load permissions", e); } finally { try { if (buff != null) { buff.close(); } - } catch (IOException e2) { + } catch (IOException ignored) { } } } + @Override public boolean hasPermission(String player, String permission) { int dotPos = permission.lastIndexOf("."); if (dotPos > -1) { @@ -191,20 +198,19 @@ public class FlatFilePermissionsResolver implements PermissionsResolver { return perms.contains("*") || perms.contains(permission); } + @Override public boolean hasPermission(String worldName, String player, String permission) { return hasPermission(player, "worlds." + worldName + "." + permission) || hasPermission(player, permission); } + @Override public boolean inGroup(String player, String group) { Set groups = userGroups.get(player.toLowerCase()); - if (groups == null) { - return false; - } - - return groups.contains(group); + return groups != null && groups.contains(group); } + @Override public String[] getGroups(String player) { Set groups = userGroups.get(player.toLowerCase()); if (groups == null) { @@ -214,22 +220,27 @@ public class FlatFilePermissionsResolver implements PermissionsResolver { return groups.toArray(new String[groups.size()]); } + @Override public boolean hasPermission(OfflinePlayer player, String permission) { return hasPermission(player.getName(), permission); } + @Override public boolean hasPermission(String worldName, OfflinePlayer player, String permission) { return hasPermission(worldName, player.getName(), permission); } + @Override public boolean inGroup(OfflinePlayer player, String group) { return inGroup(player.getName(), group); } + @Override public String[] getGroups(OfflinePlayer player) { return getGroups(player.getName()); } + @Override public String getDetectionMessage() { return "perms_groups.txt and perms_users.txt detected! Using flat file permissions."; } diff --git a/src/bukkit/java/com/sk89q/wepif/GroupManagerResolver.java b/src/bukkit/java/com/sk89q/wepif/GroupManagerResolver.java index 3bc5ea90e..90194899f 100644 --- a/src/bukkit/java/com/sk89q/wepif/GroupManagerResolver.java +++ b/src/bukkit/java/com/sk89q/wepif/GroupManagerResolver.java @@ -50,6 +50,7 @@ public class GroupManagerResolver implements PermissionsResolver { this.worldsHolder = worldsHolder; } + @Override public void load() { } @@ -73,10 +74,12 @@ public class GroupManagerResolver implements PermissionsResolver { } } + @Override public boolean hasPermission(String name, String permission) { return hasPermission(null, name, permission); } + @Override public boolean hasPermission(String worldName, String name, String permission) { if (permission == null || permission.isEmpty()) { return false; @@ -88,6 +91,7 @@ public class GroupManagerResolver implements PermissionsResolver { return permissionHandler.permission(name, permission); } + @Override public boolean inGroup(String name, String group) { if (group == null || group.isEmpty()) { return false; @@ -99,6 +103,7 @@ public class GroupManagerResolver implements PermissionsResolver { return permissionHandler.inGroup(name, group); } + @Override public String[] getGroups(String name) { AnjoPermissionsHandler permissionHandler = getPermissionHandler(name, null); if (permissionHandler == null) { @@ -107,22 +112,27 @@ public class GroupManagerResolver implements PermissionsResolver { return permissionHandler.getGroups(name); } + @Override public boolean hasPermission(OfflinePlayer player, String permission) { return hasPermission(player.getName(), permission); } + @Override public boolean hasPermission(String worldName, OfflinePlayer player, String permission) { return hasPermission(worldName, player.getName(), permission); } + @Override public boolean inGroup(OfflinePlayer player, String group) { return inGroup(player.getName(), group); } + @Override public String[] getGroups(OfflinePlayer player) { return getGroups(player.getName()); } + @Override public String getDetectionMessage() { return "GroupManager detected! Using GroupManager for permissions."; } diff --git a/src/bukkit/java/com/sk89q/wepif/NijiPermissionsResolver.java b/src/bukkit/java/com/sk89q/wepif/NijiPermissionsResolver.java index 0570a45fa..f3502d460 100644 --- a/src/bukkit/java/com/sk89q/wepif/NijiPermissionsResolver.java +++ b/src/bukkit/java/com/sk89q/wepif/NijiPermissionsResolver.java @@ -29,7 +29,13 @@ import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginManager; import com.nijikokun.bukkit.Permissions.Permissions; +import java.util.logging.Level; +import java.util.logging.Logger; + public class NijiPermissionsResolver implements PermissionsResolver { + + private static final Logger log = Logger.getLogger(NijiPermissionsResolver.class.getCanonicalName()); + private Server server; private Permissions api; @@ -56,6 +62,7 @@ public class NijiPermissionsResolver implements PermissionsResolver { return new NijiPermissionsResolver(server, (Permissions) plugin); } + @Override public void load() { } @@ -65,6 +72,7 @@ public class NijiPermissionsResolver implements PermissionsResolver { this.api = plugin; } + @Override @SuppressWarnings("static-access") public boolean hasPermission(String name, String permission) { try { @@ -76,11 +84,12 @@ public class NijiPermissionsResolver implements PermissionsResolver { return api.Security.permission(player, permission); } } catch (Throwable t) { - t.printStackTrace(); + log.log(Level.WARNING, "Failed to check permissions", t); return false; } } + @Override public boolean hasPermission(String worldName, String name, String permission) { try { try { @@ -89,11 +98,12 @@ public class NijiPermissionsResolver implements PermissionsResolver { return api.getHandler().has(server.getPlayerExact(name), permission); } } catch (Throwable t) { - t.printStackTrace(); + log.log(Level.WARNING, "Failed to check permissions", t); return false; } } + @Override @SuppressWarnings("static-access") public boolean inGroup(String name, String group) { try { @@ -105,11 +115,12 @@ public class NijiPermissionsResolver implements PermissionsResolver { return api.Security.inGroup(name, group); } } catch (Throwable t) { - t.printStackTrace(); + log.log(Level.WARNING, "Failed to check groups", t); return false; } } + @Override @SuppressWarnings("static-access") public String[] getGroups(String name) { try { @@ -128,23 +139,27 @@ public class NijiPermissionsResolver implements PermissionsResolver { return groups; } } catch (Throwable t) { - t.printStackTrace(); + log.log(Level.WARNING, "Failed to get groups", t); return new String[0]; } } + @Override public boolean hasPermission(OfflinePlayer player, String permission) { return hasPermission(player.getName(), permission); } + @Override public boolean hasPermission(String worldName, OfflinePlayer player, String permission) { return hasPermission(worldName, player.getName(), permission); } + @Override public boolean inGroup(OfflinePlayer player, String group) { return inGroup(player.getName(), group); } + @Override public String[] getGroups(OfflinePlayer player) { return getGroups(player.getName()); } @@ -155,7 +170,9 @@ public class NijiPermissionsResolver implements PermissionsResolver { return permsCommand == null || !(permsCommand.getPlugin().equals(plugin)); } + @Override public String getDetectionMessage() { return "Permissions plugin detected! Using Permissions plugin for permissions."; } + } diff --git a/src/bukkit/java/com/sk89q/wepif/PermissionsExResolver.java b/src/bukkit/java/com/sk89q/wepif/PermissionsExResolver.java index 49c2f3eca..ece76df9d 100644 --- a/src/bukkit/java/com/sk89q/wepif/PermissionsExResolver.java +++ b/src/bukkit/java/com/sk89q/wepif/PermissionsExResolver.java @@ -48,10 +48,12 @@ public class PermissionsExResolver extends DinnerPermsResolver { this.manager = manager; } + @Override public boolean hasPermission(String worldName, String name, String permission) { return manager.has(name, permission, worldName); } + @Override public boolean hasPermission(OfflinePlayer player, String permission) { Permissible permissible = getPermissible(player); if (permissible == null) { @@ -61,14 +63,17 @@ public class PermissionsExResolver extends DinnerPermsResolver { } } + @Override public boolean hasPermission(String worldName, OfflinePlayer player, String permission) { return hasPermission(worldName, player.getName(), permission); } + @Override public boolean inGroup(OfflinePlayer player, String group) { return super.inGroup(player, group) || manager.getUser(player.getName()).inGroup(group); } + @Override public String[] getGroups(OfflinePlayer player) { if (getPermissible(player) == null) { PermissionUser user = manager.getUser(player.getName()); @@ -81,6 +86,7 @@ public class PermissionsExResolver extends DinnerPermsResolver { } } + @Override public String getDetectionMessage() { return "PermissionsEx detected! Using PermissionsEx for permissions."; } diff --git a/src/bukkit/java/com/sk89q/wepif/PermissionsResolverManager.java b/src/bukkit/java/com/sk89q/wepif/PermissionsResolverManager.java index fa019b344..babc4a4cf 100644 --- a/src/bukkit/java/com/sk89q/wepif/PermissionsResolverManager.java +++ b/src/bukkit/java/com/sk89q/wepif/PermissionsResolverManager.java @@ -35,9 +35,11 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; import java.util.List; +import java.util.logging.Level; import java.util.logging.Logger; public class PermissionsResolverManager implements PermissionsResolver { + private static final String CONFIG_HEADER = "#\r\n" + "# WEPIF Configuration File\r\n" + "#\r\n" + @@ -116,8 +118,7 @@ public class PermissionsResolverManager implements PermissionsResolver { break; } } catch (Throwable e) { - logger.warning("Error in factory method for " + resolverClass.getSimpleName() + ": " + e); - e.printStackTrace(); + logger.log(Level.WARNING, "Error in factory method for " + resolverClass.getSimpleName(), e); continue; } } @@ -137,42 +138,52 @@ public class PermissionsResolverManager implements PermissionsResolver { logger.info("WEPIF: " + permissionResolver.getDetectionMessage()); } + @Override public void load() { findResolver(); } + @Override public boolean hasPermission(String name, String permission) { return permissionResolver.hasPermission(name, permission); } + @Override public boolean hasPermission(String worldName, String name, String permission) { return permissionResolver.hasPermission(worldName, name, permission); } + @Override public boolean inGroup(String player, String group) { return permissionResolver.inGroup(player, group); } + @Override public String[] getGroups(String player) { return permissionResolver.getGroups(player); } + @Override public boolean hasPermission(OfflinePlayer player, String permission) { return permissionResolver.hasPermission(player, permission); } + @Override public boolean hasPermission(String worldName, OfflinePlayer player, String permission) { return permissionResolver.hasPermission(worldName, player, permission); } + @Override public boolean inGroup(OfflinePlayer player, String group) { return permissionResolver.inGroup(player, group); } + @Override public String[] getGroups(OfflinePlayer player) { return permissionResolver.getGroups(player); } + @Override public String getDetectionMessage() { return "Using WEPIF for permissions"; } @@ -183,15 +194,14 @@ public class PermissionsResolverManager implements PermissionsResolver { try { file.createNewFile(); } catch (IOException e) { - e.printStackTrace(); + logger.log(Level.WARNING, "Failed to create new configuration file", e); } } config = new YAMLProcessor(file, false, YAMLFormat.EXTENDED); try { config.load(); } catch (IOException e) { - logger.severe("Error loading WEPIF Config: " + e); - e.printStackTrace(); + logger.log(Level.WARNING, "Error loading WEPIF configuration", e); } List keys = config.getKeys(null); config.setHeader(CONFIG_HEADER); @@ -263,7 +273,6 @@ public class PermissionsResolverManager implements PermissionsResolver { } public static class MissingPluginException extends Exception { - private static final long serialVersionUID = 7044832912491608706L; } class ServerListener implements org.bukkit.event.Listener { diff --git a/src/bukkit/java/com/sk89q/wepif/PluginPermissionsResolver.java b/src/bukkit/java/com/sk89q/wepif/PluginPermissionsResolver.java index a0c8e8c58..f0edf2bb8 100644 --- a/src/bukkit/java/com/sk89q/wepif/PluginPermissionsResolver.java +++ b/src/bukkit/java/com/sk89q/wepif/PluginPermissionsResolver.java @@ -53,41 +53,51 @@ public class PluginPermissionsResolver implements PermissionsResolver { this.plugin = permissionsPlugin; } + @Override public void load() { } + @Override public boolean hasPermission(String name, String permission) { return resolver.hasPermission(name, permission); } + @Override public boolean hasPermission(String worldName, String name, String permission) { return resolver.hasPermission(worldName, name, permission); } + @Override public boolean inGroup(String player, String group) { return resolver.inGroup(player, group); } + @Override public String[] getGroups(String player) { return resolver.getGroups(player); } + @Override public boolean hasPermission(OfflinePlayer player, String permission) { return resolver.hasPermission(player, permission); } + @Override public boolean hasPermission(String worldName, OfflinePlayer player, String permission) { return resolver.hasPermission(worldName, player, permission); } + @Override public boolean inGroup(OfflinePlayer player, String group) { return resolver.inGroup(player, group); } + @Override public String[] getGroups(OfflinePlayer player) { return resolver.getGroups(player); } + @Override public String getDetectionMessage() { return "Using plugin '" + this.plugin.getDescription().getName() + "' for permissions."; } diff --git a/src/bukkit/java/com/sk89q/wepif/WEPIFRuntimeException.java b/src/bukkit/java/com/sk89q/wepif/WEPIFRuntimeException.java index b6090d130..d1241c8f3 100644 --- a/src/bukkit/java/com/sk89q/wepif/WEPIFRuntimeException.java +++ b/src/bukkit/java/com/sk89q/wepif/WEPIFRuntimeException.java @@ -19,13 +19,10 @@ package com.sk89q.wepif; -/** - * @author zml2008 - */ public class WEPIFRuntimeException extends RuntimeException { - private static final long serialVersionUID = 5092745960439109699L; public WEPIFRuntimeException(String message) { super(message); } + } diff --git a/src/bukkit/java/com/sk89q/wepif/bPermissionsResolver.java b/src/bukkit/java/com/sk89q/wepif/bPermissionsResolver.java index d04c58730..dacc0be0f 100644 --- a/src/bukkit/java/com/sk89q/wepif/bPermissionsResolver.java +++ b/src/bukkit/java/com/sk89q/wepif/bPermissionsResolver.java @@ -26,9 +26,6 @@ import org.bukkit.OfflinePlayer; import org.bukkit.Server; import org.bukkit.entity.Player; -/** - * @author zml2008 - */ public class bPermissionsResolver implements PermissionsResolver { public static PermissionsResolver factory(Server server, YAMLProcessor config) { @@ -47,29 +44,36 @@ public class bPermissionsResolver implements PermissionsResolver { this.server = server; } + @Override public void load() { } + @Override public String getDetectionMessage() { return "bPermissions detected! Using bPermissions for permissions"; } + @Override public boolean hasPermission(String name, String permission) { return hasPermission(server.getOfflinePlayer(name), permission); } + @Override public boolean hasPermission(String worldName, String name, String permission) { return ApiLayer.hasPermission(worldName, CalculableType.USER, name, permission); } + @Override public boolean inGroup(String player, String group) { return inGroup(server.getOfflinePlayer(player), group); } + @Override public String[] getGroups(String player) { return getGroups(server.getOfflinePlayer(player)); } + @Override public boolean hasPermission(OfflinePlayer player, String permission) { Player onlinePlayer = player.getPlayer(); if (onlinePlayer == null) { @@ -79,10 +83,12 @@ public class bPermissionsResolver implements PermissionsResolver { } } + @Override public boolean hasPermission(String worldName, OfflinePlayer player, String permission) { return hasPermission(worldName, player.getName(), permission); } + @Override public boolean inGroup(OfflinePlayer player, String group) { Player onlinePlayer = player.getPlayer(); if (onlinePlayer == null) { @@ -92,6 +98,7 @@ public class bPermissionsResolver implements PermissionsResolver { } } + @Override public String[] getGroups(OfflinePlayer player) { Player onlinePlayer = player.getPlayer(); if (onlinePlayer == null) { @@ -100,4 +107,5 @@ public class bPermissionsResolver implements PermissionsResolver { return ApiLayer.getGroups(onlinePlayer.getWorld().getName(), CalculableType.USER, player.getName()); } } + } diff --git a/src/bukkit/java/com/sk89q/worldedit/bukkit/BukkitPlayerBlockBag.java b/src/bukkit/java/com/sk89q/worldedit/bukkit/BukkitPlayerBlockBag.java index 910bb34d6..acacad5e8 100644 --- a/src/bukkit/java/com/sk89q/worldedit/bukkit/BukkitPlayerBlockBag.java +++ b/src/bukkit/java/com/sk89q/worldedit/bukkit/BukkitPlayerBlockBag.java @@ -29,19 +29,14 @@ import com.sk89q.worldedit.blocks.BlockID; import com.sk89q.worldedit.blocks.ItemType; public class BukkitPlayerBlockBag extends BlockBag { - /** - * Player instance. - */ + private Player player; - /** - * The player's inventory; - */ private ItemStack[] items; /** * Construct the object. * - * @param player + * @param player the player */ public BukkitPlayerBlockBag(Player player) { this.player = player; @@ -59,17 +54,12 @@ public class BukkitPlayerBlockBag extends BlockBag { /** * Get the player. * - * @return + * @return the player */ public Player getPlayer() { return player; } - /** - * Get a block. - * - * @param id - */ @Override public void fetchItem(BaseItem item) throws BlockBagException { final int id = item.getType(); @@ -125,11 +115,6 @@ public class BukkitPlayerBlockBag extends BlockBag { } } - /** - * Store a block. - * - * @param id - */ @Override public void storeItem(BaseItem item) throws BlockBagException { final int id = item.getType(); @@ -197,9 +182,6 @@ public class BukkitPlayerBlockBag extends BlockBag { throw new OutOfSpaceException(id); } - /** - * Flush any changes. This is called at the end. - */ @Override public void flushChanges() { if (items != null) { @@ -208,21 +190,12 @@ public class BukkitPlayerBlockBag extends BlockBag { } } - /** - * Adds a position to be used a source. - * - * @param pos - */ @Override public void addSourcePosition(WorldVector pos) { } - /** - * Adds a position to be used a source. - * - * @param pos - */ @Override public void addSingleSourcePosition(WorldVector pos) { } + } diff --git a/src/bukkit/java/com/sk89q/worldedit/bukkit/CUIChannelListener.java b/src/bukkit/java/com/sk89q/worldedit/bukkit/CUIChannelListener.java index 60ef23a6b..23b190616 100644 --- a/src/bukkit/java/com/sk89q/worldedit/bukkit/CUIChannelListener.java +++ b/src/bukkit/java/com/sk89q/worldedit/bukkit/CUIChannelListener.java @@ -26,10 +26,10 @@ import org.bukkit.plugin.messaging.PluginMessageListener; import java.nio.charset.Charset; /** - * Handles incoming WorldEditCui init message - * @author zml2008 + * Handles incoming WorldEditCui init message. */ public class CUIChannelListener implements PluginMessageListener { + public static final Charset UTF_8_CHARSET = Charset.forName("UTF-8"); private final WorldEditPlugin plugin; @@ -44,4 +44,5 @@ public class CUIChannelListener implements PluginMessageListener { session.handleCUIInitializationMessage(text); session.describeCUI(plugin.wrapPlayer(player)); } + } diff --git a/src/bukkit/java/com/sk89q/worldedit/bukkit/EditSessionBlockChangeDelegate.java b/src/bukkit/java/com/sk89q/worldedit/bukkit/EditSessionBlockChangeDelegate.java index baafe9bfc..c3d1b2059 100644 --- a/src/bukkit/java/com/sk89q/worldedit/bukkit/EditSessionBlockChangeDelegate.java +++ b/src/bukkit/java/com/sk89q/worldedit/bukkit/EditSessionBlockChangeDelegate.java @@ -28,16 +28,16 @@ import com.sk89q.worldedit.blocks.BaseBlock; /** * Proxy class to catch calls to set blocks. - * - * @author sk89q */ public class EditSessionBlockChangeDelegate implements BlockChangeDelegate { + private EditSession editSession; public EditSessionBlockChangeDelegate(EditSession editSession) { this.editSession = editSession; } + @Override public boolean setRawTypeId(int x, int y, int z, int typeId) { try { return editSession.setBlock(new Vector(x, y, z), new BaseBlock(typeId)); @@ -46,6 +46,7 @@ public class EditSessionBlockChangeDelegate implements BlockChangeDelegate { } } + @Override public boolean setRawTypeIdAndData(int x, int y, int z, int typeId, int data) { try { return editSession.setBlock(new Vector(x, y, z), new BaseBlock(typeId, data)); @@ -54,23 +55,29 @@ public class EditSessionBlockChangeDelegate implements BlockChangeDelegate { } } + @Override public boolean setTypeId(int x, int y, int z, int typeId) { return setRawTypeId(x, y, z, typeId); } + @Override public boolean setTypeIdAndData(int x, int y, int z, int typeId, int data) { return setRawTypeIdAndData(x, y, z, typeId, data); } + @Override public int getTypeId(int x, int y, int z) { return editSession.getBlockType(new Vector(x, y, z)); } + @Override public int getHeight() { return editSession.getWorld().getMaxY() + 1; } + @Override public boolean isEmpty(int x, int y, int z) { return editSession.getBlockType(new Vector(x, y, z)) == BlockID.AIR; } + } diff --git a/src/bukkit/java/com/sk89q/worldedit/bukkit/WorldEditAPI.java b/src/bukkit/java/com/sk89q/worldedit/bukkit/WorldEditAPI.java index dd9d3004a..85a38ac9b 100644 --- a/src/bukkit/java/com/sk89q/worldedit/bukkit/WorldEditAPI.java +++ b/src/bukkit/java/com/sk89q/worldedit/bukkit/WorldEditAPI.java @@ -22,7 +22,12 @@ package com.sk89q.worldedit.bukkit; import org.bukkit.entity.Player; import com.sk89q.worldedit.LocalSession; +/** + * @deprecated use the regular API + */ +@Deprecated public class WorldEditAPI { + private WorldEditPlugin plugin; public WorldEditAPI(WorldEditPlugin plugin) { @@ -32,11 +37,12 @@ public class WorldEditAPI { /** * Get the session for a player. * - * @param player - * @return + * @param player the player + * @return a session */ public LocalSession getSession(Player player) { return plugin.getWorldEdit().getSession( new BukkitPlayer(plugin, plugin.getServerInterface(), player)); } + } diff --git a/src/bukkit/java/com/sk89q/worldedit/bukkit/WorldEditListener.java b/src/bukkit/java/com/sk89q/worldedit/bukkit/WorldEditListener.java index 4b212f7f0..70455cbcb 100644 --- a/src/bukkit/java/com/sk89q/worldedit/bukkit/WorldEditListener.java +++ b/src/bukkit/java/com/sk89q/worldedit/bukkit/WorldEditListener.java @@ -55,7 +55,7 @@ public class WorldEditListener implements Listener { /** * Construct the object; * - * @param plugin + * @param plugin the plugin */ public WorldEditListener(WorldEditPlugin plugin) { this.plugin = plugin; @@ -67,7 +67,7 @@ public class WorldEditListener implements Listener { return; } - // this will automatically refresh their sesssion, we don't have to do anything + // this will automatically refresh their session, we don't have to do anything WorldEdit.getInstance().getSession(plugin.wrapPlayer(event.getPlayer())); } diff --git a/src/bukkit/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java b/src/bukkit/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java index 26647fcc8..be6378380 100644 --- a/src/bukkit/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java +++ b/src/bukkit/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java @@ -71,9 +71,8 @@ import static com.google.common.base.Preconditions.checkNotNull; /** * Plugin for Bukkit. - * - * @author sk89q */ +@SuppressWarnings("deprecation") public class WorldEditPlugin extends JavaPlugin implements TabCompleter { private static final Logger log = Logger.getLogger(WorldEditPlugin.class.getCanonicalName()); @@ -88,10 +87,12 @@ public class WorldEditPlugin extends JavaPlugin implements TabCompleter { /** * Called on plugin enable. */ + @SuppressWarnings("AccessStaticViaInstance") @Override public void onEnable() { this.INSTANCE = this; + //noinspection ResultOfMethodCallIgnored getDataFolder().mkdirs(); WorldEdit worldEdit = WorldEdit.getInstance(); @@ -191,8 +192,7 @@ public class WorldEditPlugin extends JavaPlugin implements TabCompleter { protected void createDefaultConfiguration(String name) { File actual = new File(getDataFolder(), name); if (!actual.exists()) { - InputStream input = - null; + InputStream input = null; try { JarFile file = new JarFile(getFile()); ZipEntry copy = file.getEntry("defaults/" + name); @@ -207,26 +207,24 @@ public class WorldEditPlugin extends JavaPlugin implements TabCompleter { try { output = new FileOutputStream(actual); byte[] buf = new byte[8192]; - int length = 0; + int length; while ((length = input.read(buf)) > 0) { output.write(buf, 0, length); } getLogger().info("Default configuration file written: " + name); } catch (IOException e) { - e.printStackTrace(); + getLogger().log(Level.WARNING, "Failed to write default config file", e); } finally { try { - if (input != null) { - input.close(); - } - } catch (IOException e) {} + input.close(); + } catch (IOException ignored) {} try { if (output != null) { output.close(); } - } catch (IOException e) {} + } catch (IOException ignored) {} } } } @@ -262,8 +260,8 @@ public class WorldEditPlugin extends JavaPlugin implements TabCompleter { /** * Gets the session for the player. * - * @param player - * @return + * @param player a player + * @return a session */ public LocalSession getSession(Player player) { return WorldEdit.getInstance().getSession(wrapPlayer(player)); @@ -272,8 +270,8 @@ public class WorldEditPlugin extends JavaPlugin implements TabCompleter { /** * Gets the session for the player. * - * @param player - * @return + * @param player a player + * @return a session */ public EditSession createEditSession(Player player) { LocalPlayer wePlayer = wrapPlayer(player); @@ -290,8 +288,8 @@ public class WorldEditPlugin extends JavaPlugin implements TabCompleter { /** * Remember an edit session. * - * @param player - * @param editSession + * @param player a player + * @param editSession an edit session */ public void remember(Player player, EditSession editSession) { LocalPlayer wePlayer = wrapPlayer(player); @@ -306,10 +304,12 @@ public class WorldEditPlugin extends JavaPlugin implements TabCompleter { /** * Wrap an operation into an EditSession. * - * @param player - * @param op - * @throws Throwable + * @param player a player + * @param op the operation + * @throws Throwable on any error + * @deprecated use the regular API */ + @Deprecated public void perform(Player player, WorldEditOperation op) throws Throwable { LocalPlayer wePlayer = wrapPlayer(player); LocalSession session = WorldEdit.getInstance().getSession(wePlayer); @@ -325,7 +325,8 @@ public class WorldEditPlugin extends JavaPlugin implements TabCompleter { /** * Get the API. * - * @return + * @return the API + * @deprecated use the regular API */ @Deprecated public WorldEditAPI getAPI() { @@ -335,7 +336,7 @@ public class WorldEditPlugin extends JavaPlugin implements TabCompleter { /** * Returns the configuration used by WorldEdit. * - * @return + * @return the configuration */ public BukkitConfiguration getLocalConfiguration() { return config; @@ -344,7 +345,7 @@ public class WorldEditPlugin extends JavaPlugin implements TabCompleter { /** * Get the permissions resolver in use. * - * @return + * @return the permissions resolver */ public PermissionsResolverManager getPermissionsResolver() { return PermissionsResolverManager.getInstance(); @@ -353,8 +354,8 @@ public class WorldEditPlugin extends JavaPlugin implements TabCompleter { /** * Used to wrap a Bukkit Player as a LocalPlayer. * - * @param player - * @return + * @param player a player + * @return a wrapped player */ public BukkitPlayer wrapPlayer(Player player) { return new BukkitPlayer(this, this.server, player); @@ -371,7 +372,7 @@ public class WorldEditPlugin extends JavaPlugin implements TabCompleter { /** * Get the server interface. * - * @return + * @return the server interface */ public ServerInterface getServerInterface() { return server; @@ -384,7 +385,7 @@ public class WorldEditPlugin extends JavaPlugin implements TabCompleter { /** * Get WorldEdit. * - * @return + * @return an instance */ public WorldEdit getWorldEdit() { return WorldEdit.getInstance(); @@ -393,7 +394,7 @@ public class WorldEditPlugin extends JavaPlugin implements TabCompleter { /** * Gets the region selection for the player. * - * @param player + * @param player aplayer * @return the selection or null if there was none */ public Selection getSelection(Player player) { @@ -428,8 +429,8 @@ public class WorldEditPlugin extends JavaPlugin implements TabCompleter { /** * Sets the region selection for a player. * - * @param player - * @param selection + * @param player the player + * @param selection a selection */ public void setSelection(Player player, Selection selection) { if (player == null) { diff --git a/src/bukkit/java/com/sk89q/worldedit/bukkit/entity/BukkitEntity.java b/src/bukkit/java/com/sk89q/worldedit/bukkit/entity/BukkitEntity.java index dd0adfb83..e138b5cd1 100644 --- a/src/bukkit/java/com/sk89q/worldedit/bukkit/entity/BukkitEntity.java +++ b/src/bukkit/java/com/sk89q/worldedit/bukkit/entity/BukkitEntity.java @@ -26,10 +26,8 @@ import org.bukkit.entity.EntityType; import java.util.UUID; -/** - * @author zml2008 - */ public class BukkitEntity extends LocalEntity { + private final EntityType type; private final UUID entityId; @@ -48,4 +46,5 @@ public class BukkitEntity extends LocalEntity { org.bukkit.Location loc = BukkitUtil.toLocation(weLoc); return loc.getWorld().spawn(loc, type.getEntityClass()) != null; } + } diff --git a/src/bukkit/java/com/sk89q/worldedit/bukkit/entity/BukkitExpOrb.java b/src/bukkit/java/com/sk89q/worldedit/bukkit/entity/BukkitExpOrb.java index 8c2d1be3f..1b57f8143 100644 --- a/src/bukkit/java/com/sk89q/worldedit/bukkit/entity/BukkitExpOrb.java +++ b/src/bukkit/java/com/sk89q/worldedit/bukkit/entity/BukkitExpOrb.java @@ -26,10 +26,8 @@ import org.bukkit.entity.ExperienceOrb; import java.util.UUID; -/** - * @author zml2008 - */ public class BukkitExpOrb extends BukkitEntity { + private final int amount; public BukkitExpOrb(Location loc, UUID entityId, int amount) { @@ -47,4 +45,5 @@ public class BukkitExpOrb extends BukkitEntity { } return false; } + } diff --git a/src/bukkit/java/com/sk89q/worldedit/bukkit/entity/BukkitItem.java b/src/bukkit/java/com/sk89q/worldedit/bukkit/entity/BukkitItem.java index 208db6933..01ea7ad50 100644 --- a/src/bukkit/java/com/sk89q/worldedit/bukkit/entity/BukkitItem.java +++ b/src/bukkit/java/com/sk89q/worldedit/bukkit/entity/BukkitItem.java @@ -26,10 +26,8 @@ import org.bukkit.inventory.ItemStack; import java.util.UUID; -/** - * @author zml2008 - */ public class BukkitItem extends BukkitEntity { + private final ItemStack stack; public BukkitItem(Location loc, ItemStack stack, UUID entityId) { super(loc, EntityType.DROPPED_ITEM, entityId); @@ -41,4 +39,5 @@ public class BukkitItem extends BukkitEntity { org.bukkit.Location loc = BukkitUtil.toLocation(weLoc); return loc.getWorld().dropItem(loc, stack) != null; } + } diff --git a/src/bukkit/java/com/sk89q/worldedit/bukkit/entity/BukkitPainting.java b/src/bukkit/java/com/sk89q/worldedit/bukkit/entity/BukkitPainting.java index 0db7c8304..57f7eb4f5 100644 --- a/src/bukkit/java/com/sk89q/worldedit/bukkit/entity/BukkitPainting.java +++ b/src/bukkit/java/com/sk89q/worldedit/bukkit/entity/BukkitPainting.java @@ -30,18 +30,20 @@ import org.bukkit.entity.Painting; import java.util.ArrayDeque; import java.util.Deque; import java.util.UUID; +import java.util.logging.Level; +import java.util.logging.Logger; -/** - * @author zml2008 - */ public class BukkitPainting extends BukkitEntity { + + private static final Logger log = Logger.getLogger(BukkitPainting.class.getCanonicalName()); + private static int spawnTask = -1; private static final Deque spawnQueue = new ArrayDeque(); private class QueuedPaintingSpawn { private final Location weLoc; - public QueuedPaintingSpawn(Location weLoc) { + private QueuedPaintingSpawn(Location weLoc) { this.weLoc = weLoc; } @@ -49,6 +51,7 @@ public class BukkitPainting extends BukkitEntity { spawnRaw(weLoc); } } + private static class PaintingSpawnRunnable implements Runnable { @Override public void run() { @@ -58,7 +61,7 @@ public class BukkitPainting extends BukkitEntity { try { spawn.spawn(); } catch (Throwable t) { - t.printStackTrace(); + log.log(Level.WARNING, "Failed to spawn painting", t); continue; } } @@ -82,6 +85,7 @@ public class BukkitPainting extends BukkitEntity { * @param weLoc The WorldEdit location * @return Whether the spawn as successful */ + @Override public boolean spawn(Location weLoc) { synchronized (spawnQueue) { spawnQueue.add(new QueuedPaintingSpawn(weLoc)); @@ -102,4 +106,5 @@ public class BukkitPainting extends BukkitEntity { } return false; } + } diff --git a/src/bukkit/java/com/sk89q/worldedit/bukkit/selections/Polygonal2DSelection.java b/src/bukkit/java/com/sk89q/worldedit/bukkit/selections/Polygonal2DSelection.java index 59f9a3f85..387bcf6de 100644 --- a/src/bukkit/java/com/sk89q/worldedit/bukkit/selections/Polygonal2DSelection.java +++ b/src/bukkit/java/com/sk89q/worldedit/bukkit/selections/Polygonal2DSelection.java @@ -24,7 +24,6 @@ import java.util.List; import com.sk89q.worldedit.LocalWorld; import com.sk89q.worldedit.regions.selector.Polygonal2DRegionSelector; -import com.sk89q.worldedit.regions.RegionSelector; import org.bukkit.World; import com.sk89q.worldedit.BlockVector2D; import com.sk89q.worldedit.bukkit.BukkitUtil; diff --git a/src/bukkit/java/com/sk89q/worldedit/bukkit/selections/RegionSelection.java b/src/bukkit/java/com/sk89q/worldedit/bukkit/selections/RegionSelection.java index 9e142705a..db705a8be 100644 --- a/src/bukkit/java/com/sk89q/worldedit/bukkit/selections/RegionSelection.java +++ b/src/bukkit/java/com/sk89q/worldedit/bukkit/selections/RegionSelection.java @@ -52,6 +52,7 @@ public abstract class RegionSelection implements Selection { this.region = region; } + @Override public RegionSelector getRegionSelector() { return selector; } @@ -60,48 +61,58 @@ public abstract class RegionSelection implements Selection { this.selector = selector; } + @Override public Location getMinimumPoint() { return toLocation(world, region.getMinimumPoint()); } + @Override public Vector getNativeMinimumPoint() { return region.getMinimumPoint(); } + @Override public Location getMaximumPoint() { return toLocation(world, region.getMaximumPoint()); } + @Override public Vector getNativeMaximumPoint() { return region.getMaximumPoint(); } + @Override public World getWorld() { return world; } + @Override public int getArea() { return region.getArea(); } + @Override public int getWidth() { return region.getWidth(); } + @Override public int getHeight() { return region.getHeight(); } + @Override public int getLength() { return region.getLength(); } - public boolean contains(Location pt) { - if (!pt.getWorld().equals(world)) { + @Override + public boolean contains(Location position) { + if (!position.getWorld().equals(world)) { return false; } - return region.contains(toVector(pt)); + return region.contains(toVector(position)); } } diff --git a/src/bukkit/java/com/sk89q/worldedit/bukkit/selections/Selection.java b/src/bukkit/java/com/sk89q/worldedit/bukkit/selections/Selection.java index 41390461d..c3788affc 100644 --- a/src/bukkit/java/com/sk89q/worldedit/bukkit/selections/Selection.java +++ b/src/bukkit/java/com/sk89q/worldedit/bukkit/selections/Selection.java @@ -24,7 +24,13 @@ import org.bukkit.World; import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.regions.RegionSelector; +import javax.annotation.Nullable; + +/** + * An abstraction of WorldEdit regions, which do not use Bukkit objects. + */ public interface Selection { + /** * Get the lower point of a region. * @@ -56,15 +62,16 @@ public interface Selection { /** * Get the region selector. This is for internal use. * - * @return + * @return the region selector */ public RegionSelector getRegionSelector(); /** * Get the world. * - * @return + * @return the world, which may be null */ + @Nullable public World getWorld(); /** @@ -98,8 +105,9 @@ public interface Selection { /** * Returns true based on whether the region contains the point, * - * @param pt - * @return + * @param position a vector + * @return true if it is contained */ - public boolean contains(Location pt); + public boolean contains(Location position); + } diff --git a/src/forge/java/com/sk89q/worldedit/forge/ForgeUtil.java b/src/forge/java/com/sk89q/worldedit/forge/ForgeUtil.java index afcfd4be5..c04355281 100644 --- a/src/forge/java/com/sk89q/worldedit/forge/ForgeUtil.java +++ b/src/forge/java/com/sk89q/worldedit/forge/ForgeUtil.java @@ -19,14 +19,12 @@ package com.sk89q.worldedit.forge; -import java.util.Map; - +import com.sk89q.worldedit.blocks.BaseItemStack; +import cpw.mods.fml.common.FMLCommonHandler; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; -import com.sk89q.worldedit.blocks.BaseItemStack; - -import cpw.mods.fml.common.FMLCommonHandler; +import java.util.Map; public final class ForgeUtil { @@ -41,7 +39,7 @@ public final class ForgeUtil { public static ItemStack toForgeItemStack(BaseItemStack item) { ItemStack ret = new ItemStack(item.getType(), item.getAmount(), item.getData()); for (Map.Entry entry : item.getEnchantments().entrySet()) { - ret.addEnchantment(net.minecraft.enchantment.Enchantment.enchantmentsList[((Integer)entry.getKey()).intValue()], ((Integer)entry.getValue()).intValue()); + ret.addEnchantment(net.minecraft.enchantment.Enchantment.enchantmentsList[((Integer) entry.getKey())], (Integer) entry.getValue()); } return ret; diff --git a/src/forge/java/com/sk89q/worldedit/forge/TileEntityUtils.java b/src/forge/java/com/sk89q/worldedit/forge/TileEntityUtils.java index 701369061..d0e40c1ba 100644 --- a/src/forge/java/com/sk89q/worldedit/forge/TileEntityUtils.java +++ b/src/forge/java/com/sk89q/worldedit/forge/TileEntityUtils.java @@ -33,7 +33,7 @@ import static com.google.common.base.Preconditions.checkNotNull; /** * Utility methods for setting tile entities in the world. */ -class TileEntityUtils { +final class TileEntityUtils { private TileEntityUtils() { } @@ -110,7 +110,8 @@ class TileEntityUtils { * @param clazz the class * @return a tile entity (may be null if it failed) */ - static @Nullable TileEntity constructTileEntity(World world, Vector position, Class clazz) { + @Nullable + static TileEntity constructTileEntity(World world, Vector position, Class clazz) { Constructor baseConstructor; try { baseConstructor = clazz.getConstructor(); // creates "blank" TE diff --git a/src/forge/java/com/sk89q/worldedit/forge/WECUIPacketHandler.java b/src/forge/java/com/sk89q/worldedit/forge/WECUIPacketHandler.java index 6157b74d7..1fe5d1f33 100644 --- a/src/forge/java/com/sk89q/worldedit/forge/WECUIPacketHandler.java +++ b/src/forge/java/com/sk89q/worldedit/forge/WECUIPacketHandler.java @@ -33,6 +33,7 @@ import cpw.mods.fml.common.network.Player; public class WECUIPacketHandler implements IPacketHandler { public static final Charset UTF_8_CHARSET = Charset.forName("UTF-8"); + @Override public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) { if (player instanceof EntityPlayerMP) { LocalSession session = ForgeWorldEdit.inst.getSession((EntityPlayerMP) player); diff --git a/src/legacy/java/com/sk89q/worldedit/bags/BlockBag.java b/src/legacy/java/com/sk89q/worldedit/bags/BlockBag.java index 1db76df5b..c8842ccb2 100644 --- a/src/legacy/java/com/sk89q/worldedit/bags/BlockBag.java +++ b/src/legacy/java/com/sk89q/worldedit/bags/BlockBag.java @@ -25,13 +25,16 @@ import com.sk89q.worldedit.blocks.*; /** * @deprecated Block bags are currently not a supported feature of WorldEdit */ +@SuppressWarnings("deprecation") @Deprecated + public abstract class BlockBag { + /** * Stores a block as if it was mined. * - * @param id - * @throws BlockBagException + * @param id the ID of the block + * @throws BlockBagException thrown on a error * @deprecated Use {@link BlockBag#storeDroppedBlock(int, int)} instead */ @Deprecated @@ -42,9 +45,9 @@ public abstract class BlockBag { /** * Stores a block as if it was mined. * - * @param id - * @param data - * @throws BlockBagException + * @param id the ID of the block + * @param data the data value of the block + * @throws BlockBagException thrown on a error */ public void storeDroppedBlock(int id, int data) throws BlockBagException { BaseItem dropped = BlockType.getBlockBagItem(id, data); @@ -57,7 +60,7 @@ public abstract class BlockBag { /** * Sets a block as if it was placed by hand. * - * @param id + * @param id the ID of the block * @throws BlockBagException * @deprecated Use {@link #fetchPlacedBlock(int,int)} instead */ @@ -69,8 +72,8 @@ public abstract class BlockBag { /** * Sets a block as if it was placed by hand. * - * @param id - * @param data TODO + * @param id the ID of the block + * @param data the data value of the block * @throws BlockBagException */ public void fetchPlacedBlock(int id, int data) throws BlockBagException { @@ -118,7 +121,7 @@ public abstract class BlockBag { * * Either this method or fetchItem needs to be overridden * - * @param id + * @param id the ID of the block * @throws BlockBagException */ public void fetchBlock(int id) throws BlockBagException { @@ -130,7 +133,7 @@ public abstract class BlockBag { * * Either this method or fetchBlock needs to be overridden * - * @param item + * @param item the item * @throws BlockBagException */ public void fetchItem(BaseItem item) throws BlockBagException { @@ -142,7 +145,7 @@ public abstract class BlockBag { * * Either this method or storeItem needs to be overridden * - * @param id + * @param id the ID of the block * @throws BlockBagException */ public void storeBlock(int id) throws BlockBagException { @@ -154,7 +157,7 @@ public abstract class BlockBag { * * Either this method or storeBlock needs to be overridden * - * @param item + * @param item the item * @throws BlockBagException */ public void storeItem(BaseItem item) throws BlockBagException { @@ -164,7 +167,7 @@ public abstract class BlockBag { /** * Checks to see if a block exists without removing it. * - * @param id + * @param id the ID of the block * @return whether the block exists */ public boolean peekBlock(int id) { @@ -185,14 +188,15 @@ public abstract class BlockBag { /** * Adds a position to be used a source. * - * @param pos + * @param position the position of the source */ - public abstract void addSourcePosition(WorldVector pos); + public abstract void addSourcePosition(WorldVector position); /** * Adds a position to be used a source. * - * @param pos + * @param position the position of the source */ - public abstract void addSingleSourcePosition(WorldVector pos); + public abstract void addSingleSourcePosition(WorldVector position); + } diff --git a/src/legacy/java/com/sk89q/worldedit/bags/BlockBagException.java b/src/legacy/java/com/sk89q/worldedit/bags/BlockBagException.java index 660498221..8b3ace06f 100644 --- a/src/legacy/java/com/sk89q/worldedit/bags/BlockBagException.java +++ b/src/legacy/java/com/sk89q/worldedit/bags/BlockBagException.java @@ -25,5 +25,5 @@ package com.sk89q.worldedit.bags; */ @Deprecated public class BlockBagException extends Exception { - private static final long serialVersionUID = 4672190086028430655L; + } diff --git a/src/legacy/java/com/sk89q/worldedit/bags/OutOfBlocksException.java b/src/legacy/java/com/sk89q/worldedit/bags/OutOfBlocksException.java index 0eb9eb9d6..197d9c241 100644 --- a/src/legacy/java/com/sk89q/worldedit/bags/OutOfBlocksException.java +++ b/src/legacy/java/com/sk89q/worldedit/bags/OutOfBlocksException.java @@ -25,5 +25,5 @@ package com.sk89q.worldedit.bags; */ @Deprecated public class OutOfBlocksException extends BlockBagException { - private static final long serialVersionUID = 7495899825677689509L; + } diff --git a/src/legacy/java/com/sk89q/worldedit/bags/OutOfSpaceException.java b/src/legacy/java/com/sk89q/worldedit/bags/OutOfSpaceException.java index fe6610383..c5379db5d 100644 --- a/src/legacy/java/com/sk89q/worldedit/bags/OutOfSpaceException.java +++ b/src/legacy/java/com/sk89q/worldedit/bags/OutOfSpaceException.java @@ -25,16 +25,13 @@ package com.sk89q.worldedit.bags; */ @Deprecated public class OutOfSpaceException extends BlockBagException { - private static final long serialVersionUID = -2962840237632916821L; - /** - * Stores the block ID. - */ private int id; /** * Construct the object. - * @param id + * + * @param id the type ID */ public OutOfSpaceException(int id) { this.id = id; diff --git a/src/legacy/java/com/sk89q/worldedit/bags/UnplaceableBlockException.java b/src/legacy/java/com/sk89q/worldedit/bags/UnplaceableBlockException.java index 2a3f6542a..b1ab13802 100644 --- a/src/legacy/java/com/sk89q/worldedit/bags/UnplaceableBlockException.java +++ b/src/legacy/java/com/sk89q/worldedit/bags/UnplaceableBlockException.java @@ -25,6 +25,5 @@ package com.sk89q.worldedit.bags; */ @Deprecated public class UnplaceableBlockException extends BlockBagException { - private static final long serialVersionUID = 7227883966999843526L; } diff --git a/src/legacy/java/com/sk89q/worldedit/blocks/ChestBlock.java b/src/legacy/java/com/sk89q/worldedit/blocks/ChestBlock.java index d5547e661..66cd3fd33 100644 --- a/src/legacy/java/com/sk89q/worldedit/blocks/ChestBlock.java +++ b/src/legacy/java/com/sk89q/worldedit/blocks/ChestBlock.java @@ -34,8 +34,6 @@ import java.util.Map; /** * Represents a chest block. - * - * @author sk89q */ public class ChestBlock extends ContainerBlock { @@ -109,4 +107,5 @@ public class ChestBlock extends ContainerBlock { throw new RuntimeException(e); } } + } diff --git a/src/legacy/java/com/sk89q/worldedit/blocks/ContainerBlock.java b/src/legacy/java/com/sk89q/worldedit/blocks/ContainerBlock.java index aae973c44..c52f572ff 100644 --- a/src/legacy/java/com/sk89q/worldedit/blocks/ContainerBlock.java +++ b/src/legacy/java/com/sk89q/worldedit/blocks/ContainerBlock.java @@ -19,11 +19,6 @@ package com.sk89q.worldedit.blocks; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - import com.sk89q.jnbt.ByteTag; import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.ListTag; @@ -32,10 +27,13 @@ import com.sk89q.jnbt.ShortTag; import com.sk89q.jnbt.Tag; import com.sk89q.worldedit.world.DataException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + /** * Represents a block that stores items. - * - * @author sk89q */ public abstract class ContainerBlock extends BaseBlock implements TileEntityBlock { @@ -54,7 +52,7 @@ public abstract class ContainerBlock extends BaseBlock implements TileEntityBloc /** * Get the list of items. * - * @return + * @return an array of stored items */ public BaseItemStack[] getItems() { return this.items; @@ -63,7 +61,7 @@ public abstract class ContainerBlock extends BaseBlock implements TileEntityBloc /** * Set the list of items. * - * @param items + * @param items an array of stored items */ public void setItems(BaseItemStack[] items) { this.items = items; @@ -79,7 +77,7 @@ public abstract class ContainerBlock extends BaseBlock implements TileEntityBloc data.put("id", new ShortTag("id", (short) item.getType())); data.put("Damage", new ShortTag("Damage", item.getData())); data.put("Count", new ByteTag("Count", (byte) item.getAmount())); - if (item.getEnchantments().size() > 0) { + if (!item.getEnchantments().isEmpty()) { List enchantmentList = new ArrayList(); for(Map.Entry entry : item.getEnchantments().entrySet()) { Map enchantment = new HashMap(); @@ -139,4 +137,5 @@ public abstract class ContainerBlock extends BaseBlock implements TileEntityBloc } return tags; } + } diff --git a/src/legacy/java/com/sk89q/worldedit/blocks/DispenserBlock.java b/src/legacy/java/com/sk89q/worldedit/blocks/DispenserBlock.java index c13c7f163..1101366b9 100644 --- a/src/legacy/java/com/sk89q/worldedit/blocks/DispenserBlock.java +++ b/src/legacy/java/com/sk89q/worldedit/blocks/DispenserBlock.java @@ -33,8 +33,6 @@ import java.util.Map; /** * Represents dispensers. - * - * @author sk89q */ public class DispenserBlock extends ContainerBlock { @@ -106,4 +104,5 @@ public class DispenserBlock extends ContainerBlock { throw new RuntimeException(e); } } + } diff --git a/src/legacy/java/com/sk89q/worldedit/blocks/FurnaceBlock.java b/src/legacy/java/com/sk89q/worldedit/blocks/FurnaceBlock.java index 07b38c78b..8d43f9aa7 100644 --- a/src/legacy/java/com/sk89q/worldedit/blocks/FurnaceBlock.java +++ b/src/legacy/java/com/sk89q/worldedit/blocks/FurnaceBlock.java @@ -34,8 +34,6 @@ import java.util.Map; /** * Represents a furnace block. - * - * @author sk89q */ public class FurnaceBlock extends ContainerBlock { @@ -164,4 +162,5 @@ public class FurnaceBlock extends ContainerBlock { throw new RuntimeException(e); } } + } diff --git a/src/legacy/java/com/sk89q/worldedit/blocks/LazyBlock.java b/src/legacy/java/com/sk89q/worldedit/blocks/LazyBlock.java index bf9ad5d19..cb34a71d3 100644 --- a/src/legacy/java/com/sk89q/worldedit/blocks/LazyBlock.java +++ b/src/legacy/java/com/sk89q/worldedit/blocks/LazyBlock.java @@ -29,12 +29,12 @@ import static com.google.common.base.Preconditions.checkNotNull; * A implementation of a lazy block for {@link Extent#getLazyBlock(Vector)} * that takes the block's ID and metadata, but will defer loading of NBT * data until time of access. - *

- * NBT data is later loaded using a call to {@link Extent#getBlock(Vector)} - * with a stored {@link Extent} and location. - *

- * All mutators on this object will throw an - * {@link UnsupportedOperationException}. + * + *

NBT data is later loaded using a call to {@link Extent#getBlock(Vector)} + * with a stored {@link Extent} and location.

+ * + *

All mutators on this object will throw an + * {@link UnsupportedOperationException}.

*/ public class LazyBlock extends BaseBlock { diff --git a/src/legacy/java/com/sk89q/worldedit/blocks/MobSpawnerBlock.java b/src/legacy/java/com/sk89q/worldedit/blocks/MobSpawnerBlock.java index 78bd8c7d3..2c5a4a6b6 100644 --- a/src/legacy/java/com/sk89q/worldedit/blocks/MobSpawnerBlock.java +++ b/src/legacy/java/com/sk89q/worldedit/blocks/MobSpawnerBlock.java @@ -33,8 +33,6 @@ import java.util.Map; /** * A mob spawner block. - * - * @author sk89q */ public class MobSpawnerBlock extends BaseBlock implements TileEntityBlock { @@ -247,6 +245,6 @@ public class MobSpawnerBlock extends BaseBlock implements TileEntityBlock { if (spawnDataTag != null) { this.spawnData = new CompoundTag("SpawnData", spawnDataTag.getValue()); } - } + } diff --git a/src/legacy/java/com/sk89q/worldedit/blocks/NoteBlock.java b/src/legacy/java/com/sk89q/worldedit/blocks/NoteBlock.java index 0f5c819e3..ee479d4f3 100644 --- a/src/legacy/java/com/sk89q/worldedit/blocks/NoteBlock.java +++ b/src/legacy/java/com/sk89q/worldedit/blocks/NoteBlock.java @@ -29,8 +29,6 @@ import java.util.Map; /** * A note block. - * - * @author sk89q */ public class NoteBlock extends BaseBlock implements TileEntityBlock { @@ -120,4 +118,5 @@ public class NoteBlock extends BaseBlock implements TileEntityBlock { note = ((ByteTag) t).getValue(); } } + } diff --git a/src/legacy/java/com/sk89q/worldedit/blocks/SignBlock.java b/src/legacy/java/com/sk89q/worldedit/blocks/SignBlock.java index e4d36c0d2..9801aebff 100644 --- a/src/legacy/java/com/sk89q/worldedit/blocks/SignBlock.java +++ b/src/legacy/java/com/sk89q/worldedit/blocks/SignBlock.java @@ -28,8 +28,6 @@ import java.util.Map; /** * Represents a sign block. - * - * @author sk89q */ public class SignBlock extends BaseBlock implements TileEntityBlock { @@ -139,4 +137,5 @@ public class SignBlock extends BaseBlock implements TileEntityBlock { text[3] = ((StringTag) t).getValue(); } } + } diff --git a/src/legacy/java/com/sk89q/worldedit/masks/BlockMask.java b/src/legacy/java/com/sk89q/worldedit/masks/BlockMask.java index f503a9e74..a6dd9ab97 100644 --- a/src/legacy/java/com/sk89q/worldedit/masks/BlockMask.java +++ b/src/legacy/java/com/sk89q/worldedit/masks/BlockMask.java @@ -64,8 +64,8 @@ public class BlockMask extends AbstractMask { } @Override - public boolean matches(EditSession editSession, Vector pos) { - BaseBlock block = editSession.getBlock(pos); + public boolean matches(EditSession editSession, Vector position) { + BaseBlock block = editSession.getBlock(position); return blocks.contains(block) || blocks.contains(new BaseBlock(block.getType(), -1)); } diff --git a/src/legacy/java/com/sk89q/worldedit/masks/BlockTypeMask.java b/src/legacy/java/com/sk89q/worldedit/masks/BlockTypeMask.java index f504193bb..5d195c4fc 100644 --- a/src/legacy/java/com/sk89q/worldedit/masks/BlockTypeMask.java +++ b/src/legacy/java/com/sk89q/worldedit/masks/BlockTypeMask.java @@ -19,17 +19,18 @@ package com.sk89q.worldedit.masks; -import java.util.Set; import com.sk89q.worldedit.blocks.BaseBlock; +import java.util.Set; + /** * A filter that matches blocks based on block types. * - * @deprecated replaced by {@link #BlockMask} - * @author sk89q + * @deprecated replaced by {@link #BlockMask} */ @Deprecated public class BlockTypeMask extends BlockMask { + public BlockTypeMask() { super(); } @@ -49,4 +50,5 @@ public class BlockTypeMask extends BlockMask { public void add(int type) { add(new BaseBlock(type)); } + } diff --git a/src/legacy/java/com/sk89q/worldedit/masks/CombinedMask.java b/src/legacy/java/com/sk89q/worldedit/masks/CombinedMask.java index a78c0cfc4..3f7a6690e 100644 --- a/src/legacy/java/com/sk89q/worldedit/masks/CombinedMask.java +++ b/src/legacy/java/com/sk89q/worldedit/masks/CombinedMask.java @@ -72,9 +72,9 @@ public class CombinedMask extends AbstractMask { } @Override - public boolean matches(EditSession editSession, Vector pos) { + public boolean matches(EditSession editSession, Vector position) { for (Mask mask : masks) { - if (!mask.matches(editSession, pos)) { + if (!mask.matches(editSession, position)) { return false; } } diff --git a/src/legacy/java/com/sk89q/worldedit/masks/DynamicRegionMask.java b/src/legacy/java/com/sk89q/worldedit/masks/DynamicRegionMask.java index c7c061a96..ebe866f57 100644 --- a/src/legacy/java/com/sk89q/worldedit/masks/DynamicRegionMask.java +++ b/src/legacy/java/com/sk89q/worldedit/masks/DynamicRegionMask.java @@ -40,7 +40,7 @@ public class DynamicRegionMask extends AbstractMask { } @Override - public boolean matches(EditSession editSession, Vector pos) { - return region == null || region.contains(pos); + public boolean matches(EditSession editSession, Vector position) { + return region == null || region.contains(position); } } diff --git a/src/legacy/java/com/sk89q/worldedit/masks/ExistingBlockMask.java b/src/legacy/java/com/sk89q/worldedit/masks/ExistingBlockMask.java index 5a559572b..487786d06 100644 --- a/src/legacy/java/com/sk89q/worldedit/masks/ExistingBlockMask.java +++ b/src/legacy/java/com/sk89q/worldedit/masks/ExistingBlockMask.java @@ -29,7 +29,7 @@ import com.sk89q.worldedit.blocks.BlockID; @Deprecated public class ExistingBlockMask extends AbstractMask { @Override - public boolean matches(EditSession editSession, Vector pos) { - return editSession.getBlockType(pos) != BlockID.AIR; + public boolean matches(EditSession editSession, Vector position) { + return editSession.getBlockType(position) != BlockID.AIR; } } diff --git a/src/legacy/java/com/sk89q/worldedit/masks/FuzzyBlockMask.java b/src/legacy/java/com/sk89q/worldedit/masks/FuzzyBlockMask.java index 8118d6308..63093624c 100644 --- a/src/legacy/java/com/sk89q/worldedit/masks/FuzzyBlockMask.java +++ b/src/legacy/java/com/sk89q/worldedit/masks/FuzzyBlockMask.java @@ -24,6 +24,7 @@ import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.blocks.Blocks; +import java.util.Collections; import java.util.HashSet; import java.util.Set; @@ -51,15 +52,13 @@ public class FuzzyBlockMask extends AbstractMask { */ public FuzzyBlockMask(BaseBlock... block) { Set filter = new HashSet(); - for (BaseBlock b : block) { - filter.add(b); - } + Collections.addAll(filter, block); this.filter = filter; } @Override - public boolean matches(EditSession editSession, Vector pos) { - BaseBlock compare = new BaseBlock(editSession.getBlockType(pos), editSession.getBlockData(pos)); + public boolean matches(EditSession editSession, Vector position) { + BaseBlock compare = new BaseBlock(editSession.getBlockType(position), editSession.getBlockData(position)); return Blocks.containsFuzzy(filter, compare); } } diff --git a/src/legacy/java/com/sk89q/worldedit/masks/InvertedBlockTypeMask.java b/src/legacy/java/com/sk89q/worldedit/masks/InvertedBlockTypeMask.java index 79f532f80..61ae5a9a5 100644 --- a/src/legacy/java/com/sk89q/worldedit/masks/InvertedBlockTypeMask.java +++ b/src/legacy/java/com/sk89q/worldedit/masks/InvertedBlockTypeMask.java @@ -19,36 +19,31 @@ package com.sk89q.worldedit.masks; -import java.util.Set; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.Vector; +import java.util.Set; + /** * A block type mask that only matches blocks that are not in the list. - * - * @author sk89q */ @Deprecated public class InvertedBlockTypeMask extends BlockTypeMask { + public InvertedBlockTypeMask() { } - /** - * @param types - */ public InvertedBlockTypeMask(Set types) { super(types); } - /** - * @param type - */ public InvertedBlockTypeMask(int type) { super(type); } @Override - public boolean matches(EditSession editSession, Vector pos) { - return !super.matches(editSession, pos); + public boolean matches(EditSession editSession, Vector position) { + return !super.matches(editSession, position); } + } diff --git a/src/legacy/java/com/sk89q/worldedit/masks/InvertedMask.java b/src/legacy/java/com/sk89q/worldedit/masks/InvertedMask.java index df6509d53..d86ac89b3 100644 --- a/src/legacy/java/com/sk89q/worldedit/masks/InvertedMask.java +++ b/src/legacy/java/com/sk89q/worldedit/masks/InvertedMask.java @@ -36,13 +36,14 @@ public class InvertedMask extends AbstractMask { this.mask = mask; } + @Override public void prepare(LocalSession session, LocalPlayer player, Vector target) { mask.prepare(session, player, target); } @Override - public boolean matches(EditSession editSession, Vector pos) { - return !mask.matches(editSession, pos); + public boolean matches(EditSession editSession, Vector position) { + return !mask.matches(editSession, position); } public Mask getInvertedMask() { diff --git a/src/legacy/java/com/sk89q/worldedit/masks/Mask.java b/src/legacy/java/com/sk89q/worldedit/masks/Mask.java index 08041f631..cf0a04c89 100644 --- a/src/legacy/java/com/sk89q/worldedit/masks/Mask.java +++ b/src/legacy/java/com/sk89q/worldedit/masks/Mask.java @@ -33,8 +33,8 @@ public interface Mask { /** * Called one time before each edit session. * - * @param session - * @param player + * @param session a session + * @param player a player * @param target target of the brush, null if not a brush mask */ void prepare(LocalSession session, LocalPlayer player, Vector target); @@ -45,9 +45,10 @@ public interface Mask { * as getting a BaseBlock has unneeded overhead in most block querying * situations (enumerating a chest's contents is a waste, for example). * - * @param editSession - * @param pos - * @return + * @param editSession an instance + * @param position the position to check + * @return true if it matches */ - boolean matches(EditSession editSession, Vector pos); + boolean matches(EditSession editSession, Vector position); + } diff --git a/src/legacy/java/com/sk89q/worldedit/masks/RandomMask.java b/src/legacy/java/com/sk89q/worldedit/masks/RandomMask.java index 731cac3e9..a9e657ca6 100644 --- a/src/legacy/java/com/sk89q/worldedit/masks/RandomMask.java +++ b/src/legacy/java/com/sk89q/worldedit/masks/RandomMask.java @@ -35,7 +35,7 @@ public class RandomMask extends AbstractMask { } @Override - public boolean matches(EditSession editSession, Vector pos) { + public boolean matches(EditSession editSession, Vector position) { return Math.random() < ratio; } } diff --git a/src/legacy/java/com/sk89q/worldedit/masks/RegionMask.java b/src/legacy/java/com/sk89q/worldedit/masks/RegionMask.java index 1b750934b..220aaf4b9 100644 --- a/src/legacy/java/com/sk89q/worldedit/masks/RegionMask.java +++ b/src/legacy/java/com/sk89q/worldedit/masks/RegionMask.java @@ -35,7 +35,7 @@ public class RegionMask extends AbstractMask { } @Override - public boolean matches(EditSession editSession, Vector pos) { - return region.contains(pos); + public boolean matches(EditSession editSession, Vector position) { + return region.contains(position); } } diff --git a/src/legacy/java/com/sk89q/worldedit/masks/SolidBlockMask.java b/src/legacy/java/com/sk89q/worldedit/masks/SolidBlockMask.java index 80d416bfe..dd5403441 100644 --- a/src/legacy/java/com/sk89q/worldedit/masks/SolidBlockMask.java +++ b/src/legacy/java/com/sk89q/worldedit/masks/SolidBlockMask.java @@ -29,7 +29,7 @@ import com.sk89q.worldedit.blocks.BlockType; @Deprecated public class SolidBlockMask extends AbstractMask { @Override - public boolean matches(EditSession editSession, Vector pos) { - return !BlockType.canPassThrough(editSession.getBlockType(pos), editSession.getBlockData(pos)); + public boolean matches(EditSession editSession, Vector position) { + return !BlockType.canPassThrough(editSession.getBlockType(position), editSession.getBlockData(position)); } } diff --git a/src/legacy/java/com/sk89q/worldedit/masks/UnderOverlayMask.java b/src/legacy/java/com/sk89q/worldedit/masks/UnderOverlayMask.java index 8e200c468..39fe3dc8e 100644 --- a/src/legacy/java/com/sk89q/worldedit/masks/UnderOverlayMask.java +++ b/src/legacy/java/com/sk89q/worldedit/masks/UnderOverlayMask.java @@ -70,7 +70,7 @@ public class UnderOverlayMask extends AbstractMask { } @Override - public boolean matches(EditSession editSession, Vector pos) { - return !mask.matches(editSession, pos) && mask.matches(editSession, pos.add(0, yMod, 0)); + public boolean matches(EditSession editSession, Vector position) { + return !mask.matches(editSession, position) && mask.matches(editSession, position.add(0, yMod, 0)); } } diff --git a/src/legacy/java/com/sk89q/worldedit/patterns/BlockChance.java b/src/legacy/java/com/sk89q/worldedit/patterns/BlockChance.java index b87f9b20a..35c45a132 100644 --- a/src/legacy/java/com/sk89q/worldedit/patterns/BlockChance.java +++ b/src/legacy/java/com/sk89q/worldedit/patterns/BlockChance.java @@ -26,20 +26,15 @@ import com.sk89q.worldedit.blocks.BaseBlock; */ @Deprecated public class BlockChance { - /** - * Block. - */ + private BaseBlock block; - /** - * Chance. Can be any positive value. - */ private double chance; /** * Construct the object. * - * @param block - * @param chance + * @param block the block + * @param chance the probability of the block */ public BlockChance(BaseBlock block, double chance) { this.block = block; @@ -59,4 +54,5 @@ public class BlockChance { public double getChance() { return chance; } + } diff --git a/src/legacy/java/com/sk89q/worldedit/patterns/ClipboardPattern.java b/src/legacy/java/com/sk89q/worldedit/patterns/ClipboardPattern.java index cc62b4179..8808a0684 100644 --- a/src/legacy/java/com/sk89q/worldedit/patterns/ClipboardPattern.java +++ b/src/legacy/java/com/sk89q/worldedit/patterns/ClipboardPattern.java @@ -24,47 +24,28 @@ import com.sk89q.worldedit.blocks.BaseBlock; /** * Pattern that repeats the clipboard. - * - * @author sk89q */ public class ClipboardPattern implements Pattern { - /** - * Clipboard. - */ + private CuboidClipboard clipboard; - /** - * Size of the clipboard. - */ private Vector size; /** * Construct the object. * - * @param clipboard + * @param clipboard the clipboard */ public ClipboardPattern(CuboidClipboard clipboard) { this.clipboard = clipboard; this.size = clipboard.getSize(); } - /** - * Get next block. - * - * @param pos - * @return - */ - public BaseBlock next(Vector pos) { - return next(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ()); + @Override + public BaseBlock next(Vector position) { + return next(position.getBlockX(), position.getBlockY(), position.getBlockZ()); } - /** - * Get next block. - * - * @param x - * @param y - * @param z - * @return - */ + @Override public BaseBlock next(int x, int y, int z) { int xp = Math.abs(x) % size.getBlockX(); int yp = Math.abs(y) % size.getBlockY(); @@ -72,4 +53,5 @@ public class ClipboardPattern implements Pattern { return clipboard.getPoint(new Vector(xp, yp, zp)); } + } diff --git a/src/legacy/java/com/sk89q/worldedit/patterns/Pattern.java b/src/legacy/java/com/sk89q/worldedit/patterns/Pattern.java index dfadb7ba5..b27e8e0fc 100644 --- a/src/legacy/java/com/sk89q/worldedit/patterns/Pattern.java +++ b/src/legacy/java/com/sk89q/worldedit/patterns/Pattern.java @@ -27,21 +27,25 @@ import com.sk89q.worldedit.blocks.BaseBlock; */ @Deprecated public interface Pattern { - /** - * Get a block for a position. This return value of this method does - * not have to be consistent for the same position. - * - * @param pos - * @return - */ - public BaseBlock next(Vector pos); /** * Get a block for a position. This return value of this method does * not have to be consistent for the same position. * - * @param pos - * @return + * @param position the position where a block is needed + * @return a block + */ + public BaseBlock next(Vector position); + + /** + * Get a block for a position. This return value of this method does + * not have to be consistent for the same position. + * + * @param x the X coordinate + * @param y the Y coordinate + * @param z the Z coordinate + * @return a block */ public BaseBlock next(int x, int y, int z); + } diff --git a/src/legacy/java/com/sk89q/worldedit/patterns/RandomFillPattern.java b/src/legacy/java/com/sk89q/worldedit/patterns/RandomFillPattern.java index 456ce5ed1..6014eec36 100644 --- a/src/legacy/java/com/sk89q/worldedit/patterns/RandomFillPattern.java +++ b/src/legacy/java/com/sk89q/worldedit/patterns/RandomFillPattern.java @@ -32,19 +32,14 @@ import java.util.Random; */ @Deprecated public class RandomFillPattern implements Pattern { - /** - * Random number generator. - */ + private static final Random random = new Random(); - /** - * Blocks and their proportions. - */ private List blocks; /** * Construct the object. * - * @param blocks + * @param blocks a list of blocks */ public RandomFillPattern(List blocks) { double max = 0; @@ -66,13 +61,8 @@ public class RandomFillPattern implements Pattern { this.blocks = finalBlocks; } - /** - * Get next block. - * - * @param pos - * @return - */ - public BaseBlock next(Vector pos) { + @Override + public BaseBlock next(Vector position) { double r = random.nextDouble(); for (BlockChance block : blocks) { @@ -84,7 +74,9 @@ public class RandomFillPattern implements Pattern { throw new RuntimeException("ProportionalFillPattern"); } + @Override public BaseBlock next(int x, int y, int z) { return next(null); } + } diff --git a/src/legacy/java/com/sk89q/worldedit/patterns/SingleBlockPattern.java b/src/legacy/java/com/sk89q/worldedit/patterns/SingleBlockPattern.java index 5b49372a4..325b85112 100644 --- a/src/legacy/java/com/sk89q/worldedit/patterns/SingleBlockPattern.java +++ b/src/legacy/java/com/sk89q/worldedit/patterns/SingleBlockPattern.java @@ -28,40 +28,35 @@ import com.sk89q.worldedit.function.pattern.BlockPattern; */ @Deprecated public class SingleBlockPattern implements Pattern { - /** - * Block type. - */ + private BaseBlock block; /** * Construct the object. * - * @param block + * @param block the block */ public SingleBlockPattern(BaseBlock block) { this.block = block; } - /** - * Get next block. - * - * @param pos - * @return - */ - public BaseBlock next(Vector pos) { - return block; - } - - public BaseBlock next(int x, int y, int z) { - return block; - } - /** * Get the block. * - * @return + * @return the block */ public BaseBlock getBlock() { return block; } + + @Override + public BaseBlock next(Vector position) { + return block; + } + + @Override + public BaseBlock next(int x, int y, int z) { + return block; + } + } diff --git a/src/main/java/com/sk89q/jnbt/EndTag.java b/src/main/java/com/sk89q/jnbt/EndTag.java index 5051cc939..1db29b3d6 100644 --- a/src/main/java/com/sk89q/jnbt/EndTag.java +++ b/src/main/java/com/sk89q/jnbt/EndTag.java @@ -20,10 +20,7 @@ package com.sk89q.jnbt; /** - * The TAG_End tag. - * - * @author Graham Edgecombe - * + * The {@code TAG_End} tag. */ public final class EndTag extends Tag { diff --git a/src/main/java/com/sk89q/jnbt/IntArrayTag.java b/src/main/java/com/sk89q/jnbt/IntArrayTag.java index b8dced001..58b318c79 100644 --- a/src/main/java/com/sk89q/jnbt/IntArrayTag.java +++ b/src/main/java/com/sk89q/jnbt/IntArrayTag.java @@ -71,7 +71,7 @@ public final class IntArrayTag extends Tag { if (name != null && !name.equals("")) { append = "(\"" + this.getName() + "\")"; } - return "TAG_Int_Array" + append + ": " + hex.toString(); + return "TAG_Int_Array" + append + ": " + hex; } } diff --git a/src/main/java/com/sk89q/jnbt/ListTag.java b/src/main/java/com/sk89q/jnbt/ListTag.java index 4125b43ee..b03e35d33 100644 --- a/src/main/java/com/sk89q/jnbt/ListTag.java +++ b/src/main/java/com/sk89q/jnbt/ListTag.java @@ -437,12 +437,9 @@ public final class ListTag extends Tag { append = "(\"" + this.getName() + "\")"; } StringBuilder bldr = new StringBuilder(); - bldr.append("TAG_List" + append + ": " + value.size() - + " entries of type " + NBTUtils.getTypeName(type) - + "\r\n{\r\n"); + bldr.append("TAG_List").append(append).append(": ").append(value.size()).append(" entries of type ").append(NBTUtils.getTypeName(type)).append("\r\n{\r\n"); for (Tag t : value) { - bldr.append(" " + t.toString().replaceAll("\r\n", "\r\n ") - + "\r\n"); + bldr.append(" ").append(t.toString().replaceAll("\r\n", "\r\n ")).append("\r\n"); } bldr.append("}"); return bldr.toString(); diff --git a/src/main/java/com/sk89q/jnbt/NBTConstants.java b/src/main/java/com/sk89q/jnbt/NBTConstants.java index 7c8001b43..2ff2768ac 100644 --- a/src/main/java/com/sk89q/jnbt/NBTConstants.java +++ b/src/main/java/com/sk89q/jnbt/NBTConstants.java @@ -23,9 +23,6 @@ import java.nio.charset.Charset; /** * A class which holds constant values. - * - * @author Graham Edgecombe - * */ public final class NBTConstants { diff --git a/src/main/java/com/sk89q/jnbt/NBTInputStream.java b/src/main/java/com/sk89q/jnbt/NBTInputStream.java index 1d1c5215b..31fab63a1 100644 --- a/src/main/java/com/sk89q/jnbt/NBTInputStream.java +++ b/src/main/java/com/sk89q/jnbt/NBTInputStream.java @@ -29,20 +29,13 @@ import java.util.List; import java.util.Map; /** - *

* This class reads NBT, or Named Binary Tag - * streams, and produces an object graph of subclasses of the Tag + * streams, and produces an object graph of subclasses of the {@code Tag} * object. - *

* - *

- * The NBT format was created by Markus Persson, and the specification may be + *

The NBT format was created by Markus Persson, and the specification may be * found at - * http://www.minecraft.net/docs/NBT.txt. - *

- * - * @author Graham Edgecombe - * + * http://www.minecraft.net/docs/NBT.txt.

*/ public final class NBTInputStream implements Closeable { diff --git a/src/main/java/com/sk89q/jnbt/NBTOutputStream.java b/src/main/java/com/sk89q/jnbt/NBTOutputStream.java index d9a56f666..eabc87d28 100644 --- a/src/main/java/com/sk89q/jnbt/NBTOutputStream.java +++ b/src/main/java/com/sk89q/jnbt/NBTOutputStream.java @@ -26,19 +26,12 @@ import java.io.OutputStream; import java.util.List; /** - *

* This class writes NBT, or Named Binary Tag - * Tag objects to an underlying OutputStream. - *

+ * {@code Tag} objects to an underlying {@code OutputStream}. * - *

- * The NBT format was created by Markus Persson, and the specification may be + *

The NBT format was created by Markus Persson, and the specification may be * found at - * http://www.minecraft.net/docs/NBT.txt. - *

- * - * @author Graham Edgecombe - * + * http://www.minecraft.net/docs/NBT.txt.

*/ public final class NBTOutputStream implements Closeable { @@ -48,7 +41,7 @@ public final class NBTOutputStream implements Closeable { private final DataOutputStream os; /** - * Creates a new NBTOutputStream, which will write data to the + * Creates a new {@code NBTOutputStream}, which will write data to the * specified underlying output stream. * * @param os @@ -137,7 +130,7 @@ public final class NBTOutputStream implements Closeable { } /** - * Writes a TAG_Byte tag. + * Writes a {@code TAG_Byte} tag. * * @param tag * The tag. @@ -149,7 +142,7 @@ public final class NBTOutputStream implements Closeable { } /** - * Writes a TAG_Byte_Array tag. + * Writes a {@code TAG_Byte_Array} tag. * * @param tag * The tag. @@ -163,7 +156,7 @@ public final class NBTOutputStream implements Closeable { } /** - * Writes a TAG_Compound tag. + * Writes a {@code TAG_Compound} tag. * * @param tag * The tag. @@ -178,7 +171,7 @@ public final class NBTOutputStream implements Closeable { } /** - * Writes a TAG_List tag. + * Writes a {@code TAG_List} tag. * * @param tag * The tag. @@ -192,13 +185,13 @@ public final class NBTOutputStream implements Closeable { os.writeByte(NBTUtils.getTypeCode(clazz)); os.writeInt(size); - for (int i = 0; i < size; ++i) { - writeTagPayload(tags.get(i)); + for (Tag tag1 : tags) { + writeTagPayload(tag1); } } /** - * Writes a TAG_String tag. + * Writes a {@code TAG_String} tag. * * @param tag * The tag. @@ -212,7 +205,7 @@ public final class NBTOutputStream implements Closeable { } /** - * Writes a TAG_Double tag. + * Writes a {@code TAG_Double} tag. * * @param tag * The tag. @@ -224,7 +217,7 @@ public final class NBTOutputStream implements Closeable { } /** - * Writes a TAG_Float tag. + * Writes a {@code TAG_Float} tag. * * @param tag * The tag. @@ -236,7 +229,7 @@ public final class NBTOutputStream implements Closeable { } /** - * Writes a TAG_Long tag. + * Writes a {@code TAG_Long} tag. * * @param tag * The tag. @@ -248,7 +241,7 @@ public final class NBTOutputStream implements Closeable { } /** - * Writes a TAG_Int tag. + * Writes a {@code TAG_Int} tag. * * @param tag * The tag. @@ -260,7 +253,7 @@ public final class NBTOutputStream implements Closeable { } /** - * Writes a TAG_Short tag. + * Writes a {@code TAG_Short} tag. * * @param tag * The tag. @@ -272,12 +265,9 @@ public final class NBTOutputStream implements Closeable { } /** - * Writes a TAG_Empty tag. + * Writes a {@code TAG_Empty} tag. * - * @param tag - * The tag. - * @throws IOException - * if an I/O error occurs. + * @param tag the tag */ private void writeEndTagPayload(EndTag tag) { /* empty */ @@ -286,11 +276,12 @@ public final class NBTOutputStream implements Closeable { private void writeIntArrayTagPayload(IntArrayTag tag) throws IOException { int[] data = tag.getValue(); os.writeInt(data.length); - for (int i = 0; i < data.length; i++) { - os.writeInt(data[i]); + for (int aData : data) { + os.writeInt(aData); } } + @Override public void close() throws IOException { os.close(); } diff --git a/src/main/java/com/sk89q/jnbt/NBTUtils.java b/src/main/java/com/sk89q/jnbt/NBTUtils.java index 20b3e5542..428ff4d86 100644 --- a/src/main/java/com/sk89q/jnbt/NBTUtils.java +++ b/src/main/java/com/sk89q/jnbt/NBTUtils.java @@ -20,8 +20,6 @@ package com.sk89q.jnbt; import com.sk89q.worldedit.Vector; -import com.sk89q.worldedit.extent.Extent; -import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.world.storage.InvalidFormatException; import java.util.Map; @@ -171,14 +169,13 @@ public final class NBTUtils { /** * Get child tag of a NBT structure. * - * @param items - * @param key - * @param expected + * @param items the map to read from + * @param key the key to look for + * @param expected the expected NBT class type * @return child tag * @throws InvalidFormatException */ - public static T getChildTag(Map items, String key, - Class expected) throws InvalidFormatException { + public static T getChildTag(Map items, String key, Class expected) throws InvalidFormatException { if (!items.containsKey(key)) { throw new InvalidFormatException("Missing a \"" + key + "\" tag"); } diff --git a/src/main/java/com/sk89q/minecraft/util/commands/Command.java b/src/main/java/com/sk89q/minecraft/util/commands/Command.java index dc52cccef..cc811acb7 100644 --- a/src/main/java/com/sk89q/minecraft/util/commands/Command.java +++ b/src/main/java/com/sk89q/minecraft/util/commands/Command.java @@ -26,11 +26,10 @@ import java.lang.annotation.RetentionPolicy; * This annotation indicates a command. Methods should be marked with this * annotation to tell {@link CommandsManager} that the method is a command. * Note that the method name can actually be anything. - * - * @author sk89q */ @Retention(RetentionPolicy.RUNTIME) public @interface Command { + /** * A list of aliases for the command. The first alias is the most * important -- it is the main name of the command. (The method name @@ -42,7 +41,7 @@ public @interface Command { /** * Usage instruction. Example text for usage could be - * [-h harps] [name] [message]. + * {@code [-h harps] [name] [message]}. * * @return Usage instructions for a command */ @@ -85,9 +84,10 @@ public @interface Command { String help() default ""; /** + * Get whether any flag can be used. * - * - * @return Whether any flag can be provided to the command, even if it is not in {@link #flags()} + * @return true if so */ boolean anyFlags() default false; + } diff --git a/src/main/java/com/sk89q/minecraft/util/commands/CommandAlias.java b/src/main/java/com/sk89q/minecraft/util/commands/CommandAlias.java index 61042b97e..59ba3e4a4 100644 --- a/src/main/java/com/sk89q/minecraft/util/commands/CommandAlias.java +++ b/src/main/java/com/sk89q/minecraft/util/commands/CommandAlias.java @@ -26,16 +26,15 @@ import java.lang.annotation.RetentionPolicy; * Any command with this annotation will run the raw command as shown in the * thing, as long as it is registered in the current {@link CommandsManager}. * Mostly to move commands around without breaking things. - * - * @author zml2008 */ @Retention(RetentionPolicy.RUNTIME) public @interface CommandAlias { /** + * Get the raw {@link CommandsManager}-formatted command arg array to run * - * @return Raw {@link CommandsManager}-formatted command arg array to run + * @return the command */ String[] value(); } 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 7f1a4e185..34bc2540c 100644 --- a/src/main/java/com/sk89q/minecraft/util/commands/CommandContext.java +++ b/src/main/java/com/sk89q/minecraft/util/commands/CommandContext.java @@ -94,7 +94,7 @@ public class CommandContext { isHanging = false; String arg = args[i]; - if (arg.length() == 0) { + if (arg.isEmpty()) { isHanging = true; continue; } @@ -127,7 +127,7 @@ public class CommandContext { } // In case there is an empty quoted string - if (arg.length() == 0) { + if (arg.isEmpty()) { continue; } // else raise exception about hanging quotes? diff --git a/src/main/java/com/sk89q/minecraft/util/commands/CommandException.java b/src/main/java/com/sk89q/minecraft/util/commands/CommandException.java index 968c31e6a..e81344e56 100644 --- a/src/main/java/com/sk89q/minecraft/util/commands/CommandException.java +++ b/src/main/java/com/sk89q/minecraft/util/commands/CommandException.java @@ -27,8 +27,7 @@ import java.util.ListIterator; import static com.google.common.base.Preconditions.checkNotNull; public class CommandException extends Exception { - - private static final long serialVersionUID = 870638193072101739L; + private List commandStack = new ArrayList(); public CommandException() { diff --git a/src/main/java/com/sk89q/minecraft/util/commands/CommandPermissions.java b/src/main/java/com/sk89q/minecraft/util/commands/CommandPermissions.java index fcfc444ac..6e890b7fb 100644 --- a/src/main/java/com/sk89q/minecraft/util/commands/CommandPermissions.java +++ b/src/main/java/com/sk89q/minecraft/util/commands/CommandPermissions.java @@ -24,14 +24,14 @@ import java.lang.annotation.RetentionPolicy; /** * Indicates a list of permissions that should be checked. - * - * @author sk89q */ @Retention(RetentionPolicy.RUNTIME) public @interface CommandPermissions { + /** * A list of permissions. Only one permission has to be met * for the command to be permitted. */ String[] value(); + } diff --git a/src/main/java/com/sk89q/minecraft/util/commands/CommandPermissionsException.java b/src/main/java/com/sk89q/minecraft/util/commands/CommandPermissionsException.java index b5692d0bf..d86d2f225 100644 --- a/src/main/java/com/sk89q/minecraft/util/commands/CommandPermissionsException.java +++ b/src/main/java/com/sk89q/minecraft/util/commands/CommandPermissionsException.java @@ -21,9 +21,7 @@ package com.sk89q.minecraft.util.commands; /** * Thrown when not enough permissions are satisfied. - * - * @author sk89q */ public class CommandPermissionsException extends CommandException { - private static final long serialVersionUID = -602374621030168291L; + } diff --git a/src/main/java/com/sk89q/minecraft/util/commands/CommandUsageException.java b/src/main/java/com/sk89q/minecraft/util/commands/CommandUsageException.java index d767e548f..5e50c6ab5 100644 --- a/src/main/java/com/sk89q/minecraft/util/commands/CommandUsageException.java +++ b/src/main/java/com/sk89q/minecraft/util/commands/CommandUsageException.java @@ -20,7 +20,6 @@ package com.sk89q.minecraft.util.commands; public class CommandUsageException extends CommandException { - private static final long serialVersionUID = -6761418114414516542L; protected String usage; 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 8d81f46cd..6ee1fd65f 100644 --- a/src/main/java/com/sk89q/minecraft/util/commands/CommandsManager.java +++ b/src/main/java/com/sk89q/minecraft/util/commands/CommandsManager.java @@ -19,6 +19,8 @@ package com.sk89q.minecraft.util.commands; +import com.sk89q.util.StringUtil; + import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; @@ -31,16 +33,14 @@ import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; -import com.sk89q.util.StringUtil; - /** - *

Manager for handling commands. This allows you to easily process commands, - * including nested commands, by correctly annotating methods of a class.

+ * Manager for handling commands. This allows you to easily process commands, + * including nested commands, by correctly annotating methods of a class. * *

To use this, it is merely a matter of registering classes containing * the commands (as methods with the proper annotations) with the * manager. When you want to process a command, use one of the - * execute methods. If something is wrong, such as incorrect + * {@code execute} methods. If something is wrong, such as incorrect * usage, insufficient permissions, or a missing command altogether, an * exception will be raised for upstream handling.

* @@ -57,13 +57,11 @@ import com.sk89q.util.StringUtil; * allows for fast command handling. Method invocation still has to be done * with reflection, but this is quite fast in that of itself.

* - * @author sk89q * @param command sender class */ +@SuppressWarnings("ProtectedField") public abstract class CommandsManager { - /** - * Logger for general errors. - */ + protected static final Logger logger = Logger.getLogger(CommandsManager.class.getCanonicalName()); @@ -105,7 +103,7 @@ public abstract class CommandsManager { * instances will be created of the command classes and methods will * not be called statically. * - * @param cls + * @param cls the class to register */ public void register(Class cls) { registerMethods(cls, null); @@ -119,7 +117,7 @@ public abstract class CommandsManager { * not be called statically. A List of {@link Command} annotations from * registered commands is returned. * - * @param cls + * @param cls the class to register * @return A List of {@link Command} annotations from registered commands, * for use in eg. a dynamic command registration system. */ @@ -131,8 +129,8 @@ public abstract class CommandsManager { * Register the methods of a class. This will automatically construct * instances as necessary. * - * @param cls - * @param parent + * @param cls the class to register + * @param parent the parent method * @return Commands Registered */ public List registerMethods(Class cls, Method parent) { @@ -156,10 +154,10 @@ public abstract class CommandsManager { /** * Register the methods of a class. * - * @param cls - * @param parent - * @param obj - * @return + * @param cls the class to register + * @param parent the parent method + * @param obj the object whose methods will become commands if they are annotated + * @return a list of commands */ private List registerMethods(Class cls, Method parent, Object obj) { Map map; @@ -205,14 +203,14 @@ public abstract class CommandsManager { final String desc = cmd.desc(); final String usage = cmd.usage(); - if (usage.length() == 0) { + if (usage.isEmpty()) { descs.put(commandName, desc); } else { descs.put(commandName, usage + " - " + desc); } String help = cmd.help(); - if (help.length() == 0) { + if (help.isEmpty()) { help = desc; } @@ -255,8 +253,8 @@ public abstract class CommandsManager { * Checks to see whether there is a command named such at the root level. * This will check aliases as well. * - * @param command - * @return + * @param command the command + * @return true if the command exists */ public boolean hasCommand(String command) { return commands.get(null).containsKey(command.toLowerCase()); @@ -265,12 +263,17 @@ public abstract class CommandsManager { /** * Get a list of command descriptions. This is only for root commands. * - * @return + * @return a map of commands */ public Map getCommands() { return descs; } + /** + * Get the mapping of methods under a parent command. + * + * @return the mapping + */ public Map> getMethods() { return commands; } @@ -278,7 +281,7 @@ public abstract class CommandsManager { /** * Get a map from command name to help message. This is only for root commands. * - * @return + * @return a map of help messages for each command */ public Map getHelpMessages() { return helpMessages; @@ -287,10 +290,10 @@ public abstract class CommandsManager { /** * Get the usage string for a command. * - * @param args - * @param level - * @param cmd - * @return + * @param args the arguments + * @param level the depth of the command + * @param cmd the command annotation + * @return the usage string */ protected String getUsage(String[] args, int level, Command cmd) { final StringBuilder command = new StringBuilder(); @@ -304,7 +307,7 @@ public abstract class CommandsManager { command.append(getArguments(cmd)); final String help = cmd.help(); - if (help.length() > 0) { + if (!help.isEmpty()) { command.append("\n\n"); command.append(help); } @@ -316,9 +319,9 @@ public abstract class CommandsManager { final String flags = cmd.flags(); final StringBuilder command2 = new StringBuilder(); - if (flags.length() > 0) { + if (!flags.isEmpty()) { String flagString = flags.replaceAll(".:", ""); - if (flagString.length() > 0) { + if (!flagString.isEmpty()) { command2.append("[-"); for (int i = 0; i < flagString.length(); ++i) { command2.append(flagString.charAt(i)); @@ -335,22 +338,20 @@ public abstract class CommandsManager { /** * Get the usage string for a nested command. * - * @param args - * @param level - * @param method - * @param player - * @return - * @throws CommandException + * @param args the arguments + * @param level the depth of the command + * @param method the parent method + * @param player the player + * @return the usage string + * @throws CommandException on some error */ - protected String getNestedUsage(String[] args, int level, - Method method, T player) throws CommandException { - + protected String getNestedUsage(String[] args, int level, Method method, T player) throws CommandException { StringBuilder command = new StringBuilder(); command.append("/"); for (int i = 0; i <= level; ++i) { - command.append(args[i] + " "); + command.append(args[i]).append(" "); } Map map = commands.get(method); @@ -371,7 +372,7 @@ public abstract class CommandsManager { } } - if (allowedCommands.size() > 0) { + if (!allowedCommands.isEmpty()) { command.append(StringUtil.joinString(allowedCommands, "|", 0)); } else { if (!found) { @@ -412,14 +413,12 @@ public abstract class CommandsManager { /** * Attempt to execute a command. * - * @param args - * @param player - * @param methodArgs - * @throws CommandException + * @param args the arguments + * @param player the player + * @param methodArgs the arguments for the method + * @throws CommandException thrown on command error */ - public void execute(String[] args, T player, - Object... methodArgs) throws CommandException { - + public void execute(String[] args, T player, Object... methodArgs) throws CommandException { Object[] newMethodArgs = new Object[methodArgs.length + 1]; System.arraycopy(methodArgs, 0, newMethodArgs, 1, methodArgs.length); executeMethod(null, args, player, newMethodArgs, 0); @@ -428,16 +427,14 @@ public abstract class CommandsManager { /** * Attempt to execute a command. * - * @param parent - * @param args - * @param player - * @param methodArgs - * @param level - * @throws CommandException + * @param parent the parent method + * @param args an array of arguments + * @param player the player + * @param methodArgs the array of method arguments + * @param level the depth of the command + * @throws CommandException thrown on a command error */ - public void executeMethod(Method parent, String[] args, - T player, Object[] methodArgs, int level) throws CommandException { - + public void executeMethod(Method parent, String[] args, T player, Object[] methodArgs, int level) throws CommandException { String cmdName = args[level]; Map map = commands.get(parent); @@ -527,8 +524,7 @@ 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) { @@ -547,9 +543,9 @@ public abstract class CommandsManager { /** * Returns whether a player has access to a command. * - * @param method - * @param player - * @return + * @param method the method + * @param player the player + * @return true if permission is granted */ protected boolean hasPermission(Method method, T player) { CommandPermissions perms = method.getAnnotation(CommandPermissions.class); @@ -569,11 +565,11 @@ public abstract class CommandsManager { /** * Returns whether a player permission.. * - * @param player - * @param perm - * @return + * @param player the player + * @param permission the permission + * @return true if permission is granted */ - public abstract boolean hasPermission(T player, String perm); + public abstract boolean hasPermission(T player, String permission); /** * Get the injector used to create new instances. This can be diff --git a/src/main/java/com/sk89q/minecraft/util/commands/Console.java b/src/main/java/com/sk89q/minecraft/util/commands/Console.java index 338bd974a..3ab90906a 100644 --- a/src/main/java/com/sk89q/minecraft/util/commands/Console.java +++ b/src/main/java/com/sk89q/minecraft/util/commands/Console.java @@ -24,9 +24,8 @@ import java.lang.annotation.RetentionPolicy; /** * This annotation indicates that a command can be used from the console. - * - * @author sk89q */ @Retention(RetentionPolicy.RUNTIME) public @interface Console { + } diff --git a/src/main/java/com/sk89q/minecraft/util/commands/Logging.java b/src/main/java/com/sk89q/minecraft/util/commands/Logging.java index 6399bffb5..617a0ee18 100644 --- a/src/main/java/com/sk89q/minecraft/util/commands/Logging.java +++ b/src/main/java/com/sk89q/minecraft/util/commands/Logging.java @@ -27,11 +27,10 @@ import java.lang.annotation.RetentionPolicy; /** * Indicates how the affected blocks should be hinted at in the log. - * - * @author sk89q */ @Retention(RetentionPolicy.RUNTIME) public @interface Logging { + public enum LogMode { /** * Player position @@ -63,4 +62,5 @@ public @interface Logging { * Log mode. Can be either POSITION, REGION, ORIENTATION_REGION, PLACEMENT or ALL. */ LogMode value(); + } diff --git a/src/main/java/com/sk89q/minecraft/util/commands/MissingNestedCommandException.java b/src/main/java/com/sk89q/minecraft/util/commands/MissingNestedCommandException.java index aecec1f26..2ca2c2d18 100644 --- a/src/main/java/com/sk89q/minecraft/util/commands/MissingNestedCommandException.java +++ b/src/main/java/com/sk89q/minecraft/util/commands/MissingNestedCommandException.java @@ -20,7 +20,6 @@ package com.sk89q.minecraft.util.commands; public class MissingNestedCommandException extends CommandUsageException { - private static final long serialVersionUID = -4382896182979285355L; public MissingNestedCommandException(String message, String usage) { super(message, usage); diff --git a/src/main/java/com/sk89q/minecraft/util/commands/NestedCommand.java b/src/main/java/com/sk89q/minecraft/util/commands/NestedCommand.java index 8d77f6ff3..bb4a77970 100644 --- a/src/main/java/com/sk89q/minecraft/util/commands/NestedCommand.java +++ b/src/main/java/com/sk89q/minecraft/util/commands/NestedCommand.java @@ -29,11 +29,10 @@ import java.lang.annotation.RetentionPolicy; * will never called. Additionally, not all fields of {@link Command} apply * when it is used in conjunction with this annotation, although both * are still required. - * - * @author sk89q */ @Retention(RetentionPolicy.RUNTIME) public @interface NestedCommand { + /** * A list of classes with the child commands. */ @@ -43,4 +42,5 @@ public @interface NestedCommand { * If set to true it will execute the body of the tagged method. */ boolean executeBody() default false; + } diff --git a/src/main/java/com/sk89q/minecraft/util/commands/SimpleInjector.java b/src/main/java/com/sk89q/minecraft/util/commands/SimpleInjector.java index 4c23c0297..ca3e82f92 100644 --- a/src/main/java/com/sk89q/minecraft/util/commands/SimpleInjector.java +++ b/src/main/java/com/sk89q/minecraft/util/commands/SimpleInjector.java @@ -21,10 +21,12 @@ package com.sk89q.minecraft.util.commands; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; +import java.util.logging.Level; import java.util.logging.Logger; public class SimpleInjector implements Injector { - private static final Logger logger = Logger.getLogger(SimpleInjector.class.getCanonicalName()); + + private static final Logger log = Logger.getLogger(SimpleInjector.class.getCanonicalName()); private Object[] args; private Class[] argClasses; @@ -36,26 +38,23 @@ public class SimpleInjector implements Injector { } } + @Override public Object getInstance(Class clazz) { try { Constructor ctr = clazz.getConstructor(argClasses); ctr.setAccessible(true); return ctr.newInstance(args); } catch (NoSuchMethodException e) { - logger.severe("Error initializing commands class " + clazz + ": "); - e.printStackTrace(); + log.log(Level.SEVERE, "Error initializing commands class " + clazz, e); return null; } catch (InvocationTargetException e) { - logger.severe("Error initializing commands class " + clazz + ": "); - e.printStackTrace(); + log.log(Level.SEVERE, "Error initializing commands class " + clazz, e); return null; } catch (InstantiationException e) { - logger.severe("Error initializing commands class " + clazz + ": "); - e.printStackTrace(); + log.log(Level.SEVERE, "Error initializing commands class " + clazz, e); return null; } catch (IllegalAccessException e) { - logger.severe("Error initializing commands class " + clazz + ": "); - e.printStackTrace(); + log.log(Level.SEVERE, "Error initializing commands class " + clazz, e); return null; } } diff --git a/src/main/java/com/sk89q/minecraft/util/commands/UnhandledCommandException.java b/src/main/java/com/sk89q/minecraft/util/commands/UnhandledCommandException.java index 822013d1e..918ca6fd6 100644 --- a/src/main/java/com/sk89q/minecraft/util/commands/UnhandledCommandException.java +++ b/src/main/java/com/sk89q/minecraft/util/commands/UnhandledCommandException.java @@ -20,6 +20,5 @@ package com.sk89q.minecraft.util.commands; public class UnhandledCommandException extends CommandException { - private static final long serialVersionUID = 3370887306593968091L; } diff --git a/src/main/java/com/sk89q/minecraft/util/commands/WrappedCommandException.java b/src/main/java/com/sk89q/minecraft/util/commands/WrappedCommandException.java index da293d69d..02dcd8e23 100644 --- a/src/main/java/com/sk89q/minecraft/util/commands/WrappedCommandException.java +++ b/src/main/java/com/sk89q/minecraft/util/commands/WrappedCommandException.java @@ -20,9 +20,9 @@ package com.sk89q.minecraft.util.commands; public class WrappedCommandException extends CommandException { - private static final long serialVersionUID = -4075721444847778918L; public WrappedCommandException(Throwable t) { super(t); } + } diff --git a/src/main/java/com/sk89q/util/ReflectionUtil.java b/src/main/java/com/sk89q/util/ReflectionUtil.java index c1c07c610..0b80816f7 100644 --- a/src/main/java/com/sk89q/util/ReflectionUtil.java +++ b/src/main/java/com/sk89q/util/ReflectionUtil.java @@ -21,9 +21,6 @@ package com.sk89q.util; import java.lang.reflect.Field; -/** - * @author zml2008 - */ public final class ReflectionUtil { private ReflectionUtil() { @@ -37,8 +34,8 @@ public final class ReflectionUtil { Field field = checkClass.getDeclaredField(name); field.setAccessible(true); return (T) field.get(from); - } catch (NoSuchFieldException e) { - } catch (IllegalAccessException e) { + } catch (NoSuchFieldException ignored) { + } catch (IllegalAccessException ignored) { } } while (checkClass.getSuperclass() != Object.class && ((checkClass = checkClass.getSuperclass()) != null)); return null; diff --git a/src/main/java/com/sk89q/util/StringUtil.java b/src/main/java/com/sk89q/util/StringUtil.java index a8ff8cfde..90bb2f5b6 100644 --- a/src/main/java/com/sk89q/util/StringUtil.java +++ b/src/main/java/com/sk89q/util/StringUtil.java @@ -24,8 +24,6 @@ import java.util.Map; /** * String utilities. - * - * @author sk89q */ public final class StringUtil { @@ -35,9 +33,9 @@ public final class StringUtil { /** * Trim a string if it is longer than a certain length. * - * @param str - * @param len - * @return + * @param str the stirng + * @param len the length to trim to + * @return a new string */ public static String trimLength(String str, int len) { if (str.length() > len) { @@ -50,13 +48,12 @@ public final class StringUtil { /** * Join an array of strings into a string. * - * @param str - * @param delimiter - * @param initialIndex - * @return + * @param str the string array + * @param delimiter the delimiter + * @param initialIndex the initial index to start form + * @return a new string */ - public static String joinString(String[] str, String delimiter, - int initialIndex) { + public static String joinString(String[] str, String delimiter, int initialIndex) { if (str.length == 0) { return ""; } @@ -70,11 +67,11 @@ public final class StringUtil { /** * Join an array of strings into a string. * - * @param str - * @param delimiter - * @param initialIndex - * @param quote - * @return + * @param str the string array + * @param delimiter the delimiter + * @param initialIndex the initial index to start form + * @param quote the character to put around each entry + * @return a new string */ public static String joinQuotedString(String[] str, String delimiter, int initialIndex, String quote) { @@ -94,9 +91,9 @@ public final class StringUtil { /** * Join an array of strings into a string. * - * @param str - * @param delimiter - * @return + * @param str the string array + * @param delimiter the delimiter + * @return a new string */ public static String joinString(String[] str, String delimiter) { return joinString(str, delimiter, 0); @@ -105,19 +102,18 @@ public final class StringUtil { /** * Join an array of strings into a string. * - * @param str - * @param delimiter - * @param initialIndex - * @return + * @param str an array of objects + * @param delimiter the delimiter + * @param initialIndex the initial index to start form + * @return a new string */ - public static String joinString(Object[] str, String delimiter, - int initialIndex) { + public static String joinString(Object[] str, String delimiter, int initialIndex) { if (str.length == 0) { return ""; } StringBuilder buffer = new StringBuilder(str[initialIndex].toString()); for (int i = initialIndex + 1; i < str.length; ++i) { - buffer.append(delimiter).append(str[i].toString()); + buffer.append(delimiter).append(str[i]); } return buffer.toString(); } @@ -125,13 +121,12 @@ public final class StringUtil { /** * Join an array of strings into a string. * - * @param str - * @param delimiter - * @param initialIndex - * @return + * @param str a list of integers + * @param delimiter the delimiter + * @param initialIndex the initial index to start form + * @return a new string */ - public static String joinString(int[] str, String delimiter, - int initialIndex) { + public static String joinString(int[] str, String delimiter, int initialIndex) { if (str.length == 0) { return ""; } @@ -144,15 +139,14 @@ public final class StringUtil { /** * Join an list of strings into a string. - * - * @param str - * @param delimiter - * @param initialIndex - * @return + * + * @param str a list of strings + * @param delimiter the delimiter + * @param initialIndex the initial index to start form + * @return a new string */ - public static String joinString(Collection str, String delimiter, - int initialIndex) { - if (str.size() == 0) { + public static String joinString(Collection str, String delimiter,int initialIndex) { + if (str.isEmpty()) { return ""; } StringBuilder buffer = new StringBuilder(); @@ -163,7 +157,7 @@ public final class StringUtil { buffer.append(delimiter); } - buffer.append(o.toString()); + buffer.append(o); } ++i; } @@ -202,7 +196,7 @@ public final class StringUtil { * @param s the first String, must not be null * @param t the second String, must not be null * @return result distance - * @throws IllegalArgumentException if either String input null + * @throws IllegalArgumentException if either String input {@code null} */ public static int getLevenshteinDistance(String s, String t) { if (s == null || t == null) { @@ -238,9 +232,9 @@ public final class StringUtil { return n; } - int p[] = new int[n + 1]; // 'previous' cost array, horizontally - int d[] = new int[n + 1]; // cost array, horizontally - int _d[]; // placeholder to assist in swapping p and d + int[] p = new int[n + 1]; // 'previous' cost array, horizontally + int[] d = new int[n + 1]; // cost array, horizontally + int[] _d; // placeholder to assist in swapping p and d // indexes into strings s and t int i; // iterates through s diff --git a/src/main/java/com/sk89q/util/yaml/YAMLNode.java b/src/main/java/com/sk89q/util/yaml/YAMLNode.java index 662498b7d..ff0bda3a4 100644 --- a/src/main/java/com/sk89q/util/yaml/YAMLNode.java +++ b/src/main/java/com/sk89q/util/yaml/YAMLNode.java @@ -23,6 +23,7 @@ import com.sk89q.worldedit.BlockVector2D; import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector2D; +import javax.annotation.Nullable; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; @@ -30,10 +31,9 @@ import java.util.Map; /** * Represents a configuration node. - * - * @author sk89q */ public class YAMLNode { + protected Map root; private boolean writeDefaults; @@ -106,8 +106,8 @@ public class YAMLNode { * Prepare a value for serialization, in case it's not a native type * (and we don't want to serialize objects as YAML objects). * - * @param value - * @return + * @param value the value to serialize + * @return the new object */ private Object prepareSerialization(Object value) { if (value instanceof Vector) { @@ -126,8 +126,8 @@ public class YAMLNode { * Set the property at a location. This will override existing * configuration data to have it conform to key/value mappings. * - * @param path - * @param value + * @param path the path + * @param value the new value */ @SuppressWarnings("unchecked") public void setProperty(String path, Object value) { @@ -163,10 +163,10 @@ public class YAMLNode { /** * Adds a new node to the given path. The returned object is a reference * to the new node. This method will replace an existing node at - * the same path. See setProperty. + * the same path. See {@code setProperty}. * - * @param path - * @return + * @param path the path + * @return a node for the path */ public YAMLNode addNode(String path) { Map map = new LinkedHashMap(); @@ -557,9 +557,7 @@ public class YAMLNode { * @param def default value or null for an empty list as default * @return list of integers */ - public List getVectorList( - String path, List def) { - + public List getVectorList(String path, List def) { List raw = getNodeList(path, null); List list = new ArrayList(); @@ -589,8 +587,7 @@ public class YAMLNode { * @param def default value or null for an empty list as default * @return list of integers */ - public List getVector2dList( - String path, List def) { + public List getVector2dList(String path, List def) { List raw = getNodeList(path, null); List list = new ArrayList(); @@ -620,8 +617,7 @@ public class YAMLNode { * @param def default value or null for an empty list as default * @return list of integers */ - public List getBlockVector2dList( - String path, List def) { + public List getBlockVector2dList(String path, List def) { List raw = getNodeList(path, null); List list = new ArrayList(); @@ -674,9 +670,10 @@ public class YAMLNode { * path does not lead to a node, null will be returned. A node has * key/value mappings. * - * @param path + * @param path the path * @return node or null */ + @Nullable @SuppressWarnings("unchecked") public YAMLNode getNode(String path) { Object raw = getProperty(path); @@ -719,9 +716,10 @@ public class YAMLNode { /** * Casts a value to an integer. May return null. * - * @param o - * @return + * @param o the object + * @return an integer or null */ + @Nullable private static Integer castInt(Object o) { if (o == null) { return null; @@ -734,10 +732,11 @@ public class YAMLNode { /** * Casts a value to a double. May return null. - * - * @param o - * @return + * + * @param o the object + * @return a double or null */ + @Nullable private static Double castDouble(Object o) { if (o == null) { return null; @@ -750,10 +749,11 @@ public class YAMLNode { /** * Casts a value to a boolean. May return null. - * - * @param o - * @return + * + * @param o the object + * @return a boolean or null */ + @Nullable private static Boolean castBoolean(Object o) { if (o == null) { return null; @@ -768,7 +768,7 @@ public class YAMLNode { * Remove the property at a location. This will override existing * configuration data to have it conform to key/value mappings. * - * @param path + * @param path a path */ @SuppressWarnings("unchecked") public void removeProperty(String path) { @@ -800,4 +800,5 @@ public class YAMLNode { public void setWriteDefaults(boolean writeDefaults) { this.writeDefaults = writeDefaults; } + } diff --git a/src/main/java/com/sk89q/util/yaml/YAMLProcessor.java b/src/main/java/com/sk89q/util/yaml/YAMLProcessor.java index eb1e01ec2..7e23fc422 100644 --- a/src/main/java/com/sk89q/util/yaml/YAMLProcessor.java +++ b/src/main/java/com/sk89q/util/yaml/YAMLProcessor.java @@ -32,6 +32,7 @@ import org.yaml.snakeyaml.representer.Representer; import java.io.*; import java.util.*; +import java.util.Map.Entry; /** * YAML configuration loader. To use this class, construct it with path to @@ -58,13 +59,11 @@ import java.util.*; * babies: true * *

Calling code could access sturmeh's baby eating state by using - * getBoolean("sturmeh.eats.babies", false). For lists, there are - * methods such as getStringList that will return a type safe list. - * - * - * @author sk89q + * {@code getBoolean("sturmeh.eats.babies", false)}. For lists, there are + * methods such as {@code getStringList} that will return a type safe list. */ public class YAMLProcessor extends YAMLNode { + public static final String LINE_BREAK = DumperOptions.LineBreak.getPlatformLineBreak().getString(); public static final char COMMENT_CHAR = '#'; protected final Yaml yaml; @@ -117,7 +116,7 @@ public class YAMLProcessor extends YAMLNode { if (stream != null) { stream.close(); } - } catch (IOException e) { + } catch (IOException ignored) { } } } @@ -156,7 +155,7 @@ public class YAMLProcessor extends YAMLNode { /** * Return the set header. * - * @return + * @return the header text */ public String getHeader() { return header; @@ -184,13 +183,11 @@ public class YAMLProcessor extends YAMLNode { writer.append(header); writer.append(LINE_BREAK); } - if (comments.size() == 0 || format != YAMLFormat.EXTENDED) { + if (comments.isEmpty() || format != YAMLFormat.EXTENDED) { yaml.dump(root, writer); } else { // Iterate over each root-level property and dump - for (Iterator> i = root.entrySet().iterator(); i.hasNext(); ) { - Map.Entry entry = i.next(); - + for (Entry entry : root.entrySet()) { // Output comment, if present String comment = comments.get(entry.getKey()); if (comment != null) { @@ -204,13 +201,13 @@ public class YAMLProcessor extends YAMLNode { } } return true; - } catch (IOException e) { + } catch (IOException ignored) { } finally { try { if (stream != null) { stream.close(); } - } catch (IOException e) {} + } catch (IOException ignored) {} } return false; @@ -241,7 +238,7 @@ public class YAMLProcessor extends YAMLNode { * Returns a root-level comment. * * @param key the property key - * @return the comment or null + * @return the comment or {@code null} */ public String getComment(String key) { return comments.get(key); @@ -259,7 +256,7 @@ public class YAMLProcessor extends YAMLNode { * Set a root-level comment. * * @param key the property key - * @param comment the comment. May be null, in which case the comment + * @param comment the comment. May be {@code null}, in which case the comment * is removed. */ public void setComment(String key, String... comment) { @@ -300,7 +297,8 @@ public class YAMLProcessor extends YAMLNode { /** * This method returns an empty ConfigurationNode for using as a * default in methods that select a node from a node list. - * @return + * + * @return a node */ public static YAMLNode getEmptyNode(boolean writeDefaults) { return new YAMLNode(new LinkedHashMap(), writeDefaults); @@ -321,12 +319,14 @@ public class YAMLProcessor extends YAMLNode { } private static class FancyRepresenter extends Representer { - public FancyRepresenter() { + private FancyRepresenter() { this.nullRepresenter = new Represent() { + @Override public Node representData(Object o) { return representScalar(Tag.NULL, ""); } }; } } + } diff --git a/src/main/java/com/sk89q/util/yaml/YAMLProcessorException.java b/src/main/java/com/sk89q/util/yaml/YAMLProcessorException.java index 6353c7243..74816c13a 100644 --- a/src/main/java/com/sk89q/util/yaml/YAMLProcessorException.java +++ b/src/main/java/com/sk89q/util/yaml/YAMLProcessorException.java @@ -21,11 +21,8 @@ package com.sk89q.util.yaml; /** * YAMLProcessor exception. - * - * @author sk89q */ public class YAMLProcessorException extends Exception { - private static final long serialVersionUID = -2442886939908724203L; public YAMLProcessorException() { super(); @@ -34,4 +31,5 @@ public class YAMLProcessorException extends Exception { public YAMLProcessorException(String msg) { super(msg); } + } diff --git a/src/main/java/com/sk89q/worldedit/CuboidClipboard.java b/src/main/java/com/sk89q/worldedit/CuboidClipboard.java index 237d8c010..bdb8bab39 100644 --- a/src/main/java/com/sk89q/worldedit/CuboidClipboard.java +++ b/src/main/java/com/sk89q/worldedit/CuboidClipboard.java @@ -174,7 +174,7 @@ public class CuboidClipboard { final int shiftX = sizeRotated.getX() < 0 ? -sizeRotated.getBlockX() - 1 : 0; final int shiftZ = sizeRotated.getZ() < 0 ? -sizeRotated.getBlockZ() - 1 : 0; - final BaseBlock newData[][][] = new BaseBlock + final BaseBlock[][][] newData = new BaseBlock [Math.abs(sizeRotated.getBlockX())] [Math.abs(sizeRotated.getBlockY())] [Math.abs(sizeRotated.getBlockZ())]; @@ -476,8 +476,9 @@ public class CuboidClipboard { * @param position the point, relative to the origin of the copy (0, 0, 0) and not to the actual copy origin * @return air, if this block was outside the (non-cuboid) selection while copying * @throws ArrayIndexOutOfBoundsException if the position is outside the bounds of the CuboidClipboard - * @deprecated Use {@link #getBlock(Vector)} instead + * @deprecated use {@link #getBlock(Vector)} instead */ + @Deprecated public BaseBlock getPoint(Vector position) throws ArrayIndexOutOfBoundsException { final BaseBlock block = getBlock(position); if (block == null) { diff --git a/src/main/java/com/sk89q/worldedit/EditSession.java b/src/main/java/com/sk89q/worldedit/EditSession.java index f537341f3..903c866cc 100644 --- a/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/src/main/java/com/sk89q/worldedit/EditSession.java @@ -80,6 +80,8 @@ import com.sk89q.worldedit.world.biome.BaseBiome; import javax.annotation.Nullable; import java.util.*; +import java.util.logging.Level; +import java.util.logging.Logger; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; @@ -96,6 +98,8 @@ import static com.sk89q.worldedit.regions.Regions.*; @SuppressWarnings("FieldCanBeLocal") public class EditSession implements Extent { + private static final Logger log = Logger.getLogger(EditSession.class.getCanonicalName()); + /** * Used by {@link #setBlock(Vector, BaseBlock, Stage)} to * determine which {@link Extent}s should be bypassed. @@ -317,8 +321,9 @@ public class EditSession implements Extent { /** * Set whether fast mode is enabled. - *

- * Fast mode may skip lighting checks or adjacent block notification. + * + *

Fast mode may skip lighting checks or adjacent block + * notification.

* * @param enabled true to enable */ @@ -330,13 +335,14 @@ public class EditSession implements Extent { /** * Return fast mode status. - *

- * Fast mode may skip lighting checks or adjacent block notification. + * + *

Fast mode may skip lighting checks or adjacent block + * notification.

* * @return true if enabled */ public boolean hasFastMode() { - return fastModeExtent != null ? fastModeExtent.isEnabled() : false; + return fastModeExtent != null && fastModeExtent.isEnabled(); } /** @@ -369,8 +375,8 @@ public class EditSession implements Extent { /** * Get the number of blocks changed, including repeated block changes. - *

- * This number may not be accurate. + * + *

This number may not be accurate.

* * @return the number of block changes */ @@ -1486,15 +1492,14 @@ public class EditSession implements Extent { /** * Makes a pyramid. * - * @param pos - * @param block - * @param size - * @param filled + * @param position a position + * @param block a block + * @param size size of pyramid + * @param filled true if filled * @return number of blocks changed * @throws MaxChangedBlocksException */ - public int makePyramid(Vector pos, Pattern block, int size, - boolean filled) throws MaxChangedBlocksException { + public int makePyramid(Vector position, Pattern block, int size, boolean filled) throws MaxChangedBlocksException { int affected = 0; int height = size; @@ -1506,16 +1511,16 @@ public class EditSession implements Extent { if ((filled && z <= size && x <= size) || z == size || x == size) { - if (setBlock(pos.add(x, y, z), block)) { + if (setBlock(position.add(x, y, z), block)) { ++affected; } - if (setBlock(pos.add(-x, y, z), block)) { + if (setBlock(position.add(-x, y, z), block)) { ++affected; } - if (setBlock(pos.add(x, y, -z), block)) { + if (setBlock(position.add(x, y, -z), block)) { ++affected; } - if (setBlock(pos.add(-x, y, -z), block)) { + if (setBlock(position.add(-x, y, -z), block)) { ++affected; } } @@ -1527,21 +1532,21 @@ public class EditSession implements Extent { } /** - * Thaw. + * Thaw blocks in a radius. * - * @param pos - * @param radius + * @param position the position + * @param radius the radius * @return number of blocks affected * @throws MaxChangedBlocksException */ - public int thaw(Vector pos, double radius) + public int thaw(Vector position, double radius) throws MaxChangedBlocksException { int affected = 0; double radiusSq = radius * radius; - int ox = pos.getBlockX(); - int oy = pos.getBlockY(); - int oz = pos.getBlockZ(); + int ox = position.getBlockX(); + int oy = position.getBlockY(); + int oz = position.getBlockZ(); BaseBlock air = new BaseBlock(0); BaseBlock water = new BaseBlock(BlockID.STATIONARY_WATER); @@ -1549,7 +1554,7 @@ public class EditSession implements Extent { 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 ((new Vector(x, oy, z)).distanceSq(pos) > radiusSq) { + if ((new Vector(x, oy, z)).distanceSq(position) > radiusSq) { continue; } @@ -1586,21 +1591,20 @@ public class EditSession implements Extent { } /** - * Make snow. + * Make snow in a radius. * - * @param pos - * @param radius + * @param position a position + * @param radius a radius * @return number of blocks affected * @throws MaxChangedBlocksException */ - public int simulateSnow(Vector pos, double radius) - throws MaxChangedBlocksException { + public int simulateSnow(Vector position, double radius) throws MaxChangedBlocksException { int affected = 0; double radiusSq = radius * radius; - int ox = pos.getBlockX(); - int oy = pos.getBlockY(); - int oz = pos.getBlockZ(); + int ox = position.getBlockX(); + int oy = position.getBlockY(); + int oz = position.getBlockZ(); BaseBlock ice = new BaseBlock(BlockID.ICE); BaseBlock snow = new BaseBlock(BlockID.SNOW); @@ -1608,7 +1612,7 @@ public class EditSession implements Extent { 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 ((new Vector(x, oy, z)).distanceSq(pos) > radiusSq) { + if ((new Vector(x, oy, z)).distanceSq(position) > radiusSq) { continue; } @@ -1651,44 +1655,43 @@ public class EditSession implements Extent { } /** - * Green. + * Make dirt green. * - * @param pos - * @param radius + * @param position a position + * @param radius a radius * @return number of blocks affected * @throws MaxChangedBlocksException * @deprecated Use {@link #green(Vector, double, boolean)}. */ @Deprecated - public int green(Vector pos, double radius) - throws MaxChangedBlocksException { - return green(pos, radius, true); + public int green(Vector position, double radius) throws MaxChangedBlocksException { + return green(position, radius, true); } /** - * Green. + * Make dirt green. * - * @param pos - * @param radius + * @param position a position + * @param radius a radius * @param onlyNormalDirt only affect normal dirt (data value 0) * @return number of blocks affected * @throws MaxChangedBlocksException */ - public int green(Vector pos, double radius, boolean onlyNormalDirt) + public int green(Vector position, double radius, boolean onlyNormalDirt) throws MaxChangedBlocksException { int affected = 0; final double radiusSq = radius * radius; - final int ox = pos.getBlockX(); - final int oy = pos.getBlockY(); - final int oz = pos.getBlockZ(); + final int ox = position.getBlockX(); + final int oy = position.getBlockY(); + final int oz = position.getBlockZ(); final BaseBlock grass = new BaseBlock(BlockID.GRASS); final 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 ((new Vector(x, oy, z)).distanceSq(pos) > radiusSq) { + if ((new Vector(x, oy, z)).distanceSq(position) > radiusSq) { continue; } @@ -1758,23 +1761,22 @@ public class EditSession implements Extent { /** * Makes a forest. * - * @param basePos - * @param size - * @param density - * @param treeGenerator + * @param basePosition a position + * @param size a size + * @param density between 0 and 1, inclusive + * @param treeGenerator the tree genreator * @return number of trees created * @throws MaxChangedBlocksException */ - public int makeForest(Vector basePos, int size, double density, - TreeGenerator treeGenerator) throws MaxChangedBlocksException { + public int makeForest(Vector basePosition, int size, double density, TreeGenerator treeGenerator) throws MaxChangedBlocksException { int affected = 0; - for (int x = basePos.getBlockX() - size; x <= basePos.getBlockX() + for (int x = basePosition.getBlockX() - size; x <= basePosition.getBlockX() + size; ++x) { - for (int z = basePos.getBlockZ() - size; z <= basePos.getBlockZ() + for (int z = basePosition.getBlockZ() - size; z <= basePosition.getBlockZ() + size; ++z) { // Don't want to be in the ground - if (!getBlock(new Vector(x, basePos.getBlockY(), z)).isAir()) { + if (!getBlock(new Vector(x, basePosition.getBlockY(), z)).isAir()) { continue; } // The gods don't want a tree here @@ -1782,7 +1784,7 @@ public class EditSession implements Extent { continue; } // def 0.05 - for (int y = basePos.getBlockY(); y >= basePos.getBlockY() - 10; --y) { + for (int y = basePosition.getBlockY(); y >= basePosition.getBlockY() - 10; --y) { // Check if we hit the ground int t = getBlock(new Vector(x, y, z)).getType(); if (t == BlockID.GRASS || t == BlockID.DIRT) { @@ -1804,8 +1806,8 @@ public class EditSession implements Extent { /** * Get the block distribution inside a region. * - * @param region - * @return + * @param region a region + * @return the results */ public List> getBlockDistribution(Region region) { List> distribution = new ArrayList>(); @@ -1862,8 +1864,8 @@ public class EditSession implements Extent { /** * Get the block distribution (with data values) inside a region. * - * @param region - * @return + * @param region a region + * @return the results */ // TODO reduce code duplication - probably during ops-redux public List> getBlockDistributionWithData(Region region) { @@ -1942,7 +1944,7 @@ public class EditSession implements Extent { return new BaseBlock((int) typeVariable.getValue(), (int) dataVariable.getValue()); } catch (Exception e) { - e.printStackTrace(); + log.log(Level.WARNING, "Failed to create shape", e); return null; } } @@ -2161,12 +2163,12 @@ public class EditSession implements Extent { throws MaxChangedBlocksException { Set vset = new HashSet(); - List nodes = new ArrayList(nodevectors.size()); + List nodes = new ArrayList(nodevectors.size()); Interpolation interpol = new KochanekBartelsInterpolation(); - for (int loop = 0; loop < nodevectors.size(); loop++) { - Node n = new Node(nodevectors.get(loop)); + for (Vector nodevector : nodevectors) { + Node n = new Node(nodevector); n.setTension(tension); n.setBias(bias); n.setContinuity(continuity); @@ -2285,7 +2287,7 @@ public class EditSession implements Extent { // TODO: Allow biome setting via a script variable (needs BiomeType<->int mapping) return defaultBiomeType; } catch (Exception e) { - e.printStackTrace(); + log.log(Level.WARNING, "Failed to create shape", e); return null; } } @@ -2303,11 +2305,11 @@ public class EditSession implements Extent { PlayerDirection.DOWN.vector(), }; - private static final double lengthSq(double x, double y, double z) { + private static double lengthSq(double x, double y, double z) { return (x * x) + (y * y) + (z * z); } - private static final double lengthSq(double x, double z) { + private static double lengthSq(double x, double z) { return (x * x) + (z * z); } diff --git a/src/main/java/com/sk89q/worldedit/Location.java b/src/main/java/com/sk89q/worldedit/Location.java index 5097fa414..6674af51d 100644 --- a/src/main/java/com/sk89q/worldedit/Location.java +++ b/src/main/java/com/sk89q/worldedit/Location.java @@ -107,7 +107,7 @@ public class Location { @Override public String toString() { - return "World: " + world.getName() + ", Coordinates: " + position.toString() + return "World: " + world.getName() + ", Coordinates: " + position + ", Yaw: " + yaw + ", Pitch: " + pitch; } diff --git a/src/main/java/com/sk89q/worldedit/PlayerDirection.java b/src/main/java/com/sk89q/worldedit/PlayerDirection.java index d7fbdb422..92bed02f2 100644 --- a/src/main/java/com/sk89q/worldedit/PlayerDirection.java +++ b/src/main/java/com/sk89q/worldedit/PlayerDirection.java @@ -39,9 +39,9 @@ public enum PlayerDirection { UP(new Vector(0, 1, 0), new Vector(0, 0, 1), true), DOWN(new Vector(0, -1, 0), new Vector(0, 0, 1), true); - private Vector dir; - private Vector leftDir; - private boolean isOrthogonal; + private final Vector dir; + private final Vector leftDir; + private final boolean isOrthogonal; PlayerDirection(Vector vec, Vector leftDir, boolean isOrthogonal) { this.dir = vec; diff --git a/src/main/java/com/sk89q/worldedit/VectorFace.java b/src/main/java/com/sk89q/worldedit/VectorFace.java index e0a3ba3a6..4b900ec6a 100644 --- a/src/main/java/com/sk89q/worldedit/VectorFace.java +++ b/src/main/java/com/sk89q/worldedit/VectorFace.java @@ -49,9 +49,9 @@ public enum VectorFace { BELOW_EAST(DOWN, EAST), SELF(0, 0, 0); - private int modX; - private int modY; - private int modZ; + private final int modX; + private final int modY; + private final int modZ; private VectorFace(final int modX, final int modY, final int modZ) { this.modX = modX; diff --git a/src/main/java/com/sk89q/worldedit/WorldEdit.java b/src/main/java/com/sk89q/worldedit/WorldEdit.java index 30c077abd..69c83a168 100644 --- a/src/main/java/com/sk89q/worldedit/WorldEdit.java +++ b/src/main/java/com/sk89q/worldedit/WorldEdit.java @@ -62,6 +62,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; +import java.util.logging.Level; import java.util.logging.Logger; import static com.google.common.base.Preconditions.checkNotNull; @@ -761,7 +762,7 @@ public class WorldEdit { } catch (ScriptException e) { player.printError("Failed to execute:"); player.printRaw(e.getMessage()); - e.printStackTrace(); + logger.log(Level.WARNING, "Failed to execute script", e); } catch (NumberFormatException e) { throw e; } catch (WorldEditException e) { @@ -769,7 +770,7 @@ public class WorldEdit { } catch (Throwable e) { player.printError("Failed to execute (see console):"); player.printRaw(e.getClass().getCanonicalName()); - e.printStackTrace(); + logger.log(Level.WARNING, "Failed to execute script", e); } finally { for (EditSession editSession : scriptContext.getEditSessions()) { editSession.flushQueue(); diff --git a/src/main/java/com/sk89q/worldedit/WorldVector.java b/src/main/java/com/sk89q/worldedit/WorldVector.java index d03137a69..c45b53ef8 100644 --- a/src/main/java/com/sk89q/worldedit/WorldVector.java +++ b/src/main/java/com/sk89q/worldedit/WorldVector.java @@ -25,20 +25,19 @@ import com.sk89q.worldedit.world.World; /** * @deprecated Use {@link com.sk89q.worldedit.util.Location} wherever possible */ +@SuppressWarnings("deprecation") @Deprecated public class WorldVector extends Vector { - /** - * Represents the world. - */ + private LocalWorld world; /** * Construct the Vector object. * - * @param world - * @param x - * @param y - * @param z + * @param world a world + * @param x the X coordinate + * @param y the Y coordinate + * @param z the Z coordinate */ public WorldVector(LocalWorld world, double x, double y, double z) { super(x, y, z); @@ -48,10 +47,10 @@ public class WorldVector extends Vector { /** * Construct the Vector object. * - * @param world - * @param x - * @param y - * @param z + * @param world a world + * @param x the X coordinate + * @param y the Y coordinate + * @param z the Z coordinate */ public WorldVector(LocalWorld world, int x, int y, int z) { super(x, y, z); @@ -61,10 +60,10 @@ public class WorldVector extends Vector { /** * Construct the Vector object. * - * @param world - * @param x - * @param y - * @param z + * @param world a world + * @param x the X coordinate + * @param y the Y coordinate + * @param z the Z coordinate */ public WorldVector(LocalWorld world, float x, float y, float z) { super(x, y, z); @@ -74,18 +73,18 @@ public class WorldVector extends Vector { /** * Construct the Vector object. * - * @param world - * @param pt + * @param world a world + * @param other the position to copy */ - public WorldVector(LocalWorld world, Vector pt) { - super(pt); + public WorldVector(LocalWorld world, Vector other) { + super(other); this.world = world; } /** * Construct the Vector object. * - * @param world + * @param world a world */ public WorldVector(LocalWorld world) { super(); @@ -104,7 +103,7 @@ public class WorldVector extends Vector { /** * Get the world. * - * @return + * @return the world */ public LocalWorld getWorld() { return world; @@ -112,11 +111,11 @@ public class WorldVector extends Vector { /** * Get a block point from a point. - * - * @param world - * @param x - * @param y - * @param z + * + * @param world a world + * @param x the X coordinate + * @param y the Y coordinate + * @param z the Z coordinate * @return point */ public static WorldVector toBlockPoint(LocalWorld world, double x, double y, @@ -136,7 +135,7 @@ public class WorldVector extends Vector { } /** - * Return this object as a new preferred Location + * Return this object as a new preferred {@code Location} * object. * * @return a new location object diff --git a/src/main/java/com/sk89q/worldedit/WorldVector2D.java b/src/main/java/com/sk89q/worldedit/WorldVector2D.java index 72cc761f6..35a261b2a 100644 --- a/src/main/java/com/sk89q/worldedit/WorldVector2D.java +++ b/src/main/java/com/sk89q/worldedit/WorldVector2D.java @@ -56,12 +56,6 @@ public class WorldVector2D extends Vector2D { return world; } - /** - * Checks if another object is equivalent. - * - * @param obj - * @return whether the other object is equivalent - */ @Override public boolean equals(Object obj) { if (!(obj instanceof WorldVector2D)) { diff --git a/src/main/java/com/sk89q/worldedit/WorldVectorFace.java b/src/main/java/com/sk89q/worldedit/WorldVectorFace.java index db21a075d..306b2ea34 100644 --- a/src/main/java/com/sk89q/worldedit/WorldVectorFace.java +++ b/src/main/java/com/sk89q/worldedit/WorldVectorFace.java @@ -22,71 +22,32 @@ package com.sk89q.worldedit; /** * @deprecated Use {@link com.sk89q.worldedit.util.Location} wherever possible */ +@SuppressWarnings("deprecation") @Deprecated public class WorldVectorFace extends WorldVector { private VectorFace face; - /** - * Construct the Vector object. - * - * @param world - * @param x - * @param y - * @param z - * @param face - */ public WorldVectorFace(LocalWorld world, double x, double y, double z, VectorFace face) { super(world, x, y, z); this.face = face; } - /** - * Construct the Vector object. - * - * @param world - * @param x - * @param y - * @param z - * @param face - */ public WorldVectorFace(LocalWorld world, int x, int y, int z, VectorFace face) { super(world, x, y, z); this.face = face; } - /** - * Construct the Vector object. - * - * @param world - * @param x - * @param y - * @param z - * @param face - */ public WorldVectorFace(LocalWorld world, float x, float y, float z, VectorFace face) { super(world, x, y, z); this.face = face; } - /** - * Construct the Vector object. - * - * @param world - * @param pt - * @param face - */ public WorldVectorFace(LocalWorld world, Vector pt, VectorFace face) { super(world, pt); this.face = face; } - /** - * Construct the Vector object. - * - * @param world - * @param face - */ public WorldVectorFace(LocalWorld world, VectorFace face) { super(world); this.face = face; @@ -95,7 +56,7 @@ public class WorldVectorFace extends WorldVector { /** * Get the face. * - * @return + * @return the face */ public VectorFace getFace() { return face; @@ -104,7 +65,7 @@ public class WorldVectorFace extends WorldVector { /** * Get the WorldVector adjacent to this WorldVectorFace. * - * @return + * @return the face vector */ public WorldVector getFaceVector() { return new WorldVector(getWorld(), @@ -120,7 +81,7 @@ public class WorldVectorFace extends WorldVector { * @param world the world in which the resulting vector should lie * @param vector the original vector * @param face the direction in which the face should lie - * @return + * @return a face */ public static WorldVectorFace getWorldVectorFace(LocalWorld world, Vector vector, Vector face) { if (vector == null || face == null) return null; diff --git a/src/main/java/com/sk89q/worldedit/blocks/BlockData.java b/src/main/java/com/sk89q/worldedit/blocks/BlockData.java index 8ff768d2d..f7f460892 100644 --- a/src/main/java/com/sk89q/worldedit/blocks/BlockData.java +++ b/src/main/java/com/sk89q/worldedit/blocks/BlockData.java @@ -971,8 +971,9 @@ public final class BlockData { /** * Returns the data value for the next color of cloth in the rainbow. This * should not be used if you want to just increment the data value. - * @param data - * @return + * + * @param data the data value + * @return the next data value */ public static int nextClothColor(int data) { switch (data) { diff --git a/src/main/java/com/sk89q/worldedit/blocks/BlockType.java b/src/main/java/com/sk89q/worldedit/blocks/BlockType.java index 0b4e662f8..4e00f8eac 100644 --- a/src/main/java/com/sk89q/worldedit/blocks/BlockType.java +++ b/src/main/java/com/sk89q/worldedit/blocks/BlockType.java @@ -34,10 +34,9 @@ import static com.google.common.base.Preconditions.checkNotNull; /** * Block types. - * - * @author sk89q */ public enum BlockType { + AIR(BlockID.AIR, "Air", "air"), STONE(BlockID.STONE, "Stone", "stone", "rock"), GRASS(BlockID.GRASS, "Grass", "grass"), @@ -1829,4 +1828,5 @@ public enum BlockType { dataAttachments.put(typeDataKey(type, east), PlayerDirection.EAST); dataAttachments.put(typeDataKey(type, south), PlayerDirection.SOUTH); } + } diff --git a/src/main/java/com/sk89q/worldedit/blocks/metadata/MobType.java b/src/main/java/com/sk89q/worldedit/blocks/metadata/MobType.java index b498c9d7d..fbd28b32a 100644 --- a/src/main/java/com/sk89q/worldedit/blocks/metadata/MobType.java +++ b/src/main/java/com/sk89q/worldedit/blocks/metadata/MobType.java @@ -53,7 +53,7 @@ public enum MobType { WOLF("Wolf"), ZOMBIE("Zombie"); - private String name; + private final String name; private MobType(String name) { this.name = name; @@ -62,4 +62,5 @@ public enum MobType { public String getName() { return name; } + } diff --git a/src/main/java/com/sk89q/worldedit/command/GeneralCommands.java b/src/main/java/com/sk89q/worldedit/command/GeneralCommands.java index 19cef7ff9..4d8aa6f8f 100644 --- a/src/main/java/com/sk89q/worldedit/command/GeneralCommands.java +++ b/src/main/java/com/sk89q/worldedit/command/GeneralCommands.java @@ -173,7 +173,7 @@ public class GeneralCommands { } return; - } catch (NumberFormatException e) { + } catch (NumberFormatException ignored) { } if (query.length() <= 2) { diff --git a/src/main/java/com/sk89q/worldedit/command/InsufficientArgumentsException.java b/src/main/java/com/sk89q/worldedit/command/InsufficientArgumentsException.java index 64649118a..796b8e645 100644 --- a/src/main/java/com/sk89q/worldedit/command/InsufficientArgumentsException.java +++ b/src/main/java/com/sk89q/worldedit/command/InsufficientArgumentsException.java @@ -21,14 +21,10 @@ package com.sk89q.worldedit.command; import com.sk89q.worldedit.WorldEditException; -/** - * - * @author sk89q - */ public class InsufficientArgumentsException extends WorldEditException { - private static final long serialVersionUID = 995264804658899764L; public InsufficientArgumentsException(String error) { super(error); } + } diff --git a/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java b/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java index e4b5c4662..41799e8a0 100644 --- a/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java +++ b/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java @@ -65,10 +65,9 @@ import static com.sk89q.minecraft.util.commands.Logging.LogMode.REGION; /** * Selection commands. - * - * @author sk89q */ public class SelectionCommands { + private final WorldEdit we; public SelectionCommands(WorldEdit we) { diff --git a/src/main/java/com/sk89q/worldedit/command/SnapshotCommands.java b/src/main/java/com/sk89q/worldedit/command/SnapshotCommands.java index 35641f38f..8c7676eee 100644 --- a/src/main/java/com/sk89q/worldedit/command/SnapshotCommands.java +++ b/src/main/java/com/sk89q/worldedit/command/SnapshotCommands.java @@ -40,10 +40,9 @@ import java.util.logging.Logger; /** * Snapshot commands. - * - * @author sk89q */ public class SnapshotCommands { + private static final Logger logger = Logger.getLogger("Minecraft.WorldEdit"); private static final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z"); @@ -73,7 +72,7 @@ public class SnapshotCommands { try { List snapshots = config.snapshotRepo.getSnapshots(true, player.getWorld().getName()); - if (snapshots.size() > 0) { + if (!snapshots.isEmpty()) { int num = args.argsLength() > 0 ? Math.min(40, Math.max(5, args.getInteger(0))) : 5; @@ -269,4 +268,5 @@ public class SnapshotCommands { } } } + } diff --git a/src/main/java/com/sk89q/worldedit/command/SnapshotUtilCommands.java b/src/main/java/com/sk89q/worldedit/command/SnapshotUtilCommands.java index d6dd4ba89..9eeacf199 100644 --- a/src/main/java/com/sk89q/worldedit/command/SnapshotUtilCommands.java +++ b/src/main/java/com/sk89q/worldedit/command/SnapshotUtilCommands.java @@ -147,7 +147,7 @@ public class SnapshotUtilCommands { } finally { try { chunkStore.close(); - } catch (IOException e) { + } catch (IOException ignored) { } } } diff --git a/src/main/java/com/sk89q/worldedit/command/ToolCommands.java b/src/main/java/com/sk89q/worldedit/command/ToolCommands.java index 60a569ff8..59f099c58 100644 --- a/src/main/java/com/sk89q/worldedit/command/ToolCommands.java +++ b/src/main/java/com/sk89q/worldedit/command/ToolCommands.java @@ -22,7 +22,6 @@ package com.sk89q.worldedit.command; import com.sk89q.minecraft.util.commands.Command; import com.sk89q.minecraft.util.commands.CommandContext; import com.sk89q.minecraft.util.commands.CommandPermissions; -import com.sk89q.minecraft.util.commands.NestedCommand; import com.sk89q.worldedit.*; import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.blocks.ItemType; diff --git a/src/main/java/com/sk89q/worldedit/command/ToolUtilCommands.java b/src/main/java/com/sk89q/worldedit/command/ToolUtilCommands.java index 5ba04745f..f4f92675c 100644 --- a/src/main/java/com/sk89q/worldedit/command/ToolUtilCommands.java +++ b/src/main/java/com/sk89q/worldedit/command/ToolUtilCommands.java @@ -41,7 +41,7 @@ public class ToolUtilCommands { @Command( aliases = { "/", "," }, usage = "[on|off]", - desc = "Toggle the super pickaxe pickaxe function", + desc = "Toggle the super pickaxe function", min = 0, max = 1 ) diff --git a/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java b/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java index 5dd5cce8d..3ed223f53 100644 --- a/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java +++ b/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java @@ -72,10 +72,9 @@ import static com.sk89q.minecraft.util.commands.Logging.LogMode.PLACEMENT; /** * Utility commands. - * - * @author sk89q */ public class UtilityCommands { + private final WorldEdit we; public UtilityCommands(WorldEdit we) { @@ -672,4 +671,5 @@ public class UtilityCommands { actor.printRaw(ColorCodeBuilder.asColorCodes(box)); } } + } diff --git a/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java b/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java index 464999b19..8bc61b488 100644 --- a/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java +++ b/src/main/java/com/sk89q/worldedit/command/tool/BrushTool.java @@ -34,6 +34,8 @@ import com.sk89q.worldedit.function.pattern.BlockPattern; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.session.request.Request; +import static com.google.common.base.Preconditions.checkNotNull; + /** * Builds a shape at the place being looked at. */ @@ -50,9 +52,10 @@ public class BrushTool implements TraceTool { /** * Construct the tool. * - * @param permission + * @param permission the permission to check before use is allowed */ public BrushTool(String permission) { + checkNotNull(permission); this.permission = permission; } @@ -82,18 +85,18 @@ public class BrushTool implements TraceTool { /** * Set the brush. * - * @param brush - * @param perm + * @param brush tbe brush + * @param permission the permission */ - public void setBrush(Brush brush, String perm) { + public void setBrush(Brush brush, String permission) { this.brush = brush; - this.permission = perm; + this.permission = permission; } /** * Get the current brush. * - * @return + * @return the current brush */ public Brush getBrush() { return brush; @@ -102,7 +105,7 @@ public class BrushTool implements TraceTool { /** * Set the material. * - * @param material + * @param material the material */ public void setFill(Pattern material) { this.material = material; @@ -111,7 +114,7 @@ public class BrushTool implements TraceTool { /** * Get the material. * - * @return + * @return the material */ public Pattern getMaterial() { return material; @@ -120,7 +123,7 @@ public class BrushTool implements TraceTool { /** * Get the set brush size. * - * @return + * @return a radius */ public double getSize() { return size; @@ -129,7 +132,7 @@ public class BrushTool implements TraceTool { /** * Set the set brush size. * - * @param radius + * @param radius a radius */ public void setSize(double radius) { this.size = radius; @@ -138,7 +141,7 @@ public class BrushTool implements TraceTool { /** * Get the set brush range. * - * @return + * @return the range of the brush in blocks */ public int getRange() { return (range < 0) ? MAX_RANGE : Math.min(range, MAX_RANGE); @@ -147,7 +150,7 @@ public class BrushTool implements TraceTool { /** * Set the set brush range. * - * @param range + * @param range the range of the brush in blocks */ public void setRange(int range) { this.range = range; diff --git a/src/main/java/com/sk89q/worldedit/command/tool/InvalidToolBindException.java b/src/main/java/com/sk89q/worldedit/command/tool/InvalidToolBindException.java index d86b427ce..5f192d320 100644 --- a/src/main/java/com/sk89q/worldedit/command/tool/InvalidToolBindException.java +++ b/src/main/java/com/sk89q/worldedit/command/tool/InvalidToolBindException.java @@ -22,7 +22,6 @@ package com.sk89q.worldedit.command.tool; import com.sk89q.worldedit.WorldEditException; public class InvalidToolBindException extends WorldEditException { - private static final long serialVersionUID = -1865311004052447699L; private int itemId; @@ -34,4 +33,5 @@ public class InvalidToolBindException extends WorldEditException { public int getItemId() { return itemId; } + } diff --git a/src/main/java/com/sk89q/worldedit/command/tool/Tool.java b/src/main/java/com/sk89q/worldedit/command/tool/Tool.java index f1001053c..85b8460fd 100644 --- a/src/main/java/com/sk89q/worldedit/command/tool/Tool.java +++ b/src/main/java/com/sk89q/worldedit/command/tool/Tool.java @@ -23,7 +23,7 @@ import com.sk89q.worldedit.extension.platform.Actor; /** * Represents a tool. This interface alone defines nothing. A tool also - * has to implement BlockTool or TraceTool. + * has to implement {@code BlockTool} or {@code TraceTool}. */ public interface Tool { diff --git a/src/main/java/com/sk89q/worldedit/command/tool/brush/Brush.java b/src/main/java/com/sk89q/worldedit/command/tool/brush/Brush.java index aba66e9fc..71e6ea608 100644 --- a/src/main/java/com/sk89q/worldedit/command/tool/brush/Brush.java +++ b/src/main/java/com/sk89q/worldedit/command/tool/brush/Brush.java @@ -25,19 +25,19 @@ import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.function.pattern.Pattern; /** - * Represents a brush. - * - * @author sk89q + * A brush is a long-range build tool. */ public interface Brush { + /** * Build the object. * - * @param editSession - * @param pos - * @param mat - * @param size + * @param editSession the {@code EditSession} + * @param position the position + * @param pattern the pattern + * @param size the size of the brush * @throws MaxChangedBlocksException */ - public void build(EditSession editSession, Vector pos, Pattern mat, double size) throws MaxChangedBlocksException; + public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException; + } diff --git a/src/main/java/com/sk89q/worldedit/command/tool/brush/ButcherBrush.java b/src/main/java/com/sk89q/worldedit/command/tool/brush/ButcherBrush.java index 637be6d2f..b949d6b0e 100644 --- a/src/main/java/com/sk89q/worldedit/command/tool/brush/ButcherBrush.java +++ b/src/main/java/com/sk89q/worldedit/command/tool/brush/ButcherBrush.java @@ -40,8 +40,8 @@ public class ButcherBrush implements Brush { } @Override - public void build(EditSession editSession, Vector pos, Pattern mat, double size) throws MaxChangedBlocksException { - CylinderRegion region = CylinderRegion.createRadius(editSession, pos, size); + public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException { + CylinderRegion region = CylinderRegion.createRadius(editSession, position, size); List entities = editSession.getEntities(region); Operations.completeLegacy(new EntityVisitor(entities.iterator(), flags.createFunction(editSession.getWorld().getWorldData().getEntityRegistry()))); } diff --git a/src/main/java/com/sk89q/worldedit/command/tool/brush/ClipboardBrush.java b/src/main/java/com/sk89q/worldedit/command/tool/brush/ClipboardBrush.java index 7f772239d..4417d1a35 100644 --- a/src/main/java/com/sk89q/worldedit/command/tool/brush/ClipboardBrush.java +++ b/src/main/java/com/sk89q/worldedit/command/tool/brush/ClipboardBrush.java @@ -42,14 +42,14 @@ public class ClipboardBrush implements Brush { } @Override - public void build(EditSession editSession, Vector pos, Pattern mat, double size) throws MaxChangedBlocksException { + public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException { Clipboard clipboard = holder.getClipboard(); Region region = clipboard.getRegion(); Vector centerOffset = region.getCenter().subtract(clipboard.getOrigin()); Operation operation = holder .createPaste(editSession, editSession.getWorld().getWorldData()) - .to(usingOrigin ? pos : pos.subtract(centerOffset)) + .to(usingOrigin ? position : position.subtract(centerOffset)) .ignoreAirBlocks(ignoreAirBlocks) .build(); diff --git a/src/main/java/com/sk89q/worldedit/command/tool/brush/CylinderBrush.java b/src/main/java/com/sk89q/worldedit/command/tool/brush/CylinderBrush.java index bed1416a7..31b8c9ab7 100644 --- a/src/main/java/com/sk89q/worldedit/command/tool/brush/CylinderBrush.java +++ b/src/main/java/com/sk89q/worldedit/command/tool/brush/CylinderBrush.java @@ -33,8 +33,9 @@ public class CylinderBrush implements Brush { this.height = height; } - public void build(EditSession editSession, Vector pos, Pattern mat, double size) throws MaxChangedBlocksException { - editSession.makeCylinder(pos, Patterns.wrap(mat), size, size, height, true); + @Override + public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException { + editSession.makeCylinder(position, Patterns.wrap(pattern), size, size, height, true); } } diff --git a/src/main/java/com/sk89q/worldedit/command/tool/brush/GravityBrush.java b/src/main/java/com/sk89q/worldedit/command/tool/brush/GravityBrush.java index 7e90e57bc..8331b7620 100644 --- a/src/main/java/com/sk89q/worldedit/command/tool/brush/GravityBrush.java +++ b/src/main/java/com/sk89q/worldedit/command/tool/brush/GravityBrush.java @@ -37,14 +37,14 @@ public class GravityBrush implements Brush { } @Override - public void build(EditSession editSession, Vector pos, Pattern mat, double size) throws MaxChangedBlocksException { + public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException { final BaseBlock air = new BaseBlock(BlockID.AIR, 0); - final double startY = fullHeight ? editSession.getWorld().getMaxY() : pos.getBlockY() + size; - for (double x = pos.getBlockX() + size; x > pos.getBlockX() - size; --x) { - for (double z = pos.getBlockZ() + size; z > pos.getBlockZ() - size; --z) { + final double startY = fullHeight ? editSession.getWorld().getMaxY() : position.getBlockY() + size; + for (double x = position.getBlockX() + size; x > position.getBlockX() - size; --x) { + for (double z = position.getBlockZ() + size; z > position.getBlockZ() - size; --z) { double y = startY; final List blockTypes = new ArrayList(); - for (; y > pos.getBlockY() - size; --y) { + for (; y > position.getBlockY() - size; --y) { final Vector pt = new Vector(x, y, z); final BaseBlock block = editSession.getBlock(pt); if (!block.isAir()) { diff --git a/src/main/java/com/sk89q/worldedit/command/tool/brush/HollowCylinderBrush.java b/src/main/java/com/sk89q/worldedit/command/tool/brush/HollowCylinderBrush.java index 6d68cee21..236e875c6 100644 --- a/src/main/java/com/sk89q/worldedit/command/tool/brush/HollowCylinderBrush.java +++ b/src/main/java/com/sk89q/worldedit/command/tool/brush/HollowCylinderBrush.java @@ -34,8 +34,8 @@ public class HollowCylinderBrush implements Brush { } @Override - public void build(EditSession editSession, Vector pos, Pattern mat, double size) throws MaxChangedBlocksException { - editSession.makeCylinder(pos, Patterns.wrap(mat), size, size, height, false); + public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException { + editSession.makeCylinder(position, Patterns.wrap(pattern), size, size, height, false); } } diff --git a/src/main/java/com/sk89q/worldedit/command/tool/brush/HollowSphereBrush.java b/src/main/java/com/sk89q/worldedit/command/tool/brush/HollowSphereBrush.java index 4a469066c..8f1f6f3be 100644 --- a/src/main/java/com/sk89q/worldedit/command/tool/brush/HollowSphereBrush.java +++ b/src/main/java/com/sk89q/worldedit/command/tool/brush/HollowSphereBrush.java @@ -28,7 +28,7 @@ import com.sk89q.worldedit.function.pattern.Patterns; public class HollowSphereBrush implements Brush { @Override - public void build(EditSession editSession, Vector pos, Pattern mat, double size) throws MaxChangedBlocksException { - editSession.makeSphere(pos, Patterns.wrap(mat), size, size, size, false); + public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException { + editSession.makeSphere(position, Patterns.wrap(pattern), size, size, size, false); } } diff --git a/src/main/java/com/sk89q/worldedit/command/tool/brush/SmoothBrush.java b/src/main/java/com/sk89q/worldedit/command/tool/brush/SmoothBrush.java index fa9c625ed..756f575d4 100644 --- a/src/main/java/com/sk89q/worldedit/command/tool/brush/SmoothBrush.java +++ b/src/main/java/com/sk89q/worldedit/command/tool/brush/SmoothBrush.java @@ -45,10 +45,10 @@ public class SmoothBrush implements Brush { this.naturalOnly = naturalOnly; } - public void build(EditSession editSession, Vector pos, Pattern mat, double size) throws MaxChangedBlocksException { - double rad = size; - WorldVector min = new WorldVector(LocalWorldAdapter.adapt(editSession.getWorld()), pos.subtract(rad, rad, rad)); - Vector max = pos.add(rad, rad + 10, rad); + @Override + public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException { + WorldVector min = new WorldVector(LocalWorldAdapter.adapt(editSession.getWorld()), position.subtract(size, size, size)); + Vector max = position.add(size, size + 10, size); Region region = new CuboidRegion(editSession.getWorld(), min, max); HeightMap heightMap = new HeightMap(editSession, region, naturalOnly); HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1.0)); diff --git a/src/main/java/com/sk89q/worldedit/command/tool/brush/SphereBrush.java b/src/main/java/com/sk89q/worldedit/command/tool/brush/SphereBrush.java index ea79d8251..7df1fa599 100644 --- a/src/main/java/com/sk89q/worldedit/command/tool/brush/SphereBrush.java +++ b/src/main/java/com/sk89q/worldedit/command/tool/brush/SphereBrush.java @@ -28,7 +28,7 @@ import com.sk89q.worldedit.function.pattern.Patterns; public class SphereBrush implements Brush { @Override - public void build(EditSession editSession, Vector pos, Pattern mat, double size) throws MaxChangedBlocksException { - editSession.makeSphere(pos, Patterns.wrap(mat), size, size, size, true); + public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException { + editSession.makeSphere(position, Patterns.wrap(pattern), size, size, size, true); } } diff --git a/src/main/java/com/sk89q/worldedit/event/Event.java b/src/main/java/com/sk89q/worldedit/event/Event.java index 4e9a1fd0f..f95af68e6 100644 --- a/src/main/java/com/sk89q/worldedit/event/Event.java +++ b/src/main/java/com/sk89q/worldedit/event/Event.java @@ -19,8 +19,6 @@ package com.sk89q.worldedit.event; -import com.sk89q.worldedit.util.eventbus.EventBus; - /** * An abstract base class for all WorldEdit events. */ diff --git a/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlatform.java b/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlatform.java index a6534f8a4..7cc6e1009 100644 --- a/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlatform.java +++ b/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlatform.java @@ -19,9 +19,6 @@ package com.sk89q.worldedit.extension.platform; -import com.sk89q.minecraft.util.commands.Command; -import com.sk89q.minecraft.util.commands.CommandsManager; -import com.sk89q.worldedit.LocalPlayer; import com.sk89q.worldedit.world.World; import java.util.Collections; diff --git a/src/main/java/com/sk89q/worldedit/extension/platform/Platform.java b/src/main/java/com/sk89q/worldedit/extension/platform/Platform.java index 412afd9ea..03d4812a9 100644 --- a/src/main/java/com/sk89q/worldedit/extension/platform/Platform.java +++ b/src/main/java/com/sk89q/worldedit/extension/platform/Platform.java @@ -30,9 +30,9 @@ import java.util.Map; /** * Represents a platform that WorldEdit has been implemented for. - *

- * It is strongly recommended that implementations extend from - * {@link AbstractPlatform}. + * + *

It is strongly recommended that implementations extend from + * {@link AbstractPlatform}.

*/ public interface Platform { @@ -58,8 +58,8 @@ public interface Platform { void reload(); /** - * Schedules the given task to be invoked once every period ticks - * after an initial delay of delay ticks. + * Schedules the given {@code task} to be invoked once every + * {@code period} ticks after an initial delay of {@code delay} ticks. * * @param delay Delay in server ticks before executing first repeat * @param period Period in server ticks of the task @@ -68,12 +68,17 @@ public interface Platform { */ int schedule(long delay, long period, Runnable task); + /** + * Get a list of available or loaded worlds. + * + * @return a list of worlds + */ List getWorlds(); /** * Create a duplicate of the given player. - *

- * The given player may have been provided by a different platform. + * + *

The given player may have been provided by a different platform.

* * @param player the player to match * @return a matched player, otherwise null @@ -82,8 +87,8 @@ public interface Platform { /** * Create a duplicate of the given world. - *

- * The given world may have been provided by a different platform. + * + *

The given world may have been provided by a different platform.

* * @param world the world to match * @return a matched world, otherwise null @@ -111,9 +116,9 @@ public interface Platform { /** * Get the version of WorldEdit that this platform provides. - *

- * This version should match WorldEdit releases because it may be - * checked to match. + * + *

This version should match WorldEdit releases because it may be + * checked to match.

* * @return the version */ @@ -121,9 +126,9 @@ public interface Platform { /** * Get a friendly name of the platform. - *

- * The name can be anything (reasonable). An example name may be - * "Bukkit" or "Forge". + * + *

The name can be anything (reasonable). An example name may be + * "Bukkit" or "Forge".

* * @return the platform name */ diff --git a/src/main/java/com/sk89q/worldedit/extent/buffer/ForgetfulExtentBuffer.java b/src/main/java/com/sk89q/worldedit/extent/buffer/ForgetfulExtentBuffer.java index 297df8b1a..abdef5478 100644 --- a/src/main/java/com/sk89q/worldedit/extent/buffer/ForgetfulExtentBuffer.java +++ b/src/main/java/com/sk89q/worldedit/extent/buffer/ForgetfulExtentBuffer.java @@ -141,8 +141,8 @@ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pat } @Override - public boolean contains(Vector pt) { - return buffer.containsKey(pt.toBlockVector()); + public boolean contains(Vector position) { + return buffer.containsKey(position.toBlockVector()); } @Override diff --git a/src/main/java/com/sk89q/worldedit/extent/clipboard/Clipboard.java b/src/main/java/com/sk89q/worldedit/extent/clipboard/Clipboard.java index e68d5b2c0..fa7ff1929 100644 --- a/src/main/java/com/sk89q/worldedit/extent/clipboard/Clipboard.java +++ b/src/main/java/com/sk89q/worldedit/extent/clipboard/Clipboard.java @@ -30,8 +30,8 @@ public interface Clipboard extends Extent { /** * Get the bounding region of this extent. - *

- * Implementations should return a copy of the region. + * + *

Implementations should return a copy of the region.

* * @return the bounding region */ diff --git a/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SchematicReader.java b/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SchematicReader.java index bae3ae753..c6a17cb88 100644 --- a/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SchematicReader.java +++ b/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SchematicReader.java @@ -21,8 +21,6 @@ package com.sk89q.worldedit.extent.clipboard.io; import com.sk89q.jnbt.ByteArrayTag; import com.sk89q.jnbt.CompoundTag; -import com.sk89q.jnbt.DoubleTag; -import com.sk89q.jnbt.FloatTag; import com.sk89q.jnbt.IntTag; import com.sk89q.jnbt.ListTag; import com.sk89q.jnbt.NBTInputStream; diff --git a/src/main/java/com/sk89q/worldedit/extent/inventory/BlockBagExtent.java b/src/main/java/com/sk89q/worldedit/extent/inventory/BlockBagExtent.java index 7eca18d20..9cdc2b3ae 100644 --- a/src/main/java/com/sk89q/worldedit/extent/inventory/BlockBagExtent.java +++ b/src/main/java/com/sk89q/worldedit/extent/inventory/BlockBagExtent.java @@ -24,14 +24,11 @@ import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.extent.AbstractDelegateExtent; import com.sk89q.worldedit.extent.Extent; -import com.sk89q.worldedit.world.World; import javax.annotation.Nullable; import java.util.HashMap; import java.util.Map; -import static com.google.common.base.Preconditions.checkNotNull; - /** * Applies a {@link BlockBag} to operations. */ diff --git a/src/main/java/com/sk89q/worldedit/extent/world/FastModeExtent.java b/src/main/java/com/sk89q/worldedit/extent/world/FastModeExtent.java index be421cbc2..ea9161fea 100644 --- a/src/main/java/com/sk89q/worldedit/extent/world/FastModeExtent.java +++ b/src/main/java/com/sk89q/worldedit/extent/world/FastModeExtent.java @@ -97,7 +97,7 @@ public class FastModeExtent extends AbstractDelegateExtent { return new Operation() { @Override public Operation resume(RunContext run) throws WorldEditException { - if (dirtyChunks.size() > 0) { + if (!dirtyChunks.isEmpty()) { world.fixAfterFastMode(dirtyChunks); } return null; diff --git a/src/main/java/com/sk89q/worldedit/function/mask/BlockMask.java b/src/main/java/com/sk89q/worldedit/function/mask/BlockMask.java index 91ac89c14..bd2e1c831 100644 --- a/src/main/java/com/sk89q/worldedit/function/mask/BlockMask.java +++ b/src/main/java/com/sk89q/worldedit/function/mask/BlockMask.java @@ -34,9 +34,9 @@ import static com.google.common.base.Preconditions.checkNotNull; /** * A mask that checks whether blocks at the given positions are matched by * a block in a list. - *

- * This mask checks for both an exact block ID and data value match, as well - * for a block with the same ID but a data value of -1. + * + *

This mask checks for both an exact block ID and data value match, as well + * for a block with the same ID but a data value of -1.

*/ public class BlockMask extends AbstractExtentMask { diff --git a/src/main/java/com/sk89q/worldedit/function/mask/Masks.java b/src/main/java/com/sk89q/worldedit/function/mask/Masks.java index 86280cb08..b6e94adc2 100644 --- a/src/main/java/com/sk89q/worldedit/function/mask/Masks.java +++ b/src/main/java/com/sk89q/worldedit/function/mask/Masks.java @@ -200,9 +200,9 @@ public final class Masks { checkNotNull(mask); return new com.sk89q.worldedit.masks.AbstractMask() { @Override - public boolean matches(EditSession editSession, Vector pos) { + public boolean matches(EditSession editSession, Vector position) { Request.request().setEditSession(editSession); - return mask.test(pos); + return mask.test(position); } }; } diff --git a/src/main/java/com/sk89q/worldedit/function/visitor/BreadthFirstSearch.java b/src/main/java/com/sk89q/worldedit/function/visitor/BreadthFirstSearch.java index 5356f568d..5f1121eb2 100644 --- a/src/main/java/com/sk89q/worldedit/function/visitor/BreadthFirstSearch.java +++ b/src/main/java/com/sk89q/worldedit/function/visitor/BreadthFirstSearch.java @@ -103,12 +103,12 @@ public abstract class BreadthFirstSearch implements Operation { * that it has not been visited. The position passed to this method * will still be visited even if it fails * {@link #isVisitable(com.sk89q.worldedit.Vector, com.sk89q.worldedit.Vector)}. - *

- * This method should be used before the search begins, because if + * + *

This method should be used before the search begins, because if * the position does fail the test, and the search has already * visited it (because it is connected to another root point), * the search will mark the position as "visited" and a call to this - * method will do nothing. + * method will do nothing.

* * @param position the position */ diff --git a/src/main/java/com/sk89q/worldedit/internal/command/CommandLoggingHandler.java b/src/main/java/com/sk89q/worldedit/internal/command/CommandLoggingHandler.java index b09a26bee..4633afc52 100644 --- a/src/main/java/com/sk89q/worldedit/internal/command/CommandLoggingHandler.java +++ b/src/main/java/com/sk89q/worldedit/internal/command/CommandLoggingHandler.java @@ -89,7 +89,7 @@ public class CommandLoggingHandler extends AbstractInvokeListener implements Inv builder.append("WorldEdit: ").append(sender.getName()); if (sender.isPlayer()) { - builder.append(" (in \"" + player.getWorld().getName() + "\")"); + builder.append(" (in \"").append(player.getWorld().getName()).append("\")"); } builder.append(": ").append(context.getCommand()); @@ -112,15 +112,15 @@ public class CommandLoggingHandler extends AbstractInvokeListener implements Inv /* FALL-THROUGH */ case POSITION: - builder.append(" - Position: " + position); + builder.append(" - Position: ").append(position); break; case ALL: - builder.append(" - Position: " + position); + builder.append(" - Position: ").append(position); /* FALL-THROUGH */ case ORIENTATION_REGION: - builder.append(" - Orientation: " + player.getCardinalDirection().name()); + builder.append(" - Orientation: ").append(player.getCardinalDirection().name()); /* FALL-THROUGH */ case REGION: diff --git a/src/main/java/com/sk89q/worldedit/internal/expression/Expression.java b/src/main/java/com/sk89q/worldedit/internal/expression/Expression.java index 09583d5bb..5a61709f3 100644 --- a/src/main/java/com/sk89q/worldedit/internal/expression/Expression.java +++ b/src/main/java/com/sk89q/worldedit/internal/expression/Expression.java @@ -65,8 +65,6 @@ import java.util.Stack; * *

Variables are also supported and can be set either by passing values * to {@link #evaluate(double...)}.

- * - * @author TomyLobo */ public class Expression { diff --git a/src/main/java/com/sk89q/worldedit/internal/expression/parser/ParserProcessors.java b/src/main/java/com/sk89q/worldedit/internal/expression/parser/ParserProcessors.java index 0989701b1..fc29e37d5 100644 --- a/src/main/java/com/sk89q/worldedit/internal/expression/parser/ParserProcessors.java +++ b/src/main/java/com/sk89q/worldedit/internal/expression/parser/ParserProcessors.java @@ -112,8 +112,7 @@ public final class ParserProcessors { default: Map m = lBinaryOpMapsLA[i] = new HashMap(); - for (int j = 0; j < a.length; ++j) { - final Object[] element = a[j]; + for (final Object[] element : a) { m.put((String) element[0], (String) element[1]); } } @@ -135,8 +134,7 @@ public final class ParserProcessors { default: Map m = lBinaryOpMapsRA[i] = new HashMap(); - for (int j = 0; j < a.length; ++j) { - final Object[] element = a[j]; + for (final Object[] element : a) { m.put((String) element[0], (String) element[1]); } } diff --git a/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Function.java b/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Function.java index 23f96f95c..1fef4a580 100644 --- a/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Function.java +++ b/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Function.java @@ -53,7 +53,7 @@ public class Function extends Node { return invokeMethod(method, args); } - protected static final double invokeMethod(Method method, Object[] args) throws EvaluationException { + protected static double invokeMethod(Method method, Object[] args) throws EvaluationException { try { return (Double) method.invoke(null, args); } catch (InvocationTargetException e) { diff --git a/src/main/java/com/sk89q/worldedit/internal/expression/runtime/SimpleFor.java b/src/main/java/com/sk89q/worldedit/internal/expression/runtime/SimpleFor.java index 5de499ec7..36cf5da81 100644 --- a/src/main/java/com/sk89q/worldedit/internal/expression/runtime/SimpleFor.java +++ b/src/main/java/com/sk89q/worldedit/internal/expression/runtime/SimpleFor.java @@ -85,7 +85,7 @@ public class SimpleFor extends Node { public RValue optimize() throws EvaluationException { // TODO: unroll small loops into Sequences - return new SimpleFor(getPosition(), (LValue) counter.optimize(), first.optimize(), last.optimize(), body.optimize()); + return new SimpleFor(getPosition(), counter.optimize(), first.optimize(), last.optimize(), body.optimize()); } @Override diff --git a/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Switch.java b/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Switch.java index 80754f8a9..164293ff4 100644 --- a/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Switch.java +++ b/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Switch.java @@ -181,9 +181,7 @@ public class Switch extends Node implements RValue { } if (invokable instanceof Sequence) { - for (RValue subInvokable : ((Sequence) invokable).sequence) { - newSequence.add(subInvokable); - } + Collections.addAll(newSequence, ((Sequence) invokable).sequence); } else { newSequence.add(invokable); } diff --git a/src/main/java/com/sk89q/worldedit/regions/ConvexPolyhedralRegion.java b/src/main/java/com/sk89q/worldedit/regions/ConvexPolyhedralRegion.java index 8c64d3eb9..2484cf062 100644 --- a/src/main/java/com/sk89q/worldedit/regions/ConvexPolyhedralRegion.java +++ b/src/main/java/com/sk89q/worldedit/regions/ConvexPolyhedralRegion.java @@ -277,14 +277,14 @@ public class ConvexPolyhedralRegion extends AbstractRegion { } @Override - public boolean contains(Vector pt) { + public boolean contains(Vector position) { if (!isDefined()) { return false; } - final int x = pt.getBlockX(); - final int y = pt.getBlockY(); - final int z = pt.getBlockZ(); + final int x = position.getBlockX(); + final int y = position.getBlockY(); + final int z = position.getBlockZ(); final Vector min = getMinimumPoint(); final Vector max = getMaximumPoint(); @@ -296,7 +296,7 @@ public class ConvexPolyhedralRegion extends AbstractRegion { if (z < min.getBlockZ()) return false; if (z > max.getBlockZ()) return false; - return containsRaw(pt); + return containsRaw(position); } private boolean containsRaw(Vector pt) { diff --git a/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java b/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java index 5bbecfedb..71143b3d3 100644 --- a/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java +++ b/src/main/java/com/sk89q/worldedit/regions/CuboidRegion.java @@ -330,10 +330,10 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion { } @Override - public boolean contains(Vector pt) { - double x = pt.getX(); - double y = pt.getY(); - double z = pt.getZ(); + public boolean contains(Vector position) { + double x = position.getX(); + double y = position.getY(); + double z = position.getZ(); Vector min = getMinimumPoint(); Vector max = getMaximumPoint(); diff --git a/src/main/java/com/sk89q/worldedit/regions/CylinderRegion.java b/src/main/java/com/sk89q/worldedit/regions/CylinderRegion.java index 9bd4dcb84..0f483be4e 100644 --- a/src/main/java/com/sk89q/worldedit/regions/CylinderRegion.java +++ b/src/main/java/com/sk89q/worldedit/regions/CylinderRegion.java @@ -37,10 +37,9 @@ import static com.google.common.base.Preconditions.checkNotNull; /** * Represents a cylindrical region. - * - * @author yetanotherx */ public class CylinderRegion extends AbstractRegion implements FlatRegion { + private Vector2D center; private Vector2D radius; private int minY; @@ -305,13 +304,13 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion { * Checks to see if a point is inside this region. */ @Override - public boolean contains(Vector pt) { - final int blockY = pt.getBlockY(); + public boolean contains(Vector position) { + final int blockY = position.getBlockY(); if (blockY < minY || blockY > maxY) { return false; } - return pt.toVector2D().subtract(center).divide(radius).lengthSq() <= 1; + return position.toVector2D().subtract(center).divide(radius).lengthSq() <= 1; } diff --git a/src/main/java/com/sk89q/worldedit/regions/EllipsoidRegion.java b/src/main/java/com/sk89q/worldedit/regions/EllipsoidRegion.java index 3a99bd445..48e0a0609 100644 --- a/src/main/java/com/sk89q/worldedit/regions/EllipsoidRegion.java +++ b/src/main/java/com/sk89q/worldedit/regions/EllipsoidRegion.java @@ -206,8 +206,8 @@ public class EllipsoidRegion extends AbstractRegion { } @Override - public boolean contains(Vector pt) { - return pt.subtract(center).divide(radius).lengthSq() <= 1; + public boolean contains(Vector position) { + return position.subtract(center).divide(radius).lengthSq() <= 1; } /** diff --git a/src/main/java/com/sk89q/worldedit/regions/NullRegion.java b/src/main/java/com/sk89q/worldedit/regions/NullRegion.java index 0f5839ad0..611835550 100644 --- a/src/main/java/com/sk89q/worldedit/regions/NullRegion.java +++ b/src/main/java/com/sk89q/worldedit/regions/NullRegion.java @@ -83,7 +83,7 @@ public class NullRegion implements Region { } @Override - public boolean contains(Vector pt) { + public boolean contains(Vector position) { return false; } diff --git a/src/main/java/com/sk89q/worldedit/regions/Polygonal2DRegion.java b/src/main/java/com/sk89q/worldedit/regions/Polygonal2DRegion.java index 6eeffb466..f3e207380 100644 --- a/src/main/java/com/sk89q/worldedit/regions/Polygonal2DRegion.java +++ b/src/main/java/com/sk89q/worldedit/regions/Polygonal2DRegion.java @@ -19,10 +19,6 @@ package com.sk89q.worldedit.regions; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; import com.sk89q.worldedit.BlockVector; import com.sk89q.worldedit.BlockVector2D; import com.sk89q.worldedit.LocalWorld; @@ -32,12 +28,16 @@ import com.sk89q.worldedit.regions.iterator.FlatRegion3DIterator; import com.sk89q.worldedit.regions.iterator.FlatRegionIterator; import com.sk89q.worldedit.world.World; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; + /** * Represents a 2D polygonal region. - * - * @author sk89q */ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion { + private List points; private Vector2D min; private Vector2D max; @@ -60,7 +60,7 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion { /** * Construct the region. * - * @param world + * @param world the world */ public Polygonal2DRegion(World world) { this(world, Collections.emptyList(), 0, 0); @@ -75,10 +75,10 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion { /** * Construct the region. * - * @param world - * @param points - * @param minY - * @param maxY + * @param world the world + * @param points list of points + * @param minY minimum Y + * @param maxY maximum Y */ public Polygonal2DRegion(World world, List points, int minY, int maxY) { super(world); @@ -89,6 +89,11 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion { recalculate(); } + /** + * Make a copy of another region. + * + * @param region the other region + */ public Polygonal2DRegion(Polygonal2DRegion region) { this(region.world, region.points, region.minY, region.maxY); hasY = region.hasY; @@ -97,7 +102,7 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion { /** * Get the list of points. * - * @return + * @return a list of points */ public List getPoints() { return Collections.unmodifiableList(points); @@ -108,7 +113,7 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion { * called after points have been changed. */ protected void recalculate() { - if (points.size() == 0) { + if (points.isEmpty()) { min = new Vector2D(0, 0); minY = 0; max = new Vector2D(0, 0); @@ -145,38 +150,34 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion { /** * Add a point to the list. * - * @param pt + * @param position the position */ - public void addPoint(Vector2D pt) { - points.add(pt.toBlockVector2D()); + public void addPoint(Vector2D position) { + points.add(position.toBlockVector2D()); recalculate(); } /** * Add a point to the list. * - * @param pt + * @param position the position */ - public void addPoint(BlockVector2D pt) { - points.add(pt); + public void addPoint(BlockVector2D position) { + points.add(position); recalculate(); } /** * Add a point to the list. * - * @param pt + * @param position the position */ - public void addPoint(Vector pt) { - points.add(new BlockVector2D(pt.getBlockX(), pt.getBlockZ())); + public void addPoint(Vector position) { + points.add(new BlockVector2D(position.getBlockX(), position.getBlockZ())); recalculate(); } - /** - * Get the minimum Y. - * - * @return min y - */ + @Override public int getMinimumY() { return minY; } @@ -189,7 +190,7 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion { /** * Set the minimum Y. * - * @param y + * @param y the Y */ public void setMinimumY(int y) { hasY = true; @@ -197,11 +198,7 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion { recalculate(); } - /** - * Get the maximum Y. - * - * @return max y - */ + @Override public int getMaximumY() { return maxY; } @@ -209,7 +206,7 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion { /** * Set the maximum Y. * - * @param y + * @param y the Y */ public void setMaximumY(int y) { hasY = true; @@ -217,29 +214,17 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion { recalculate(); } - /** - * Get the lower point of a region. - * - * @return min. point - */ + @Override public Vector getMinimumPoint() { return min.toVector(minY); } - /** - * Get the upper point of a region. - * - * @return max. point - */ + @Override public Vector getMaximumPoint() { return max.toVector(maxY); } - /** - * Get the number of blocks in the region. - * - * @return number of blocks - */ + @Override public int getArea() { double area = 0; int i, j = points.size() - 1; @@ -254,38 +239,22 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion { * (maxY - minY + 1)); } - /** - * Get X-size. - * - * @return width - */ + @Override public int getWidth() { return max.getBlockX() - min.getBlockX() + 1; } - /** - * Get Y-size. - * - * @return height - */ + @Override public int getHeight() { return maxY - minY + 1; } - /** - * Get Z-size. - * - * @return length - */ + @Override public int getLength() { return max.getBlockZ() - min.getBlockZ() + 1; } - /** - * Expand the region. - * - * @param changes - */ + @Override public void expand(Vector... changes) throws RegionOperationException { for (Vector change : changes) { if (change.getBlockX() != 0 || change.getBlockZ() != 0) { @@ -304,11 +273,7 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion { recalculate(); } - /** - * Contract the region. - * - * @param changes - */ + @Override public void contract(Vector... changes) throws RegionOperationException { for (Vector change : changes) { if (change.getBlockX() != 0 || change.getBlockZ() != 0) { @@ -344,24 +309,21 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion { recalculate(); } - /** - * Checks to see if a point is inside this region. - */ - public boolean contains(Vector pt) { - return contains(points, minY, maxY, pt); + @Override + public boolean contains(Vector position) { + return contains(points, minY, maxY, position); } /** * Checks to see if a point is inside a region. * - * @param points - * @param minY - * @param maxY - * @param pt - * @return + * @param points a list of points + * @param minY the min Y + * @param maxY the max Y + * @param pt the position to check + * @return true if the given polygon contains the given point */ - public static boolean contains(List points, int minY, - int maxY, Vector pt) { + public static boolean contains(List points, int minY, int maxY, Vector pt) { if (points.size() < 3) { return false; } @@ -422,7 +384,7 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion { /** * Return the number of points. * - * @return + * @return the number of points */ public int size() { return points.size(); @@ -431,7 +393,7 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion { /** * Expand the height of the polygon to fit the specified Y. * - * @param y + * @param y the amount to expand * @return true if the area was expanded */ public boolean expandY(int y) { @@ -451,11 +413,6 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion { return false; } - /** - * Get the iterator. - * - * @return iterator of points inside the region - */ @Override public Iterator iterator() { return new FlatRegion3DIterator(this); @@ -484,13 +441,14 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion { Iterator it = pts.iterator(); while (it.hasNext()) { BlockVector2D current = it.next(); - sb.append("(" + current.getBlockX() + ", " + current.getBlockZ() + ")"); + sb.append("(").append(current.getBlockX()).append(", ").append(current.getBlockZ()).append(")"); if (it.hasNext()) sb.append(" - "); } - sb.append(" * (" + minY + " - " + maxY + ")"); + sb.append(" * (").append(minY).append(" - ").append(maxY).append(")"); return sb.toString(); } + @Override public Polygonal2DRegion clone() { Polygonal2DRegion clone = (Polygonal2DRegion) super.clone(); clone.points = new ArrayList(points); @@ -505,4 +463,5 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion { return points; } + } diff --git a/src/main/java/com/sk89q/worldedit/regions/Region.java b/src/main/java/com/sk89q/worldedit/regions/Region.java index b175d851c..954296565 100644 --- a/src/main/java/com/sk89q/worldedit/regions/Region.java +++ b/src/main/java/com/sk89q/worldedit/regions/Region.java @@ -26,14 +26,15 @@ import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector2D; import com.sk89q.worldedit.world.World; +import javax.annotation.Nullable; import java.util.List; import java.util.Set; /** - * - * @author sk89q + * Represents a physical shape. */ public interface Region extends Iterable, Cloneable { + /** * Get the lower point of a region. * @@ -104,7 +105,7 @@ public interface Region extends Iterable, Cloneable { /** * Shift the region. * - * @param change + * @param change the change * @throws RegionOperationException */ public void shift(Vector change) throws RegionOperationException; @@ -112,47 +113,53 @@ public interface Region extends Iterable, Cloneable { /** * Returns true based on whether the region contains the point. * - * @param pt - * @return + * @param position the position + * @return true if contained */ - public boolean contains(Vector pt); + public boolean contains(Vector position); /** * Get a list of chunks. * - * @return + * @return a list of chunk coordinates */ public Set getChunks(); /** * Return a list of 16*16*16 chunks in a region * - * @return The chunk cubes this region overlaps with + * @return the chunk cubes this region overlaps with */ public Set getChunkCubes(); /** - * Get the world the selection is in + * Sets the world that the selection is in. * - * @return + * @return the world, or null */ + @Nullable public World getWorld(); /** - * Sets the world the selection is in + * Sets the world that the selection is in. * - * @return + * @param world the world, which may be null */ - public void setWorld(World world); + public void setWorld(@Nullable World world); /** - * Sets the world the selection is in + * Sets the world that the selection is in. * - * @return + * @param world the world, which may be null */ @Deprecated - public void setWorld(LocalWorld world); + public void setWorld(@Nullable LocalWorld world); + /** + * Make a clone of the region. + * + * @return a cloned version + */ public Region clone(); /** diff --git a/src/main/java/com/sk89q/worldedit/regions/RegionIntersection.java b/src/main/java/com/sk89q/worldedit/regions/RegionIntersection.java index 92ee3bdee..070a3527f 100644 --- a/src/main/java/com/sk89q/worldedit/regions/RegionIntersection.java +++ b/src/main/java/com/sk89q/worldedit/regions/RegionIntersection.java @@ -25,6 +25,7 @@ import com.sk89q.worldedit.LocalWorld; import com.sk89q.worldedit.Vector; import java.util.ArrayList; +import java.util.Collections; import java.util.Iterator; import java.util.List; @@ -34,11 +35,11 @@ import static com.google.common.base.Preconditions.checkNotNull; /** * An intersection of several other regions. Any location that is contained in one * of the child regions is considered as contained by this region. - *

- * {@link #iterator()} returns a special iterator that will iterate through + * + *

{@link #iterator()} returns a special iterator that will iterate through * the iterators of each region in an undefined sequence. Some positions may * be repeated if the position is contained in more than one region, but this cannot - * be guaranteed to occur. + * be guaranteed to occur.

*/ public class RegionIntersection extends AbstractRegion { @@ -71,7 +72,7 @@ public class RegionIntersection extends AbstractRegion { public RegionIntersection(LocalWorld world, List regions) { super(world); checkNotNull(regions); - checkArgument(regions.size() > 0, "empty region list is not supported"); + checkArgument(!regions.isEmpty(), "empty region list is not supported"); for (Region region : regions) { this.regions.add(region); } @@ -87,9 +88,7 @@ public class RegionIntersection extends AbstractRegion { super(world); checkNotNull(regions); checkArgument(regions.length > 0, "empty region list is not supported"); - for (Region region : regions) { - this.regions.add(region); - } + Collections.addAll(this.regions, regions); } @Override @@ -123,11 +122,11 @@ public class RegionIntersection extends AbstractRegion { } @Override - public boolean contains(Vector pt) { - checkNotNull(pt); + public boolean contains(Vector position) { + checkNotNull(position); for (Region region : regions) { - if (region.contains(pt)) { + if (region.contains(position)) { return true; } } diff --git a/src/main/java/com/sk89q/worldedit/regions/RegionOperationException.java b/src/main/java/com/sk89q/worldedit/regions/RegionOperationException.java index ad8ec012d..4226b1818 100644 --- a/src/main/java/com/sk89q/worldedit/regions/RegionOperationException.java +++ b/src/main/java/com/sk89q/worldedit/regions/RegionOperationException.java @@ -22,9 +22,9 @@ package com.sk89q.worldedit.regions; import com.sk89q.worldedit.WorldEditException; public class RegionOperationException extends WorldEditException { - private static final long serialVersionUID = -6180325009115242142L; public RegionOperationException(String msg) { super(msg); } + } diff --git a/src/main/java/com/sk89q/worldedit/regions/Regions.java b/src/main/java/com/sk89q/worldedit/regions/Regions.java index 14b01c826..6c44fea5d 100644 --- a/src/main/java/com/sk89q/worldedit/regions/Regions.java +++ b/src/main/java/com/sk89q/worldedit/regions/Regions.java @@ -73,10 +73,10 @@ public final class Regions { /** * Attempt to get a {@link FlatRegion} from the given region. - *

- * If the given region is already a {@link FlatRegion}, then the region + * + *

If the given region is already a {@link FlatRegion}, then the region * will be cast and returned. Otherwise, a new {@link CuboidRegion} will - * be created covers the provided region's minimum and maximum extents. + * be created covers the provided region's minimum and maximum extents.

* * @param region the region * @return a flat region diff --git a/src/main/java/com/sk89q/worldedit/regions/TransformRegion.java b/src/main/java/com/sk89q/worldedit/regions/TransformRegion.java index b024bf867..3ffb59a03 100644 --- a/src/main/java/com/sk89q/worldedit/regions/TransformRegion.java +++ b/src/main/java/com/sk89q/worldedit/regions/TransformRegion.java @@ -147,8 +147,8 @@ public class TransformRegion extends AbstractRegion { } @Override - public boolean contains(Vector pt) { - return region.contains(transform.inverse().apply(pt)); + public boolean contains(Vector position) { + return region.contains(transform.inverse().apply(position)); } @Override diff --git a/src/main/java/com/sk89q/worldedit/schematic/MCEditSchematicFormat.java b/src/main/java/com/sk89q/worldedit/schematic/MCEditSchematicFormat.java index 39dd8886a..118681eb6 100644 --- a/src/main/java/com/sk89q/worldedit/schematic/MCEditSchematicFormat.java +++ b/src/main/java/com/sk89q/worldedit/schematic/MCEditSchematicFormat.java @@ -238,26 +238,21 @@ public class MCEditSchematicFormat extends SchematicFormat { blocks[index] = (byte) block.getType(); blockData[index] = (byte) block.getData(); - // Store TileEntity data - if (block instanceof TileEntityBlock) { - TileEntityBlock tileEntityBlock = block; - - // Get the list of key/values from the block - CompoundTag rawTag = tileEntityBlock.getNbtData(); - if (rawTag != null) { - Map values = new HashMap(); - for (Entry entry : rawTag.getValue().entrySet()) { - values.put(entry.getKey(), entry.getValue()); - } - - values.put("id", new StringTag("id", tileEntityBlock.getNbtId())); - values.put("x", new IntTag("x", x)); - values.put("y", new IntTag("y", y)); - values.put("z", new IntTag("z", z)); - - CompoundTag tileEntityTag = new CompoundTag("TileEntity", values); - tileEntities.add(tileEntityTag); + // Get the list of key/values from the block + CompoundTag rawTag = block.getNbtData(); + if (rawTag != null) { + Map values = new HashMap(); + for (Entry entry : rawTag.getValue().entrySet()) { + values.put(entry.getKey(), entry.getValue()); } + + values.put("id", new StringTag("id", block.getNbtId())); + values.put("x", new IntTag("x", x)); + values.put("y", new IntTag("y", y)); + values.put("z", new IntTag("z", z)); + + CompoundTag tileEntityTag = new CompoundTag("TileEntity", values); + tileEntities.add(tileEntityTag); } } } diff --git a/src/main/java/com/sk89q/worldedit/scripting/CraftScriptContext.java b/src/main/java/com/sk89q/worldedit/scripting/CraftScriptContext.java index bd4725655..bca3f641a 100644 --- a/src/main/java/com/sk89q/worldedit/scripting/CraftScriptContext.java +++ b/src/main/java/com/sk89q/worldedit/scripting/CraftScriptContext.java @@ -35,10 +35,10 @@ import java.util.Set; /** * The context given to scripts. - * - * @author sk89q */ +@SuppressWarnings("deprecation") public class CraftScriptContext extends CraftScriptEnvironment { + private List editSessions = new ArrayList(); private String[] args; @@ -53,7 +53,7 @@ public class CraftScriptContext extends CraftScriptEnvironment { * Get an edit session. Every subsequent call returns a new edit session. * Usually you only need to use one edit session. * - * @return + * @return an edit session */ public EditSession remember() { EditSession editSession = controller.getEditSessionFactory() @@ -67,7 +67,7 @@ public class CraftScriptContext extends CraftScriptEnvironment { /** * Get the player. * - * @return + * @return the calling player */ public Player getPlayer() { return player; @@ -76,7 +76,7 @@ public class CraftScriptContext extends CraftScriptEnvironment { /** * Get the player's session. * - * @return + * @return a session */ public LocalSession getSession() { return session; @@ -85,7 +85,7 @@ public class CraftScriptContext extends CraftScriptEnvironment { /** * Get the configuration for WorldEdit. * - * @return + * @return the configuration */ public LocalConfiguration getConfiguration() { return config; @@ -94,7 +94,7 @@ public class CraftScriptContext extends CraftScriptEnvironment { /** * Get a list of edit sessions that have been created. * - * @return + * @return a list of created {@code EditSession}s */ public List getEditSessions() { return Collections.unmodifiableList(editSessions); @@ -103,34 +103,34 @@ public class CraftScriptContext extends CraftScriptEnvironment { /** * Print a regular message to the user. * - * @param msg + * @param message a message */ - public void print(String msg) { - player.print(msg); + public void print(String message) { + player.print(message); } /** * Print an error message to the user. * - * @param msg + * @param message a message */ - public void error(String msg) { - player.printError(msg); + public void error(String message) { + player.printError(message); } /** * Print an raw message to the user. * - * @param msg + * @param message a message */ - public void printRaw(String msg) { - player.printRaw(msg); + public void printRaw(String message) { + player.printRaw(message); } /** * Checks to make sure that there are enough but not too many arguments. * - * @param min + * @param min a number of arguments * @param max -1 for no maximum * @param usage usage string * @throws InsufficientArgumentsException @@ -145,54 +145,50 @@ public class CraftScriptContext extends CraftScriptEnvironment { /** * Get an item ID from an item name or an item ID number. * - * @param arg + * @param input input to parse * @param allAllowed true to ignore blacklists - * @return + * @return a block * @throws UnknownItemException * @throws DisallowedItemException */ - public BaseBlock getBlock(String arg, boolean allAllowed) - throws WorldEditException { - return controller.getBlock(player, arg, allAllowed); + public BaseBlock getBlock(String input, boolean allAllowed) throws WorldEditException { + return controller.getBlock(player, input, allAllowed); } /** * Get a block. * - * @param id - * @return + * @param id the type Id + * @return a block * @throws UnknownItemException * @throws DisallowedItemException */ - public BaseBlock getBlock(String id) - throws WorldEditException { + public BaseBlock getBlock(String id) throws WorldEditException { return controller.getBlock(player, id, false); } /** * Get a list of blocks as a set. This returns a Pattern. * - * @param list + * @param list the input * @return pattern * @throws UnknownItemException * @throws DisallowedItemException */ - public Pattern getBlockPattern(String list) - throws WorldEditException { + public Pattern getBlockPattern(String list) throws WorldEditException { return controller.getBlockPattern(player, list); } /** * Get a list of blocks as a set. * - * @param list - * @param allBlocksAllowed + * @param list a list + * @param allBlocksAllowed true if all blocks are allowed * @return set * @throws UnknownItemException * @throws DisallowedItemException */ - public Set getBlockIDs(String list, boolean allBlocksAllowed) - throws WorldEditException { + public Set getBlockIDs(String list, boolean allBlocksAllowed) throws WorldEditException { return controller.getBlockIDs(player, list, allBlocksAllowed); } @@ -200,13 +196,13 @@ public class CraftScriptContext extends CraftScriptEnvironment { * Gets the path to a file. This method will check to see if the filename * has valid characters and has an extension. It also prevents directory * traversal exploits by checking the root directory and the file directory. - * On success, a java.io.File object will be returned. + * On success, a {@code java.io.File} object will be returned. * *

Use this method if you need to read a file from a directory.

* * @param folder sub-directory to look in * @param filename filename (user-submitted) - * @return + * @return a file * @throws FilenameException */ @Deprecated @@ -219,7 +215,7 @@ public class CraftScriptContext extends CraftScriptEnvironment { * Gets the path to a file for opening. This method will check to see if the * filename has valid characters and has an extension. It also prevents * directory traversal exploits by checking the root directory and the file - * directory. On success, a java.io.File object will be + * directory. On success, a {@code java.io.File} object will be * returned. * *

Use this method if you need to read a file from a directory.

@@ -228,12 +224,10 @@ public class CraftScriptContext extends CraftScriptEnvironment { * @param filename filename (user-submitted) * @param defaultExt default extension to append if there is none * @param exts list of extensions for file open dialog, null for no filter - * @return + * @return a file * @throws FilenameException */ - public File getSafeOpenFile(String folder, String filename, - String defaultExt, String... exts) - throws FilenameException { + public File getSafeOpenFile(String folder, String filename, String defaultExt, String... exts) throws FilenameException { File dir = controller.getWorkingDirectoryFile(folder); return controller.getSafeOpenFile(player, dir, filename, defaultExt, exts); } @@ -242,7 +236,7 @@ public class CraftScriptContext extends CraftScriptEnvironment { * Gets the path to a file for saving. This method will check to see if the * filename has valid characters and has an extension. It also prevents * directory traversal exploits by checking the root directory and the file - * directory. On success, a java.io.File object will be + * directory. On success, a {@code java.io.File} object will be * returned. * *

Use this method if you need to read a file from a directory.

@@ -251,13 +245,12 @@ public class CraftScriptContext extends CraftScriptEnvironment { * @param filename filename (user-submitted) * @param defaultExt default extension to append if there is none * @param exts list of extensions for file save dialog, null for no filter - * @return + * @return a file * @throws FilenameException */ - public File getSafeSaveFile(String folder, String filename, - String defaultExt, String... exts) - throws FilenameException { + public File getSafeSaveFile(String folder, String filename, String defaultExt, String... exts) throws FilenameException { File dir = controller.getWorkingDirectoryFile(folder); return controller.getSafeSaveFile(player, dir, filename, defaultExt, exts); } + } diff --git a/src/main/java/com/sk89q/worldedit/scripting/RhinoContextFactory.java b/src/main/java/com/sk89q/worldedit/scripting/RhinoContextFactory.java index 54ab0d0e6..b61edb0d3 100644 --- a/src/main/java/com/sk89q/worldedit/scripting/RhinoContextFactory.java +++ b/src/main/java/com/sk89q/worldedit/scripting/RhinoContextFactory.java @@ -25,6 +25,7 @@ import org.mozilla.javascript.ContextFactory; import org.mozilla.javascript.Scriptable; public class RhinoContextFactory extends ContextFactory { + protected int timeLimit; public RhinoContextFactory(int timeLimit) { @@ -60,8 +61,9 @@ public class RhinoContextFactory extends ContextFactory { private static class RhinoContext extends Context { long startTime; - public RhinoContext(ContextFactory factory) { + private RhinoContext(ContextFactory factory) { super(factory); } } + } diff --git a/src/main/java/com/sk89q/worldedit/scripting/RhinoCraftScriptEngine.java b/src/main/java/com/sk89q/worldedit/scripting/RhinoCraftScriptEngine.java index 33e7ad67a..7f3354bbc 100644 --- a/src/main/java/com/sk89q/worldedit/scripting/RhinoCraftScriptEngine.java +++ b/src/main/java/com/sk89q/worldedit/scripting/RhinoCraftScriptEngine.java @@ -34,14 +34,17 @@ import com.sk89q.worldedit.WorldEditException; public class RhinoCraftScriptEngine implements CraftScriptEngine { private int timeLimit; + @Override public void setTimeLimit(int milliseconds) { timeLimit = milliseconds; } + @Override public int getTimeLimit() { return timeLimit; } + @Override public Object evaluate(String script, String filename, Map args) throws ScriptException, Throwable { RhinoContextFactory factory = new RhinoContextFactory(timeLimit); @@ -59,7 +62,7 @@ public class RhinoCraftScriptEngine implements CraftScriptEngine { throw new ScriptException(e.getMessage()); } catch (RhinoException e) { if (e instanceof WrappedException) { - Throwable cause = ((WrappedException) e).getCause(); + Throwable cause = e.getCause(); if (cause instanceof WorldEditException) { throw cause; } diff --git a/src/main/java/com/sk89q/worldedit/scripting/java/RhinoScriptEngine.java b/src/main/java/com/sk89q/worldedit/scripting/java/RhinoScriptEngine.java index 80e21e71f..bf64e4e12 100644 --- a/src/main/java/com/sk89q/worldedit/scripting/java/RhinoScriptEngine.java +++ b/src/main/java/com/sk89q/worldedit/scripting/java/RhinoScriptEngine.java @@ -47,10 +47,12 @@ public class RhinoScriptEngine extends AbstractScriptEngine { factory.enterContext(); } + @Override public Bindings createBindings() { return new SimpleBindings(); } + @Override public Object eval(String script, ScriptContext context) throws ScriptException { @@ -81,6 +83,7 @@ public class RhinoScriptEngine extends AbstractScriptEngine { } } + @Override public Object eval(Reader reader, ScriptContext context) throws ScriptException { @@ -113,6 +116,7 @@ public class RhinoScriptEngine extends AbstractScriptEngine { } } + @Override public ScriptEngineFactory getFactory() { if (factory != null) { return factory; diff --git a/src/main/java/com/sk89q/worldedit/scripting/java/RhinoScriptEngineFactory.java b/src/main/java/com/sk89q/worldedit/scripting/java/RhinoScriptEngineFactory.java index aee1ccb94..0e3c4be1d 100644 --- a/src/main/java/com/sk89q/worldedit/scripting/java/RhinoScriptEngineFactory.java +++ b/src/main/java/com/sk89q/worldedit/scripting/java/RhinoScriptEngineFactory.java @@ -52,26 +52,32 @@ public class RhinoScriptEngineFactory implements ScriptEngineFactory { extensions = Collections.unmodifiableList(extensions); } + @Override public String getEngineName() { return "Rhino JavaScript Engine (SK)"; } + @Override public String getEngineVersion() { return "unknown"; } + @Override public List getExtensions() { return extensions; } + @Override public String getLanguageName() { return "EMCAScript"; } + @Override public String getLanguageVersion() { return "1.8"; } + @Override public String getMethodCallSyntax(String obj, String m, String... args) { StringBuilder s = new StringBuilder(); s.append(obj); @@ -91,20 +97,24 @@ public class RhinoScriptEngineFactory implements ScriptEngineFactory { return s.toString(); } + @Override public List getMimeTypes() { return mimeTypes; } + @Override public List getNames() { return names; } + @Override public String getOutputStatement(String str) { return "print(" + str.replace("\\", "\\\\") .replace("\"", "\\\\\"") .replace(";", "\\\\;") + ")"; } + @Override public Object getParameter(String key) { if (key.equals(ScriptEngine.ENGINE)) { return getEngineName(); @@ -123,6 +133,7 @@ public class RhinoScriptEngineFactory implements ScriptEngineFactory { } } + @Override public String getProgram(String... statements) { StringBuilder s = new StringBuilder(); for (String stmt : statements) { @@ -132,6 +143,7 @@ public class RhinoScriptEngineFactory implements ScriptEngineFactory { return s.toString(); } + @Override public ScriptEngine getScriptEngine() { return new RhinoScriptEngine(); } diff --git a/src/main/java/com/sk89q/worldedit/session/PasteBuilder.java b/src/main/java/com/sk89q/worldedit/session/PasteBuilder.java index 571387cf5..5abe2e5f6 100644 --- a/src/main/java/com/sk89q/worldedit/session/PasteBuilder.java +++ b/src/main/java/com/sk89q/worldedit/session/PasteBuilder.java @@ -49,8 +49,8 @@ public class PasteBuilder { * Create a new instance. * * @param holder the clipboard holder - * @param targetExtent - * @param targetWorldData + * @param targetExtent an extent + * @param targetWorldData world data of the target */ PasteBuilder(ClipboardHolder holder, Extent targetExtent, WorldData targetWorldData) { checkNotNull(holder); diff --git a/src/main/java/com/sk89q/worldedit/session/SessionOwner.java b/src/main/java/com/sk89q/worldedit/session/SessionOwner.java index be288dccb..6326e30ba 100644 --- a/src/main/java/com/sk89q/worldedit/session/SessionOwner.java +++ b/src/main/java/com/sk89q/worldedit/session/SessionOwner.java @@ -19,7 +19,6 @@ package com.sk89q.worldedit.session; -import com.sk89q.worldedit.util.Identifiable; import com.sk89q.worldedit.util.auth.Subject; /** diff --git a/src/main/java/com/sk89q/worldedit/session/request/RequestSelection.java b/src/main/java/com/sk89q/worldedit/session/request/RequestSelection.java index 3ac222542..d714508a8 100644 --- a/src/main/java/com/sk89q/worldedit/session/request/RequestSelection.java +++ b/src/main/java/com/sk89q/worldedit/session/request/RequestSelection.java @@ -33,9 +33,9 @@ import java.util.Set; * A region that mirrors the current selection according to the current * {@link LocalSession} and {@link LocalWorld} set on the current * {@link Request}. - *

- * If a selection cannot be taken, then the selection will be assumed to be - * that of a {@link NullRegion}. + * + *

If a selection cannot be taken, then the selection will be assumed to be + * that of a {@link NullRegion}.

*/ public class RequestSelection implements Region { @@ -109,8 +109,8 @@ public class RequestSelection implements Region { } @Override - public boolean contains(Vector pt) { - return getRegion().contains(pt); + public boolean contains(Vector position) { + return getRegion().contains(position); } @Override diff --git a/src/main/java/com/sk89q/worldedit/util/Countable.java b/src/main/java/com/sk89q/worldedit/util/Countable.java index db98a832c..e1f48d135 100644 --- a/src/main/java/com/sk89q/worldedit/util/Countable.java +++ b/src/main/java/com/sk89q/worldedit/util/Countable.java @@ -19,56 +19,34 @@ package com.sk89q.worldedit.util; -/** - * - * @author sk89q - * @param - */ public class Countable implements Comparable> { - /** - * ID. - */ + private T id; - /** - * Amount. - */ private int amount; /** * Construct the object. * - * @param id - * @param amount + * @param id the ID + * @param amount the count of */ public Countable(T id, int amount) { this.id = id; this.amount = amount; } - /** - * @return the id - */ public T getID() { return id; } - /** - * @param id the id to set - */ public void setID(T id) { this.id = id; } - /** - * @return the amount - */ public int getAmount() { return amount; } - /** - * @param amount the amount to set - */ public void setAmount(int amount) { this.amount = amount; } @@ -87,12 +65,7 @@ public class Countable implements Comparable> { ++this.amount; } - /** - * Comparison. - * - * @param other - * @return - */ + @Override public int compareTo(Countable other) { if (amount > other.amount) { return 1; diff --git a/src/main/java/com/sk89q/worldedit/util/FileDialogUtil.java b/src/main/java/com/sk89q/worldedit/util/FileDialogUtil.java index 8346edc11..47659b036 100644 --- a/src/main/java/com/sk89q/worldedit/util/FileDialogUtil.java +++ b/src/main/java/com/sk89q/worldedit/util/FileDialogUtil.java @@ -68,7 +68,7 @@ public final class FileDialogUtil { private Set exts; private String desc; - public ExtensionFilter(String[] exts) { + private ExtensionFilter(String[] exts) { this.exts = new HashSet(Arrays.asList(exts)); desc = StringUtil.joinString(exts, ","); diff --git a/src/main/java/com/sk89q/worldedit/util/Location.java b/src/main/java/com/sk89q/worldedit/util/Location.java index f1fbcc8ce..4d75c45bd 100644 --- a/src/main/java/com/sk89q/worldedit/util/Location.java +++ b/src/main/java/com/sk89q/worldedit/util/Location.java @@ -26,13 +26,13 @@ import static com.google.common.base.Preconditions.checkNotNull; /** * Represents a location in a world with has a direction. - *

- * Like {@code Vectors}, {@code Locations} are immutable and mutator methods - * will create a new copy. - *

- * At the moment, but this may change in the future, {@link #hashCode()} and + * + *

Like {@code Vectors}, {@code Locations} are immutable and mutator methods + * will create a new copy.

+ * + *

At the moment, but this may change in the future, {@link #hashCode()} and * {@link #equals(Object)} are subject to minor differences caused by - * floating point errors. + * floating point errors.

*/ public class Location { diff --git a/src/main/java/com/sk89q/worldedit/util/PropertiesConfiguration.java b/src/main/java/com/sk89q/worldedit/util/PropertiesConfiguration.java index b690f8e2c..5a9a399ba 100644 --- a/src/main/java/com/sk89q/worldedit/util/PropertiesConfiguration.java +++ b/src/main/java/com/sk89q/worldedit/util/PropertiesConfiguration.java @@ -21,6 +21,11 @@ package com.sk89q.worldedit.util; +import com.sk89q.util.StringUtil; +import com.sk89q.worldedit.LocalConfiguration; +import com.sk89q.worldedit.LocalSession; +import com.sk89q.worldedit.world.snapshot.SnapshotRepository; + import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; @@ -31,27 +36,24 @@ import java.io.OutputStream; import java.util.HashSet; import java.util.Properties; import java.util.Set; - -import com.sk89q.util.StringUtil; -import com.sk89q.worldedit.LocalConfiguration; -import com.sk89q.worldedit.LocalSession; -import com.sk89q.worldedit.world.snapshot.SnapshotRepository; +import java.util.logging.Level; +import java.util.logging.Logger; /** * Simple LocalConfiguration that loads settings using - * java.util.Properties. - * - * @author sk89q + * {@code java.util.Properties}. */ public class PropertiesConfiguration extends LocalConfiguration { + private static final Logger log = Logger.getLogger(PropertiesConfiguration.class.getCanonicalName()); + protected Properties properties; protected File path; /** * Construct the object. The configuration isn't loaded yet. * - * @param path + * @param path the path tot he configuration */ public PropertiesConfiguration(File path) { this.path = path; @@ -59,23 +61,20 @@ public class PropertiesConfiguration extends LocalConfiguration { properties = new Properties(); } - /** - * Load the configuration file. - */ @Override public void load() { InputStream stream = null; try { stream = new FileInputStream(path); properties.load(stream); - } catch (FileNotFoundException e) { + } catch (FileNotFoundException ignored) { } catch (IOException e) { - e.printStackTrace(); + log.log(Level.WARNING, "Failed to read configuration", e); } finally { if (stream != null) { try { stream.close(); - } catch (IOException e) { + } catch (IOException ignored) { } } } @@ -115,7 +114,7 @@ public class PropertiesConfiguration extends LocalConfiguration { LocalSession.MAX_HISTORY_SIZE = Math.max(15, getInt("history-size", 15)); String snapshotsDir = getString("snapshots-dir", ""); - if (snapshotsDir.length() > 0) { + if (!snapshotsDir.isEmpty()) { snapshotRepo = new SnapshotRepository(snapshotsDir); } @@ -125,14 +124,14 @@ public class PropertiesConfiguration extends LocalConfiguration { output = new FileOutputStream(path); properties.store(output, "Don't put comments; they get removed"); } catch (FileNotFoundException e) { - e.printStackTrace(); + log.log(Level.WARNING, "Failed to write configuration", e); } catch (IOException e) { - e.printStackTrace(); + log.log(Level.WARNING, "Failed to write configuration", e); } finally { if (output != null) { try { output.close(); - } catch (IOException e) { + } catch (IOException ignored) { } } } @@ -141,9 +140,9 @@ public class PropertiesConfiguration extends LocalConfiguration { /** * Get a string value. * - * @param key - * @param def - * @return + * @param key the key + * @param def the default value + * @return the value */ protected String getString(String key, String def) { if (def == null) { @@ -161,9 +160,9 @@ public class PropertiesConfiguration extends LocalConfiguration { /** * Get a boolean value. * - * @param key - * @param def - * @return + * @param key the key + * @param def the default value + * @return the value */ protected boolean getBool(String key, boolean def) { String val = properties.getProperty(key); @@ -179,9 +178,9 @@ public class PropertiesConfiguration extends LocalConfiguration { /** * Get an integer value. * - * @param key - * @param def - * @return + * @param key the key + * @param def the default value + * @return the value */ protected int getInt(String key, int def) { String val = properties.getProperty(key); @@ -201,9 +200,9 @@ public class PropertiesConfiguration extends LocalConfiguration { /** * Get a double value. * - * @param key - * @param def - * @return + * @param key the key + * @param def the default value + * @return the value */ protected double getDouble(String key, double def) { String val = properties.getProperty(key); @@ -223,9 +222,9 @@ public class PropertiesConfiguration extends LocalConfiguration { /** * Get a double value. * - * @param key - * @param def - * @return + * @param key the key + * @param def the default value + * @return the value */ protected Set getIntSet(String key, int[] def) { String val = properties.getProperty(key); @@ -243,10 +242,11 @@ public class PropertiesConfiguration extends LocalConfiguration { try { int v = Integer.parseInt(part.trim()); set.add(v); - } catch (NumberFormatException e) { + } catch (NumberFormatException ignored) { } } return set; } } + } diff --git a/src/main/java/com/sk89q/worldedit/util/TargetBlock.java b/src/main/java/com/sk89q/worldedit/util/TargetBlock.java index a97a182a0..d647ca067 100644 --- a/src/main/java/com/sk89q/worldedit/util/TargetBlock.java +++ b/src/main/java/com/sk89q/worldedit/util/TargetBlock.java @@ -29,12 +29,11 @@ import com.sk89q.worldedit.internal.LocalWorldAdapter; * This class uses an inefficient method to figure out what block a player * is looking towards. * - * Originally written by toi. It was ported to WorldEdit and trimmed down by - * sk89q. Thanks to Raphfrk for optimization of toi's original class. - * - * @author toi + *

Originally written by toi. It was ported to WorldEdit and trimmed down by + * sk89q. Thanks to Raphfrk for optimization of toi's original class.

*/ public class TargetBlock { + private LocalWorld world; private int maxDistance; private double checkDistance, curDistance; @@ -81,8 +80,8 @@ public class TargetBlock { * Set the values, all constructors uses this function * * @param loc location of the view - * @param xRotation - * @param yRotation + * @param xRotation the X rotation + * @param yRotation the Y rotation * @param maxDistance how far it checks for blocks * @param viewHeight where the view is positioned in y-axis * @param checkDistance how often to check for blocks, the smaller the more precise @@ -210,4 +209,5 @@ public class TargetBlock { getAnyTargetBlock(); return WorldVectorFace.getWorldVectorFace(world, getCurrentBlock(), getPreviousBlock()); } + } diff --git a/src/main/java/com/sk89q/worldedit/util/TreeGenerator.java b/src/main/java/com/sk89q/worldedit/util/TreeGenerator.java index c28400d76..2b686e7d5 100644 --- a/src/main/java/com/sk89q/worldedit/util/TreeGenerator.java +++ b/src/main/java/com/sk89q/worldedit/util/TreeGenerator.java @@ -19,22 +19,23 @@ package com.sk89q.worldedit.util; -import java.util.EnumSet; -import java.util.HashMap; -import java.util.Map; -import java.util.Random; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.blocks.BlockID; +import javax.annotation.Nullable; +import java.util.EnumSet; +import java.util.HashMap; +import java.util.Map; +import java.util.Random; + /** * Tree generator. - * - * @author sk89q */ public class TreeGenerator { + public enum TreeType { TREE("Regular tree", "tree", "regular"), BIG_TREE("Big tree", "big", "bigtree"), @@ -42,22 +43,25 @@ public class TreeGenerator { TALL_REDWOOD("Tall redwood", "tallredwood", "tallsequoia", "tallsequoioideae"), BIRCH("Birch", "birch", "white", "whitebark"), PINE("Pine", "pine") { + @Override public boolean generate(EditSession editSession, Vector pos) throws MaxChangedBlocksException { makePineTree(editSession, pos); return true; } }, RANDOM_REDWOOD("Random redwood", "randredwood", "randomredwood", "anyredwood") { + @Override public boolean generate(EditSession editSession, Vector pos) throws MaxChangedBlocksException { TreeType[] choices = new TreeType[] { TreeType.REDWOOD, TreeType.TALL_REDWOOD }; - return choices[rand.nextInt(choices.length)].generate(editSession, pos); + return choices[TreeGenerator.RANDOM.nextInt(choices.length)].generate(editSession, pos); } }, JUNGLE("Jungle", "jungle"), SMALL_JUNGLE("Small jungle", "shortjungle", "smalljungle"), SHORT_JUNGLE("Short jungle") { + @Override public boolean generate(EditSession editSession, Vector pos) throws MaxChangedBlocksException { return SMALL_JUNGLE.generate(editSession, pos); } @@ -71,12 +75,13 @@ public class TreeGenerator { MEGA_REDWOOD("Mega Redwood", "megaredwood"), TALL_BIRCH("Tall Birch", "tallbirch"), RANDOM("Random", "rand", "random") { + @Override public boolean generate(EditSession editSession, Vector pos) throws MaxChangedBlocksException { TreeType[] choices = new TreeType[] { TreeType.TREE, TreeType.BIG_TREE, TreeType.BIRCH, TreeType.REDWOOD, TreeType.TALL_REDWOOD, TreeType.PINE }; - return choices[rand.nextInt(choices.length)].generate(editSession, pos); + return choices[TreeGenerator.RANDOM.nextInt(choices.length)].generate(editSession, pos); } }; @@ -108,7 +113,7 @@ public class TreeGenerator { /** * Get user-friendly tree type name. * - * @return + * @return a name */ public String getName() { return name; @@ -117,22 +122,23 @@ public class TreeGenerator { /** * Return type from name. May return null. * - * @param name - * @return + * @param name name to search + * @return a tree type or null */ + @Nullable public static TreeType lookup(String name) { return lookup.get(name.toLowerCase()); } - }; + } - private static Random rand = new Random(); + private static final Random RANDOM = new Random(); private TreeType type; /** * Construct the tree generator with a tree type. * - * @param type + * @param type the tree type */ @Deprecated public TreeGenerator(TreeType type) { @@ -142,22 +148,21 @@ public class TreeGenerator { /** * Generate a tree. * - * @param editSession - * @param pos - * @return + * @param editSession the edit session + * @param position the position to generate the tree at + * @return true if generation was successful * @throws MaxChangedBlocksException */ - public boolean generate(EditSession editSession, Vector pos) - throws MaxChangedBlocksException { - return type.generate(editSession, pos); + public boolean generate(EditSession editSession, Vector position) throws MaxChangedBlocksException { + return type.generate(editSession, position); } /** * Makes a terrible looking pine tree. * - * @param basePos + * @param basePosition the base position */ - private static void makePineTree(EditSession editSession, Vector basePos) + private static void makePineTree(EditSession editSession, Vector basePosition) throws MaxChangedBlocksException { int trunkHeight = (int) Math.floor(Math.random() * 2) + 3; int height = (int) Math.floor(Math.random() * 5) + 8; @@ -167,58 +172,60 @@ public class TreeGenerator { // Create trunk for (int i = 0; i < trunkHeight; ++i) { - if (!editSession.setBlockIfAir(basePos.add(0, i, 0), logBlock)) { + if (!editSession.setBlockIfAir(basePosition.add(0, i, 0), logBlock)) { return; } } // Move up - basePos = basePos.add(0, trunkHeight, 0); + basePosition = basePosition.add(0, trunkHeight, 0); // Create tree + leaves for (int i = 0; i < height; ++i) { - editSession.setBlockIfAir(basePos.add(0, i, 0), logBlock); + editSession.setBlockIfAir(basePosition.add(0, i, 0), logBlock); // Less leaves at these levels double chance = ((i == 0 || i == height - 1) ? 0.6 : 1); // Inner leaves - editSession.setChanceBlockIfAir(basePos.add(-1, i, 0), leavesBlock, chance); - editSession.setChanceBlockIfAir(basePos.add(1, i, 0), leavesBlock, chance); - editSession.setChanceBlockIfAir(basePos.add(0, i, -1), leavesBlock, chance); - editSession.setChanceBlockIfAir(basePos.add(0, i, 1), leavesBlock, chance); - editSession.setChanceBlockIfAir(basePos.add(1, i, 1), leavesBlock, chance); - editSession.setChanceBlockIfAir(basePos.add(-1, i, 1), leavesBlock, chance); - editSession.setChanceBlockIfAir(basePos.add(1, i, -1), leavesBlock, chance); - editSession.setChanceBlockIfAir(basePos.add(-1, i, -1), leavesBlock, chance); + editSession.setChanceBlockIfAir(basePosition.add(-1, i, 0), leavesBlock, chance); + editSession.setChanceBlockIfAir(basePosition.add(1, i, 0), leavesBlock, chance); + editSession.setChanceBlockIfAir(basePosition.add(0, i, -1), leavesBlock, chance); + editSession.setChanceBlockIfAir(basePosition.add(0, i, 1), leavesBlock, chance); + editSession.setChanceBlockIfAir(basePosition.add(1, i, 1), leavesBlock, chance); + editSession.setChanceBlockIfAir(basePosition.add(-1, i, 1), leavesBlock, chance); + editSession.setChanceBlockIfAir(basePosition.add(1, i, -1), leavesBlock, chance); + editSession.setChanceBlockIfAir(basePosition.add(-1, i, -1), leavesBlock, chance); if (!(i == 0 || i == height - 1)) { for (int j = -2; j <= 2; ++j) { - editSession.setChanceBlockIfAir(basePos.add(-2, i, j), leavesBlock, 0.6); + editSession.setChanceBlockIfAir(basePosition.add(-2, i, j), leavesBlock, 0.6); } for (int j = -2; j <= 2; ++j) { - editSession.setChanceBlockIfAir(basePos.add(2, i, j), leavesBlock, 0.6); + editSession.setChanceBlockIfAir(basePosition.add(2, i, j), leavesBlock, 0.6); } for (int j = -2; j <= 2; ++j) { - editSession.setChanceBlockIfAir(basePos.add(j, i, -2), leavesBlock, 0.6); + editSession.setChanceBlockIfAir(basePosition.add(j, i, -2), leavesBlock, 0.6); } for (int j = -2; j <= 2; ++j) { - editSession.setChanceBlockIfAir(basePos.add(j, i, 2), leavesBlock, 0.6); + editSession.setChanceBlockIfAir(basePosition.add(j, i, 2), leavesBlock, 0.6); } } } - editSession.setBlockIfAir(basePos.add(0, height, 0), leavesBlock); + editSession.setBlockIfAir(basePosition.add(0, height, 0), leavesBlock); } /** * Looks up a tree type. May return null if a tree type by that * name is not found. * - * @param type - * @return + * @param type the tree type + * @return a tree type or null */ + @Nullable public static TreeType lookup(String type) { return TreeType.lookup(type); } + } diff --git a/src/main/java/com/sk89q/worldedit/util/YAMLConfiguration.java b/src/main/java/com/sk89q/worldedit/util/YAMLConfiguration.java index c800591c5..3110c5bf9 100644 --- a/src/main/java/com/sk89q/worldedit/util/YAMLConfiguration.java +++ b/src/main/java/com/sk89q/worldedit/util/YAMLConfiguration.java @@ -27,14 +27,15 @@ import com.sk89q.worldedit.world.snapshot.SnapshotRepository; import java.io.IOException; import java.util.HashSet; +import java.util.logging.Level; import java.util.logging.Logger; /** - * A less simple implementation of {@link LocalConfiguration} using YAML configuration files. - * - * @author sk89q + * A less simple implementation of {@link LocalConfiguration} + * using YAML configuration files. */ public class YAMLConfiguration extends LocalConfiguration { + protected final YAMLProcessor config; protected final Logger logger; @@ -48,8 +49,7 @@ public class YAMLConfiguration extends LocalConfiguration { try { config.load(); } catch (IOException e) { - logger.severe("Error loading WorldEdit configuration: " + e); - e.printStackTrace(); + logger.log(Level.WARNING, "Error loading WorldEdit configuration", e); } profile = config.getBoolean("debug", profile); @@ -112,7 +112,7 @@ public class YAMLConfiguration extends LocalConfiguration { showHelpInfo = config.getBoolean("show-help-on-first-use", true); String snapshotsDir = config.getString("snapshots.directory", ""); - if (snapshotsDir.length() > 0) { + if (!snapshotsDir.isEmpty()) { snapshotRepo = new SnapshotRepository(snapshotsDir); } @@ -123,4 +123,5 @@ public class YAMLConfiguration extends LocalConfiguration { public void unload() { } + } diff --git a/src/main/java/com/sk89q/worldedit/util/collection/DoubleArrayList.java b/src/main/java/com/sk89q/worldedit/util/collection/DoubleArrayList.java index 26f518d4e..f2b0a2539 100644 --- a/src/main/java/com/sk89q/worldedit/util/collection/DoubleArrayList.java +++ b/src/main/java/com/sk89q/worldedit/util/collection/DoubleArrayList.java @@ -29,28 +29,18 @@ import java.util.NoSuchElementException; /** * Double array lists to work like a Map, but not really. * - * @author sk89q - * @param - * @param + *

The usefulness of this class is highly questionable.

*/ public class DoubleArrayList implements Iterable> { - /** - * First list. - */ + private List
listA = new ArrayList(); - /** - * Second list. - */ private List listB = new ArrayList(); - /** - * Is reversed when iterating. - */ private boolean isReversed = false; /** * Construct the object. * - * @param isReversed + * @param isReversed true if the list should be reversed */ public DoubleArrayList(boolean isReversed) { this.isReversed = isReversed; @@ -59,8 +49,8 @@ public class DoubleArrayList implements Iterable> { /** * Add an item. * - * @param a - * @param b + * @param a the first item + * @param b the second item */ public void put(A a, B b) { listA.add(a); @@ -69,7 +59,8 @@ public class DoubleArrayList implements Iterable> { /** * Get size. - * @return + * + * @return count of objects */ public int size() { return listA.size(); @@ -86,7 +77,7 @@ public class DoubleArrayList implements Iterable> { /** * Get an entry set. * - * @return + * @return entry set */ public Iterator> iterator(boolean reversed) { if (reversed) { @@ -100,19 +91,13 @@ public class DoubleArrayList implements Iterable> { } } - /** - * Get an entry set. - * - * @return - */ + @Override public Iterator> iterator() { return iterator(isReversed); } /** * Entry iterator. - * - * @param */ public class ForwardEntryIterator> implements Iterator> { @@ -125,14 +110,17 @@ public class DoubleArrayList implements Iterable> { this.valueIterator = valueIterator; } + @Override public boolean hasNext() { return keyIterator.hasNext(); } + @Override public Map.Entry next() throws NoSuchElementException { return new Entry(keyIterator.next(), valueIterator.next()); } + @Override public void remove() { throw new UnsupportedOperationException(); } @@ -140,8 +128,6 @@ public class DoubleArrayList implements Iterable> { /** * Entry iterator. - * - * @param */ public class ReverseEntryIterator> implements Iterator> { @@ -154,14 +140,17 @@ public class DoubleArrayList implements Iterable> { this.valueIterator = valueIterator; } + @Override public boolean hasNext() { return keyIterator.hasPrevious(); } + @Override public Map.Entry next() throws NoSuchElementException { return new Entry(keyIterator.previous(), valueIterator.previous()); } + @Override public void remove() { throw new UnsupportedOperationException(); } @@ -169,9 +158,6 @@ public class DoubleArrayList implements Iterable> { /** * Class to masquerade as Map.Entry. - * - * @param - * @param */ public class Entry implements Map.Entry { private A key; @@ -182,16 +168,20 @@ public class DoubleArrayList implements Iterable> { this.value = value; } + @Override public A getKey() { return key; } + @Override public B getValue() { return value; } + @Override public B setValue(B value) { throw new UnsupportedOperationException(); } } + } diff --git a/src/main/java/com/sk89q/worldedit/util/collection/FastListIterator.java b/src/main/java/com/sk89q/worldedit/util/collection/FastListIterator.java index 688ce9e55..638de0194 100644 --- a/src/main/java/com/sk89q/worldedit/util/collection/FastListIterator.java +++ b/src/main/java/com/sk89q/worldedit/util/collection/FastListIterator.java @@ -30,12 +30,12 @@ import static com.google.common.base.Preconditions.checkNotNull; * A fast iterator for lists that uses an internal index integer * and caches the size of the list. The size of the list cannot change * during iteration and {@link Iterator#remove()} is not supported. - *

- * The iterator in Java, at least in older Java versions, is very slow, + * + *

The iterator in Java, at least in older Java versions, is very slow, * causing a significant amount of time in operations in WorldEdit * being spent on {@link Iterator#hasNext()}. In contrast, the iterator * implemented by this class is very quick, as long as - * {@link List#get(int)} is fast. + * {@link List#get(int)} is fast.

* * @param the element */ diff --git a/src/main/java/com/sk89q/worldedit/util/command/CommandCallable.java b/src/main/java/com/sk89q/worldedit/util/command/CommandCallable.java index 85b4133a0..e62b2260e 100644 --- a/src/main/java/com/sk89q/worldedit/util/command/CommandCallable.java +++ b/src/main/java/com/sk89q/worldedit/util/command/CommandCallable.java @@ -29,8 +29,9 @@ public interface CommandCallable extends CommandCompleter { /** * Execute the correct command based on the input. - *

- * The implementing class must perform the necessary permission checks. + * + *

The implementing class must perform the necessary permission + * checks.

* * @param arguments the arguments * @param locals the locals diff --git a/src/main/java/com/sk89q/worldedit/util/command/Description.java b/src/main/java/com/sk89q/worldedit/util/command/Description.java index 72e9fd5f0..5fe33702c 100644 --- a/src/main/java/com/sk89q/worldedit/util/command/Description.java +++ b/src/main/java/com/sk89q/worldedit/util/command/Description.java @@ -51,7 +51,7 @@ public interface Description { * Get the usage string of this command. * *

A usage string may look like - * [-w <world>] <var1> <var2>.

+ * {@code [-w <world>] <var1> <var2>}.

* * @return a usage string */ diff --git a/src/main/java/com/sk89q/worldedit/util/command/InvalidUsageException.java b/src/main/java/com/sk89q/worldedit/util/command/InvalidUsageException.java index 9795aaaef..f121a2fe8 100644 --- a/src/main/java/com/sk89q/worldedit/util/command/InvalidUsageException.java +++ b/src/main/java/com/sk89q/worldedit/util/command/InvalidUsageException.java @@ -27,17 +27,17 @@ import static com.google.common.base.Preconditions.checkNotNull; /** * Thrown when a command is not used properly. - *

- * When handling this exception, print the error message if it is not null. + * + *

When handling this exception, print the error message if it is not null. * Print a one line help instruction unless {@link #isFullHelpSuggested()} - * is true, which, in that case, the full help of the command should be shown. - *

- * If no error message is set and full help is not to be shown, then a generic - * "you used this command incorrectly" message should be shown. + * is true, which, in that case, the full help of the command should be + * shown.

+ * + *

If no error message is set and full help is not to be shown, then a generic + * "you used this command incorrectly" message should be shown.

*/ public class InvalidUsageException extends CommandException { - private static final long serialVersionUID = -3222004168669490390L; private final CommandCallable command; private final boolean fullHelpSuggested; diff --git a/src/main/java/com/sk89q/worldedit/util/command/MissingParameterException.java b/src/main/java/com/sk89q/worldedit/util/command/MissingParameterException.java index 8080929e3..bbdf0e0d5 100644 --- a/src/main/java/com/sk89q/worldedit/util/command/MissingParameterException.java +++ b/src/main/java/com/sk89q/worldedit/util/command/MissingParameterException.java @@ -25,7 +25,5 @@ import com.sk89q.worldedit.util.command.parametric.ParameterException; * Thrown when there is a missing parameter. */ public class MissingParameterException extends ParameterException { - - private static final long serialVersionUID = 2169299987926950535L; } diff --git a/src/main/java/com/sk89q/worldedit/util/command/SimpleDescription.java b/src/main/java/com/sk89q/worldedit/util/command/SimpleDescription.java index efd5aed95..74e386ec8 100644 --- a/src/main/java/com/sk89q/worldedit/util/command/SimpleDescription.java +++ b/src/main/java/com/sk89q/worldedit/util/command/SimpleDescription.java @@ -115,7 +115,7 @@ public class SimpleDescription implements Description { if (!first) { builder.append(" "); } - builder.append(parameter.toString()); + builder.append(parameter); first = false; } diff --git a/src/main/java/com/sk89q/worldedit/util/command/UnconsumedParameterException.java b/src/main/java/com/sk89q/worldedit/util/command/UnconsumedParameterException.java index 360a5408c..0a399f64d 100644 --- a/src/main/java/com/sk89q/worldedit/util/command/UnconsumedParameterException.java +++ b/src/main/java/com/sk89q/worldedit/util/command/UnconsumedParameterException.java @@ -26,8 +26,6 @@ import com.sk89q.worldedit.util.command.parametric.ParameterException; * case of the user providing too many parameters. */ public class UnconsumedParameterException extends ParameterException { - - private static final long serialVersionUID = 4449104854894946023L; private String unconsumed; diff --git a/src/main/java/com/sk89q/worldedit/util/command/binding/Switch.java b/src/main/java/com/sk89q/worldedit/util/command/binding/Switch.java index 34c25cad5..8d0e122ff 100644 --- a/src/main/java/com/sk89q/worldedit/util/command/binding/Switch.java +++ b/src/main/java/com/sk89q/worldedit/util/command/binding/Switch.java @@ -25,7 +25,7 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** - * Indicates a command flag, such as /command -f. + * Indicates a command flag, such as {@code /command -f}. * *

If used on a boolean type, then the flag will be a non-value flag. If * used on any other type, then the flag will be a value flag.

diff --git a/src/main/java/com/sk89q/worldedit/util/command/parametric/BindingBehavior.java b/src/main/java/com/sk89q/worldedit/util/command/parametric/BindingBehavior.java index e194bce56..eeef23dbd 100644 --- a/src/main/java/com/sk89q/worldedit/util/command/parametric/BindingBehavior.java +++ b/src/main/java/com/sk89q/worldedit/util/command/parametric/BindingBehavior.java @@ -47,6 +47,6 @@ public enum BindingBehavior { * such as from a {@link CommandLocals}. These are "magic" bindings that inject * variables.

*/ - PROVIDES; + PROVIDES } diff --git a/src/main/java/com/sk89q/worldedit/util/command/parametric/BindingHelper.java b/src/main/java/com/sk89q/worldedit/util/command/parametric/BindingHelper.java index b56c76426..a29d6ddd3 100644 --- a/src/main/java/com/sk89q/worldedit/util/command/parametric/BindingHelper.java +++ b/src/main/java/com/sk89q/worldedit/util/command/parametric/BindingHelper.java @@ -64,7 +64,7 @@ public class BindingHelper implements Binding { // Set classifier if (!info.classifier().equals(Annotation.class)) { - classifier = (Class) info.classifier(); + classifier = info.classifier(); types.add(classifier); } diff --git a/src/main/java/com/sk89q/worldedit/util/command/parametric/ExceptionConverterHelper.java b/src/main/java/com/sk89q/worldedit/util/command/parametric/ExceptionConverterHelper.java index 8a72f1a33..177e5a899 100644 --- a/src/main/java/com/sk89q/worldedit/util/command/parametric/ExceptionConverterHelper.java +++ b/src/main/java/com/sk89q/worldedit/util/command/parametric/ExceptionConverterHelper.java @@ -89,7 +89,7 @@ public abstract class ExceptionConverterHelper implements ExceptionConverter { final Class cls; final Method method; - public ExceptionHandler(Class cls, Method method) { + private ExceptionHandler(Class cls, Method method) { this.cls = cls; this.method = method; } diff --git a/src/main/java/com/sk89q/worldedit/util/command/parametric/ParameterException.java b/src/main/java/com/sk89q/worldedit/util/command/parametric/ParameterException.java index 8dc924f15..2fe681ba7 100644 --- a/src/main/java/com/sk89q/worldedit/util/command/parametric/ParameterException.java +++ b/src/main/java/com/sk89q/worldedit/util/command/parametric/ParameterException.java @@ -24,8 +24,6 @@ package com.sk89q.worldedit.util.command.parametric; */ public class ParameterException extends Exception { - private static final long serialVersionUID = -8255175019708245673L; - public ParameterException() { super(); } diff --git a/src/main/java/com/sk89q/worldedit/util/command/parametric/ParametricBuilder.java b/src/main/java/com/sk89q/worldedit/util/command/parametric/ParametricBuilder.java index c7b94ebde..822826fed 100644 --- a/src/main/java/com/sk89q/worldedit/util/command/parametric/ParametricBuilder.java +++ b/src/main/java/com/sk89q/worldedit/util/command/parametric/ParametricBuilder.java @@ -84,9 +84,9 @@ public class ParametricBuilder { * if this is not specific enough, an annotation can be defined and used. This * makes it a "classifier" and it will take precedence over the base type. For * example, even if there is a binding that handles {@link String} parameters, - * a special @MyArg annotation can be assigned to a {@link String} + * a special {@code @MyArg} annotation can be assigned to a {@link String} * parameter, which will cause the {@link Builder} to consult the {@link Binding} - * associated with @MyArg rather than with the binding for + * associated with {@code @MyArg} rather than with the binding for * the {@link String} type.

* * @param binding the binding diff --git a/src/main/java/com/sk89q/worldedit/util/command/parametric/ParametricException.java b/src/main/java/com/sk89q/worldedit/util/command/parametric/ParametricException.java index f2c826d73..346816330 100644 --- a/src/main/java/com/sk89q/worldedit/util/command/parametric/ParametricException.java +++ b/src/main/java/com/sk89q/worldedit/util/command/parametric/ParametricException.java @@ -25,8 +25,6 @@ package com.sk89q.worldedit.util.command.parametric; */ public class ParametricException extends RuntimeException { - private static final long serialVersionUID = -5426219576099680971L; - public ParametricException() { super(); } diff --git a/src/main/java/com/sk89q/worldedit/util/eventbus/AnnotatedSubscriberFinder.java b/src/main/java/com/sk89q/worldedit/util/eventbus/AnnotatedSubscriberFinder.java index f3b610a9e..03c001138 100644 --- a/src/main/java/com/sk89q/worldedit/util/eventbus/AnnotatedSubscriberFinder.java +++ b/src/main/java/com/sk89q/worldedit/util/eventbus/AnnotatedSubscriberFinder.java @@ -27,8 +27,8 @@ import java.lang.reflect.Method; /** * A {@link SubscriberFindingStrategy} for collecting all event handler methods * that are marked with the {@link Subscribe} annotation. - *

- * Original for Guava, licensed under the Apache License, Version 2.0. + * + *

Original for Guava, licensed under the Apache License, Version 2.0.

*/ class AnnotatedSubscriberFinder implements SubscriberFindingStrategy { diff --git a/src/main/java/com/sk89q/worldedit/util/eventbus/EventBus.java b/src/main/java/com/sk89q/worldedit/util/eventbus/EventBus.java index ef2b3691d..0ee7b7d65 100644 --- a/src/main/java/com/sk89q/worldedit/util/eventbus/EventBus.java +++ b/src/main/java/com/sk89q/worldedit/util/eventbus/EventBus.java @@ -36,13 +36,14 @@ import static com.google.common.base.Preconditions.checkNotNull; /** * Dispatches events to listeners, and provides ways for listeners to register * themselves. - *

- * This class is based on Guava's {@link EventBus} but priority is supported + * + *

This class is based on Guava's {@link EventBus} but priority is supported * and events are dispatched at the time of call, rather than being queued up. - * This does allow dispatching during an in-progress dispatch. - *

- * This implementation utilizes naive synchronization on all getter and setter - * methods. Dispatch does not occur when a lock has been acquired, however. + * This does allow dispatching during an in-progress dispatch.

+ * + *

This implementation utilizes naive synchronization on all getter and + * setter methods. Dispatch does not occur when a lock has been acquired, + * however.

*/ public class EventBus { diff --git a/src/main/java/com/sk89q/worldedit/util/eventbus/EventHandler.java b/src/main/java/com/sk89q/worldedit/util/eventbus/EventHandler.java index 31c5b3c1e..6488af945 100644 --- a/src/main/java/com/sk89q/worldedit/util/eventbus/EventHandler.java +++ b/src/main/java/com/sk89q/worldedit/util/eventbus/EventHandler.java @@ -26,8 +26,8 @@ import static com.google.common.base.Preconditions.checkNotNull; /** * Event handler object for {@link EventBus} that is able to dispatch * an event. - *

- * Original for Guava, licensed under the Apache License, Version 2.0. + * + *

Original for Guava, licensed under the Apache License, Version 2.0.

*/ public abstract class EventHandler implements Comparable { @@ -62,8 +62,8 @@ public abstract class EventHandler implements Comparable { /** * Dispatch the given event. - *

- * Subclasses should override {@link #dispatch(Object)}. + * + *

Subclasses should override {@link #dispatch(Object)}.

* * @param event the event * @throws InvocationTargetException thrown if an exception is thrown during dispatch diff --git a/src/main/java/com/sk89q/worldedit/util/eventbus/HierarchyCache.java b/src/main/java/com/sk89q/worldedit/util/eventbus/HierarchyCache.java index 7c0557c0a..31aeb1f53 100644 --- a/src/main/java/com/sk89q/worldedit/util/eventbus/HierarchyCache.java +++ b/src/main/java/com/sk89q/worldedit/util/eventbus/HierarchyCache.java @@ -26,10 +26,10 @@ import com.sk89q.worldedit.internal.annotation.RequiresNewerGuava; import java.util.*; /** - * Holds a cache of class hierarcy. - *

- * This exists because Bukkit has an ancient version of Guava and the cache - * library in Guava has since changed. + * Holds a cache of class hierarchy. + * + *

This exists because Bukkit has an ancient version of Guava and the cache + * library in Guava has since changed. */ @RequiresNewerGuava class HierarchyCache { diff --git a/src/main/java/com/sk89q/worldedit/util/eventbus/Subscribe.java b/src/main/java/com/sk89q/worldedit/util/eventbus/Subscribe.java index fc94f38e3..6616ea65e 100644 --- a/src/main/java/com/sk89q/worldedit/util/eventbus/Subscribe.java +++ b/src/main/java/com/sk89q/worldedit/util/eventbus/Subscribe.java @@ -29,7 +29,7 @@ import static java.lang.annotation.RetentionPolicy.*; * Used to mark methods as event handlers. */ @Retention(RUNTIME) -@Target({METHOD}) +@Target(METHOD) public @interface Subscribe { /** diff --git a/src/main/java/com/sk89q/worldedit/util/formatting/ColorCodeBuilder.java b/src/main/java/com/sk89q/worldedit/util/formatting/ColorCodeBuilder.java index a0b9a534c..c6bb755bd 100644 --- a/src/main/java/com/sk89q/worldedit/util/formatting/ColorCodeBuilder.java +++ b/src/main/java/com/sk89q/worldedit/util/formatting/ColorCodeBuilder.java @@ -61,7 +61,7 @@ public class ColorCodeBuilder { } else { StyleSet style = parentStyle.extend(message.getStyle()); builder.append(getAdditive(style, lastStyle)); - builder.append(node.toString()); + builder.append(node); lastStyle = style; } } @@ -102,7 +102,7 @@ public class ColorCodeBuilder { StringBuilder builder = new StringBuilder(); builder.append(getFormattingCode(style)); if (style.getColor() != null) { - builder.append(style.getColor().toString()); + builder.append(style.getColor()); } return builder.toString(); } @@ -236,7 +236,7 @@ public class ColorCodeBuilder { } // Iterate over the wrapped lines, applying the last color from one line to the beginning of the next - if (lines.get(0).length() == 0 || lines.get(0).charAt(0) != Style.COLOR_CHAR) { + if (lines.get(0).isEmpty() || lines.get(0).charAt(0) != Style.COLOR_CHAR) { lines.set(0, Style.WHITE + lines.get(0)); } for (int i = 1; i < lines.size(); i++) { @@ -244,7 +244,7 @@ public class ColorCodeBuilder { final String subLine = lines.get(i); char color = pLine.charAt(pLine.lastIndexOf(Style.COLOR_CHAR) + 1); - if (subLine.length() == 0 || subLine.charAt(0) != Style.COLOR_CHAR) { + if (subLine.isEmpty() || subLine.charAt(0) != Style.COLOR_CHAR) { lines.set(i, Style.getByChar(color) + subLine); } } diff --git a/src/main/java/com/sk89q/worldedit/util/formatting/Style.java b/src/main/java/com/sk89q/worldedit/util/formatting/Style.java index 3eafd3c8d..c6fd71ddb 100644 --- a/src/main/java/com/sk89q/worldedit/util/formatting/Style.java +++ b/src/main/java/com/sk89q/worldedit/util/formatting/Style.java @@ -127,7 +127,7 @@ public enum Style { * convert color codes from your custom format. */ public static final char COLOR_CHAR = '\u00A7'; - private static final Pattern STRIP_COLOR_PATTERN = Pattern.compile("(?i)" + String.valueOf(COLOR_CHAR) + "[0-9A-FK-OR]"); + private static final Pattern STRIP_COLOR_PATTERN = Pattern.compile("(?i)" + COLOR_CHAR + "[0-9A-FK-OR]"); private final int intCode; private final char code; @@ -254,10 +254,10 @@ public enum Style { Style color = getByChar(c); if (color != null) { - result = color.toString() + result; + result = color + result; // Once we find a color or reset we can stop searching - if (color.isColor() || color.equals(RESET)) { + if (color.isColor() || color == RESET) { break; } } diff --git a/src/main/java/com/sk89q/worldedit/util/formatting/StyleSet.java b/src/main/java/com/sk89q/worldedit/util/formatting/StyleSet.java index 35663fa9e..408dc1e43 100644 --- a/src/main/java/com/sk89q/worldedit/util/formatting/StyleSet.java +++ b/src/main/java/com/sk89q/worldedit/util/formatting/StyleSet.java @@ -74,7 +74,7 @@ public class StyleSet { * @return true if bold */ public boolean isBold() { - return getBold() != null && getBold() == true; + return getBold() != null && getBold(); } /** @@ -101,7 +101,7 @@ public class StyleSet { * @return true if italicized */ public boolean isItalic() { - return getItalic() != null && getItalic() == true; + return getItalic() != null && getItalic(); } /** @@ -128,7 +128,7 @@ public class StyleSet { * @return true if underlined */ public boolean isUnderline() { - return getUnderline() != null && getUnderline() == true; + return getUnderline() != null && getUnderline(); } /** @@ -155,7 +155,7 @@ public class StyleSet { * @return true if there is strikethrough applied */ public boolean isStrikethrough() { - return getStrikethrough() != null && getStrikethrough() == true; + return getStrikethrough() != null && getStrikethrough(); } /** diff --git a/src/main/java/com/sk89q/worldedit/util/formatting/StyledFragment.java b/src/main/java/com/sk89q/worldedit/util/formatting/StyledFragment.java index 7674d9bf8..eaa4293cc 100644 --- a/src/main/java/com/sk89q/worldedit/util/formatting/StyledFragment.java +++ b/src/main/java/com/sk89q/worldedit/util/formatting/StyledFragment.java @@ -57,7 +57,7 @@ public class StyledFragment extends Fragment { protected Fragment lastText() { Fragment text; - if (children.size() > 0) { + if (!children.isEmpty()) { text = children.get(children.size() - 1); if (text == lastText) { return text; diff --git a/src/main/java/com/sk89q/worldedit/util/function/LevenshteinDistance.java b/src/main/java/com/sk89q/worldedit/util/function/LevenshteinDistance.java index 8767f3a2f..723db8123 100644 --- a/src/main/java/com/sk89q/worldedit/util/function/LevenshteinDistance.java +++ b/src/main/java/com/sk89q/worldedit/util/function/LevenshteinDistance.java @@ -114,7 +114,7 @@ public class LevenshteinDistance implements Function { * @param s the first String, must not be null * @param t the second String, must not be null * @return result distance - * @throws IllegalArgumentException if either String input null + * @throws IllegalArgumentException if either String input {@code null} */ public static int distance(String s, String t) { if (s == null || t == null) { @@ -150,9 +150,9 @@ public class LevenshteinDistance implements Function { return n; } - int p[] = new int[n + 1]; // 'previous' cost array, horizontally - int d[] = new int[n + 1]; // cost array, horizontally - int _d[]; // placeholder to assist in swapping p and d + int[] p = new int[n + 1]; // 'previous' cost array, horizontally + int[] d = new int[n + 1]; // cost array, horizontally + int[] _d; // placeholder to assist in swapping p and d // indexes into strings s and t int i; // iterates through s diff --git a/src/main/java/com/sk89q/worldedit/util/io/file/FileSelectionAbortedException.java b/src/main/java/com/sk89q/worldedit/util/io/file/FileSelectionAbortedException.java index e25c79002..e16dbca1a 100644 --- a/src/main/java/com/sk89q/worldedit/util/io/file/FileSelectionAbortedException.java +++ b/src/main/java/com/sk89q/worldedit/util/io/file/FileSelectionAbortedException.java @@ -20,7 +20,6 @@ package com.sk89q.worldedit.util.io.file; public class FileSelectionAbortedException extends FilenameException { - private static final long serialVersionUID = 7377072269988014886L; public FileSelectionAbortedException() { super(""); @@ -29,4 +28,5 @@ public class FileSelectionAbortedException extends FilenameException { public FileSelectionAbortedException(String msg) { super("", msg); } + } diff --git a/src/main/java/com/sk89q/worldedit/util/io/file/FilenameException.java b/src/main/java/com/sk89q/worldedit/util/io/file/FilenameException.java index 1c585a0cc..d79ec24f4 100644 --- a/src/main/java/com/sk89q/worldedit/util/io/file/FilenameException.java +++ b/src/main/java/com/sk89q/worldedit/util/io/file/FilenameException.java @@ -22,7 +22,6 @@ package com.sk89q.worldedit.util.io.file; import com.sk89q.worldedit.WorldEditException; public class FilenameException extends WorldEditException { - private static final long serialVersionUID = 6072601657326106265L; private String filename; @@ -39,4 +38,5 @@ public class FilenameException extends WorldEditException { public String getFilename() { return filename; } + } diff --git a/src/main/java/com/sk89q/worldedit/util/io/file/FilenameResolutionException.java b/src/main/java/com/sk89q/worldedit/util/io/file/FilenameResolutionException.java index b214795cb..743affd23 100644 --- a/src/main/java/com/sk89q/worldedit/util/io/file/FilenameResolutionException.java +++ b/src/main/java/com/sk89q/worldedit/util/io/file/FilenameResolutionException.java @@ -20,7 +20,6 @@ package com.sk89q.worldedit.util.io.file; public class FilenameResolutionException extends FilenameException { - private static final long serialVersionUID = 4673670296313383121L; public FilenameResolutionException(String filename) { super(filename); @@ -29,4 +28,5 @@ public class FilenameResolutionException extends FilenameException { public FilenameResolutionException(String filename, String msg) { super(filename, msg); } + } diff --git a/src/main/java/com/sk89q/worldedit/util/io/file/InvalidFilenameException.java b/src/main/java/com/sk89q/worldedit/util/io/file/InvalidFilenameException.java index 73a3b9d46..867eb3539 100644 --- a/src/main/java/com/sk89q/worldedit/util/io/file/InvalidFilenameException.java +++ b/src/main/java/com/sk89q/worldedit/util/io/file/InvalidFilenameException.java @@ -20,7 +20,6 @@ package com.sk89q.worldedit.util.io.file; public class InvalidFilenameException extends FilenameException { - private static final long serialVersionUID = 7377072269988014886L; public InvalidFilenameException(String filename) { super(filename); @@ -29,4 +28,5 @@ public class InvalidFilenameException extends FilenameException { public InvalidFilenameException(String filename, String msg) { super(filename, msg); } + } diff --git a/src/main/java/com/sk89q/worldedit/util/logging/LogFormat.java b/src/main/java/com/sk89q/worldedit/util/logging/LogFormat.java index c605b6a3a..e37284ff8 100644 --- a/src/main/java/com/sk89q/worldedit/util/logging/LogFormat.java +++ b/src/main/java/com/sk89q/worldedit/util/logging/LogFormat.java @@ -55,7 +55,7 @@ public class LogFormat extends Formatter { if (t != null) { StringWriter writer = new StringWriter(); t.printStackTrace(new PrintWriter(writer)); - text.append(writer.toString()); + text.append(writer); } return text.toString(); diff --git a/src/main/java/com/sk89q/worldedit/world/AbstractWorld.java b/src/main/java/com/sk89q/worldedit/world/AbstractWorld.java index b51a1cac8..7a9d27e70 100644 --- a/src/main/java/com/sk89q/worldedit/world/AbstractWorld.java +++ b/src/main/java/com/sk89q/worldedit/world/AbstractWorld.java @@ -226,7 +226,8 @@ public abstract class AbstractWorld implements World { private final Vector position; private final int blockId; private final double priority; - public QueuedEffect(Vector position, int blockId, double priority) { + + private QueuedEffect(Vector position, int blockId, double priority) { this.position = position; this.blockId = blockId; this.priority = priority; diff --git a/src/main/java/com/sk89q/worldedit/world/DataException.java b/src/main/java/com/sk89q/worldedit/world/DataException.java index b75cf5193..d44964007 100644 --- a/src/main/java/com/sk89q/worldedit/world/DataException.java +++ b/src/main/java/com/sk89q/worldedit/world/DataException.java @@ -21,11 +21,8 @@ package com.sk89q.worldedit.world; /** * Thrown when there is an exception related to data handling. - * - * @author sk89q */ public class DataException extends Exception { - private static final long serialVersionUID = 5806521052111023788L; public DataException(String msg) { super(msg); @@ -34,4 +31,5 @@ public class DataException extends Exception { public DataException() { super(); } + } diff --git a/src/main/java/com/sk89q/worldedit/world/NbtValued.java b/src/main/java/com/sk89q/worldedit/world/NbtValued.java index 02a3db0cc..50262730d 100644 --- a/src/main/java/com/sk89q/worldedit/world/NbtValued.java +++ b/src/main/java/com/sk89q/worldedit/world/NbtValued.java @@ -24,27 +24,29 @@ import com.sk89q.jnbt.CompoundTag; import javax.annotation.Nullable; /** - * Indicates an object that contains extra data identified as an NBT structure. This - * interface is used when saving and loading objects to a serialized format, but may - * be used in other cases. + * Indicates an object that contains extra data identified as an NBT structure. + * This interface is used when saving and loading objects to a serialized + * format, but may be used in other cases. */ public interface NbtValued { /** - * Returns whether the block contains NBT data. {@link #getNbtData()} must not return - * null if this method returns true. + * Returns whether the block contains NBT data. {@link #getNbtData()} + * must not return null if this method returns true. * * @return true if there is NBT data */ public boolean hasNbtData(); /** - * Get the object's NBT data (tile entity data). The returned tag, if modified - * in any way, should be sent to {@link #setNbtData(CompoundTag)} so that - * the instance knows of the changes. Making changes without calling - * {@link #setNbtData(CompoundTag)} could have unintended consequences. + * Get the object's NBT data (tile entity data). The returned tag, if + * modified in any way, should be sent to {@link #setNbtData(CompoundTag)} + * so that the instance knows of the changes. Making changes without + * calling {@link #setNbtData(CompoundTag)} could have unintended + * consequences. * - *

{@link #hasNbtData()} must return true if and only if method does not return null.

+ *

{@link #hasNbtData()} must return true if and only if method does + * not return null.

* * @return compound tag, or null */ diff --git a/src/main/java/com/sk89q/worldedit/world/World.java b/src/main/java/com/sk89q/worldedit/world/World.java index 657f510e3..03e70ff7a 100644 --- a/src/main/java/com/sk89q/worldedit/world/World.java +++ b/src/main/java/com/sk89q/worldedit/world/World.java @@ -72,8 +72,9 @@ public interface World extends Extent { /** * Create a mask that matches all liquids. - *

- * Implementations should override this so that custom liquids are supported. + * + *

Implementations should override this so that custom liquids + * are supported.

* * @return a mask */ @@ -96,13 +97,13 @@ public interface World extends Extent { * {@code notifyAndLight} parameter indicates whether adjacent blocks * should be notified that changes have been made and lighting operations * should be executed. - *

- * If it's not possible to skip lighting, or if it's not possible to + * + *

If it's not possible to skip lighting, or if it's not possible to * avoid notifying adjacent blocks, then attempt to meet the - * specification as best as possible. - *

- * On implementations where the world is not simulated, the - * {@code notifyAndLight} parameter has no effect either way. + * specification as best as possible.

+ * + *

On implementations where the world is not simulated, the + * {@code notifyAndLight} parameter has no effect either way.

* * @param position position of the block * @param block block to set @@ -229,12 +230,12 @@ public interface World extends Extent { /** * Fix the given chunks after fast mode was used. - *

- * Fast mode makes calls to {@link #setBlock(Vector, BaseBlock, boolean)} + * + *

Fast mode makes calls to {@link #setBlock(Vector, BaseBlock, boolean)} * with {@code false} for the {@code notifyAndLight} parameter, which * may causes lighting errors to accumulate. Use of this method, if * it is implemented by the underlying world, corrects those lighting - * errors and may trigger block change notifications. + * errors and may trigger block change notifications.

* * @param chunks a list of chunk coordinates to fix */ diff --git a/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk.java b/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk.java index 497935a7f..15a93f575 100644 --- a/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk.java +++ b/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk.java @@ -19,7 +19,13 @@ package com.sk89q.worldedit.world.chunk; -import com.sk89q.jnbt.*; +import com.sk89q.jnbt.ByteArrayTag; +import com.sk89q.jnbt.ByteTag; +import com.sk89q.jnbt.CompoundTag; +import com.sk89q.jnbt.IntTag; +import com.sk89q.jnbt.ListTag; +import com.sk89q.jnbt.NBTUtils; +import com.sk89q.jnbt.Tag; import com.sk89q.worldedit.BlockVector; import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.blocks.BaseBlock; @@ -28,6 +34,7 @@ import com.sk89q.worldedit.world.DataException; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.storage.InvalidFormatException; +import javax.annotation.Nullable; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -93,38 +100,38 @@ public class AnvilChunk implements Chunk { } int sectionsize = 16 * 16 * 16; - for (int i = 0; i < blocks.length; i++) { - if (blocks[i].length != sectionsize) { + for (byte[] block : blocks) { + if (block.length != sectionsize) { throw new InvalidFormatException( "Chunk blocks byte array expected " + "to be " + sectionsize + " bytes; found " - + blocks[i].length); + + block.length); } } - for (int i = 0; i < data.length; i++) { - if (data[i].length != (sectionsize / 2)) { + for (byte[] aData : data) { + if (aData.length != (sectionsize / 2)) { throw new InvalidFormatException("Chunk block data byte array " + "expected to be " + sectionsize + " bytes; found " - + data[i].length); + + aData.length); } } } @Override - public int getBlockID(Vector pos) throws DataException { - int x = pos.getBlockX() - rootX * 16; - int y = pos.getBlockY(); - int z = pos.getBlockZ() - rootZ * 16; + public int getBlockID(Vector position) throws DataException { + int x = position.getBlockX() - rootX * 16; + int y = position.getBlockY(); + int z = position.getBlockZ() - rootZ * 16; int section = y >> 4; if (section < 0 || section >= blocks.length) { - throw new DataException("Chunk does not contain position " + pos); + throw new DataException("Chunk does not contain position " + position); } int yindex = y & 0x0F; if (yindex < 0 || yindex >= 16) { - throw new DataException("Chunk does not contain position " + pos); + throw new DataException("Chunk does not contain position " + position); } int index = x + (z * 16 + (yindex * 16 * 16)); @@ -144,25 +151,25 @@ public class AnvilChunk implements Chunk { return (blocks[section][index] & 0xFF) + addId; } catch (IndexOutOfBoundsException e) { - throw new DataException("Chunk does not contain position " + pos); + throw new DataException("Chunk does not contain position " + position); } } @Override - public int getBlockData(Vector pos) throws DataException { - int x = pos.getBlockX() - rootX * 16; - int y = pos.getBlockY(); - int z = pos.getBlockZ() - rootZ * 16; + public int getBlockData(Vector position) throws DataException { + int x = position.getBlockX() - rootX * 16; + int y = position.getBlockY(); + int z = position.getBlockZ() - rootZ * 16; int section = y >> 4; int yIndex = y & 0x0F; if (section < 0 || section >= blocks.length) { - throw new DataException("Chunk does not contain position " + pos); + throw new DataException("Chunk does not contain position " + position); } if (yIndex < 0 || yIndex >= 16) { - throw new DataException("Chunk does not contain position " + pos); + throw new DataException("Chunk does not contain position " + position); } int index = x + (z * 16 + (yIndex * 16 * 16)); @@ -176,7 +183,7 @@ public class AnvilChunk implements Chunk { return data[section][index] & 0xF; } } catch (IndexOutOfBoundsException e) { - throw new DataException("Chunk does not contain position " + pos); + throw new DataException("Chunk does not contain position " + position); } } @@ -233,26 +240,28 @@ public class AnvilChunk implements Chunk { * return null if there is no tile entity data. Not public yet because * what this function returns isn't ideal for usage. * - * @param pos - * @return - * @throws DataException + * @param position the position + * @return the compound tag for that position, which may be null + * @throws DataException thrown if there is a data error */ - private CompoundTag getBlockTileEntity(Vector pos) throws DataException { + @Nullable + private CompoundTag getBlockTileEntity(Vector position) throws DataException { if (tileEntities == null) { populateTileEntities(); } - Map values = tileEntities.get(new BlockVector(pos)); + Map values = tileEntities.get(new BlockVector(position)); if (values == null) { return null; } + return new CompoundTag("", values); } @Override - public BaseBlock getBlock(Vector pos) throws DataException { - int id = getBlockID(pos); - int data = getBlockData(pos); + public BaseBlock getBlock(Vector position) throws DataException { + int id = getBlockID(position); + int data = getBlockData(position); BaseBlock block; /*if (id == BlockID.WALL_SIGN || id == BlockID.SIGN_POST) { @@ -271,11 +280,9 @@ public class AnvilChunk implements Chunk { block = new BaseBlock(id, data); //} - if (block instanceof TileEntityBlock) { - CompoundTag tileEntity = getBlockTileEntity(pos); - if (tileEntity != null) { - ((TileEntityBlock) block).setNbtData(tileEntity); - } + CompoundTag tileEntity = getBlockTileEntity(position); + if (tileEntity != null) { + ((TileEntityBlock) block).setNbtData(tileEntity); } return block; diff --git a/src/main/java/com/sk89q/worldedit/world/chunk/Chunk.java b/src/main/java/com/sk89q/worldedit/world/chunk/Chunk.java index 71cd44627..03eff63be 100644 --- a/src/main/java/com/sk89q/worldedit/world/chunk/Chunk.java +++ b/src/main/java/com/sk89q/worldedit/world/chunk/Chunk.java @@ -23,33 +23,37 @@ import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.world.DataException; +/** + * A 16 by 16 block chunk. + */ public interface Chunk { /** * Get the block ID of a block. * - * @param pos - * @return - * @throws DataException + * @param position the position of the block + * @return the type ID of the block + * @throws DataException thrown on data error */ - public int getBlockID(Vector pos) throws DataException; + public int getBlockID(Vector position) throws DataException; /** * Get the block data of a block. * - * @param pos - * @return - * @throws DataException + * @param position the position of the block + * @return the data value of the block + * @throws DataException thrown on data error */ - public int getBlockData(Vector pos) throws DataException; + public int getBlockData(Vector position) throws DataException; /** * Get a block; * - * @param pos - * @return block - * @throws DataException + * @param position the position of the block + * @return block the block + * @throws DataException thrown on data error */ - public BaseBlock getBlock(Vector pos) throws DataException; + public BaseBlock getBlock(Vector position) throws DataException; + } diff --git a/src/main/java/com/sk89q/worldedit/world/chunk/OldChunk.java b/src/main/java/com/sk89q/worldedit/world/chunk/OldChunk.java index 4996ba399..d92bb1bda 100644 --- a/src/main/java/com/sk89q/worldedit/world/chunk/OldChunk.java +++ b/src/main/java/com/sk89q/worldedit/world/chunk/OldChunk.java @@ -19,11 +19,15 @@ package com.sk89q.worldedit.world.chunk; -import com.sk89q.jnbt.*; +import com.sk89q.jnbt.ByteArrayTag; +import com.sk89q.jnbt.CompoundTag; +import com.sk89q.jnbt.IntTag; +import com.sk89q.jnbt.ListTag; +import com.sk89q.jnbt.NBTUtils; +import com.sk89q.jnbt.Tag; import com.sk89q.worldedit.BlockVector; import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.blocks.BaseBlock; -import com.sk89q.worldedit.blocks.TileEntityBlock; import com.sk89q.worldedit.world.DataException; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.storage.InvalidFormatException; @@ -33,11 +37,10 @@ import java.util.List; import java.util.Map; /** - * Represents a chunk. - * - * @author sk89q + * Represents an Alpha chunk. */ public class OldChunk implements Chunk { + private CompoundTag rootTag; private byte[] blocks; private byte[] data; @@ -45,19 +48,16 @@ public class OldChunk implements Chunk { private int rootZ; private Map> tileEntities; - @SuppressWarnings("unused") - private World world; // TODO: remove if stays unused. /** * Construct the chunk with a compound tag. * - * @param tag + * @param world the world + * @param tag the tag * @throws DataException */ public OldChunk(World world, CompoundTag tag) throws DataException { rootTag = tag; - this.world = world; - blocks = NBTUtils.getChildTag(rootTag.getValue(), "Blocks", ByteArrayTag.class).getValue(); data = NBTUtils.getChildTag(rootTag.getValue(), "Data", ByteArrayTag.class).getValue(); @@ -77,27 +77,27 @@ public class OldChunk implements Chunk { } @Override - public int getBlockID(Vector pos) throws DataException { - if(pos.getBlockY() >= 128) return 0; + public int getBlockID(Vector position) throws DataException { + if(position.getBlockY() >= 128) return 0; - int x = pos.getBlockX() - rootX * 16; - int y = pos.getBlockY(); - int z = pos.getBlockZ() - rootZ * 16; + int x = position.getBlockX() - rootX * 16; + int y = position.getBlockY(); + int z = position.getBlockZ() - rootZ * 16; int index = y + (z * 128 + (x * 128 * 16)); try { return blocks[index]; } catch (IndexOutOfBoundsException e) { - throw new DataException("Chunk does not contain position " + pos); + throw new DataException("Chunk does not contain position " + position); } } @Override - public int getBlockData(Vector pos) throws DataException { - if(pos.getBlockY() >= 128) return 0; + public int getBlockData(Vector position) throws DataException { + if(position.getBlockY() >= 128) return 0; - int x = pos.getBlockX() - rootX * 16; - int y = pos.getBlockY(); - int z = pos.getBlockZ() - rootZ * 16; + int x = position.getBlockX() - rootX * 16; + int y = position.getBlockY(); + int z = position.getBlockZ() - rootZ * 16; int index = y + (z * 128 + (x * 128 * 16)); boolean shift = index % 2 == 0; index /= 2; @@ -109,7 +109,7 @@ public class OldChunk implements Chunk { return data[index] & 0xF; } } catch (IndexOutOfBoundsException e) { - throw new DataException("Chunk does not contain position " + pos); + throw new DataException("Chunk does not contain position " + position); } } @@ -166,16 +166,16 @@ public class OldChunk implements Chunk { * return null if there is no tile entity data. Not public yet because * what this function returns isn't ideal for usage. * - * @param pos - * @return + * @param position the position + * @return a tag * @throws DataException */ - private CompoundTag getBlockTileEntity(Vector pos) throws DataException { + private CompoundTag getBlockTileEntity(Vector position) throws DataException { if (tileEntities == null) { populateTileEntities(); } - Map values = tileEntities.get(new BlockVector(pos)); + Map values = tileEntities.get(new BlockVector(position)); if (values == null) { return null; } @@ -183,9 +183,9 @@ public class OldChunk implements Chunk { } @Override - public BaseBlock getBlock(Vector pos) throws DataException { - int id = getBlockID(pos); - int data = getBlockData(pos); + public BaseBlock getBlock(Vector position) throws DataException { + int id = getBlockID(position); + int data = getBlockData(position); BaseBlock block; /*if (id == BlockID.WALL_SIGN || id == BlockID.SIGN_POST) { @@ -204,11 +204,9 @@ public class OldChunk implements Chunk { block = new BaseBlock(id, data); //} - if (block instanceof TileEntityBlock) { - CompoundTag tileEntity = getBlockTileEntity(pos); - if (tileEntity != null) { - ((TileEntityBlock) block).setNbtData(tileEntity); - } + CompoundTag tileEntity = getBlockTileEntity(position); + if (tileEntity != null) { + block.setNbtData(tileEntity); } return block; diff --git a/src/main/java/com/sk89q/worldedit/world/registry/EntityRegistry.java b/src/main/java/com/sk89q/worldedit/world/registry/EntityRegistry.java index 787585327..2a3830134 100644 --- a/src/main/java/com/sk89q/worldedit/world/registry/EntityRegistry.java +++ b/src/main/java/com/sk89q/worldedit/world/registry/EntityRegistry.java @@ -20,8 +20,6 @@ package com.sk89q.worldedit.world.registry; import com.sk89q.worldedit.entity.BaseEntity; -import com.sk89q.worldedit.entity.Entity; -import com.sk89q.worldedit.entity.metadata.EntityType; import javax.annotation.Nullable; diff --git a/src/main/java/com/sk89q/worldedit/world/snapshot/InvalidSnapshotException.java b/src/main/java/com/sk89q/worldedit/world/snapshot/InvalidSnapshotException.java index 30171acfb..54ef58d3f 100644 --- a/src/main/java/com/sk89q/worldedit/world/snapshot/InvalidSnapshotException.java +++ b/src/main/java/com/sk89q/worldedit/world/snapshot/InvalidSnapshotException.java @@ -19,11 +19,6 @@ package com.sk89q.worldedit.world.snapshot; -/** - * - * @author sk89q - */ public class InvalidSnapshotException extends Exception { - private static final long serialVersionUID = 7307139106494852893L; } diff --git a/src/main/java/com/sk89q/worldedit/world/snapshot/ModificationTimerParser.java b/src/main/java/com/sk89q/worldedit/world/snapshot/ModificationTimerParser.java index 970fd006e..cc4f54225 100644 --- a/src/main/java/com/sk89q/worldedit/world/snapshot/ModificationTimerParser.java +++ b/src/main/java/com/sk89q/worldedit/world/snapshot/ModificationTimerParser.java @@ -25,6 +25,7 @@ import java.util.GregorianCalendar; public class ModificationTimerParser implements SnapshotDateParser { + @Override public Calendar detectDate(File file) { Calendar cal = new GregorianCalendar(); cal.setTimeInMillis(file.lastModified()); diff --git a/src/main/java/com/sk89q/worldedit/world/snapshot/Snapshot.java b/src/main/java/com/sk89q/worldedit/world/snapshot/Snapshot.java index 9793521fa..d087b5b28 100644 --- a/src/main/java/com/sk89q/worldedit/world/snapshot/Snapshot.java +++ b/src/main/java/com/sk89q/worldedit/world/snapshot/Snapshot.java @@ -30,30 +30,21 @@ import java.util.logging.Logger; import java.util.zip.ZipFile; /** - * - * @author sk89q + * A snapshot is a backup. */ public class Snapshot implements Comparable { - protected static Logger logger = Logger.getLogger("Minecraft.WorldEdit"); - /** - * Stores snapshot file. - */ + protected static Logger logger = Logger.getLogger(Snapshot.class.getCanonicalName()); + protected File file; - /** - * Name of the snapshot; - */ protected String name; - /** - * Stores the date associated with the snapshot. - */ protected Calendar date; /** * Construct a snapshot restoration operation. * - * @param repo - * @param snapshot + * @param repo a repository + * @param snapshot a snapshot name */ public Snapshot(SnapshotRepository repo, String snapshot) { file = new File(repo.getDirectory(), snapshot); @@ -63,7 +54,7 @@ public class Snapshot implements Comparable { /** * Get a chunk store. * - * @return + * @return a chunk store * @throws IOException * @throws DataException */ @@ -79,7 +70,7 @@ public class Snapshot implements Comparable { /** * Get a chunk store. * - * @return + * @return a chunk store * @throws IOException * @throws DataException */ @@ -165,7 +156,7 @@ public class Snapshot implements Comparable { /** * Get the snapshot's name. * - * @return + * @return the name of the snapshot */ public String getName() { return name; @@ -174,7 +165,7 @@ public class Snapshot implements Comparable { /** * Get the file for the snapshot. * - * @return + * @return path to the snapshot */ public File getFile() { return file; @@ -183,7 +174,7 @@ public class Snapshot implements Comparable { /** * Get the date associated with this snapshot. * - * @return + * @return date for the snapshot */ public Calendar getDate() { return date; @@ -192,12 +183,13 @@ public class Snapshot implements Comparable { /** * Set the date of the snapshot. * - * @param date + * @param date the date of the snapshot */ public void setDate(Calendar date) { this.date = date; } + @Override public int compareTo(Snapshot o) { if (o.date == null || date == null) { // Remove the folder from the name @@ -210,10 +202,7 @@ public class Snapshot implements Comparable { @Override public boolean equals(Object o) { - if (o instanceof Snapshot) { - return file.equals(((Snapshot) o).file); - } - return false; + return o instanceof Snapshot && file.equals(((Snapshot) o).file); } @Override diff --git a/src/main/java/com/sk89q/worldedit/world/snapshot/SnapshotDateParser.java b/src/main/java/com/sk89q/worldedit/world/snapshot/SnapshotDateParser.java index 71321103b..b3d499148 100644 --- a/src/main/java/com/sk89q/worldedit/world/snapshot/SnapshotDateParser.java +++ b/src/main/java/com/sk89q/worldedit/world/snapshot/SnapshotDateParser.java @@ -19,20 +19,22 @@ package com.sk89q.worldedit.world.snapshot; +import javax.annotation.Nullable; import java.io.File; import java.util.Calendar; /** * A name parser attempts to make sense of a filename for a snapshot. - * - * @author sk89q */ public interface SnapshotDateParser { + /** * Attempt to detect a date from a file. * - * @param file + * @param file the file * @return date or null */ + @Nullable public Calendar detectDate(File file); + } diff --git a/src/main/java/com/sk89q/worldedit/world/snapshot/SnapshotRepository.java b/src/main/java/com/sk89q/worldedit/world/snapshot/SnapshotRepository.java index a7f14cd27..0b6ede080 100644 --- a/src/main/java/com/sk89q/worldedit/world/snapshot/SnapshotRepository.java +++ b/src/main/java/com/sk89q/worldedit/world/snapshot/SnapshotRepository.java @@ -21,6 +21,9 @@ package com.sk89q.worldedit.world.snapshot; +import com.sk89q.worldedit.world.storage.MissingWorldException; + +import javax.annotation.Nullable; import java.io.File; import java.io.FilenameFilter; import java.util.ArrayList; @@ -28,31 +31,23 @@ import java.util.Calendar; import java.util.Collections; import java.util.List; -import com.sk89q.worldedit.world.storage.MissingWorldException; - /** - * - * @author sk89q + * A repository contains zero or more snapshots. */ public class SnapshotRepository { - /** - * Stores the directory the snapshots come from. - */ protected File dir; - /** - * List of date parsers. - */ protected List dateParsers = new ArrayList(); /** * Create a new instance of a repository. * - * @param dir + * @param dir the directory */ public SnapshotRepository(File dir) { this.dir = dir; - // If folder dont exist, make it. + + // If folder doesn't exist, make it dir.mkdirs(); dateParsers.add(new YYMMDDHHIISSParser()); @@ -62,7 +57,7 @@ public class SnapshotRepository { /** * Create a new instance of a repository. * - * @param dir + * @param dir the directory */ public SnapshotRepository(String dir) { this(new File(dir)); @@ -72,10 +67,10 @@ public class SnapshotRepository { * Get a list of snapshots in a directory. The newest snapshot is * near the top of the array. * - * @param newestFirst - * @return + * @param newestFirst true to get the newest first + * @return a list of snapshots */ - public List getSnapshots(boolean newestFirst, String worldname) throws MissingWorldException { + public List getSnapshots(boolean newestFirst, String worldName) throws MissingWorldException { FilenameFilter filter = new FilenameFilter() { @Override public boolean accept(File dir, String name) { @@ -86,18 +81,18 @@ public class SnapshotRepository { File[] snapshotFiles = dir.listFiles(); if (snapshotFiles == null) { - throw new MissingWorldException(worldname); + throw new MissingWorldException(worldName); } List list = new ArrayList(snapshotFiles.length); for (File file : snapshotFiles) { if (isValidSnapshot(file)) { Snapshot snapshot = new Snapshot(this, file.getName()); - if (snapshot.containsWorld(worldname)) { + if (snapshot.containsWorld(worldName)) { detectDate(snapshot); list.add(snapshot); } - } else if (file.isDirectory() && file.getName().equalsIgnoreCase(worldname)) { + } else if (file.isDirectory() && file.getName().equalsIgnoreCase(worldName)) { for (String name : file.list(filter)) { Snapshot snapshot = new Snapshot(this, file.getName() + "/" + name); detectDate(snapshot); @@ -118,16 +113,16 @@ public class SnapshotRepository { /** * Get the first snapshot after a date. * - * @param date - * @return + * @param date a date + * @return a snapshot or null */ + @Nullable public Snapshot getSnapshotAfter(Calendar date, String world) throws MissingWorldException { List snapshots = getSnapshots(true, world); Snapshot last = null; for (Snapshot snapshot : snapshots) { - if (snapshot.getDate() != null - && snapshot.getDate().before(date)) { + if (snapshot.getDate() != null && snapshot.getDate().before(date)) { return last; } @@ -140,9 +135,10 @@ public class SnapshotRepository { /** * Get the first snapshot before a date. * - * @param date - * @return + * @param date a date + * @return a snapshot or null */ + @Nullable public Snapshot getSnapshotBefore(Calendar date, String world) throws MissingWorldException { List snapshots = getSnapshots(false, world); Snapshot last = null; @@ -161,7 +157,7 @@ public class SnapshotRepository { /** * Attempt to detect a snapshot's date and assign it. * - * @param snapshot + * @param snapshot the snapshot */ protected void detectDate(Snapshot snapshot) { for (SnapshotDateParser parser : dateParsers) { @@ -178,12 +174,14 @@ public class SnapshotRepository { /** * Get the default snapshot. * - * @return + * @param world the world name + * @return a snapshot or null */ + @Nullable public Snapshot getDefaultSnapshot(String world) throws MissingWorldException { List snapshots = getSnapshots(true, world); - if (snapshots.size() == 0) { + if (snapshots.isEmpty()) { return null; } @@ -193,7 +191,7 @@ public class SnapshotRepository { /** * Check to see if a snapshot is valid. * - * @param snapshot + * @param snapshot a snapshot name * @return whether it is a valid snapshot */ public boolean isValidSnapshotName(String snapshot) { @@ -203,27 +201,27 @@ public class SnapshotRepository { /** * Check to see if a snapshot is valid. * - * @param f + * @param file the file to the snapshot * @return whether it is a valid snapshot */ - protected boolean isValidSnapshot(File f) { - if (!f.getName().matches("^[A-Za-z0-9_\\- \\./\\\\'\\$@~!%\\^\\*\\(\\)\\[\\]\\+\\{\\},\\?]+$")) { + protected boolean isValidSnapshot(File file) { + if (!file.getName().matches("^[A-Za-z0-9_\\- \\./\\\\'\\$@~!%\\^\\*\\(\\)\\[\\]\\+\\{\\},\\?]+$")) { return false; } - return (f.isDirectory() && (new File(f, "level.dat")).exists()) - || (f.isFile() && (f.getName().toLowerCase().endsWith(".zip") - || f.getName().toLowerCase().endsWith(".tar.bz2") - || f.getName().toLowerCase().endsWith(".tar.gz") - || f.getName().toLowerCase().endsWith(".tar"))); + return (file.isDirectory() && (new File(file, "level.dat")).exists()) + || (file.isFile() && (file.getName().toLowerCase().endsWith(".zip") + || file.getName().toLowerCase().endsWith(".tar.bz2") + || file.getName().toLowerCase().endsWith(".tar.gz") + || file.getName().toLowerCase().endsWith(".tar"))); } /** * Get a snapshot. * - * @param name - * @return - * @throws InvalidSnapshotException + * @param name the name of the snapshot + * @return a snapshot + * @throws InvalidSnapshotException if the snapshot is invalid */ public Snapshot getSnapshot(String name) throws InvalidSnapshotException { if (!isValidSnapshotName(name)) { @@ -236,9 +234,10 @@ public class SnapshotRepository { /** * Get the snapshot directory. * - * @return + * @return a path */ public File getDirectory() { return dir; } + } diff --git a/src/main/java/com/sk89q/worldedit/world/snapshot/SnapshotRestore.java b/src/main/java/com/sk89q/worldedit/world/snapshot/SnapshotRestore.java index 68e93213d..ca636e007 100644 --- a/src/main/java/com/sk89q/worldedit/world/snapshot/SnapshotRestore.java +++ b/src/main/java/com/sk89q/worldedit/world/snapshot/SnapshotRestore.java @@ -40,34 +40,15 @@ import java.util.List; import java.util.Map; /** - * - * @author sk89q + * A snapshot restore operation. */ public class SnapshotRestore { - /** - * Store a list of chunks that are needed and the points in them. - */ - private final Map> neededChunks = - new LinkedHashMap>(); - /** - * Chunk store. - */ + + private final Map> neededChunks = new LinkedHashMap>(); private final ChunkStore chunkStore; - /** - * Edit session. - */ private final EditSession editSession; - /** - * Count of the number of missing chunks. - */ private ArrayList missingChunks; - /** - * Count of the number of chunks that could be loaded for other reasons. - */ private ArrayList errorChunks; - /** - * Last error message. - */ private String lastErrorMessage; /** @@ -139,7 +120,7 @@ public class SnapshotRestore { /** * Get the number of chunks that are needed. * - * @return + * @return a number of chunks */ public int getChunksAffected() { return neededChunks.size(); @@ -192,7 +173,7 @@ public class SnapshotRestore { * Get a list of the missing chunks. restore() must have been called * already. * - * @return + * @return a list of coordinates */ public List getMissingChunks() { return missingChunks; @@ -202,7 +183,7 @@ public class SnapshotRestore { * Get a list of the chunks that could not have been loaded for other * reasons. restore() must have been called already. * - * @return + * @return a list of coordinates */ public List getErrorChunks() { return errorChunks; @@ -212,16 +193,19 @@ public class SnapshotRestore { * Checks to see where the backup succeeded in any capacity. False will * be returned if no chunk could be successfully loaded. * - * @return + * @return true if there was total failure */ public boolean hadTotalFailure() { return missingChunks.size() + errorChunks.size() == getChunksAffected(); } /** - * @return the lastErrorMessage + * Get the last error message. + * + * @return a message */ public String getLastErrorMessage() { return lastErrorMessage; } + } diff --git a/src/main/java/com/sk89q/worldedit/world/snapshot/YYMMDDHHIISSParser.java b/src/main/java/com/sk89q/worldedit/world/snapshot/YYMMDDHHIISSParser.java index b5383518e..3356f71f6 100644 --- a/src/main/java/com/sk89q/worldedit/world/snapshot/YYMMDDHHIISSParser.java +++ b/src/main/java/com/sk89q/worldedit/world/snapshot/YYMMDDHHIISSParser.java @@ -31,6 +31,7 @@ public class YYMMDDHHIISSParser implements SnapshotDateParser { Pattern.compile("([0-9]+)[^0-9]?([0-9]+)[^0-9]?([0-9]+)[^0-9]?" + "([0-9]+)[^0-9]?([0-9]+)[^0-9]?([0-9]+)"); + @Override public Calendar detectDate(File file) { Matcher matcher = patt.matcher(file.getName()); if (matcher.matches()) { diff --git a/src/main/java/com/sk89q/worldedit/world/storage/BlockData.java b/src/main/java/com/sk89q/worldedit/world/storage/BlockData.java index ef9c94931..3df632d76 100644 --- a/src/main/java/com/sk89q/worldedit/world/storage/BlockData.java +++ b/src/main/java/com/sk89q/worldedit/world/storage/BlockData.java @@ -25,19 +25,19 @@ import com.sk89q.worldedit.CuboidClipboard.FlipDirection; * Block data related classes. * * @deprecated use {@link com.sk89q.worldedit.blocks.BlockData} - * @author sk89q */ @Deprecated public final class BlockData { + private BlockData() { } /** * Rotate a block's data value 90 degrees (north->east->south->west->north); * - * @param type - * @param data - * @return + * @param type type ID of the block + * @param data data value of the block + * @return a new data value * @deprecated use {@link com.sk89q.worldedit.blocks.BlockData#rotate90(int, int)} */ @Deprecated @@ -47,10 +47,10 @@ public final class BlockData { /** * Rotate a block's data value -90 degrees (north<-east<-south<-west<-north); - * - * @param type - * @param data - * @return + * + * @param type type ID of the block + * @param data data value of the block + * @return a new data value * @deprecated use {@link com.sk89q.worldedit.blocks.BlockData#rotate90Reverse(int, int)} */ @Deprecated @@ -60,10 +60,10 @@ public final class BlockData { /** * Flip a block's data value. - * - * @param type - * @param data - * @return + * + * @param type type ID of the block + * @param data data value of the block + * @return a new data value * @deprecated use return {@link com.sk89q.worldedit.blocks.BlockData#flip(int, int)} */ @Deprecated @@ -73,11 +73,11 @@ public final class BlockData { /** * Flip a block's data value. - * - * @param type - * @param data - * @param direction - * @return + * + * @param type type ID of the block + * @param data data value of the block + * @param direction the direction to flip + * @return a new data value * @deprecated use {@link com.sk89q.worldedit.blocks.BlockData#flip(int, int, FlipDirection)} */ @Deprecated @@ -104,8 +104,9 @@ public final class BlockData { /** * Returns the data value for the next color of cloth in the rainbow. This * should not be used if you want to just increment the data value. - * @param data - * @return + * + * @param data the data value + * @return a new data value * @deprecated use {@link com.sk89q.worldedit.blocks.BlockData#nextClothColor(int)} */ @Deprecated @@ -116,12 +117,15 @@ public final class BlockData { /** * Returns the data value for the previous ext color of cloth in the rainbow. * This should not be used if you want to just increment the data value. - * @param data - * @return + * + * @param data the data value + * @return a new data value * @deprecated use {@link com.sk89q.worldedit.blocks.BlockData#prevClothColor(int)} */ @Deprecated public static int prevClothColor(int data) { return com.sk89q.worldedit.blocks.BlockData.prevClothColor(data); } + + } diff --git a/src/main/java/com/sk89q/worldedit/world/storage/ChunkStore.java b/src/main/java/com/sk89q/worldedit/world/storage/ChunkStore.java index bf24dc068..57296cc3e 100644 --- a/src/main/java/com/sk89q/worldedit/world/storage/ChunkStore.java +++ b/src/main/java/com/sk89q/worldedit/world/storage/ChunkStore.java @@ -35,24 +35,24 @@ import java.util.Map; /** * Represents chunk storage mechanisms. - * - * @author sk89q */ public abstract class ChunkStore { + /** * >> to chunk * << from chunk */ public static final int CHUNK_SHIFTS = 4; + /** * Convert a position to a chunk. * - * @param pos - * @return + * @param position the position + * @return chunk coordinates */ - public static BlockVector2D toChunk(Vector pos) { - int chunkX = (int) Math.floor(pos.getBlockX() / 16.0); - int chunkZ = (int) Math.floor(pos.getBlockZ() / 16.0); + public static BlockVector2D toChunk(Vector position) { + int chunkX = (int) Math.floor(position.getBlockX() / 16.0); + int chunkZ = (int) Math.floor(position.getBlockZ() / 16.0); return new BlockVector2D(chunkX, chunkZ); } @@ -60,46 +60,45 @@ public abstract class ChunkStore { /** * Get the tag for a chunk. * - * @param pos + * @param position the position of the chunk * @return tag - * @throws DataException - * @throws IOException + * @throws DataException thrown on data error + * @throws IOException thrown on I/O error */ - public abstract CompoundTag getChunkTag(Vector2D pos, World world) - throws DataException, IOException; + public abstract CompoundTag getChunkTag(Vector2D position, World world) throws DataException, IOException; /** * Get a chunk at a location. * - * @param pos - * @return - * @throws ChunkStoreException - * @throws IOException - * @throws DataException + * @param position the position of the chunk + * @return a chunk + * @throws ChunkStoreException thrown if there is an error from the chunk store + * @throws DataException thrown on data error + * @throws IOException thrown on I/O error */ - public Chunk getChunk(Vector2D pos, World world) throws DataException, IOException { - - CompoundTag tag = getChunkTag(pos, world); + public Chunk getChunk(Vector2D position, World world) throws DataException, IOException { + CompoundTag tag = getChunkTag(position, world); Map tags = tag.getValue(); - if(tags.containsKey("Sections")) { + if (tags.containsKey("Sections")) { return new AnvilChunk(world, tag); } + return new OldChunk(world, tag); } /** * Close resources. * - * @throws IOException + * @throws IOException on I/O error */ public void close() throws IOException { - } /** * Returns whether the chunk store is of this type. * - * @return + * @return true if valid */ public abstract boolean isValid(); + } diff --git a/src/main/java/com/sk89q/worldedit/world/storage/ChunkStoreException.java b/src/main/java/com/sk89q/worldedit/world/storage/ChunkStoreException.java index 350655b07..67bcfe898 100644 --- a/src/main/java/com/sk89q/worldedit/world/storage/ChunkStoreException.java +++ b/src/main/java/com/sk89q/worldedit/world/storage/ChunkStoreException.java @@ -21,12 +21,7 @@ package com.sk89q.worldedit.world.storage; import com.sk89q.worldedit.world.DataException; -/** - * - * @author sk89q - */ public class ChunkStoreException extends DataException { - private static final long serialVersionUID = 1483900743779953289L; public ChunkStoreException(String msg) { super(msg); @@ -35,4 +30,5 @@ public class ChunkStoreException extends DataException { public ChunkStoreException() { super(); } + } diff --git a/src/main/java/com/sk89q/worldedit/world/storage/FileLegacyChunkStore.java b/src/main/java/com/sk89q/worldedit/world/storage/FileLegacyChunkStore.java index d9b6ffbac..605eaa9f5 100644 --- a/src/main/java/com/sk89q/worldedit/world/storage/FileLegacyChunkStore.java +++ b/src/main/java/com/sk89q/worldedit/world/storage/FileLegacyChunkStore.java @@ -28,21 +28,17 @@ import java.io.IOException; import java.io.InputStream; /** - * Represents the chunk store used by Minecraft alpha. - * - * @author sk89q + * Represents the chunk store used by Minecraft Alpha. */ public class FileLegacyChunkStore extends LegacyChunkStore { - /** - * Folder to read from. - */ + private File path; /** * Create an instance. The passed path is the folder to read the * chunk files from. * - * @param path + * @param path path to a folder */ public FileLegacyChunkStore(File path) { this.path = path; @@ -51,16 +47,15 @@ public class FileLegacyChunkStore extends LegacyChunkStore { /** * Get the input stream for a chunk file. * - * @param f1 - * @param f2 - * @param name - * @return + * @param f1 the first part of the pathname + * @param f2 the second part of the pathname + * @param name the name of the file + * @return an input stream * @throws DataException * @throws IOException */ @Override - protected InputStream getInputStream(String f1, String f2, String name) - throws DataException, IOException { + protected InputStream getInputStream(String f1, String f2, String name) throws DataException, IOException { String file = f1 + File.separator + f2 + File.separator + name; try { return new FileInputStream(new File(path, file)); @@ -73,4 +68,5 @@ public class FileLegacyChunkStore extends LegacyChunkStore { public boolean isValid() { return true; // Yeah, oh well } + } diff --git a/src/main/java/com/sk89q/worldedit/world/storage/FileMcRegionChunkStore.java b/src/main/java/com/sk89q/worldedit/world/storage/FileMcRegionChunkStore.java index fae1894d3..69f18dec0 100644 --- a/src/main/java/com/sk89q/worldedit/world/storage/FileMcRegionChunkStore.java +++ b/src/main/java/com/sk89q/worldedit/world/storage/FileMcRegionChunkStore.java @@ -29,27 +29,30 @@ import java.io.InputStream; import java.util.regex.Pattern; public class FileMcRegionChunkStore extends McRegionChunkStore { - /** - * Folder to read from. - */ + private File path; /** * Create an instance. The passed path is the folder to read the * chunk files from. * - * @param path + * @param path a path */ public FileMcRegionChunkStore(File path) { this.path = path; } @Override - protected InputStream getInputStream(String name, String world) throws IOException, - DataException { + protected InputStream getInputStream(String name, String world) throws IOException, DataException { Pattern ext = Pattern.compile(".*\\.mc[ra]$"); // allow either file extension, both work the same File file = null; - for (File f : new File(path, "region" + File.separator).listFiles()) { + File[] files = new File(path, "region").listFiles(); + + if (files == null) { + throw new FileNotFoundException(); + } + + for (File f : files) { String tempName = f.getName().replaceFirst("mcr$", "mca"); // matcher only does one at a time if (ext.matcher(f.getName()).matches() && name.equalsIgnoreCase(tempName)) { // get full original path now diff --git a/src/main/java/com/sk89q/worldedit/world/storage/InvalidFormatException.java b/src/main/java/com/sk89q/worldedit/world/storage/InvalidFormatException.java index 9fceae352..4216e15f0 100644 --- a/src/main/java/com/sk89q/worldedit/world/storage/InvalidFormatException.java +++ b/src/main/java/com/sk89q/worldedit/world/storage/InvalidFormatException.java @@ -21,14 +21,10 @@ package com.sk89q.worldedit.world.storage; import com.sk89q.worldedit.world.DataException; -/** - * - * @author sk89q - */ public class InvalidFormatException extends DataException { - private static final long serialVersionUID = -3401820540902726145L; public InvalidFormatException(String msg) { super(msg); } + } diff --git a/src/main/java/com/sk89q/worldedit/world/storage/LegacyChunkStore.java b/src/main/java/com/sk89q/worldedit/world/storage/LegacyChunkStore.java index 3a4c73119..1a2eb46c9 100644 --- a/src/main/java/com/sk89q/worldedit/world/storage/LegacyChunkStore.java +++ b/src/main/java/com/sk89q/worldedit/world/storage/LegacyChunkStore.java @@ -36,20 +36,19 @@ import java.util.zip.GZIPInputStream; * Represents chunk stores that use Alpha's file format for storing chunks. * The code to resolve the filename is already implemented in this class * and an inheriting class merely needs to implement getInputStream(). - * - * @author sk89q */ public abstract class LegacyChunkStore extends ChunkStore { + /** * Get the filename of a chunk. * - * @param pos - * @param separator - * @return + * @param position chunk position + * @param separator folder separator character + * @return pathname */ - public static String getFilename(Vector2D pos, String separator) { - int x = pos.getBlockX(); - int z = pos.getBlockZ(); + public static String getFilename(Vector2D position, String separator) { + int x = position.getBlockX(); + int z = position.getBlockZ(); String folder1 = Integer.toString(divisorMod(x, 64), 36); String folder2 = Integer.toString(divisorMod(z, 64), 36); @@ -63,25 +62,17 @@ public abstract class LegacyChunkStore extends ChunkStore { * Get the filename of a chunk, using the system's default path * separator. * - * @param pos - * @return + * @param position chunk position + * @return pathname */ - public static String getFilename(Vector2D pos) { - return getFilename(pos, File.separator); + public static String getFilename(Vector2D position) { + return getFilename(position, File.separator); } - /** - * Get the tag for a chunk. - * - * @param pos - * @return tag - * @throws DataException - * @throws IOException - */ @Override - public CompoundTag getChunkTag(Vector2D pos, World world) throws DataException, IOException { - int x = pos.getBlockX(); - int z = pos.getBlockZ(); + public CompoundTag getChunkTag(Vector2D position, World world) throws DataException, IOException { + int x = position.getBlockX(); + int z = position.getBlockZ(); String folder1 = Integer.toString(divisorMod(x, 64), 36); String folder2 = Integer.toString(divisorMod(z, 64), 36); @@ -100,7 +91,7 @@ public abstract class LegacyChunkStore extends ChunkStore { + tag.getClass().getName()); } - Map children = (Map) ((CompoundTag) tag).getValue(); + Map children = ((CompoundTag) tag).getValue(); CompoundTag rootTag = null; // Find Level tag @@ -126,13 +117,6 @@ public abstract class LegacyChunkStore extends ChunkStore { } } - /** - * Modulus, divisor-style. - * - * @param a - * @param n - * @return - */ private static int divisorMod(int a, int n) { return (int) (a - n * Math.floor(Math.floor(a) / (double) n)); } @@ -140,12 +124,12 @@ public abstract class LegacyChunkStore extends ChunkStore { /** * Get the input stream for a chunk file. * - * @param f1 - * @param f2 - * @param name - * @return + * @param f1 the first part of the path + * @param f2 the second part of the path + * @param name the name + * @return an input stream * @throws IOException */ - protected abstract InputStream getInputStream(String f1, String f2, String name) - throws IOException, DataException; + protected abstract InputStream getInputStream(String f1, String f2, String name) throws IOException, DataException; + } diff --git a/src/main/java/com/sk89q/worldedit/world/storage/McRegionChunkStore.java b/src/main/java/com/sk89q/worldedit/world/storage/McRegionChunkStore.java index 4350c2060..fd564752a 100644 --- a/src/main/java/com/sk89q/worldedit/world/storage/McRegionChunkStore.java +++ b/src/main/java/com/sk89q/worldedit/world/storage/McRegionChunkStore.java @@ -31,22 +31,21 @@ import java.io.InputStream; import java.util.Map; public abstract class McRegionChunkStore extends ChunkStore { + protected String curFilename = null; protected McRegionReader cachedReader = null; /** * Get the filename of a region file. * - * @param pos - * @return + * @param position chunk position + * @return the filename */ - public static String getFilename(Vector2D pos) { - int x = pos.getBlockX(); - int z = pos.getBlockZ(); + public static String getFilename(Vector2D position) { + int x = position.getBlockX(); + int z = position.getBlockZ(); - String filename = "r." + (x >> 5) + "." + (z >> 5) + ".mca"; - - return filename; + return "r." + (x >> 5) + "." + (z >> 5) + ".mca"; } protected McRegionReader getReader(Vector2D pos, String worldname) throws DataException, IOException { @@ -57,7 +56,7 @@ public abstract class McRegionChunkStore extends ChunkStore { } else { try { cachedReader.close(); - } catch (IOException e) { + } catch (IOException ignored) { } } } @@ -68,22 +67,20 @@ public abstract class McRegionChunkStore extends ChunkStore { } @Override - public CompoundTag getChunkTag(Vector2D pos, World world) throws DataException, IOException { - - McRegionReader reader = getReader(pos, world.getName()); + public CompoundTag getChunkTag(Vector2D position, World world) throws DataException, IOException { + McRegionReader reader = getReader(position, world.getName()); - InputStream stream = reader.getChunkInputStream(pos); + InputStream stream = reader.getChunkInputStream(position); NBTInputStream nbt = new NBTInputStream(stream); Tag tag; try { tag = nbt.readTag(); if (!(tag instanceof CompoundTag)) { - throw new ChunkStoreException("CompoundTag expected for chunk; got " - + tag.getClass().getName()); + throw new ChunkStoreException("CompoundTag expected for chunk; got " + tag.getClass().getName()); } - Map children = (Map) ((CompoundTag) tag).getValue(); + Map children = ((CompoundTag) tag).getValue(); CompoundTag rootTag = null; // Find Level tag @@ -93,8 +90,7 @@ public abstract class McRegionChunkStore extends ChunkStore { rootTag = (CompoundTag) entry.getValue(); break; } else { - throw new ChunkStoreException("CompoundTag expected for 'Level'; got " - + entry.getValue().getClass().getName()); + throw new ChunkStoreException("CompoundTag expected for 'Level'; got " + entry.getValue().getClass().getName()); } } } @@ -112,22 +108,18 @@ public abstract class McRegionChunkStore extends ChunkStore { /** * Get the input stream for a chunk file. * - * @param name - * @return + * @param name the name of the chunk file + * @param worldName the world name + * @return an input stream * @throws IOException */ - protected abstract InputStream getInputStream(String name, String worldname) - throws IOException, DataException; + protected abstract InputStream getInputStream(String name, String worldName) throws IOException, DataException; - /** - * Close resources. - * - * @throws IOException - */ @Override public void close() throws IOException { if (cachedReader != null) { cachedReader.close(); } } + } diff --git a/src/main/java/com/sk89q/worldedit/world/storage/McRegionReader.java b/src/main/java/com/sk89q/worldedit/world/storage/McRegionReader.java index 71c2fc780..6f4509267 100644 --- a/src/main/java/com/sk89q/worldedit/world/storage/McRegionReader.java +++ b/src/main/java/com/sk89q/worldedit/world/storage/McRegionReader.java @@ -55,6 +55,10 @@ package com.sk89q.worldedit.world.storage; +import com.sk89q.worldedit.Vector2D; +import com.sk89q.worldedit.util.io.ForwardSeekableInputStream; +import com.sk89q.worldedit.world.DataException; + import java.io.ByteArrayInputStream; import java.io.DataInputStream; import java.io.IOException; @@ -62,15 +66,9 @@ import java.io.InputStream; import java.util.zip.GZIPInputStream; import java.util.zip.InflaterInputStream; -import com.sk89q.worldedit.Vector2D; -import com.sk89q.worldedit.util.io.ForwardSeekableInputStream; -import com.sk89q.worldedit.world.DataException; - /** * Reader for a MCRegion file. This reader works on input streams, meaning * that it can be used to read files from non-file based sources. - * - * @author sk89q */ public class McRegionReader { @@ -83,12 +81,12 @@ public class McRegionReader { protected ForwardSeekableInputStream stream; protected DataInputStream dataStream; - protected int offsets[]; + protected int[] offsets; /** * Construct the reader. * - * @param stream + * @param stream the stream * @throws DataException * @throws IOException */ @@ -117,16 +115,14 @@ public class McRegionReader { /** * Gets the uncompressed data input stream for a chunk. * - * @param pos - * @return + * @param position chunk position + * @return an input stream * @throws IOException * @throws DataException */ - public synchronized InputStream getChunkInputStream(Vector2D pos) - throws IOException, DataException { - - int x = pos.getBlockX() & 31; - int z = pos.getBlockZ() & 31; + public synchronized InputStream getChunkInputStream(Vector2D position) throws IOException, DataException { + int x = position.getBlockX() & 31; + int z = position.getBlockZ() & 31; if (x < 0 || x >= 32 || z < 0 || z >= 32) { throw new DataException("MCRegion file does not contain " + x + "," + z); @@ -175,9 +171,9 @@ public class McRegionReader { /** * Get the offset for a chunk. May return 0 if it doesn't exist. * - * @param x - * @param z - * @return + * @param x the X coordinate + * @param z the Z coordinate + * @return the offset */ private int getOffset(int x, int z) { return offsets[x + z * 32]; @@ -185,10 +181,10 @@ public class McRegionReader { /** * Returns whether the file contains a chunk. - * - * @param x - * @param z - * @return + * + * @param x the X coordinate + * @param z the Z coordinate + * @return the offset */ public boolean hasChunk(int x, int z) { return getOffset(x, z) != 0; @@ -196,8 +192,6 @@ public class McRegionReader { /** * Close the stream. - * - * @throws IOException */ public void close() throws IOException { stream.close(); diff --git a/src/main/java/com/sk89q/worldedit/world/storage/MissingChunkException.java b/src/main/java/com/sk89q/worldedit/world/storage/MissingChunkException.java index f5e78b1d4..0ed5c0554 100644 --- a/src/main/java/com/sk89q/worldedit/world/storage/MissingChunkException.java +++ b/src/main/java/com/sk89q/worldedit/world/storage/MissingChunkException.java @@ -22,29 +22,28 @@ package com.sk89q.worldedit.world.storage; import com.sk89q.worldedit.Vector2D; /** - * - * @author sk89q + * Thrown if a chunk is missing. */ public class MissingChunkException extends ChunkStoreException { - private static final long serialVersionUID = 8013715483709973489L; - private Vector2D pos; + private Vector2D position; public MissingChunkException() { super(); } - public MissingChunkException(Vector2D pos) { + public MissingChunkException(Vector2D position) { super(); - this.pos = pos; + this.position = position; } /** * Get chunk position in question. May be null if unknown. * - * @return + * @return a chunk position */ public Vector2D getChunkPosition() { - return pos; + return position; } + } diff --git a/src/main/java/com/sk89q/worldedit/world/storage/MissingWorldException.java b/src/main/java/com/sk89q/worldedit/world/storage/MissingWorldException.java index 97b442444..0dc65cf97 100644 --- a/src/main/java/com/sk89q/worldedit/world/storage/MissingWorldException.java +++ b/src/main/java/com/sk89q/worldedit/world/storage/MissingWorldException.java @@ -19,36 +19,36 @@ package com.sk89q.worldedit.world.storage; +import javax.annotation.Nullable; + /** - * - * @author sk89q + * Thrown if the world is missing. */ public class MissingWorldException extends ChunkStoreException { - private static final long serialVersionUID = 6487395784195658467L; - - private String worldname; + private String worldName; public MissingWorldException() { super(); } - public MissingWorldException(String worldname) { + public MissingWorldException(String worldName) { super(); - this.worldname = worldname; + this.worldName = worldName; } - public MissingWorldException(String msg, String worldname) { + public MissingWorldException(String msg, String worldName) { super(msg); - this.worldname = worldname; + this.worldName = worldName; } /** * Get name of the world in question. May be null if unknown. * - * @return + * @return the world name */ - public String getWorldname() { - return worldname; + @Nullable + public String getWorldName() { + return worldName; } } diff --git a/src/main/java/com/sk89q/worldedit/world/storage/TrueZipLegacyChunkStore.java b/src/main/java/com/sk89q/worldedit/world/storage/TrueZipLegacyChunkStore.java index 48f7f9f94..33e59f590 100644 --- a/src/main/java/com/sk89q/worldedit/world/storage/TrueZipLegacyChunkStore.java +++ b/src/main/java/com/sk89q/worldedit/world/storage/TrueZipLegacyChunkStore.java @@ -19,36 +19,25 @@ package com.sk89q.worldedit.world.storage; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.util.regex.Pattern; -import java.util.zip.ZipException; -import java.util.Enumeration; - import com.sk89q.worldedit.world.DataException; import de.schlichtherle.util.zip.ZipEntry; import de.schlichtherle.util.zip.ZipFile; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.util.Enumeration; +import java.util.regex.Pattern; +import java.util.zip.ZipException; + /** * Represents the chunk store used by Minecraft alpha but zipped. Uses * the replacement classes for java.util.zip.* from TrueZip. - * - * @author sk89q */ public class TrueZipLegacyChunkStore extends LegacyChunkStore { - /** - * ZIP file. - */ - @SuppressWarnings("unused") + private File zipFile; - /** - * Actual ZIP. - */ private ZipFile zip; - /** - * Folder inside the ZIP file to read from, if any. - */ private String folder; /** @@ -56,13 +45,12 @@ public class TrueZipLegacyChunkStore extends LegacyChunkStore { * path to look into in the ZIP for the files. Use a blank string for * the folder to not look into a subdirectory. * - * @param zipFile - * @param folder + * @param zipFile the ZIP file to open + * @param folder the folder to look into in the ZIP * @throws IOException * @throws ZipException */ - public TrueZipLegacyChunkStore(File zipFile, String folder) - throws IOException, ZipException { + public TrueZipLegacyChunkStore(File zipFile, String folder) throws IOException, ZipException { this.zipFile = zipFile; this.folder = folder; @@ -70,15 +58,14 @@ public class TrueZipLegacyChunkStore extends LegacyChunkStore { } /** - * Create an instance. The subfolder containing the chunk data will + * Create an instance. The subf-older containing the chunk data will * be detected. * - * @param zipFile + * @param zipFile the ZIP file to open * @throws IOException * @throws ZipException */ - public TrueZipLegacyChunkStore(File zipFile) - throws IOException, ZipException { + public TrueZipLegacyChunkStore(File zipFile) throws IOException, ZipException { this.zipFile = zipFile; zip = new ZipFile(zipFile); @@ -87,17 +74,16 @@ public class TrueZipLegacyChunkStore extends LegacyChunkStore { /** * Get the input stream for a chunk file. * - * @param f1 - * @param f2 - * @param name - * @return + * @param f1 the first part of the filename + * @param f2 the second part of the filename + * @param name the name of the file + * @return an input stream * @throws IOException * @throws DataException */ @Override @SuppressWarnings("unchecked") - protected InputStream getInputStream(String f1, String f2, String name) - throws IOException, DataException { + protected InputStream getInputStream(String f1, String f2, String name) throws IOException, DataException { String file = f1 + "/" + f2 + "/" + name; // Detect subfolder for the world's files @@ -117,9 +103,8 @@ public class TrueZipLegacyChunkStore extends LegacyChunkStore { // So not there either... if (testEntry == null) { - for (Enumeration e = zip.entries(); e.hasMoreElements();) { - - testEntry = (ZipEntry) e.nextElement(); + for (Enumeration e = zip.entries(); e.hasMoreElements(); ) { + testEntry = e.nextElement(); // Whoo, found level.dat! if (pattern.matcher(testEntry.getName()).matches()) { @@ -149,8 +134,8 @@ public class TrueZipLegacyChunkStore extends LegacyChunkStore { /** * Get an entry from the ZIP, trying both types of slashes. * - * @param file - * @return + * @param file the file + * @return an entry */ private ZipEntry getEntry(String file) { ZipEntry entry = zip.getEntry(file); @@ -160,11 +145,6 @@ public class TrueZipLegacyChunkStore extends LegacyChunkStore { return zip.getEntry(file.replace("/", "\\")); } - /** - * Close resources. - * - * @throws IOException - */ @Override public void close() throws IOException { zip.close(); @@ -174,4 +154,5 @@ public class TrueZipLegacyChunkStore extends LegacyChunkStore { public boolean isValid() { return true; // Yeah, oh well } + } diff --git a/src/main/java/com/sk89q/worldedit/world/storage/TrueZipMcRegionChunkStore.java b/src/main/java/com/sk89q/worldedit/world/storage/TrueZipMcRegionChunkStore.java index 2a2bf7366..cc5378a4e 100644 --- a/src/main/java/com/sk89q/worldedit/world/storage/TrueZipMcRegionChunkStore.java +++ b/src/main/java/com/sk89q/worldedit/world/storage/TrueZipMcRegionChunkStore.java @@ -21,36 +21,25 @@ package com.sk89q.worldedit.world.storage; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.util.regex.Pattern; -import java.util.zip.ZipException; -import java.util.Enumeration; - import com.sk89q.worldedit.world.DataException; import de.schlichtherle.util.zip.ZipEntry; import de.schlichtherle.util.zip.ZipFile; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.util.Enumeration; +import java.util.regex.Pattern; +import java.util.zip.ZipException; + /** * Represents the chunk store used by Minecraft but zipped. Uses * the replacement classes for java.util.zip.* from TrueZip. - * - * @author sk89q */ public class TrueZipMcRegionChunkStore extends McRegionChunkStore { - /** - * ZIP file. - */ protected File zipFile; - /** - * Actual ZIP. - */ protected ZipFile zip; - /** - * Folder inside the ZIP file to read from, if any. - */ protected String folder; /** @@ -58,13 +47,12 @@ public class TrueZipMcRegionChunkStore extends McRegionChunkStore { * path to look into in the ZIP for the files. Use a blank string for * the folder to not look into a subdirectory. * - * @param zipFile - * @param folder + * @param zipFile the ZIP file + * @param folder the folder to look into * @throws IOException * @throws ZipException */ - public TrueZipMcRegionChunkStore(File zipFile, String folder) - throws IOException, ZipException { + public TrueZipMcRegionChunkStore(File zipFile, String folder) throws IOException, ZipException { this.zipFile = zipFile; this.folder = folder; @@ -75,12 +63,11 @@ public class TrueZipMcRegionChunkStore extends McRegionChunkStore { * Create an instance. The subfolder containing the chunk data will * be detected. * - * @param zipFile + * @param zipFile the ZIP file * @throws IOException * @throws ZipException */ - public TrueZipMcRegionChunkStore(File zipFile) - throws IOException, ZipException { + public TrueZipMcRegionChunkStore(File zipFile) throws IOException, ZipException { this.zipFile = zipFile; zip = new ZipFile(zipFile); @@ -89,16 +76,15 @@ public class TrueZipMcRegionChunkStore extends McRegionChunkStore { /** * Get the input stream for a chunk file. * - * @param name - * @return + * @param name the name + * @param worldName the world name + * @return an input stream * @throws IOException * @throws DataException */ @Override @SuppressWarnings("unchecked") - protected InputStream getInputStream(String name, String worldname) - throws IOException, DataException { - + protected InputStream getInputStream(String name, String worldName) throws IOException, DataException { // Detect subfolder for the world's files if (folder != null) { if (!folder.equals("")) { @@ -107,11 +93,11 @@ public class TrueZipMcRegionChunkStore extends McRegionChunkStore { } else { Pattern pattern = Pattern.compile(".*\\.mc[ra]$"); // World pattern - Pattern worldPattern = Pattern.compile(worldname + "\\$"); + Pattern worldPattern = Pattern.compile(worldName + "\\$"); for (Enumeration e = zip.entries(); e.hasMoreElements(); ) { - ZipEntry testEntry = (ZipEntry) e.nextElement(); + ZipEntry testEntry = e.nextElement(); // Check for world - if (worldPattern.matcher(worldname).matches()) { + if (worldPattern.matcher(worldName).matches()) { // Check for file if (pattern.matcher(testEntry.getName()).matches()) { folder = testEntry.getName().substring(0, testEntry.getName().lastIndexOf("/")); @@ -123,7 +109,7 @@ public class TrueZipMcRegionChunkStore extends McRegionChunkStore { // Check if world is found if (folder == null) { - throw new MissingWorldException("Target world is not present in ZIP.", worldname); + throw new MissingWorldException("Target world is not present in ZIP.", worldName); } } @@ -141,8 +127,8 @@ public class TrueZipMcRegionChunkStore extends McRegionChunkStore { /** * Get an entry from the ZIP, trying both types of slashes. * - * @param file - * @return + * @param file the file + * @return an entry */ private ZipEntry getEntry(String file) { ZipEntry entry = zip.getEntry(file); @@ -152,11 +138,6 @@ public class TrueZipMcRegionChunkStore extends McRegionChunkStore { return zip.getEntry(file.replace("/", "\\")); } - /** - * Close resources. - * - * @throws IOException - */ @Override public void close() throws IOException { zip.close(); @@ -176,4 +157,5 @@ public class TrueZipMcRegionChunkStore extends McRegionChunkStore { return false; } + } diff --git a/src/main/java/com/sk89q/worldedit/world/storage/ZippedLegacyChunkStore.java b/src/main/java/com/sk89q/worldedit/world/storage/ZippedLegacyChunkStore.java index 833d108a2..30c9fa41a 100644 --- a/src/main/java/com/sk89q/worldedit/world/storage/ZippedLegacyChunkStore.java +++ b/src/main/java/com/sk89q/worldedit/world/storage/ZippedLegacyChunkStore.java @@ -32,22 +32,10 @@ import java.util.Enumeration; /** * Represents the chunk store used by Minecraft alpha but zipped. - * - * @author sk89q */ public class ZippedLegacyChunkStore extends LegacyChunkStore { - /** - * ZIP file. - */ - @SuppressWarnings("unused") - private File zipFile; - /** - * Actual ZIP. - */ + private ZipFile zip; - /** - * Folder inside the ZIP file to read from, if any. - */ private String folder; /** @@ -55,14 +43,12 @@ public class ZippedLegacyChunkStore extends LegacyChunkStore { * path to look into in the ZIP for the files. Use a blank string for * the folder to not look into a subdirectory. * - * @param zipFile - * @param folder + * @param zipFile the zip file + * @param folder the folder * @throws IOException * @throws ZipException */ - public ZippedLegacyChunkStore(File zipFile, String folder) - throws IOException, ZipException { - this.zipFile = zipFile; + public ZippedLegacyChunkStore(File zipFile, String folder) throws IOException, ZipException { this.folder = folder; zip = new ZipFile(zipFile); @@ -72,30 +58,26 @@ public class ZippedLegacyChunkStore extends LegacyChunkStore { * Create an instance. The subfolder containing the chunk data will * be detected. * - * @param zipFile + * @param zipFile the zip file * @throws IOException * @throws ZipException */ - public ZippedLegacyChunkStore(File zipFile) - throws IOException, ZipException { - this.zipFile = zipFile; - + public ZippedLegacyChunkStore(File zipFile) throws IOException, ZipException { zip = new ZipFile(zipFile); } /** * Get the input stream for a chunk file. * - * @param f1 - * @param f2 - * @param name - * @return + * @param f1 the first part of the path + * @param f2 the second part of the path + * @param name the name of the file + * @return an input stream * @throws IOException * @throws DataException */ @Override - protected InputStream getInputStream(String f1, String f2, String name) - throws IOException, DataException { + protected InputStream getInputStream(String f1, String f2, String name) throws IOException, DataException { String file = f1 + "/" + f2 + "/" + name; // Detect subfolder for the world's files @@ -117,7 +99,7 @@ public class ZippedLegacyChunkStore extends LegacyChunkStore { if (testEntry == null) { for (Enumeration e = zip.entries(); e.hasMoreElements(); ) { - testEntry = (ZipEntry) e.nextElement(); + testEntry = e.nextElement(); // Whoo, found level.dat! if (pattern.matcher(testEntry.getName()).matches()) { @@ -147,8 +129,8 @@ public class ZippedLegacyChunkStore extends LegacyChunkStore { /** * Get an entry from the ZIP, trying both types of slashes. * - * @param file - * @return + * @param file the file + * @return an entry */ private ZipEntry getEntry(String file) { ZipEntry entry = zip.getEntry(file); @@ -158,11 +140,6 @@ public class ZippedLegacyChunkStore extends LegacyChunkStore { return zip.getEntry(file.replace("/", "\\")); } - /** - * Close resources. - * - * @throws IOException - */ @Override public void close() throws IOException { zip.close(); @@ -172,4 +149,5 @@ public class ZippedLegacyChunkStore extends LegacyChunkStore { public boolean isValid() { return true; // Yeah, oh well } + } diff --git a/src/main/java/com/sk89q/worldedit/world/storage/ZippedMcRegionChunkStore.java b/src/main/java/com/sk89q/worldedit/world/storage/ZippedMcRegionChunkStore.java index a0948de64..b6c7ff569 100644 --- a/src/main/java/com/sk89q/worldedit/world/storage/ZippedMcRegionChunkStore.java +++ b/src/main/java/com/sk89q/worldedit/world/storage/ZippedMcRegionChunkStore.java @@ -34,22 +34,11 @@ import java.util.Enumeration; /** * Represents the chunk store used by Minecraft alpha but zipped. - * - * @author sk89q */ public class ZippedMcRegionChunkStore extends McRegionChunkStore { - /** - * ZIP file. - */ protected File zipFile; - /** - * Actual ZIP. - */ protected ZipFile zip; - /** - * Folder inside the ZIP file to read from, if any. - */ protected String folder; /** @@ -57,13 +46,12 @@ public class ZippedMcRegionChunkStore extends McRegionChunkStore { * path to look into in the ZIP for the files. Use a blank string for * the folder to not look into a subdirectory. * - * @param zipFile - * @param folder + * @param zipFile the ZIP file + * @param folder the folder * @throws IOException * @throws ZipException */ - public ZippedMcRegionChunkStore(File zipFile, String folder) - throws IOException, ZipException { + public ZippedMcRegionChunkStore(File zipFile, String folder) throws IOException, ZipException { this.zipFile = zipFile; this.folder = folder; @@ -71,32 +59,21 @@ public class ZippedMcRegionChunkStore extends McRegionChunkStore { } /** - * Create an instance. The subfolder containing the chunk data will + * Create an instance. The sub-folder containing the chunk data will * be detected. * - * @param zipFile + * @param zipFile the ZIP file * @throws IOException * @throws ZipException */ - public ZippedMcRegionChunkStore(File zipFile) - throws IOException, ZipException { + public ZippedMcRegionChunkStore(File zipFile) throws IOException, ZipException { this.zipFile = zipFile; zip = new ZipFile(zipFile); } - /** - * Get the input stream for a chunk file. - * - * @param name - * @return - * @throws IOException - * @throws DataException - */ @Override - protected InputStream getInputStream(String name, String worldname) - throws IOException, DataException { - + protected InputStream getInputStream(String name, String worldName) throws IOException, DataException { // Detect subfolder for the world's files if (folder != null) { if (!folder.equals("")) { @@ -105,9 +82,9 @@ public class ZippedMcRegionChunkStore extends McRegionChunkStore { } else { Pattern pattern = Pattern.compile(".*\\.mc[ra]$"); for (Enumeration e = zip.entries(); e.hasMoreElements(); ) { - ZipEntry testEntry = (ZipEntry) e.nextElement(); + ZipEntry testEntry = e.nextElement(); // Check for world - if (testEntry.getName().startsWith(worldname + "/")) { + if (testEntry.getName().startsWith(worldName + "/")) { if (pattern.matcher(testEntry.getName()).matches()) { // does entry end in .mca folder = testEntry.getName().substring(0, testEntry.getName().lastIndexOf("/")); name = folder + "/" + name; @@ -119,7 +96,7 @@ public class ZippedMcRegionChunkStore extends McRegionChunkStore { // Check if world is found if (folder == null) { - throw new MissingWorldException("Target world is not present in ZIP.", worldname); + throw new MissingWorldException("Target world is not present in ZIP.", worldName); } } @@ -137,8 +114,8 @@ public class ZippedMcRegionChunkStore extends McRegionChunkStore { /** * Get an entry from the ZIP, trying both types of slashes. * - * @param file - * @return + * @param file the file + * @return a ZIP entry */ private ZipEntry getEntry(String file) { ZipEntry entry = zip.getEntry(file); @@ -148,11 +125,6 @@ public class ZippedMcRegionChunkStore extends McRegionChunkStore { return zip.getEntry(file.replace("/", "\\")); } - /** - * Close resources. - * - * @throws IOException - */ @Override public void close() throws IOException { zip.close(); diff --git a/src/test/java/com/sk89q/minecraft/util/commands/CommandContextTest.java b/src/test/java/com/sk89q/minecraft/util/commands/CommandContextTest.java index ff3669015..bcdf19dd2 100644 --- a/src/test/java/com/sk89q/minecraft/util/commands/CommandContextTest.java +++ b/src/test/java/com/sk89q/minecraft/util/commands/CommandContextTest.java @@ -22,12 +22,16 @@ package com.sk89q.minecraft.util.commands; import org.junit.Before; import org.junit.Test; -import static org.junit.Assert.*; - import java.util.Arrays; import java.util.HashSet; +import java.util.logging.Level; +import java.util.logging.Logger; + +import static org.junit.Assert.*; public class CommandContextTest { + + private static final Logger log = Logger.getLogger(CommandContextTest.class.getCanonicalName()); private static final String firstCmdString = "herpderp -opw testers \"mani world\" 'another thing' because something"; CommandContext firstCommand; @@ -36,7 +40,7 @@ public class CommandContextTest { try { firstCommand = new CommandContext(firstCmdString, new HashSet(Arrays.asList('o', 'w'))); } catch (CommandException e) { - e.printStackTrace(); + log.log(Level.WARNING, "Error", e); fail("Unexpected exception when creating CommandContext"); } } @@ -75,7 +79,7 @@ public class CommandContextTest { new CommandContext(cmd); new CommandContext(cmd2); } catch (CommandException e) { - e.printStackTrace(); + log.log(Level.WARNING, "Error", e); fail("Error creating CommandContext"); } } @@ -86,7 +90,7 @@ public class CommandContextTest { try { new CommandContext(cmd); } catch (CommandException e) { - e.printStackTrace(); + log.log(Level.WARNING, "Error", e); fail("Error creating CommandContext"); } } @@ -97,7 +101,7 @@ public class CommandContextTest { try { new CommandContext(cmd); } catch (CommandException e) { - e.printStackTrace(); + log.log(Level.WARNING, "Error", e); fail("Error creating CommandContext"); } } @@ -111,7 +115,7 @@ public class CommandContextTest { CommandContext context2 = new CommandContext("r hello -f world"); assertTrue(context2.hasFlag('f')); } catch (CommandException e) { - e.printStackTrace(); + log.log(Level.WARNING, "Error", e); fail("Error creating CommandContext"); } } @@ -127,7 +131,7 @@ public class CommandContextTest { CommandContext context2 = new CommandContext("pm name \"hello world\" foo bar"); assertEquals("\"hello world\" foo bar", context2.getJoinedStrings(1)); } catch (CommandException e) { - e.printStackTrace(); + log.log(Level.WARNING, "Error", e); fail("Error creating CommandContext"); } } @@ -139,7 +143,7 @@ public class CommandContextTest { assertArrayEquals(new String[] { "foo", "bar", "baz" }, context.getSlice(0)); } catch (CommandException e) { - e.printStackTrace(); + log.log(Level.WARNING, "Error", e); fail("Error creating CommandContext"); } } @@ -150,7 +154,7 @@ public class CommandContextTest { CommandContext context = new CommandContext("region flag xmas blocked-cmds \"\""); assertEquals(context.argsLength(), 3); } catch (CommandException e) { - e.printStackTrace(); + log.log(Level.WARNING, "Error", e); fail("Error creating CommandContext"); } } diff --git a/src/test/java/com/sk89q/worldedit/blocks/BlockDataTest.java b/src/test/java/com/sk89q/worldedit/blocks/BlockDataTest.java index e9a969c47..044b6a88b 100644 --- a/src/test/java/com/sk89q/worldedit/blocks/BlockDataTest.java +++ b/src/test/java/com/sk89q/worldedit/blocks/BlockDataTest.java @@ -19,18 +19,16 @@ package com.sk89q.worldedit.blocks; +import com.sk89q.worldedit.CuboidClipboard.FlipDirection; +import org.junit.Test; + import java.util.TreeSet; -import org.junit.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; -import com.sk89q.worldedit.CuboidClipboard.FlipDirection; - -import static org.junit.Assert.*; - -/** - * @author TomyLobo - */ public class BlockDataTest { + @Test public void testRotateFlip() { for (int type = 0; type < 256; ++type) { @@ -138,4 +136,5 @@ public class BlockDataTest { } } } + } diff --git a/src/test/java/com/sk89q/worldedit/internal/expression/ExpressionTest.java b/src/test/java/com/sk89q/worldedit/internal/expression/ExpressionTest.java index dbac19b1b..d60ed68f9 100644 --- a/src/test/java/com/sk89q/worldedit/internal/expression/ExpressionTest.java +++ b/src/test/java/com/sk89q/worldedit/internal/expression/ExpressionTest.java @@ -19,15 +19,16 @@ package com.sk89q.worldedit.internal.expression; -import static org.junit.Assert.*; -import static java.lang.Math.*; - -import com.sk89q.worldedit.internal.expression.runtime.ExpressionEnvironment; -import org.junit.*; - import com.sk89q.worldedit.internal.expression.lexer.LexerException; import com.sk89q.worldedit.internal.expression.parser.ParserException; import com.sk89q.worldedit.internal.expression.runtime.EvaluationException; +import com.sk89q.worldedit.internal.expression.runtime.ExpressionEnvironment; +import org.junit.Test; + +import static java.lang.Math.atan2; +import static java.lang.Math.sin; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; public class ExpressionTest { @Test @@ -74,11 +75,11 @@ public class ExpressionTest { try { compile("("); fail("Error expected"); - } catch (ParserException e) {} + } catch (ParserException ignored) {} try { compile("x("); fail("Error expected"); - } catch (ParserException e) {} + } catch (ParserException ignored) {} // test overloader errors try {