From 273b4701408654698e54b63886d819ad7945498e Mon Sep 17 00:00:00 2001 From: Dan Mulloy Date: Wed, 17 Jun 2015 15:08:58 -0400 Subject: [PATCH] And a few more --- .../com/comphenix/protocol/CommandFilter.java | 1 - .../protocol/async/AsyncListenerHandler.java | 45 ++++++++++--------- .../comphenix/protocol/async/AsyncMarker.java | 1 + .../concurrency/AbstractIntervalTree.java | 1 + .../protocol/events/NetworkMarker.java | 1 + .../injector/player/PlayerInjector.java | 5 ++- .../injector/spigot/SpigotPacketInjector.java | 7 ++- .../reflect/compiler/StructureCompiler.java | 3 +- .../comphenix/protocol/utility/HexDumper.java | 1 - .../protocol/utility/SafeCacheBuilder.java | 21 ++++++++- .../protocol/wrappers/BlockPosition.java | 3 ++ .../protocol/wrappers/BukkitConverters.java | 5 +++ .../protocol/wrappers/ChunkPosition.java | 19 ++++---- .../protocol/wrappers/TroveWrapper.java | 12 ++++- .../protocol/wrappers/WrappedAttribute.java | 19 ++++---- .../protocol/wrappers/WrappedDataWatcher.java | 4 +- .../protocol/wrappers/WrappedGameProfile.java | 1 + .../protocol/wrappers/WrappedServerPing.java | 1 + .../wrappers/WrappedWatchableObject.java | 1 - .../wrappers/collection/ConvertedMap.java | 23 +++++----- .../protocol/wrappers/nbt/NbtCompound.java | 7 +++ .../protocol/wrappers/nbt/NbtFactory.java | 7 +++ .../protocol/wrappers/nbt/NbtList.java | 2 +- .../wrappers/nbt/io/NbtBinarySerializer.java | 1 + .../nbt/io/NbtConfigurationSerializer.java | 15 ++++--- .../wrappers/nbt/io/NbtTextSerializer.java | 3 ++ 26 files changed, 142 insertions(+), 67 deletions(-) diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/CommandFilter.java b/ProtocolLib/src/main/java/com/comphenix/protocol/CommandFilter.java index afa44431..e78a5528 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/CommandFilter.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/CommandFilter.java @@ -321,7 +321,6 @@ public class CommandFilter extends CommandBase { * @param event - the event. * @param handler - failure handler. * @return TRUE if we should, FALSE otherwise. - * @throws ScriptException If one of the filters failed. */ public boolean filterEvent(PacketEvent event, FilterFailedHandler handler) { for (Iterator it = filters.iterator(); it.hasNext(); ) { diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/async/AsyncListenerHandler.java b/ProtocolLib/src/main/java/com/comphenix/protocol/async/AsyncListenerHandler.java index 4a77424c..4c49e922 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/async/AsyncListenerHandler.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/async/AsyncListenerHandler.java @@ -2,16 +2,16 @@ * ProtocolLib - Bukkit server library that allows access to the Minecraft protocol. * Copyright (C) 2012 Kristian S. Stangeland * - * This program is free software; you can redistribute it and/or modify it under the terms of the - * GNU General Public License as published by the Free Software Foundation; either version 2 of + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with this program; - * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * You should have received a copy of the GNU General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * 02111-1307 USA */ @@ -48,7 +48,7 @@ import com.google.common.base.Joiner; */ public class AsyncListenerHandler { public static final ReportType REPORT_HANDLER_NOT_STARTED = new ReportType( - "Plugin %s did not start the asynchronous handler %s by calling start() or syncStart()."); + "Plugin %s did not start the asynchronous handler %s by calling start() or syncStart()."); /** * Signal an end to packet processing. @@ -209,6 +209,7 @@ public class AsyncListenerHandler { * close a specific worker is less efficient than stopping an arbitrary worker. *

* Warning: Never call the run() method in the main thread. + * @return The listener loop */ public AsyncRunnable getListenerLoop() { return new AsyncRunnable() { @@ -315,7 +316,7 @@ public class AsyncListenerHandler { * public Void apply(@Nullable AsyncRunnable workerLoop) { * Thread thread = Thread.currentThread(); * int prevPriority = thread.getPriority(); - * + * * thread.setPriority(Thread.MIN_PRIORITY); * workerLoop.run(); * thread.setPriority(prevPriority); @@ -357,9 +358,9 @@ public class AsyncListenerHandler { * @return A friendly thread name. */ public String getFriendlyWorkerName(int id) { - return String.format("Protocol Worker #%s - %s - [recv: %s, send: %s]", - id, - PacketAdapter.getPluginName(listener), + return String.format("Protocol Worker #%s - %s - [recv: %s, send: %s]", + id, + PacketAdapter.getPluginName(listener), fromWhitelist(listener.getReceivingWhitelist()), fromWhitelist(listener.getSendingWhitelist()) ); @@ -383,8 +384,8 @@ public class AsyncListenerHandler { * This is useful if you need to synchronize with the main thread in your packet listener, but * you're not performing any expensive processing. *

- * Note: Use a asynchronous worker if the packet listener may use more than 0.5 ms - * of processing time on a single packet. Do as much as possible on the worker thread, and schedule synchronous tasks + * Note: Use a asynchronous worker if the packet listener may use more than 0.5 ms + * of processing time on a single packet. Do as much as possible on the worker thread, and schedule synchronous tasks * to use the Bukkit API instead. * @return TRUE if the synchronized processing was successfully started, FALSE if it's already running. * @throws IllegalStateException If we couldn't start the underlying task. @@ -399,12 +400,12 @@ public class AsyncListenerHandler { * This is useful if you need to synchronize with the main thread in your packet listener, but * you're not performing any expensive processing. *

- * The processing time parameter gives the upper bound for the amount of time spent processing pending packets. - * It should be set to a fairly low number, such as 0.5 ms or 1% of a game tick - to reduce the impact + * The processing time parameter gives the upper bound for the amount of time spent processing pending packets. + * It should be set to a fairly low number, such as 0.5 ms or 1% of a game tick - to reduce the impact * on the main thread. Never go beyond 50 milliseconds. *

- * Note: Use a asynchronous worker if the packet listener may exceed the ideal processing time - * on a single packet. Do as much as possible on the worker thread, and schedule synchronous tasks + * Note: Use a asynchronous worker if the packet listener may exceed the ideal processing time + * on a single packet. Do as much as possible on the worker thread, and schedule synchronous tasks * to use the Bukkit API instead. * * @param time - the amount of processing time alloted per game tick (20 ticks per second). @@ -503,7 +504,7 @@ public class AsyncListenerHandler { } /** - * Set the current number of workers. + * Set the current number of workers. *

* This method can only be called with a count of zero when the listener is closing. * @param count - new number of workers. @@ -563,7 +564,7 @@ public class AsyncListenerHandler { */ private void listenerLoop(int workerID) { // Danger, danger! - if (Thread.currentThread().getId() == mainThread.getId()) + if (Thread.currentThread().getId() == mainThread.getId()) throw new IllegalStateException("Do not call this method from the main thread."); if (cancelled) throw new IllegalStateException("Listener has been cancelled. Create a new listener instead."); @@ -584,7 +585,7 @@ public class AsyncListenerHandler { // This is a bit slow, but it should be safe synchronized (stopLock) { // Are we the one who is supposed to stop? - if (stoppedTasks.contains(workerID)) + if (stoppedTasks.contains(workerID)) return; if (waitForStops()) return; @@ -616,7 +617,7 @@ public class AsyncListenerHandler { AsyncMarker marker = packet.getAsyncMarker(); // Here's the core of the asynchronous processing - try { + try { synchronized (marker.getProcessingLock()) { marker.setListenerHandler(this); marker.setWorkerID(workerID); @@ -624,7 +625,7 @@ public class AsyncListenerHandler { // We're not THAT worried about performance here if (timedManager.isTiming()) { // Retrieve the tracker to use - TimedTracker tracker = timedManager.getTracker(listener, + TimedTracker tracker = timedManager.getTracker(listener, packet.isServerPacket() ? ListenerType.ASYNC_SERVER_SIDE : ListenerType.ASYNC_CLIENT_SIDE); long token = tracker.beginTracking(); diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/async/AsyncMarker.java b/ProtocolLib/src/main/java/com/comphenix/protocol/async/AsyncMarker.java index 5049e4c4..e4aa2578 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/async/AsyncMarker.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/async/AsyncMarker.java @@ -401,6 +401,7 @@ public class AsyncMarker implements Serializable, Comparable { /** * Determine if Minecraft allows asynchronous processing of this packet. + * @param event - packet event * @return TRUE if it does, FALSE otherwise. * @throws FieldAccessException If determining fails for some reasaon */ diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/concurrency/AbstractIntervalTree.java b/ProtocolLib/src/main/java/com/comphenix/protocol/concurrency/AbstractIntervalTree.java index 8fb4c87c..06693459 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/concurrency/AbstractIntervalTree.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/concurrency/AbstractIntervalTree.java @@ -139,6 +139,7 @@ public abstract class AbstractIntervalTree, TValue * Removes every interval that intersects with the given range. * @param lowerBound - lowest value to remove. * @param upperBound - highest value to remove. + * @return Intervals that were removed */ public Set remove(TKey lowerBound, TKey upperBound) { return remove(lowerBound, upperBound, false); diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/events/NetworkMarker.java b/ProtocolLib/src/main/java/com/comphenix/protocol/events/NetworkMarker.java index 5a7c622c..1e990e40 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/events/NetworkMarker.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/events/NetworkMarker.java @@ -339,6 +339,7 @@ public abstract class NetworkMarker { *

* It's safe to modify the input stream. * @throws IOException If integer reading fails + * @return An input stream without the header */ protected abstract DataInputStream skipHeader(DataInputStream input) throws IOException; diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/injector/player/PlayerInjector.java b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/player/PlayerInjector.java index 7afda252..36531f69 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/injector/player/PlayerInjector.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/player/PlayerInjector.java @@ -443,9 +443,10 @@ public abstract class PlayerInjector implements SocketInjector { /** * Retrieves the current net handler for this player. - * @boolean refresh - Whether or not to refresh + * @param refresh - Whether or not to refresh * @return Current net handler. * @throws IllegalAccessException Unable to find or retrieve net handler. + * @return The current net handler for this player */ protected Object getNetHandler(boolean refresh) throws IllegalAccessException { // What a mess @@ -564,7 +565,7 @@ public abstract class PlayerInjector implements SocketInjector { /** * Determine if this inject method can even be attempted. - * @param GamePhase - Game phase + * @param state - Game phase * @return TRUE if can be attempted, though possibly with failure, FALSE otherwise. */ public abstract boolean canInject(GamePhase state); diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/injector/spigot/SpigotPacketInjector.java b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/spigot/SpigotPacketInjector.java index 4653de65..a31fcfcc 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/injector/spigot/SpigotPacketInjector.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/spigot/SpigotPacketInjector.java @@ -52,7 +52,7 @@ import com.google.common.collect.MapMaker; import com.google.common.collect.Maps; /** - * Offload all the work to Spigot, if possible. + * Offload all the work to Spigot, if possible. * * @author Kristian */ @@ -104,11 +104,14 @@ public class SpigotPacketInjector implements SpigotPacketListener { private PacketInjector proxyPacketInjector; // Background task - private static final int BACKGROUND_DELAY = 30 * PacketFilterManager.TICKS_PER_SECOND; + private static final int BACKGROUND_DELAY = 30 * PacketFilterManager.TICKS_PER_SECOND; private int backgroundId; /** * Create a new spigot injector. + * @param reporter - error reporter + * @param invoker - listener invoker + * @param server - server */ public SpigotPacketInjector(ErrorReporter reporter, ListenerInvoker invoker, Server server) { this.reporter = reporter; diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/compiler/StructureCompiler.java b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/compiler/StructureCompiler.java index f8e52843..80234722 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/compiler/StructureCompiler.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/compiler/StructureCompiler.java @@ -157,7 +157,7 @@ public final class StructureCompiler { /** * Lookup the current class loader for any previously generated classes before we attempt to generate something. - * @param Type + * @param Type * @param source - the structure modifier to look up. * @return TRUE if we successfully found a previously generated class, FALSE otherwise. */ @@ -192,6 +192,7 @@ public final class StructureCompiler { *

* WARNING: Do NOT call this method in the main thread. Compiling may easily take 10 ms, which is already * over 1/4 of a tick (50 ms). Let the background thread automatically compile the structure modifiers instead. + * @param Type * @param source - structure modifier to compile. * @return A compiled structure modifier. */ diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/utility/HexDumper.java b/ProtocolLib/src/main/java/com/comphenix/protocol/utility/HexDumper.java index f447668b..6ddc420a 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/utility/HexDumper.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/utility/HexDumper.java @@ -133,7 +133,6 @@ public class HexDumper { * Append the hex dump of the given data to the string builder, using the current formatting settings. * @param appendable - appendable source. * @param data - the data to dump. - * @param length - the number of bytes to dump. * @throws IOException Any underlying IO exception. */ public void appendTo(Appendable appendable, byte[] data) throws IOException { diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/utility/SafeCacheBuilder.java b/ProtocolLib/src/main/java/com/comphenix/protocol/utility/SafeCacheBuilder.java index 99d6498e..bf3bd24e 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/utility/SafeCacheBuilder.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/utility/SafeCacheBuilder.java @@ -61,7 +61,7 @@ public class SafeCacheBuilder { * * @throws IllegalArgumentException if {@code concurrencyLevel} is * nonpositive - * @throws IllegalStateExeption if a concurrency level was already set + * @throws IllegalStateException if a concurrency level was already set */ public SafeCacheBuilder concurrencyLevel(int concurrencyLevel) { builder.concurrencyLevel(concurrencyLevel); @@ -121,6 +121,8 @@ public class SafeCacheBuilder { * @param duration the length of time after an entry is created that it * should be automatically removed * @param unit the unit that {@code duration} is expressed in + * @return This for chaining + * * @throws IllegalArgumentException if {@code duration} is negative * @throws IllegalStateException if the time to live or time to idle was * already set @@ -138,6 +140,9 @@ public class SafeCacheBuilder { * the need for expensive resizing operations later, but setting this value * unnecessarily high wastes memory. * + * @param initialCapacity - initial capacity + * @return This for chaining + * * @throws IllegalArgumentException if {@code initialCapacity} is negative * @throws IllegalStateException if an initial capacity was already set */ @@ -162,6 +167,8 @@ public class SafeCacheBuilder { * without a code change. * * @param size the maximum size of the cache + * @return This for chaining + * * @throws IllegalArgumentException if {@code size} is negative * @throws IllegalStateException if a maximum size was already set */ @@ -202,6 +209,9 @@ public class SafeCacheBuilder { * incompatible with the listener, you will likely experience a * {@link ClassCastException} at some undefined point in the future. * + * @param listener - removal listener + * @return This for chaining + * * @throws IllegalStateException if a removal listener was already set */ @SuppressWarnings("unchecked") @@ -219,6 +229,9 @@ public class SafeCacheBuilder { * which have been configured with {@link #expireAfterWrite} or * {@link #expireAfterAccess}. * + * @param ticker - ticker + * @return This for chaining + * * @throws IllegalStateException if a ticker was already set */ public SafeCacheBuilder ticker(Ticker ticker) { @@ -242,6 +255,8 @@ public class SafeCacheBuilder { * Note: when this method is used, the resulting cache will use * identity ({@code ==}) comparison to determine equality of values. * + * @return This for chaining + * * @throws IllegalStateException if the value strength was already set */ public SafeCacheBuilder softValues() { @@ -257,6 +272,8 @@ public class SafeCacheBuilder { * Warning: when this method is used, the resulting cache will use * identity ({@code ==}) comparison to determine equality of keys. * + * @return This for chaining + * * @throws IllegalStateException if the key strength was already set */ public SafeCacheBuilder weakKeys() { @@ -277,6 +294,8 @@ public class SafeCacheBuilder { * Note: when this method is used, the resulting cache will use * identity ({@code ==}) comparison to determine equality of values. * + * @return This for chaining + * * @throws IllegalStateException if the value strength was already set */ public SafeCacheBuilder weakValues() { diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/BlockPosition.java b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/BlockPosition.java index f9e9f5af..b86ab877 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/BlockPosition.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/BlockPosition.java @@ -50,6 +50,9 @@ public class BlockPosition { /** * Construct an immutable 3D vector. + * @param x - x coordinate + * @param y - y coordinate + * @param z - z coordinate */ public BlockPosition(int x, int y, int z) { this.x = x; diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/BukkitConverters.java b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/BukkitConverters.java index 9db4d779..a128d2b5 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/BukkitConverters.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/BukkitConverters.java @@ -210,6 +210,8 @@ public class BukkitConverters { /** * Retrieve an equivalent converter for a map of generic keys and primitive values. + * @param Key type + * @param Value type * @param genericKeyType - the generic key type. * @param keyConverter - an equivalent converter for the generic type. * @return An equivalent converter. @@ -264,6 +266,7 @@ public class BukkitConverters { /** * Retrieve an equivalent converter for a list of generic items. + * @param Type * @param genericItemType - the generic item type. * @param itemConverter - an equivalent converter for the generic type. * @return An equivalent converter. @@ -320,6 +323,7 @@ public class BukkitConverters { /** * Retrieve an equivalent converter for an array of generic items. + * @param Type *

* The array is wrapped in a list. * @param genericItemType - the generic item type. @@ -878,6 +882,7 @@ public class BukkitConverters { /** * Wraps a given equivalent converter in NULL checks, ensuring that such values are ignored. + * @param Type * @param delegate - the underlying equivalent converter. * @return A equivalent converter that ignores NULL values. */ diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/ChunkPosition.java b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/ChunkPosition.java index 9854ce49..022491c3 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/ChunkPosition.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/ChunkPosition.java @@ -2,16 +2,16 @@ * ProtocolLib - Bukkit server library that allows access to the Minecraft protocol. * Copyright (C) 2012 Kristian S. Stangeland * - * This program is free software; you can redistribute it and/or modify it under the terms of the - * GNU General Public License as published by the Free Software Foundation; either version 2 of + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with this program; - * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * You should have received a copy of the GNU General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * 02111-1307 USA */ @@ -51,6 +51,9 @@ public class ChunkPosition { /** * Construct an immutable 3D vector. + * @param x - x coordinate + * @param y - y coordinate + * @param z - z coordinate */ public ChunkPosition(int x, int y, int z) { this.x = x; @@ -173,7 +176,7 @@ public class ChunkPosition { @Override public ChunkPosition getSpecific(Object generic) { if (MinecraftReflection.isChunkPosition(generic)) { - // Use a structure modifier + // Use a structure modifier intModifier = new StructureModifier(generic.getClass(), null, false).withType(int.class); // Damn it all @@ -189,7 +192,7 @@ public class ChunkPosition { } catch (FieldAccessException e) { // This is an exeptional work-around, so we don't want to burden the caller with the messy details throw new RuntimeException("Field access error.", e); - } + } } } diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/TroveWrapper.java b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/TroveWrapper.java index 08132b1e..7108d603 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/TroveWrapper.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/TroveWrapper.java @@ -51,6 +51,7 @@ public class TroveWrapper { */ public static ReadOnlyFieldAccessor wrapMapField(final FieldAccessor accessor, final Function noEntryTransform) { return new ReadOnlyFieldAccessor() { + @Override public Object get(Object instance) { Object troveMap = accessor.get(instance); @@ -59,6 +60,7 @@ public class TroveWrapper { TroveWrapper.transformNoEntryValue(troveMap, noEntryTransform); return getDecoratedMap(troveMap); } + @Override public Field getField() { return accessor.getField(); } @@ -72,9 +74,11 @@ public class TroveWrapper { */ public static ReadOnlyFieldAccessor wrapSetField(final FieldAccessor accessor) { return new ReadOnlyFieldAccessor() { + @Override public Object get(Object instance) { return getDecoratedSet(accessor.get(instance)); } + @Override public Field getField() { return accessor.getField(); } @@ -88,9 +92,11 @@ public class TroveWrapper { */ public static ReadOnlyFieldAccessor wrapListField(final FieldAccessor accessor) { return new ReadOnlyFieldAccessor() { + @Override public Object get(Object instance) { return getDecoratedList(accessor.get(instance)); } + @Override public Field getField() { return accessor.getField(); } @@ -99,6 +105,8 @@ public class TroveWrapper { /** * Retrieve a Java wrapper for the corresponding Trove map. + * @param Key type + * @param Value type * @param troveMap - the trove map to wrap. * @return The wrapped GNU Trove map. * @throws IllegalStateException If GNU Trove cannot be found in the class map. @@ -113,6 +121,7 @@ public class TroveWrapper { /** * Retrieve a Java wrapper for the corresponding Trove set. + * @param Type * @param troveSet - the trove set to wrap. * @return The wrapped GNU Trove set. * @throws IllegalStateException If GNU Trove cannot be found in the class map. @@ -127,6 +136,7 @@ public class TroveWrapper { /** * Retrieve a Java wrapper for the corresponding Trove list. + * @param Type * @param troveList - the trove list to wrap. * @return The wrapped GNU Trove list. * @throws IllegalStateException If GNU Trove cannot be found in the class map. @@ -185,7 +195,7 @@ public class TroveWrapper { } /** - * Retrieve the corresponding decorator. + * Retrieve the corresponding decorator. * @param trove - the trove class. * @return The wrapped trove class. */ diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/WrappedAttribute.java b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/WrappedAttribute.java index a4e3b639..ab5a8a7a 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/WrappedAttribute.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/WrappedAttribute.java @@ -121,13 +121,14 @@ public class WrappedAttribute extends AbstractWrapper { */ public PacketContainer getParentPacket() { return new PacketContainer( - PacketType.Play.Server.UPDATE_ATTRIBUTES, + PacketType.Play.Server.UPDATE_ATTRIBUTES, modifier.withType(MinecraftReflection.getPacketClass()).read(0) ); } /** * Determine if the attribute has a given attribute modifier, identified by UUID. + * @param id - the id to check for. * @return TRUE if it does, FALSE otherwise. */ public boolean hasModifier(UUID id) { @@ -154,13 +155,13 @@ public class WrappedAttribute extends AbstractWrapper { * Retrieve an immutable set of all the attribute modifiers that will compute the final value of this attribute. * @return Every attribute modifier. */ - public Set getModifiers() { + public Set getModifiers() { if (attributeModifiers == null) { @SuppressWarnings("unchecked") Collection collection = (Collection) modifier.withType(Collection.class).read(0); // Convert to an equivalent wrapper - ConvertedSet converted = + ConvertedSet converted = new ConvertedSet(getSetSafely(collection)) { @Override protected Object toInner(WrappedAttributeModifier outer) { @@ -197,7 +198,7 @@ public class WrappedAttribute extends AbstractWrapper { return getBaseValue() == other.getBaseValue() && Objects.equal(getAttributeKey(), other.getAttributeKey()) && Sets.symmetricDifference( - getModifiers(), + getModifiers(), other.getModifiers() ).isEmpty(); } @@ -229,7 +230,7 @@ public class WrappedAttribute extends AbstractWrapper { x += modifier.getAmount(); break; case 1: // Multiply percentage - y += x * modifier.getAmount(); + y += x * modifier.getAmount(); break; case 2: y *= 1 + modifier.getAmount(); @@ -280,7 +281,7 @@ public class WrappedAttribute extends AbstractWrapper { } /** - * Represents a builder for wrapped attributes. + * Represents a builder for wrapped attributes. *

* Use {@link WrappedAttribute#newBuilder()} to construct it. * @author Kristian @@ -390,9 +391,9 @@ public class WrappedAttribute extends AbstractWrapper { try { Object handle = ATTRIBUTE_CONSTRUCTOR.newInstance( - packet.getHandle(), - attributeKey, - baseValue, + packet.getHandle(), + attributeKey, + baseValue, getUnwrappedModifiers()); // Create it diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/WrappedDataWatcher.java b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/WrappedDataWatcher.java index 22e31624..368d52c0 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/WrappedDataWatcher.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/WrappedDataWatcher.java @@ -322,6 +322,7 @@ public class WrappedDataWatcher extends AbstractWrapper implements Iterable * * * diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/collection/ConvertedMap.java b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/collection/ConvertedMap.java index 53a1db8f..b7a95dbf 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/collection/ConvertedMap.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/collection/ConvertedMap.java @@ -2,16 +2,16 @@ * ProtocolLib - Bukkit server library that allows access to the Minecraft protocol. * Copyright (C) 2012 Kristian S. Stangeland * - * This program is free software; you can redistribute it and/or modify it under the terms of the - * GNU General Public License as published by the Free Software Foundation; either version 2 of + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with this program; - * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * You should have received a copy of the GNU General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * 02111-1307 USA */ @@ -84,6 +84,7 @@ public abstract class ConvertedMap extends AbstractConverte /** * Convert a value from the inner map to the outer visible map. + * @param key - unused value. * @param inner - the inner value. * @return The outer value. */ @@ -93,6 +94,7 @@ public abstract class ConvertedMap extends AbstractConverte /** * Convert a value from the outer map to the internal inner map. + * @param key - unused value. * @param outer - the outer value. * @return The inner value. */ @@ -161,7 +163,8 @@ public abstract class ConvertedMap extends AbstractConverte * * @return a string representation of this map */ - public String toString() { + @Override + public String toString() { Iterator> i = entrySet().iterator(); if (!i.hasNext()) return "{}"; @@ -189,7 +192,7 @@ public abstract class ConvertedMap extends AbstractConverte * @return The converted set of entries. */ static Set> convertedEntrySet( - final Collection> entries, + final Collection> entries, final BiFunction innerFunction, final BiFunction outerFunction) { @@ -209,7 +212,7 @@ public abstract class ConvertedMap extends AbstractConverte @Override public VInner setValue(VInner value) { - return innerFunction.apply(getKey(), outer.setValue(outerFunction.apply(getKey(), value))); + return innerFunction.apply(getKey(), outer.setValue(outerFunction.apply(getKey(), value))); } @Override @@ -235,7 +238,7 @@ public abstract class ConvertedMap extends AbstractConverte @Override public VOuter setValue(VOuter value) { final VInner converted = innerFunction.apply(getKey(), value); - return outerFunction.apply(getKey(), inner.setValue(converted)); + return outerFunction.apply(getKey(), inner.setValue(converted)); } @Override diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/nbt/NbtCompound.java b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/nbt/NbtCompound.java index 52e6b362..29c96678 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/nbt/NbtCompound.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/nbt/NbtCompound.java @@ -37,6 +37,7 @@ public interface NbtCompound extends NbtBase>>, Iterable< /** * Retrieve the value of a given entry. + * @param Type * @param key - key of the entry to retrieve. * @return The value of this entry, or NULL if not found. */ @@ -52,6 +53,7 @@ public interface NbtCompound extends NbtBase>>, Iterable< /** * Set a entry based on its name. + * @param Type * @param entry - entry with a name and value. * @return This compound, for chaining. * @throws IllegalArgumentException If entry is NULL. @@ -302,6 +304,7 @@ public interface NbtCompound extends NbtBase>>, Iterable< /** * Retrieve the NBT list value of an entry identified by a given key. + * @param Type * @param key - the key of the entry. * @return The NBT list value of the entry. * @throws IllegalArgumentException If the key doesn't exist. @@ -310,6 +313,7 @@ public interface NbtCompound extends NbtBase>>, Iterable< /** * Retrieve a NBT list value by its key, or create a new list if it doesn't exist. + * @param Type * @param key - the key of the entry to find or create. * @return The compound value that was retrieved or just created. */ @@ -317,6 +321,7 @@ public interface NbtCompound extends NbtBase>>, Iterable< /** * Associate a NBT list with the given key. + * @param Type * @param list - the list value. * @return This current compound, for chaining. */ @@ -324,6 +329,7 @@ public interface NbtCompound extends NbtBase>>, Iterable< /** * Associate a new NBT list with the given key. + * @param Type * @param key - the key and name of the new NBT list. * @param list - the list of NBT elements. * @return This current compound, for chaining. @@ -332,6 +338,7 @@ public interface NbtCompound extends NbtBase>>, Iterable< /** * Remove the NBT element that is associated with the given key. + * @param Type * @param key - the key of the element to remove. * @return The removed element, or NULL if no such element was found. */ diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/nbt/NbtFactory.java b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/nbt/NbtFactory.java index 99992c8c..21eab44f 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/nbt/NbtFactory.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/nbt/NbtFactory.java @@ -94,6 +94,8 @@ public class NbtFactory { * Get a NBT wrapper from a NBT base. *

* This may clone the content if the NbtBase is not a NbtWrapper. + * + * @param Type * @param base - the base class. * @return A NBT wrapper. */ @@ -282,6 +284,7 @@ public class NbtFactory { * Initialize a NBT wrapper. *

* Use {@link #fromNMS(Object, String)} instead. + * @param Type * @param handle - the underlying net.minecraft.server object to wrap. * @return A NBT wrapper. */ @@ -301,6 +304,7 @@ public class NbtFactory { /** * Initialize a NBT wrapper with a name. + * @param Type * @param name - the name of the tag, or NULL if not valid. * @param handle - the underlying net.minecraft.server object to wrap. * @return A NBT wrapper. @@ -460,6 +464,7 @@ public class NbtFactory { /** * Create a new NBT wrapper from a given type. + * @param Type * @param type - the NBT type. * @param name - the name of the NBT tag. * @return The new wrapped NBT tag. @@ -539,6 +544,7 @@ public class NbtFactory { /** * Create a new NBT wrapper from a given type. + * @param Type * @param type - the NBT type. * @param name - the name of the NBT tag. * @param value - the value of the new tag. @@ -555,6 +561,7 @@ public class NbtFactory { /** * Create a new NBT wrapper from a given type. + * @param Type * @param type - type of the NBT value. * @param name - the name of the NBT tag. * @param value - the value of the new tag. diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/nbt/NbtList.java b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/nbt/NbtList.java index e5dfacc6..f7e5be7c 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/nbt/NbtList.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/nbt/NbtList.java @@ -46,7 +46,7 @@ public interface NbtList extends NbtBase>>, Iterable< /** * Add a NBT list or NBT compound to the list. - * @param element + * @param element Element to add */ public abstract void add(NbtBase element); diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/nbt/io/NbtBinarySerializer.java b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/nbt/io/NbtBinarySerializer.java index b1ba1db0..32be7b2c 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/nbt/io/NbtBinarySerializer.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/nbt/io/NbtBinarySerializer.java @@ -102,6 +102,7 @@ public class NbtBinarySerializer { /** * Load an NBT tag from a stream. + * @param Type * @param source - the input stream. * @return An NBT tag. */ diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/nbt/io/NbtConfigurationSerializer.java b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/nbt/io/NbtConfigurationSerializer.java index 2b7c81ab..27f32cd1 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/nbt/io/NbtConfigurationSerializer.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/nbt/io/NbtConfigurationSerializer.java @@ -69,6 +69,7 @@ public class NbtConfigurationSerializer { /** * Write the content of a NBT tag to a configuration section. + * @param Type * @param value - the NBT tag to write. * @param destination - the destination section. */ @@ -143,7 +144,7 @@ public class NbtConfigurationSerializer { private Integer getNextIndex() { Integer listIndex = workingIndex.get(current); - if (listIndex != null) + if (listIndex != null) return workingIndex.put(current, listIndex + 1); else return null; @@ -167,7 +168,8 @@ public class NbtConfigurationSerializer { } /** - * Read a NBT tag from a root configuration. + * Read a NBT tag from a root configuration. + * @param Type * @param root - configuration that contains the NBT tag. * @param nodeName - name of the NBT tag. * @return The read NBT tag. @@ -178,7 +180,7 @@ public class NbtConfigurationSerializer { } /** - * Read a NBT compound from a root configuration. + * Read a NBT compound from a root configuration. * @param root - configuration that contains the NBT compound. * @param nodeName - name of the NBT compound. * @return The read NBT compound. @@ -188,7 +190,8 @@ public class NbtConfigurationSerializer { } /** - * Read a NBT compound from a root configuration. + * Read a NBT compound from a root configuration. + * @param Type * @param root - configuration that contains the NBT compound. * @param nodeName - name of the NBT compound. * @return The read NBT compound. @@ -248,7 +251,7 @@ public class NbtConfigurationSerializer { ConfigurationSection section = (ConfigurationSection) node; // As above - for (String key : section.getKeys(false)) + for (String key : section.getKeys(false)) compound.put(readNode(section, key)); return (NbtWrapper) compound; } @@ -315,7 +318,7 @@ public class NbtConfigurationSerializer { * @return An equivalent byte array. */ private static byte[] toByteArray(int[] data) { - ByteBuffer byteBuffer = ByteBuffer.allocate(data.length * 4); + ByteBuffer byteBuffer = ByteBuffer.allocate(data.length * 4); IntBuffer intBuffer = byteBuffer.asIntBuffer(); intBuffer.put(data); diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/nbt/io/NbtTextSerializer.java b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/nbt/io/NbtTextSerializer.java index c9e2b8ed..874f25c5 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/nbt/io/NbtTextSerializer.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/nbt/io/NbtTextSerializer.java @@ -48,6 +48,7 @@ public class NbtTextSerializer { /** * Serialize a NBT tag to a base-64 encoded string. + * @param Type * @param value - the NBT tag to serialize. * @return The NBT tag in base-64 form. */ @@ -63,6 +64,7 @@ public class NbtTextSerializer { /** * Deserialize a NBT tag from a base-64 encoded string. + * @param Type * @param input - the base-64 string. * @return The NBT tag contained in the string. * @throws IOException If we are unable to parse the input. @@ -87,6 +89,7 @@ public class NbtTextSerializer { /** * Deserialize a NBT list from a base-64 encoded string. + * @param Type * @param input - the base-64 string. * @return The NBT tag contained in the string. * @throws IOException If we are unable to parse the input.

Type to Value