From 912468f8a1d797ee6e2194f7a44cbfab808eee47 Mon Sep 17 00:00:00 2001 From: sk89q Date: Wed, 29 Dec 2010 23:15:53 -0800 Subject: [PATCH] Fixed Java warnings. --- src/CuboidClipboard.java | 5 +++-- src/EditSession.java | 19 ++++--------------- src/MinecraftServerInterface.java | 1 + src/SnapshotRestore.java | 4 ++-- src/WorldEdit.java | 4 ---- src/WorldEditBridge.java | 2 +- src/WorldEditListener.java | 8 +------- .../worldedit/DisallowedItemException.java | 2 ++ src/com/sk89q/worldedit/DoubleArrayList.java | 10 +++++++--- .../worldedit/EmptyClipboardException.java | 1 + .../worldedit/GroupRestrictionsManager.java | 3 +-- .../worldedit/IncompleteRegionException.java | 3 ++- .../InsufficientArgumentsException.java | 2 ++ .../sk89q/worldedit/InvalidItemException.java | 2 ++ .../worldedit/MaxChangedBlocksException.java | 2 ++ .../sk89q/worldedit/MaxRadiusException.java | 1 + .../worldedit/UnknownDirectionException.java | 2 ++ .../sk89q/worldedit/UnknownItemException.java | 2 ++ .../sk89q/worldedit/WorldEditException.java | 4 +++- .../worldedit/WorldEditNotInstalled.java | 3 ++- .../worldedit/blocks/MobSpawnerBlock.java | 3 --- src/com/sk89q/worldedit/data/Chunk.java | 3 ++- .../worldedit/data/ChunkStoreException.java | 2 ++ .../sk89q/worldedit/data/DataException.java | 2 ++ .../data/InvalidFormatException.java | 2 ++ .../worldedit/data/MissingChunkException.java | 2 ++ .../data/TrueZipAlphaChunkStore.java | 3 +-- .../worldedit/data/ZippedAlphaChunkStore.java | 5 ++++- .../snapshots/InvalidSnapshotException.java | 1 + 29 files changed, 57 insertions(+), 46 deletions(-) diff --git a/src/CuboidClipboard.java b/src/CuboidClipboard.java index 14c8a04ce..f348c9f37 100644 --- a/src/CuboidClipboard.java +++ b/src/CuboidClipboard.java @@ -483,8 +483,9 @@ public class CuboidClipboard { * @return child tag * @throws DataException */ - private static Tag getChildTag(Map items, String key, Class expected) - throws DataException { + private static Tag getChildTag(Map items, String key, + Class expected) throws DataException { + if (!items.containsKey(key)) { throw new DataException("Schematic file is missing a \"" + key + "\" tag"); } diff --git a/src/EditSession.java b/src/EditSession.java index df99e3bf2..d895a04f5 100755 --- a/src/EditSession.java +++ b/src/EditSession.java @@ -20,9 +20,7 @@ import com.sk89q.worldedit.*; import com.sk89q.worldedit.regions.*; import com.sk89q.worldedit.blocks.*; -import com.sk89q.worldedit.data.*; import com.sk89q.worldedit.patterns.*; -import java.io.IOException; import java.util.Map; import java.util.HashMap; import java.util.LinkedHashMap; @@ -80,10 +78,6 @@ public class EditSession { * Random number generator. */ private static Random prng = new Random(); - /** - * Total number of blocks set over time. - */ - private int blockIndex = 0; /** * Construct the object with a maximum number of blocks. @@ -228,9 +222,9 @@ public class EditSession { // In the case of the queue, the block may have not actually been // changed yet if (queued) { - BlockVector blockPt = pt.toBlockVector(); + /*BlockVector blockPt = pt.toBlockVector(); - /*if (current.containsKey(blockPt)) { + if (current.containsKey(blockPt)) { return current.get(blockPt); }*/ } @@ -1088,10 +1082,6 @@ public class EditSession { Vector newMin = min.add(shift); Vector newMax = min.add(shift); - - int xs = region.getWidth(); - int ys = region.getHeight(); - int zs = region.getLength(); Map delayed = new LinkedHashMap(); @@ -1737,8 +1727,6 @@ public class EditSession { // Move up basePos = basePos.add(0, trunkHeight, 0); - int pos2[] = {-2, 2}; - // Create tree + leaves for (int i = 0; i < height; i++) { setBlockIfAir(basePos.add(0, i, 0), logBlock); @@ -1828,7 +1816,8 @@ public class EditSession { public List> getBlockDistribution(Region region) { List> distribution = new ArrayList>(); - Map map = new HashMap(); + Map> map = + new HashMap>(); if (region instanceof CuboidRegion) { // Doing this for speed diff --git a/src/MinecraftServerInterface.java b/src/MinecraftServerInterface.java index 2f4b2f49a..ac533d8fb 100644 --- a/src/MinecraftServerInterface.java +++ b/src/MinecraftServerInterface.java @@ -91,6 +91,7 @@ public class MinecraftServerInterface { * @return * @throws Throwable */ + @SuppressWarnings("rawtypes") private static T createNoConstructor(Class clazz) throws Throwable { try { ReflectionFactory factory = ReflectionFactory.getReflectionFactory(); diff --git a/src/SnapshotRestore.java b/src/SnapshotRestore.java index ac4460190..d780c6273 100644 --- a/src/SnapshotRestore.java +++ b/src/SnapshotRestore.java @@ -171,7 +171,7 @@ public class SnapshotRestore { * * @return */ - public List getMissingChunks() { + public List getMissingChunks() { return missingChunks; } @@ -181,7 +181,7 @@ public class SnapshotRestore { * * @return */ - public List getErrorChunks() { + public List getErrorChunks() { return errorChunks; } diff --git a/src/WorldEdit.java b/src/WorldEdit.java index 721756e64..d42cfa870 100644 --- a/src/WorldEdit.java +++ b/src/WorldEdit.java @@ -19,10 +19,6 @@ import java.util.logging.Level; import java.util.logging.Logger; -import java.util.jar.Manifest; -import java.util.jar.Attributes; -import java.net.URL; -import java.io.IOException; /** * Entry point for the plugin for hey0's mod. diff --git a/src/WorldEditBridge.java b/src/WorldEditBridge.java index 47033f5d7..f38196d7e 100644 --- a/src/WorldEditBridge.java +++ b/src/WorldEditBridge.java @@ -41,7 +41,7 @@ public class WorldEditBridge { * @throws NoSuchMethodException */ private static Object invokeMethod(Object obj, String name, Object[] args, - Class ... types) throws InvocationTargetException, IllegalAccessException, + Class ... types) throws InvocationTargetException, IllegalAccessException, NoSuchMethodException { Method method = obj.getClass().getDeclaredMethod(name, types); return method.invoke(obj, args); diff --git a/src/WorldEditListener.java b/src/WorldEditListener.java index d5b364806..b756c9eb0 100755 --- a/src/WorldEditListener.java +++ b/src/WorldEditListener.java @@ -1617,10 +1617,6 @@ public class WorldEditListener extends PluginListener { public CuboidClipboard.FlipDirection getFlipDirection( WorldEditPlayer player, String dir) throws UnknownDirectionException { - int xm = 0; - int ym = 0; - int zm = 0; - if (dir.equals("me")) { dir = player.getCardinalDirection(); } @@ -1728,6 +1724,7 @@ public class WorldEditListener extends PluginListener { * @return false if you want the action to go through */ @Override + @SuppressWarnings("deprecation") public boolean onBlockCreate(Player modPlayer, Block blockPlaced, Block blockClicked, int itemInHand) { WorldEditPlayer player = new WorldEditPlayer(modPlayer); @@ -1898,9 +1895,6 @@ public class WorldEditListener extends PluginListener { WorldEditSession.SuperPickaxeMode.SAME_TYPE_RECURSIVE) { Vector origin = new Vector(blockClicked.getX(), blockClicked.getY(), blockClicked.getZ()); - int ox = blockClicked.getX(); - int oy = blockClicked.getY(); - int oz = blockClicked.getZ(); int size = session.getSuperPickaxeRange(); int initialType = ServerInterface.getBlockType(origin); diff --git a/src/com/sk89q/worldedit/DisallowedItemException.java b/src/com/sk89q/worldedit/DisallowedItemException.java index 564c09460..b7b4e772a 100644 --- a/src/com/sk89q/worldedit/DisallowedItemException.java +++ b/src/com/sk89q/worldedit/DisallowedItemException.java @@ -24,6 +24,8 @@ package com.sk89q.worldedit; * @author sk89q */ public class DisallowedItemException extends WorldEditException { + private static final long serialVersionUID = -8080026411461549979L; + private String type; public DisallowedItemException(String type) { diff --git a/src/com/sk89q/worldedit/DoubleArrayList.java b/src/com/sk89q/worldedit/DoubleArrayList.java index afbd0e6e9..71d9d2765 100644 --- a/src/com/sk89q/worldedit/DoubleArrayList.java +++ b/src/com/sk89q/worldedit/DoubleArrayList.java @@ -104,7 +104,9 @@ public class DoubleArrayList implements Iterable> { * @param * @param */ - public class ForwardEntryIterator implements Iterator> { + public class ForwardEntryIterator> + implements Iterator> { + private Iterator keyIterator; private Iterator valueIterator; @@ -132,7 +134,9 @@ public class DoubleArrayList implements Iterable> { * @param * @param */ - public class ReverseEntryIterator implements Iterator> { + public class ReverseEntryIterator> + implements Iterator> { + private ListIterator keyIterator; private ListIterator valueIterator; @@ -160,7 +164,7 @@ public class DoubleArrayList implements Iterable> { * @param * @param */ - public class Entry implements Map.Entry { + public class Entry implements Map.Entry { private A key; private B value; diff --git a/src/com/sk89q/worldedit/EmptyClipboardException.java b/src/com/sk89q/worldedit/EmptyClipboardException.java index faceea8ba..07e348424 100644 --- a/src/com/sk89q/worldedit/EmptyClipboardException.java +++ b/src/com/sk89q/worldedit/EmptyClipboardException.java @@ -24,5 +24,6 @@ package com.sk89q.worldedit; * @author Albert */ public class EmptyClipboardException extends WorldEditException { + private static final long serialVersionUID = -3197424556127109425L; } diff --git a/src/com/sk89q/worldedit/GroupRestrictionsManager.java b/src/com/sk89q/worldedit/GroupRestrictionsManager.java index 288d6f147..5a0e58135 100644 --- a/src/com/sk89q/worldedit/GroupRestrictionsManager.java +++ b/src/com/sk89q/worldedit/GroupRestrictionsManager.java @@ -7,7 +7,6 @@ package com.sk89q.worldedit; import java.util.Map; import java.util.HashMap; -import java.util.logging.Level; import java.util.logging.Logger; import java.io.*; @@ -109,7 +108,7 @@ public class GroupRestrictionsManager { int changeLimit = parts.length > 1 ? Integer.parseInt(parts[1]) : -1; changeLimits.put(groupID, changeLimit); } catch (NumberFormatException e) { - logger.log(Level.ALL.WARNING, "Integer expected in" + logger.warning("Integer expected in" + "WorldEdit group permissions line: " + line); } } diff --git a/src/com/sk89q/worldedit/IncompleteRegionException.java b/src/com/sk89q/worldedit/IncompleteRegionException.java index f726b25a7..f9851532a 100644 --- a/src/com/sk89q/worldedit/IncompleteRegionException.java +++ b/src/com/sk89q/worldedit/IncompleteRegionException.java @@ -22,8 +22,9 @@ package com.sk89q.worldedit; /** * Raised when a region is not fully defined. * - * @author Albert + * @author sk89q */ public class IncompleteRegionException extends WorldEditException { + private static final long serialVersionUID = 458988897980179094L; } diff --git a/src/com/sk89q/worldedit/InsufficientArgumentsException.java b/src/com/sk89q/worldedit/InsufficientArgumentsException.java index 56ea003b3..49f1bbb22 100644 --- a/src/com/sk89q/worldedit/InsufficientArgumentsException.java +++ b/src/com/sk89q/worldedit/InsufficientArgumentsException.java @@ -24,6 +24,8 @@ package com.sk89q.worldedit; * @author sk89q */ public class InsufficientArgumentsException extends WorldEditException { + private static final long serialVersionUID = 995264804658899764L; + public InsufficientArgumentsException(String error) { super(error); } diff --git a/src/com/sk89q/worldedit/InvalidItemException.java b/src/com/sk89q/worldedit/InvalidItemException.java index 7c6eb7508..22bb0e1a5 100644 --- a/src/com/sk89q/worldedit/InvalidItemException.java +++ b/src/com/sk89q/worldedit/InvalidItemException.java @@ -24,6 +24,8 @@ package com.sk89q.worldedit; * @author sk89q */ public class InvalidItemException extends DisallowedItemException { + private static final long serialVersionUID = -2739618871154124586L; + public InvalidItemException(String type, String message) { super(type, message); } diff --git a/src/com/sk89q/worldedit/MaxChangedBlocksException.java b/src/com/sk89q/worldedit/MaxChangedBlocksException.java index 3a238034a..1f5b21c6b 100644 --- a/src/com/sk89q/worldedit/MaxChangedBlocksException.java +++ b/src/com/sk89q/worldedit/MaxChangedBlocksException.java @@ -24,6 +24,8 @@ package com.sk89q.worldedit; * @author sk89q */ public class MaxChangedBlocksException extends WorldEditException { + private static final long serialVersionUID = -2621044030640945259L; + int maxBlocks; public MaxChangedBlocksException(int maxBlocks) { diff --git a/src/com/sk89q/worldedit/MaxRadiusException.java b/src/com/sk89q/worldedit/MaxRadiusException.java index 7c96fd88a..5ca4035ba 100644 --- a/src/com/sk89q/worldedit/MaxRadiusException.java +++ b/src/com/sk89q/worldedit/MaxRadiusException.java @@ -25,4 +25,5 @@ package com.sk89q.worldedit; * @author sk89q */ public class MaxRadiusException extends WorldEditException { + private static final long serialVersionUID = -8405382841529528119L; } diff --git a/src/com/sk89q/worldedit/UnknownDirectionException.java b/src/com/sk89q/worldedit/UnknownDirectionException.java index e3f3bc974..9fe27a183 100644 --- a/src/com/sk89q/worldedit/UnknownDirectionException.java +++ b/src/com/sk89q/worldedit/UnknownDirectionException.java @@ -24,6 +24,8 @@ package com.sk89q.worldedit; * @author sk89q */ public class UnknownDirectionException extends WorldEditException { + private static final long serialVersionUID = 5705931351293248358L; + private String dir; public UnknownDirectionException(String dir) { diff --git a/src/com/sk89q/worldedit/UnknownItemException.java b/src/com/sk89q/worldedit/UnknownItemException.java index f734ec9f9..5045231c2 100644 --- a/src/com/sk89q/worldedit/UnknownItemException.java +++ b/src/com/sk89q/worldedit/UnknownItemException.java @@ -25,6 +25,8 @@ package com.sk89q.worldedit; * @author sk89q */ public class UnknownItemException extends WorldEditException { + private static final long serialVersionUID = 2661079183700565880L; + private String type; public UnknownItemException(String type) { diff --git a/src/com/sk89q/worldedit/WorldEditException.java b/src/com/sk89q/worldedit/WorldEditException.java index 55c6bcd09..347ee31a1 100644 --- a/src/com/sk89q/worldedit/WorldEditException.java +++ b/src/com/sk89q/worldedit/WorldEditException.java @@ -21,9 +21,11 @@ package com.sk89q.worldedit; /** * - * @author Albert + * @author sk89q */ public abstract class WorldEditException extends Exception { + private static final long serialVersionUID = 3201997990797993987L; + protected WorldEditException() { } diff --git a/src/com/sk89q/worldedit/WorldEditNotInstalled.java b/src/com/sk89q/worldedit/WorldEditNotInstalled.java index 8da44fdca..b754f0558 100644 --- a/src/com/sk89q/worldedit/WorldEditNotInstalled.java +++ b/src/com/sk89q/worldedit/WorldEditNotInstalled.java @@ -22,8 +22,9 @@ package com.sk89q.worldedit; /** * Raised when WorldEdit is not installed. * - * @author Albert + * @author sk89q */ public class WorldEditNotInstalled extends WorldEditException { + private static final long serialVersionUID = -4698408698930848121L; } diff --git a/src/com/sk89q/worldedit/blocks/MobSpawnerBlock.java b/src/com/sk89q/worldedit/blocks/MobSpawnerBlock.java index e086b6861..118b70ab1 100644 --- a/src/com/sk89q/worldedit/blocks/MobSpawnerBlock.java +++ b/src/com/sk89q/worldedit/blocks/MobSpawnerBlock.java @@ -19,12 +19,9 @@ package com.sk89q.worldedit.blocks; -import com.sk89q.worldedit.*; import com.sk89q.worldedit.data.*; import java.util.Map; import java.util.HashMap; -import java.util.List; -import java.util.ArrayList; import org.jnbt.*; /** diff --git a/src/com/sk89q/worldedit/data/Chunk.java b/src/com/sk89q/worldedit/data/Chunk.java index 3b1b6f59d..541f0fea5 100644 --- a/src/com/sk89q/worldedit/data/Chunk.java +++ b/src/com/sk89q/worldedit/data/Chunk.java @@ -236,7 +236,8 @@ public class Chunk { * @return child tag * @throws InvalidFormatException */ - public static Tag getChildTag(Map items, String key, Class expected) + public static Tag getChildTag(Map items, String key, + Class expected) throws InvalidFormatException { if (!items.containsKey(key)) { throw new InvalidFormatException("Missing a \"" + key + "\" tag"); diff --git a/src/com/sk89q/worldedit/data/ChunkStoreException.java b/src/com/sk89q/worldedit/data/ChunkStoreException.java index a251fe7be..78759b644 100644 --- a/src/com/sk89q/worldedit/data/ChunkStoreException.java +++ b/src/com/sk89q/worldedit/data/ChunkStoreException.java @@ -24,6 +24,8 @@ package com.sk89q.worldedit.data; * @author sk89q */ public class ChunkStoreException extends DataException { + private static final long serialVersionUID = 1483900743779953289L; + public ChunkStoreException(String msg) { super(msg); } diff --git a/src/com/sk89q/worldedit/data/DataException.java b/src/com/sk89q/worldedit/data/DataException.java index fd7c70a52..eda9b19c9 100644 --- a/src/com/sk89q/worldedit/data/DataException.java +++ b/src/com/sk89q/worldedit/data/DataException.java @@ -25,6 +25,8 @@ package com.sk89q.worldedit.data; * @author sk89q */ public class DataException extends Exception { + private static final long serialVersionUID = 5806521052111023788L; + public DataException(String msg) { super(msg); } diff --git a/src/com/sk89q/worldedit/data/InvalidFormatException.java b/src/com/sk89q/worldedit/data/InvalidFormatException.java index 27a5ee170..941d8b983 100644 --- a/src/com/sk89q/worldedit/data/InvalidFormatException.java +++ b/src/com/sk89q/worldedit/data/InvalidFormatException.java @@ -24,6 +24,8 @@ package com.sk89q.worldedit.data; * @author sk89q */ public class InvalidFormatException extends DataException { + private static final long serialVersionUID = -3401820540902726145L; + public InvalidFormatException(String msg) { super(msg); } diff --git a/src/com/sk89q/worldedit/data/MissingChunkException.java b/src/com/sk89q/worldedit/data/MissingChunkException.java index 99bb5092f..e8798b99b 100644 --- a/src/com/sk89q/worldedit/data/MissingChunkException.java +++ b/src/com/sk89q/worldedit/data/MissingChunkException.java @@ -26,6 +26,8 @@ import com.sk89q.worldedit.Vector2D; * @author sk89q */ public class MissingChunkException extends ChunkStoreException { + private static final long serialVersionUID = 8013715483709973489L; + private Vector2D pos; public MissingChunkException() { diff --git a/src/com/sk89q/worldedit/data/TrueZipAlphaChunkStore.java b/src/com/sk89q/worldedit/data/TrueZipAlphaChunkStore.java index 48236ec38..8452b6e0b 100644 --- a/src/com/sk89q/worldedit/data/TrueZipAlphaChunkStore.java +++ b/src/com/sk89q/worldedit/data/TrueZipAlphaChunkStore.java @@ -22,7 +22,6 @@ package com.sk89q.worldedit.data; import de.schlichtherle.io.*; import de.schlichtherle.io.File; import de.schlichtherle.io.FileInputStream; -import de.schlichtherle.io.FileOutputStream; import java.io.*; /** @@ -150,7 +149,7 @@ public class TrueZipAlphaChunkStore extends NestedFileChunkStore { @Override public void close() throws IOException { try { - path.umount(); + File.umount(new File(path)); } catch (ArchiveException e) { throw new IOException(e); } diff --git a/src/com/sk89q/worldedit/data/ZippedAlphaChunkStore.java b/src/com/sk89q/worldedit/data/ZippedAlphaChunkStore.java index e4a9dcd3d..7e08d3c97 100644 --- a/src/com/sk89q/worldedit/data/ZippedAlphaChunkStore.java +++ b/src/com/sk89q/worldedit/data/ZippedAlphaChunkStore.java @@ -32,6 +32,7 @@ public class ZippedAlphaChunkStore extends NestedFileChunkStore { /** * ZIP file. */ + @SuppressWarnings("unused") private File zipFile; /** * Actual ZIP. @@ -105,7 +106,9 @@ public class ZippedAlphaChunkStore extends NestedFileChunkStore { // So not there either... if (testEntry == null) { - for (Enumeration e = zip.entries(); e.hasMoreElements(); ) { + for (Enumeration e = zip.entries(); + e.hasMoreElements(); ) { + testEntry = (ZipEntry)e.nextElement(); // Whoo, found level.dat! diff --git a/src/com/sk89q/worldedit/snapshots/InvalidSnapshotException.java b/src/com/sk89q/worldedit/snapshots/InvalidSnapshotException.java index 172b1892e..061ab37a1 100644 --- a/src/com/sk89q/worldedit/snapshots/InvalidSnapshotException.java +++ b/src/com/sk89q/worldedit/snapshots/InvalidSnapshotException.java @@ -24,5 +24,6 @@ package com.sk89q.worldedit.snapshots; * @author sk89q */ public class InvalidSnapshotException extends Exception { + private static final long serialVersionUID = 7307139106494852893L; }