From bba1054f9761451c396f5786ac55011f316d7ac0 Mon Sep 17 00:00:00 2001 From: Dan Mulloy Date: Wed, 17 Jun 2015 14:25:39 -0400 Subject: [PATCH] Fix a ton of JavaDoc errors --- .../com/comphenix/protocol/CommandFilter.java | 8 +- .../com/comphenix/protocol/PacketType.java | 1 + .../comphenix/protocol/ProtocolConfig.java | 2 +- .../comphenix/protocol/ProtocolManager.java | 42 +++--- .../protocol/async/AsyncFilterManager.java | 3 +- .../comphenix/protocol/async/AsyncMarker.java | 1 + .../protocol/async/AsyncRunnable.java | 13 +- .../protocol/collections/IntegerMap.java | 3 +- .../concurrency/AbstractIntervalTree.java | 1 + .../protocol/concurrency/BlockingHashMap.java | 22 ++-- .../concurrency/ConcurrentPlayerMap.java | 9 +- .../protocol/concurrency/IntegerSet.java | 16 +-- .../protocol/concurrency/PacketTypeSet.java | 4 +- .../protocol/error/DetailedErrorReporter.java | 1 + .../protocol/error/ErrorReporter.java | 18 +-- .../com/comphenix/protocol/error/Report.java | 18 +-- .../protocol/events/ListenerPriority.java | 14 +- .../protocol/events/ListeningWhitelist.java | 24 ++-- .../protocol/events/NetworkMarker.java | 44 ++++--- .../protocol/events/PacketAdapter.java | 35 +++-- .../protocol/events/PacketContainer.java | 13 +- .../protocol/events/PacketListener.java | 20 +-- .../protocol/injector/BukkitUnwrapper.java | 30 ++--- .../protocol/injector/NetworkProcessor.java | 3 +- .../protocol/injector/PacketConstructor.java | 24 ++-- .../injector/PacketFilterManager.java | 3 +- .../injector/netty/NettyProtocolInjector.java | 2 +- .../injector/packet/InterceptWritePacket.java | 5 +- .../injector/packet/PacketRegistry.java | 30 +++-- .../player/PlayerInjectionHandler.java | 2 +- .../injector/player/PlayerInjector.java | 3 + .../injector/server/SocketInjector.java | 5 +- .../comphenix/protocol/metrics/Metrics.java | 33 ++--- .../protocol/reflect/ClassAnalyser.java | 4 +- .../protocol/reflect/FuzzyReflection.java | 34 ++--- .../protocol/reflect/MethodUtils.java | 124 +++++++++--------- .../protocol/reflect/ObjectEnum.java | 22 ++-- .../protocol/reflect/PrettyPrinter.java | 22 ++-- .../protocol/reflect/StructureModifier.java | 5 +- .../protocol/reflect/VolatileField.java | 1 + .../protocol/reflect/accessors/Accessors.java | 2 +- .../reflect/cloning/SerializableCloner.java | 1 + .../reflect/compiler/BackgroundCompiler.java | 22 ++-- .../reflect/compiler/StructureCompiler.java | 53 ++++---- .../reflect/fuzzy/AbstractFuzzyMember.java | 10 +- .../reflect/fuzzy/FuzzyMethodContract.java | 39 +++--- .../reflect/instances/DefaultInstances.java | 6 +- .../instances/NotConstructableException.java | 6 +- .../protocol/timing/StatisticsStream.java | 9 +- .../protocol/timing/TimedTracker.java | 6 +- .../protocol/utility/ChatExtensions.java | 15 ++- .../comphenix/protocol/utility/HexDumper.java | 6 +- .../protocol/utility/MinecraftReflection.java | 29 +++- .../protocol/utility/SafeCacheBuilder.java | 16 ++- .../protocol/wrappers/AbstractWrapper.java | 2 +- .../protocol/wrappers/BukkitConverters.java | 6 +- .../protocol/wrappers/WrappedGameProfile.java | 2 +- .../protocol/wrappers/WrappedServerPing.java | 6 +- .../wrappers/WrappedSignedProperty.java | 1 - .../protocol/wrappers/WrappedStatistic.java | 7 +- .../wrappers/WrappedWatchableObject.java | 3 +- .../protocol/wrappers/nbt/NbtCompound.java | 9 +- .../protocol/wrappers/nbt/NbtFactory.java | 54 ++++---- .../protocol/wrappers/nbt/NbtList.java | 21 +-- 64 files changed, 529 insertions(+), 466 deletions(-) diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/CommandFilter.java b/ProtocolLib/src/main/java/com/comphenix/protocol/CommandFilter.java index bbbcf323..afa44431 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/CommandFilter.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/CommandFilter.java @@ -295,7 +295,7 @@ public class CommandFilter extends CommandBase { @Override public boolean handle(PacketEvent event, Filter filter, Exception ex) { reporter.reportMinimal(plugin, "filterEvent(PacketEvent)", ex, event); - reporter.reportWarning(this, + reporter.reportWarning(this, Report.newBuilder(REPORT_FILTER_REMOVED_FOR_ERROR).messageParam(filter.getName(), ex.getClass().getSimpleName()) ); return false; @@ -321,7 +321,7 @@ public class CommandFilter extends CommandBase { * @param event - the event. * @param handler - failure handler. * @return TRUE if we should, FALSE otherwise. - * @throws FilterFailedException If one of the filters failed. + * @throws ScriptException If one of the filters failed. */ public boolean filterEvent(PacketEvent event, FilterFailedHandler handler) { for (Iterator it = filters.iterator(); it.hasNext(); ) { @@ -389,7 +389,7 @@ public class CommandFilter extends CommandBase { // Make sure we can use the conversable interface if (sender instanceof Conversable) { - final MultipleLinesPrompt prompt = + final MultipleLinesPrompt prompt = new MultipleLinesPrompt(new CompilationSuccessCanceller(), "function(event, packet) {"); new ConversationFactory(plugin). @@ -424,7 +424,7 @@ public class CommandFilter extends CommandBase { whom.sendRawMessage(ChatColor.RED + "Cancelled filter."); } } catch (Exception e) { - reporter.reportDetailed(this, + reporter.reportDetailed(this, Report.newBuilder(REPORT_CANNOT_HANDLE_CONVERSATION).error(e).callerParam(event) ); } diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/PacketType.java b/ProtocolLib/src/main/java/com/comphenix/protocol/PacketType.java index bd3b4173..b0cbcdda 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/PacketType.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/PacketType.java @@ -823,6 +823,7 @@ public class PacketType implements Serializable, Comparable { * Construct a legacy packet type. * @param sender - client or server. * @param legacyId - the legacy packet ID. + * @return Legacy packet type */ public static PacketType newLegacy(Sender sender, int legacyId) { return new PacketType(Protocol.LEGACY, sender, PacketType.UNKNOWN_PACKET, legacyId, MinecraftVersion.WORLD_UPDATE); diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolConfig.java b/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolConfig.java index 05a84de1..7a7227dd 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolConfig.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolConfig.java @@ -423,7 +423,7 @@ public class ProtocolConfig { /** * Set the starting injection method to use. - * @return Injection method. + * @param hook Injection method */ public void setInjectionMethod(PlayerInjectHooks hook) { setConfig(global, INJECTION_METHOD, hook.name()); diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolManager.java b/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolManager.java index e75ccd4a..8e4796c1 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolManager.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolManager.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 */ @@ -53,7 +53,7 @@ public interface ProtocolManager extends PacketStream { /** * Send a packet to the given player. *

- * Re-sending a previously cancelled packet is discouraged. Use {@link AsyncMarker#incrementProcessingDelay()} + * Re-sending a previously cancelled packet is discouraged. Use {@link AsyncMarker#incrementProcessingDelay()} * to delay a packet until a certain condition has been met. * * @param receiver - the receiver. @@ -62,13 +62,13 @@ public interface ProtocolManager extends PacketStream { * @throws InvocationTargetException - if an error occurred when sending the packet. */ @Override - public void sendServerPacket(Player receiver, PacketContainer packet, boolean filters) + public void sendServerPacket(Player receiver, PacketContainer packet, boolean filters) throws InvocationTargetException; /** * Simulate receiving a certain packet from a given player. *

- * Receiving a previously cancelled packet is discouraged. Use {@link AsyncMarker#incrementProcessingDelay()} + * Receiving a previously cancelled packet is discouraged. Use {@link AsyncMarker#incrementProcessingDelay()} * to delay a packet until a certain condition has been met. * * @param sender - the sender. @@ -78,7 +78,7 @@ public interface ProtocolManager extends PacketStream { * @throws IllegalAccessException If the underlying method caused an error. */ @Override - public void recieveClientPacket(Player sender, PacketContainer packet, boolean filters) + public void recieveClientPacket(Player sender, PacketContainer packet, boolean filters) throws IllegalAccessException, InvocationTargetException; /** @@ -89,9 +89,9 @@ public interface ProtocolManager extends PacketStream { public void broadcastServerPacket(PacketContainer packet); /** - * Broadcast a packet to every player that is receiving information about a given entity. + * Broadcast a packet to every player that is receiving information about a given entity. *

- * This is usually every player in the same world within an observable distance. If the entity is a + * This is usually every player in the same world within an observable distance. If the entity is a * player, it will only be included if includeTracker is TRUE. * @param packet - the packet to broadcast. * @param entity - the entity whose trackers we will inform. @@ -115,17 +115,17 @@ public interface ProtocolManager extends PacketStream { public ImmutableSet getPacketListeners(); /** - * Adds a packet listener. + * Adds a packet listener. *

- * Adding an already registered listener has no effect. If you need to change the packets - * the current listener is observing, you must first remove the packet listener before you + * Adding an already registered listener has no effect. If you need to change the packets + * the current listener is observing, you must first remove the packet listener before you * can register it again. * @param listener - new packet listener. */ public void addPacketListener(PacketListener listener); /** - * Removes a given packet listener. + * Removes a given packet listener. *

* Attempting to remove a listener that doesn't exist has no effect. * @param listener - the packet listener to remove. @@ -158,7 +158,7 @@ public interface ProtocolManager extends PacketStream { /** * Constructs a new encapsulated Minecraft packet with the given ID. *

- * If set to true, the forceDefaults option will force the system to automatically + * If set to true, the forceDefaults option will force the system to automatically * give non-primitive fields in the packet sensible default values. For instance, certain * packets - like Packet60Explosion - require a List or Set to be non-null. If the * forceDefaults option is true, the List or Set will be automatically created. @@ -175,7 +175,7 @@ public interface ProtocolManager extends PacketStream { /** * Constructs a new encapsulated Minecraft packet with the given ID. *

- * If set to true, the forceDefaults option will force the system to automatically + * If set to true, the forceDefaults option will force the system to automatically * give non-primitive fields in the packet sensible default values. For instance, certain * packets - like Packet60Explosion - require a List or Set to be non-null. If the * forceDefaults option is true, the List or Set will be automatically created. @@ -199,7 +199,7 @@ public interface ProtocolManager extends PacketStream { /** * Construct a packet using the special builtin Minecraft constructors. - * @param id - the packet type. + * @param type - the packet type. * @param arguments - arguments that will be passed to the constructor. * @return The packet constructor. */ @@ -208,7 +208,7 @@ public interface ProtocolManager extends PacketStream { /** * Completely resend an entity to a list of clients. *

- * Note that this method is NOT thread safe. If you call this method from anything + * Note that this method is NOT thread safe. If you call this method from anything * but the main thread, it will throw an exception. * @param entity - entity to refresh. * @param observers - the clients to update. @@ -269,7 +269,7 @@ public interface ProtocolManager extends PacketStream { public MinecraftVersion getMinecraftVersion(); /** - * Determines whether or not this protocol manager has been disabled. + * Determines whether or not this protocol manager has been disabled. * @return TRUE if it has, FALSE otherwise. */ public boolean isClosed(); diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/async/AsyncFilterManager.java b/ProtocolLib/src/main/java/com/comphenix/protocol/async/AsyncFilterManager.java index 4f4b47ed..22018be7 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/async/AsyncFilterManager.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/async/AsyncFilterManager.java @@ -373,7 +373,6 @@ public class AsyncFilterManager implements AsynchronousManager { /** * Construct an async marker with the given sending priority delta and timeout delta. - * @param sendingDelta - how many packets we're willing to wait. * @param timeoutDelta - how long (in ms) until the packet expire. * @return An async marker. */ @@ -473,6 +472,8 @@ public class AsyncFilterManager implements AsynchronousManager { /** * Send any due packets, or clean up packets that have expired. + * @param tickCounter Tick counter + * @param onMainThread Whether or not to execute on the main thread */ public void sendProcessedPackets(int tickCounter, boolean onMainThread) { // The server queue is unlikely to need checking that often 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 3c74919e..5049e4c4 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/async/AsyncMarker.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/async/AsyncMarker.java @@ -402,6 +402,7 @@ public class AsyncMarker implements Serializable, Comparable { /** * Determine if Minecraft allows asynchronous processing of this packet. * @return TRUE if it does, FALSE otherwise. + * @throws FieldAccessException If determining fails for some reasaon */ public boolean isMinecraftAsync(PacketEvent event) throws FieldAccessException { if (isMinecraftAsync == null && !alwaysSync) { diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/async/AsyncRunnable.java b/ProtocolLib/src/main/java/com/comphenix/protocol/async/AsyncRunnable.java index 29ff5e8c..134c3f8d 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/async/AsyncRunnable.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/async/AsyncRunnable.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 */ @@ -35,6 +35,7 @@ public interface AsyncRunnable extends Runnable { *

* This may not occur right away. * @return TRUE if the thread was stopped, FALSE if it was already stopped. + * @throws InterruptedException if it is interrupted */ public boolean stop() throws InterruptedException; diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/collections/IntegerMap.java b/ProtocolLib/src/main/java/com/comphenix/protocol/collections/IntegerMap.java index dde7331b..4319ec7f 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/collections/IntegerMap.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/collections/IntegerMap.java @@ -18,6 +18,7 @@ public class IntegerMap { /** * Construct a new integer map. + * @param Parameter type * @return A new integer map. */ public static IntegerMap newMap() { @@ -51,7 +52,7 @@ public class IntegerMap { public T put(int key, T value) { ensureCapacity(key); - T old = array[key]; + T old = array[key]; array[key] = Preconditions.checkNotNull(value, "value cannot be NULL"); if (old == null) 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 c68812d1..8fb4c87c 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/concurrency/AbstractIntervalTree.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/concurrency/AbstractIntervalTree.java @@ -149,6 +149,7 @@ public abstract class AbstractIntervalTree, TValue * @param lowerBound - lowest value to remove. * @param upperBound - highest value to remove. * @param preserveDifference - whether or not to preserve the intervals that are partially outside. + * @return Intervals that were removed */ public Set remove(TKey lowerBound, TKey upperBound, boolean preserveDifference) { checkBounds(lowerBound, upperBound); diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/concurrency/BlockingHashMap.java b/ProtocolLib/src/main/java/com/comphenix/protocol/concurrency/BlockingHashMap.java index f8f684ec..efdc1cef 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/concurrency/BlockingHashMap.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/concurrency/BlockingHashMap.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,6 +48,8 @@ public class BlockingHashMap { /** * Retrieve a cache loader that will always throw an exception. + * @param Type of the key + * @param Type of the value * @return An invalid cache loader. */ public static CacheLoader newInvalidCacheLoader() { @@ -83,6 +85,8 @@ public class BlockingHashMap { /** * Initialize a new map. + * @param Type of the key + * @param Type of the value * @return The created map. */ public static BlockingHashMap create() { @@ -91,7 +95,7 @@ public class BlockingHashMap { /** * Waits until a value has been associated with the given key, and then retrieves that value. - * @param key - the key whose associated value is to be returned + * @param key - the key whose associated value is to be returned * @return The value to which the specified key is mapped. * @throws InterruptedException If the current thread got interrupted while waiting. */ @@ -118,7 +122,7 @@ public class BlockingHashMap { /** * Waits until a value has been associated with the given key, and then retrieves that value. - * @param key - the key whose associated value is to be returned + * @param key - the key whose associated value is to be returned * @param timeout - the amount of time to wait until an association has been made. * @param unit - unit of timeout. * @return The value to which the specified key is mapped, or NULL if the timeout elapsed. @@ -133,7 +137,7 @@ public class BlockingHashMap { *

* If timeout is zero, this method will return immediately if it can't find an socket injector. * - * @param key - the key whose associated value is to be returned + * @param key - the key whose associated value is to be returned * @param timeout - the amount of time to wait until an association has been made. * @param unit - unit of timeout. * @param ignoreInterrupted - TRUE if we should ignore the thread being interrupted, FALSE otherwise. diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/concurrency/ConcurrentPlayerMap.java b/ProtocolLib/src/main/java/com/comphenix/protocol/concurrency/ConcurrentPlayerMap.java index ae937846..5e0d975e 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/concurrency/ConcurrentPlayerMap.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/concurrency/ConcurrentPlayerMap.java @@ -6,7 +6,6 @@ import java.util.Iterator; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; -import java.util.concurrent.ExecutionException; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -70,6 +69,7 @@ public class ConcurrentPlayerMap extends AbstractMap imp /** * Construct a new concurrent player map that uses each player's address as key. + * @param Parameter type * @return Concurrent player map. */ public static ConcurrentPlayerMap usingAddress() { @@ -78,6 +78,7 @@ public class ConcurrentPlayerMap extends AbstractMap imp /** * Construct a new concurrent player map that uses each player's name as key. + * @param Parameter type * @return Concurrent player map. */ public static ConcurrentPlayerMap usingName() { @@ -177,7 +178,6 @@ public class ConcurrentPlayerMap extends AbstractMap imp * Lookup a player by key in the cache, optionally searching every online player. * @param key - the key of the player we are locating. * @return The player, or NULL if not found. - * @throws ExecutionException */ protected Player lookupPlayer(Object key) { try { @@ -293,7 +293,7 @@ public class ConcurrentPlayerMap extends AbstractMap imp private Iterator> entryIterator() { // Skip entries with stale data final Iterator> source = valueLookup.entrySet().iterator(); - final AbstractIterator> filtered = + final AbstractIterator> filtered = new AbstractIterator>() { @Override protected Entry computeNext() { @@ -315,12 +315,15 @@ public class ConcurrentPlayerMap extends AbstractMap imp // We can't return AbstractIterator directly, as it doesn't permitt the remove() method return new Iterator>() { + @Override public boolean hasNext() { return filtered.hasNext(); } + @Override public Entry next() { return filtered.next(); } + @Override public void remove() { source.remove(); } diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/concurrency/IntegerSet.java b/ProtocolLib/src/main/java/com/comphenix/protocol/concurrency/IntegerSet.java index a163cb0a..3cc1df77 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/concurrency/IntegerSet.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/concurrency/IntegerSet.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 */ @@ -25,7 +25,7 @@ import java.util.Set; /** * Represents a very quick integer set that uses a lookup table to store membership. *

- * This class is intentionally missing a size method. + * This class is intentionally missing a size method. * @author Kristian */ public class IntegerSet { @@ -67,7 +67,7 @@ public class IntegerSet { /** * Add the given element to the set, or do nothing if it already exists. * @param element - element to add. - * @throws OutOfBoundsException If the given element is not in the range [0, count). + * @throws ArrayIndexOutOfBoundsException If the given element is not in the range [0, count). */ public void add(int element) { array[element] = true; diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/concurrency/PacketTypeSet.java b/ProtocolLib/src/main/java/com/comphenix/protocol/concurrency/PacketTypeSet.java index 30b72ba8..fa5cc0e0 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/concurrency/PacketTypeSet.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/concurrency/PacketTypeSet.java @@ -65,7 +65,7 @@ public class PacketTypeSet { /** * Remove the given types from the set. - * @param type - the types to remove. + * @param types Types to remove */ public synchronized void removeAll(Iterable types) { for (PacketType type : types) { @@ -101,7 +101,7 @@ public class PacketTypeSet { } /** - * Determine if the type of a packet is in the current set. + * Determine if the type of a packet is in the current set. * @param packet - the packet. * @return TRUE if it is, FALSE otherwise. */ diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/error/DetailedErrorReporter.java b/ProtocolLib/src/main/java/com/comphenix/protocol/error/DetailedErrorReporter.java index 9593c4f7..7138857e 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/error/DetailedErrorReporter.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/error/DetailedErrorReporter.java @@ -93,6 +93,7 @@ public class DetailedErrorReporter implements ErrorReporter { /** * Create a default error reporting system. + * @param plugin - the plugin owner. */ public DetailedErrorReporter(Plugin plugin) { this(plugin, DEFAULT_PREFIX, DEFAULT_SUPPORT_URL); diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/error/ErrorReporter.java b/ProtocolLib/src/main/java/com/comphenix/protocol/error/ErrorReporter.java index 476321b6..ac647395 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/error/ErrorReporter.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/error/ErrorReporter.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 */ @@ -56,20 +56,20 @@ public interface ErrorReporter { /** * Prints a debug message from the current sender. * @param sender - the sender. - * @param report - the report builder. + * @param builder - the report builder. */ public abstract void reportDebug(Object sender, ReportBuilder builder); /** * Prints a warning message from the current plugin. - * @param sender - the object containing the caller method. + * @param sender - the object containing the caller method. * @param report - an error report to include. */ public abstract void reportWarning(Object sender, Report report); /** * Prints a warning message from the current plugin. - * @param sender - the object containing the caller method. + * @param sender - the object containing the caller method. * @param reportBuilder - an error report builder that will be used to get the report. */ public abstract void reportWarning(Object sender, ReportBuilder reportBuilder); diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/error/Report.java b/ProtocolLib/src/main/java/com/comphenix/protocol/error/Report.java index 3bbe2c38..5cb33e34 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/error/Report.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/error/Report.java @@ -10,7 +10,7 @@ import javax.annotation.Nullable; * * @author Kristian */ -public class Report { +public class Report { private final ReportType type; private final Throwable exception; private final Object[] messageParameters; @@ -76,7 +76,7 @@ public class Report { } /** - * Set the minimum number of nanoseconds to wait until a report of equal type and parameters + * Set the minimum number of nanoseconds to wait until a report of equal type and parameters * is allowed to be printed again. * @param rateLimit - number of nanoseconds, or 0 to disable. Cannot be negative. * @return This builder, for chaining. @@ -122,8 +122,8 @@ public class Report { * @param type - the report type that will be used to construct the message. * @param messageParameters - parameters used to construct the report message. * @param callerParameters - parameters from the caller method. - */ - protected Report(ReportType type, @Nullable Throwable exception, + */ + protected Report(ReportType type, @Nullable Throwable exception, @Nullable Object[] messageParameters, @Nullable Object[] callerParameters) { this(type, exception, messageParameters, callerParameters, 0); } @@ -135,8 +135,8 @@ public class Report { * @param messageParameters - parameters used to construct the report message. * @param callerParameters - parameters from the caller method. * @param rateLimit - minimum number of nanoseconds to wait until a report of equal type and parameters is allowed to be printed again. - */ - protected Report(ReportType type, @Nullable Throwable exception, + */ + protected Report(ReportType type, @Nullable Throwable exception, @Nullable Object[] messageParameters, @Nullable Object[] callerParameters, long rateLimit) { if (type == null) throw new IllegalArgumentException("type cannot be NULL."); @@ -157,7 +157,7 @@ public class Report { /** * Retrieve the message parameters that will be used to construc the report message. - * * This should not be confused with the method parameters of the caller method. * @return Message parameters. */ @@ -231,8 +231,8 @@ public class Report { return true; if (obj instanceof Report) { Report other = (Report) obj; - return type == other.type && - Arrays.equals(callerParameters, other.callerParameters) && + return type == other.type && + Arrays.equals(callerParameters, other.callerParameters) && Arrays.equals(messageParameters, other.messageParameters); } return false; diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/events/ListenerPriority.java b/ProtocolLib/src/main/java/com/comphenix/protocol/events/ListenerPriority.java index 06edf32b..7146e9c5 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/events/ListenerPriority.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/events/ListenerPriority.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 */ @@ -47,7 +47,7 @@ public enum ListenerPriority { HIGHEST(4), /** * Event is listened to purely for monitoring the outcome of an event. - *

+ *

* No modifications to the event should be made under this priority. */ MONITOR(5); diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/events/ListeningWhitelist.java b/ProtocolLib/src/main/java/com/comphenix/protocol/events/ListeningWhitelist.java index a209d4ae..2048983e 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/events/ListeningWhitelist.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/events/ListeningWhitelist.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 */ @@ -32,7 +32,7 @@ import com.google.common.collect.Sets; /** * Determines which packets will be observed by a listener, and with what priority. - * @author Kristian + * @author Kristian */ public class ListeningWhitelist { /** @@ -60,7 +60,7 @@ public class ListeningWhitelist { *

* Deprecated: Use {@link #newBuilder()} instead. * @param priority - the listener priority. - * @param whitelist - set of IDs to observe/enable. + * @param whitelist - set of IDs to observe/enable. */ @Deprecated public ListeningWhitelist(ListenerPriority priority, Set whitelist) { @@ -192,7 +192,7 @@ public class ListeningWhitelist { /** * Determine if any of the given IDs can be found in the whitelist. * @param whitelist - whitelist to test. - * @param idList - list of packet IDs to find. + * @param idList - list of packet IDs to find. * @return TRUE if any of the packets in the list can be found in the whitelist, FALSE otherwise. */ public static boolean containsAny(ListeningWhitelist whitelist, int... idList) { @@ -442,7 +442,7 @@ public class ListeningWhitelist { /** * Set the options to copy when constructing new whitelists. - * @param options - the options array. + * @param serverOptions - the options array. * @return This builder, for chaining. */ public Builder options(ListenerOptions[] serverOptions) { @@ -452,7 +452,7 @@ public class ListeningWhitelist { /** * Options to merge into the current set of options. - * @param options - the options array. + * @param serverOptions - the options array. * @return This builder, for chaining. */ public Builder mergeOptions(ListenerOptions... serverOptions) { @@ -461,7 +461,7 @@ public class ListeningWhitelist { /** * Options to merge into the current set of options. - * @param options - the options array. + * @param serverOptions - the options array. * @return This builder, for chaining. */ public Builder mergeOptions(Collection serverOptions) { 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 90fe717f..5a7c622c 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/events/NetworkMarker.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/events/NetworkMarker.java @@ -24,12 +24,12 @@ import com.google.common.collect.Lists; import com.google.common.primitives.Ints; /** - * Marker containing the serialized packet data seen from the network, + * Marker containing the serialized packet data seen from the network, * or output handlers that will serialize the current packet. * * @author Kristian */ -public abstract class NetworkMarker { +public abstract class NetworkMarker { public static class EmptyBufferMarker extends NetworkMarker { public EmptyBufferMarker(@Nonnull ConnectionSide side) { super(side, (byte[]) null, null); @@ -48,7 +48,7 @@ public abstract class NetworkMarker { @Override protected DataInputStream addHeader(DataInputStream input, PacketType type) { throw new IllegalStateException("Buffer is empty."); - } + } } // Custom network handler @@ -68,8 +68,9 @@ public abstract class NetworkMarker { /** * Construct a new network marker. - * @param side - whether or not this marker belongs to a client or server packet. + * @param side - which side this marker belongs to. * @param inputBuffer - the read serialized packet data. + * @param type - packet type */ public NetworkMarker(@Nonnull ConnectionSide side, ByteBuffer inputBuffer, PacketType type) { this.side = Preconditions.checkNotNull(side, "side cannot be NULL."); @@ -81,9 +82,9 @@ public abstract class NetworkMarker { * Construct a new network marker. *

* The input buffer is only non-null for client-side packets. - * @param side - whether or not this marker belongs to a client or server packet. + * @param side - which side this marker belongs to. * @param inputBuffer - the read serialized packet data. - * @param handler - handle skipping headers. + * @param type - packet type */ public NetworkMarker(@Nonnull ConnectionSide side, byte[] inputBuffer, PacketType type) { this.side = Preconditions.checkNotNull(side, "side cannot be NULL."); @@ -115,7 +116,7 @@ public abstract class NetworkMarker { /** * Retrieve the serialized packet data (excluding the header by default) from the network input stream. *

- * The returned buffer is read-only. If the parent event is a server side packet this + * The returned buffer is read-only. If the parent event is a server side packet this * method throws {@link IllegalStateException}. *

* It returns NULL if the packet was transmitted by a plugin locally. @@ -128,7 +129,7 @@ public abstract class NetworkMarker { /** * Retrieve the serialized packet data from the network input stream. *

- * The returned buffer is read-only. If the parent event is a server side packet this + * The returned buffer is read-only. If the parent event is a server side packet this * method throws {@link IllegalStateException}. *

* It returns NULL if the packet was transmitted by a plugin locally. @@ -143,7 +144,7 @@ public abstract class NetworkMarker { ByteBuffer result = inputBuffer.asReadOnlyBuffer(); try { - if (excludeHeader) + if (excludeHeader) result = skipHeader(result); else result = addHeader(result, type); @@ -158,7 +159,7 @@ public abstract class NetworkMarker { /** * Retrieve the serialized packet data (excluding the header by default) as an input stream. *

- * The data is exactly the same as in {@link #getInputBuffer()}. + * The data is exactly the same as in {@link #getInputBuffer()}. * @see #getInputBuffer() * @return The incoming serialized packet data as a stream, or NULL if the packet was transmitted locally. */ @@ -169,7 +170,7 @@ public abstract class NetworkMarker { /** * Retrieve the serialized packet data as an input stream. *

- * The data is exactly the same as in {@link #getInputBuffer()}. + * The data is exactly the same as in {@link #getInputBuffer()}. * @see #getInputBuffer() * @param excludeHeader - whether or not to exclude the packet ID header. * @return The incoming serialized packet data as a stream, or NULL if the packet was transmitted locally. @@ -186,7 +187,7 @@ public abstract class NetworkMarker { ); try { - if (excludeHeader) + if (excludeHeader) input = skipHeader(input); else input = addHeader(input, type); @@ -207,7 +208,7 @@ public abstract class NetworkMarker { /** * Enqueue the given output handler for managing how the current packet will be written to the network stream. *

- * Note that output handlers are not serialized, as most consumers will probably implement them using anonymous classes. + * Note that output handlers are not serialized, as most consumers will probably implement them using anonymous classes. * It is not safe to serialize anonymous classes, as their name depend on the order in which they are declared in the parent class. *

* This can only be invoked on server side packet events. @@ -261,10 +262,10 @@ public abstract class NetworkMarker { } /** - * Add a listener that is invoked after a packet has been successfully sent to the client, or received - * by the server. + * Add a listener that is invoked after a packet has been successfully sent to the client, or received + * by the server. *

- * Received packets are not guarenteed to have been fully processed, but packets passed + * Received packets are not guarenteed to have been fully processed, but packets passed * to {@link ProtocolManager#recieveClientPacket(Player, PacketContainer)} will be processed after the * current packet event. *

@@ -324,7 +325,9 @@ public abstract class NetworkMarker { * Return a byte buffer without the header in the current packet. *

* It's safe to modify the position of the buffer. - * @param buffer - a read-only byte source. + * @param buffer - a read-only byte source. + * @return A byte buffer without the header in the current packet. + * @throws IOException If integer reading fails */ protected ByteBuffer skipHeader(ByteBuffer buffer) throws IOException { skipHeader(new DataInputStream(new ByteBufferInputStream(buffer))); @@ -335,13 +338,14 @@ public abstract class NetworkMarker { * Return an input stream without the header in the current packet. *

* It's safe to modify the input stream. + * @throws IOException If integer reading fails */ protected abstract DataInputStream skipHeader(DataInputStream input) throws IOException; /** * Return the byte buffer prepended with the packet header. - * @param buffer - the read-only byte buffer. - * @param type - the current packet. + * @param buffer - the read-only byte buffer. + * @param type - the current packet. * @return The byte buffer. */ protected abstract ByteBuffer addHeader(ByteBuffer buffer, PacketType type); @@ -349,7 +353,7 @@ public abstract class NetworkMarker { /** * Return the input stream prepended with the packet header. * @param input - the input stream. - * @param type - the current packet. + * @param type - the current packet. * @return The byte buffer. */ protected abstract DataInputStream addHeader(DataInputStream input, PacketType type); diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/events/PacketAdapter.java b/ProtocolLib/src/main/java/com/comphenix/protocol/events/PacketAdapter.java index 95f3edcf..079e4deb 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/events/PacketAdapter.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/events/PacketAdapter.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 */ @@ -50,7 +50,7 @@ public abstract class PacketAdapter implements PacketListener { */ public PacketAdapter(@Nonnull AdapterParameteters params) { this( - checkValidity(params).plugin, params.connectionSide, params.listenerPriority, + checkValidity(params).plugin, params.connectionSide, params.listenerPriority, params.gamePhase, params.options, params.packets ); } @@ -58,7 +58,6 @@ public abstract class PacketAdapter implements PacketListener { /** * Initialize a packet listener with the given parameters. * @param plugin - the plugin. - * @param listenerPriority - the priority. * @param types - the packet types. */ public PacketAdapter(Plugin plugin, PacketType... types) { @@ -241,7 +240,7 @@ public abstract class PacketAdapter implements PacketListener { */ @Deprecated public PacketAdapter( - Plugin plugin, ConnectionSide connectionSide, ListenerPriority listenerPriority, + Plugin plugin, ConnectionSide connectionSide, ListenerPriority listenerPriority, GamePhase gamePhase, ListenerOptions[] options, Integer... packets) { this(plugin, connectionSide, listenerPriority, gamePhase, options, @@ -251,7 +250,7 @@ public abstract class PacketAdapter implements PacketListener { // For internal use only private PacketAdapter( - Plugin plugin, ConnectionSide connectionSide, ListenerPriority listenerPriority, + Plugin plugin, ConnectionSide connectionSide, ListenerPriority listenerPriority, GamePhase gamePhase, ListenerOptions[] options, PacketType... packets) { if (plugin == null) @@ -272,7 +271,7 @@ public abstract class PacketAdapter implements PacketListener { // Special case that allows us to specify optionIntercept(). if (connectionSide == ConnectionSide.BOTH) { - serverOptions = except(serverOptions, new ListenerOptions[0], + serverOptions = except(serverOptions, new ListenerOptions[0], ListenerOptions.INTERCEPT_INPUT_BUFFER); } @@ -360,10 +359,10 @@ public abstract class PacketAdapter implements PacketListener { } @Override - public String toString() { - // This is used by the error reporter - return String.format("PacketAdapter[plugin=%s, sending=%s, receiving=%s]", - getPluginName(this), + public String toString() { + // This is used by the error reporter + return String.format("PacketAdapter[plugin=%s, sending=%s, receiving=%s]", + getPluginName(this), sendingWhitelist, receivingWhitelist); } @@ -441,7 +440,7 @@ public abstract class PacketAdapter implements PacketListener { } /** - * Set this adapter to also look for client-side packets. + * Set this adapter to also look for client-side packets. * @return This builder, for chaining. */ public AdapterParameteters clientSide() { @@ -449,7 +448,7 @@ public abstract class PacketAdapter implements PacketListener { } /** - * Set this adapter to also look for server-side packets. + * Set this adapter to also look for server-side packets. * @return This builder, for chaining. */ public AdapterParameteters serverSide() { @@ -457,7 +456,7 @@ public abstract class PacketAdapter implements PacketListener { } /** - * Set the the event priority, where the execution is in ascending order from lowest to highest. + * Set the the event priority, where the execution is in ascending order from lowest to highest. *

* Default is {@link ListenerPriority#NORMAL}. * @param listenerPriority - the new event priority. diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/events/PacketContainer.java b/ProtocolLib/src/main/java/com/comphenix/protocol/events/PacketContainer.java index b7275b48..6f81fd2a 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/events/PacketContainer.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/events/PacketContainer.java @@ -164,10 +164,9 @@ public class PacketContainer implements Serializable { /** * Creates a packet container for an existing packet. - *

- * Deprecated: Use {@link #PacketContainer(PacketType, Object))} instead. * @param id - ID of the given packet. * @param handle - contained packet. + * @deprecated Use {@link #PacketContainer(PacketType, Object)} instead */ @Deprecated public PacketContainer(int id, Object handle) { @@ -176,11 +175,10 @@ public class PacketContainer implements Serializable { /** * Creates a packet container for an existing packet. - *

- * Deprecated: Use {@link #PacketContainer(PacketType, Object, StructureModifier))} instead. * @param id - ID of the given packet. * @param handle - contained packet. * @param structure - structure modifier. + * @deprecated Use {@link #PacketContainer(PacketType, Object, StructureModifier)} instead */ @Deprecated public PacketContainer(int id, Object handle, StructureModifier structure) { @@ -197,7 +195,7 @@ public class PacketContainer implements Serializable { /** * Creates a packet container for an existing packet. - * @param id - ID of the given packet. + * @param type - Type of the given packet. * @param handle - contained packet. */ public PacketContainer(PacketType type, Object handle) { @@ -206,7 +204,7 @@ public class PacketContainer implements Serializable { /** * Creates a packet container for an existing packet. - * @param id - ID of the given packet. + * @param type - Type of the given packet. * @param handle - contained packet. * @param structure - structure modifier. */ @@ -255,6 +253,7 @@ public class PacketContainer implements Serializable { /** * Retrieves a read/write structure for every field with the given type. + * @param Type * @param primitiveType - the type to find. * @return A modifier for this specific type. */ @@ -681,7 +680,7 @@ public class PacketContainer implements Serializable { /** * Retrieve a read/write structure for the PlayerInfoData list fields in the following packet:
*
    - *
  • {@link PacketType.Play.Server.PLAYER_INFO}
  • + *
  • {@link PacketType.Play.Server#PLAYER_INFO} *
* @return A modifier for PlayerInfoData list fields. */ diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/events/PacketListener.java b/ProtocolLib/src/main/java/com/comphenix/protocol/events/PacketListener.java index 5d1e4143..7a83d4f7 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/events/PacketListener.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/events/PacketListener.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 */ @@ -34,7 +34,7 @@ public interface PacketListener { *

* This method is executed on the main thread in 1.6.4 and earlier, and thus the Bukkit API is safe to use. *

- * In Minecraft 1.7.2 and later, this method MAY be executed asynchronously, but only if {@link ListenerOptions#ASYNC} + * In Minecraft 1.7.2 and later, this method MAY be executed asynchronously, but only if {@link ListenerOptions#ASYNC} * have been specified in the listener. This is off by default. * @param event - the packet that should be sent. */ @@ -43,9 +43,9 @@ public interface PacketListener { /** * Invoked right before a received packet from a client is being processed. *

- * WARNING:
- * This method will be called asynchronously! You should synchronize with the main - * thread using {@link org.bukkit.scheduler.BukkitScheduler#scheduleSyncDelayedTask(Plugin, Runnable, long) scheduleSyncDelayedTask} + * WARNING:
+ * This method will be called asynchronously! You should synchronize with the main + * thread using {@link org.bukkit.scheduler.BukkitScheduler#scheduleSyncDelayedTask(Plugin, Runnable, long) scheduleSyncDelayedTask} * if you need to call the Bukkit API. * @param event - the packet that has been received. */ diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/injector/BukkitUnwrapper.java b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/BukkitUnwrapper.java index 772b6a29..75ae4746 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/injector/BukkitUnwrapper.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/BukkitUnwrapper.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 */ @@ -38,8 +38,8 @@ import com.google.common.primitives.Primitives; *

* Typical conversions include: *

    - *
  • org.bukkit.entity.Player -> net.minecraft.server.EntityPlayer
  • - *
  • org.bukkit.World -> net.minecraft.server.WorldServer
  • + *
  • org.bukkit.entity.Player to net.minecraft.server.EntityPlayer
  • + *
  • org.bukkit.World to net.minecraft.server.WorldServer
  • *
* * @author Kristian @@ -91,7 +91,7 @@ public class BukkitUnwrapper implements Unwrapper { @Override public Object unwrapItem(Object wrappedObject) { // Special case - if (wrappedObject == null) + if (wrappedObject == null) return null; Class currentClass = PacketConstructor.getClass(wrappedObject); @@ -149,7 +149,7 @@ public class BukkitUnwrapper implements Unwrapper { try { final Method find = type.getMethod("getHandle"); - // It's thread safe, as getMethod should return the same handle + // It's thread safe, as getMethod should return the same handle Unwrapper methodUnwrapper = new Unwrapper() { @Override public Object unwrapItem(Object wrappedObject) { @@ -159,7 +159,7 @@ public class BukkitUnwrapper implements Unwrapper { return find.invoke(wrappedObject); } catch (IllegalArgumentException e) { - reporter.reportDetailed(this, + reporter.reportDetailed(this, Report.newBuilder(REPORT_ILLEGAL_ARGUMENT).error(e).callerParam(wrappedObject, find) ); } catch (IllegalAccessException e) { @@ -178,7 +178,7 @@ public class BukkitUnwrapper implements Unwrapper { return methodUnwrapper; } catch (SecurityException e) { - reporter.reportDetailed(this, + reporter.reportDetailed(this, Report.newBuilder(REPORT_SECURITY_LIMITATION).error(e).callerParam(type) ); } catch (NoSuchMethodException e) { @@ -188,7 +188,7 @@ public class BukkitUnwrapper implements Unwrapper { if (fieldUnwrapper != null) return fieldUnwrapper; else - reporter.reportDetailed(this, + reporter.reportDetailed(this, Report.newBuilder(REPORT_CANNOT_FIND_UNWRAP_METHOD).error(e).callerParam(type)); } @@ -214,7 +214,7 @@ public class BukkitUnwrapper implements Unwrapper { return checkClass((Class) wrappedObject, type, find.getType()); return FieldUtils.readField(find, wrappedObject, true); } catch (IllegalAccessException e) { - reporter.reportDetailed(this, + reporter.reportDetailed(this, Report.newBuilder(REPORT_CANNOT_READ_FIELD_HANDLE).error(e).callerParam(wrappedObject, find) ); return null; @@ -227,7 +227,7 @@ public class BukkitUnwrapper implements Unwrapper { } else { // Inform about this too - reporter.reportDetailed(this, + reporter.reportDetailed(this, Report.newBuilder(REPORT_CANNOT_READ_FIELD_HANDLE).callerParam(find) ); return null; diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/injector/NetworkProcessor.java b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/NetworkProcessor.java index 28af22ee..fbd033e3 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/injector/NetworkProcessor.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/NetworkProcessor.java @@ -36,7 +36,7 @@ public class NetworkProcessor { */ public byte[] processOutput(PacketEvent event, NetworkMarker marker, final byte[] input) { // Bit of a hack - but we need the performance - PriorityQueue handlers = (PriorityQueue) + PriorityQueue handlers = (PriorityQueue) marker.getOutputHandlers(); byte[] output = input; @@ -66,6 +66,7 @@ public class NetworkProcessor { /** * Invoke the post listeners and packet transmission, if any. + * @param event - PacketEvent * @param marker - the network marker, or NULL. */ public void invokePostEvent(PacketEvent event, NetworkMarker marker) { diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/injector/PacketConstructor.java b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/PacketConstructor.java index ef569ff1..cc0b5bd4 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/injector/PacketConstructor.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/PacketConstructor.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 */ @@ -38,7 +38,7 @@ import com.google.common.primitives.Primitives; */ public class PacketConstructor { /** - * A packet constructor that automatically converts Bukkit types to their NMS conterpart. + * A packet constructor that automatically converts Bukkit types to their NMS conterpart. *

* Remember to call withPacket(). */ @@ -59,7 +59,7 @@ public class PacketConstructor { private PacketConstructor(Constructor constructorMethod) { this.constructorMethod = constructorMethod; this.unwrappers = Lists.newArrayList((Unwrapper) new BukkitUnwrapper(new RethrowErrorReporter() )); - this.unwrappers.addAll(BukkitConverters.getUnwrappers()); + this.unwrappers.addAll(BukkitConverters.getUnwrappers()); } private PacketConstructor(PacketType type, Constructor constructorMethod, List unwrappers, Unwrapper[] paramUnwrapper) { @@ -104,7 +104,7 @@ public class PacketConstructor { /** * Create a packet constructor that creates packets using the given ID. *

- * Note that if you pass a Class as a value, it will use its type directly. + * Note that if you pass a Class as a value, it will use its type directly. *

* Deprecated: Use {@link #withPacket(PacketType, Object[])} instead. * @param id - legacy (1.6.4) packet ID. @@ -120,7 +120,7 @@ public class PacketConstructor { /** * Create a packet constructor that creates packets using the given types. *

- * Note that if you pass a Class as a value, it will use its type directly. + * Note that if you pass a Class as a value, it will use its type directly. * @param type - the type of the packet to create. * @param values - the values that will match each parameter in the desired constructor. * @return A packet constructor with these types. @@ -129,7 +129,7 @@ public class PacketConstructor { public PacketConstructor withPacket(PacketType type, Object[] values) { Class[] types = new Class[values.length]; Throwable lastException = null; - Unwrapper[] paramUnwrapper = new Unwrapper[values.length]; + Unwrapper[] paramUnwrapper = new Unwrapper[values.length]; for (int i = 0; i < types.length; i++) { // Default type @@ -258,7 +258,7 @@ public class PacketConstructor { /** * Convert the given wrapped object to the equivalent net.minecraft.server object. *

- * Note that we may pass in a class instead of object - in that case, the unwrapper should + * Note that we may pass in a class instead of object - in that case, the unwrapper should * return the equivalent NMS class. * @param wrappedObject - wrapped object or class. * @return The equivalent net.minecraft.server object or class. diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/injector/PacketFilterManager.java b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/PacketFilterManager.java index 11fcedb8..9f7c0582 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/injector/PacketFilterManager.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/PacketFilterManager.java @@ -223,7 +223,8 @@ public final class PacketFilterManager implements ProtocolManager, ListenerInvok private boolean debug; /** - * Only create instances of this class if protocol lib is disabled. + * Only create instances of this class if ProtocolLib is disabled. + * @param builder - PacketFilterBuilder */ public PacketFilterManager(PacketFilterBuilder builder) { // Used to determine if injection is needed diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/injector/netty/NettyProtocolInjector.java b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/netty/NettyProtocolInjector.java index 68424f13..0a48352d 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/injector/netty/NettyProtocolInjector.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/netty/NettyProtocolInjector.java @@ -201,7 +201,7 @@ public class NettyProtocolInjector implements ChannelListener { /** * Inject our packet handling into a specific player. - * @param player + * @param player Player to inject into */ public void injectPlayer(Player player) { injectionFactory.fromPlayer(player, this).inject(); diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/injector/packet/InterceptWritePacket.java b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/packet/InterceptWritePacket.java index f1fd11b4..67332f7b 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/injector/packet/InterceptWritePacket.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/packet/InterceptWritePacket.java @@ -116,7 +116,10 @@ public class InterceptWritePacket { /** * Construct a new instance of the proxy object. - * @return New instance of proxy, or NULL if we failed. + * @param proxyObject - Object to construct proxy of + * @param event - Packet event + * @param marker - Network marker + * @return New instance of the proxy, or null if we failed. */ @SuppressWarnings("deprecation") public Object constructProxy(Object proxyObject, PacketEvent event, NetworkMarker marker) { diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/injector/packet/PacketRegistry.java b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/packet/PacketRegistry.java index 960cc734..75bcc0f2 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/injector/packet/PacketRegistry.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/packet/PacketRegistry.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 */ @@ -96,7 +96,7 @@ public class PacketRegistry { return NETTY.getPacketTypeLookup().containsKey(type); // Look up the correct type - return type.isClient() ? + return type.isClient() ? LEGACY.getClientPackets().contains(type.getLegacyId()) : LEGACY.getServerPackets().contains(type.getLegacyId()); } @@ -120,7 +120,7 @@ public class PacketRegistry { ); } } catch (CannotFindTroveNoEntryValue e) { - ProtocolLibrary.getErrorReporter().reportWarning(PacketRegistry.class, + ProtocolLibrary.getErrorReporter().reportWarning(PacketRegistry.class, Report.newBuilder(REPORT_CANNOT_CORRECT_TROVE_MAP).error(e.getCause())); } } @@ -139,6 +139,7 @@ public class PacketRegistry { if (NETTY != null) { @SuppressWarnings("unchecked") Map result = (Map)Maps.transformValues(NETTY.getPacketClassLookup(), new Function() { + @Override public Integer apply(PacketType type) { return type.getLegacyId(); }; @@ -161,6 +162,7 @@ public class PacketRegistry { return result; } return Maps.transformValues(LEGACY.getPacketToID(), new Function() { + @Override public PacketType apply(Integer packetId) { return PacketType.findLegacy(packetId); }; @@ -288,7 +290,7 @@ public class PacketRegistry { * @param types - packet type. * @return Set of integers. */ - public static Set toLegacy(Set types) { + public static Set toLegacy(Set types) { Set result = Sets.newHashSet(); for (PacketType type : types) @@ -298,20 +300,20 @@ public class PacketRegistry { /** * Convert a set of legacy packet IDs to packet types. - * @param types - legacy packet IDs. + * @param ids - legacy packet IDs. * @return Set of packet types. */ - public static Set toPacketTypes(Set ids) { + public static Set toPacketTypes(Set ids) { return toPacketTypes(ids, null); } /** * Convert a set of legacy packet IDs to packet types. - * @param types - legacy packet IDs. + * @param ids - legacy packet IDs. * @param preference - the sender preference, if any. * @return Set of packet types. */ - public static Set toPacketTypes(Set ids, Sender preference) { + public static Set toPacketTypes(Set ids, Sender preference) { Set result = Sets.newHashSet(); for (int id : ids) @@ -417,7 +419,7 @@ public class PacketRegistry { } else { final int id = LEGACY.getPacketID(packet); - return PacketType.hasLegacy(id) ? + return PacketType.hasLegacy(id) ? PacketType.fromLegacy(id, sender) : null; } } diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/injector/player/PlayerInjectionHandler.java b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/player/PlayerInjectionHandler.java index a6a33175..11098470 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/injector/player/PlayerInjectionHandler.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/player/PlayerInjectionHandler.java @@ -129,7 +129,7 @@ public interface PlayerInjectionHandler { * Send the given packet to the given receiver. * @param receiver - the player receiver. * @param packet - the packet to send. - * @param marker + * @param marker - network marker. * @param filters - whether or not to invoke the packet filters. * @throws InvocationTargetException If an error occurred during sending. */ 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 62683c6e..7afda252 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 @@ -156,6 +156,7 @@ public abstract class PlayerInjector implements SocketInjector { /** * Initialize all fields for this player injector, if it hasn't already. + * @param injectionSource - Injection source * @throws IllegalAccessException An error has occured. */ public void initialize(Object injectionSource) throws IllegalAccessException { @@ -442,6 +443,7 @@ public abstract class PlayerInjector implements SocketInjector { /** * Retrieves the current net handler for this player. + * @boolean refresh - Whether or not to refresh * @return Current net handler. * @throws IllegalAccessException Unable to find or retrieve net handler. */ @@ -562,6 +564,7 @@ public abstract class PlayerInjector implements SocketInjector { /** * Determine if this inject method can even be attempted. + * @param GamePhase - 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/server/SocketInjector.java b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/server/SocketInjector.java index 38dfaa5c..9060d884 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/injector/server/SocketInjector.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/server/SocketInjector.java @@ -42,11 +42,12 @@ public interface SocketInjector { * @param filtered - whether or not the packet will be filtered by our listeners. * @throws InvocationTargetException If an error occured when sending the packet. */ - public abstract void sendServerPacket(Object packet, NetworkMarker marker, boolean filtered) + public abstract void sendServerPacket(Object packet, NetworkMarker marker, boolean filtered) throws InvocationTargetException; /** * Retrieve the hooked player. + * @return The hooked player. */ public abstract Player getPlayer(); @@ -57,7 +58,7 @@ public interface SocketInjector { public abstract Player getUpdatedPlayer(); /** - * Invoked when a delegated socket injector transfers the state of one injector to the next. + * Invoked when a delegated socket injector transfers the state of one injector to the next. * @param delegate - the new injector. */ public abstract void transferState(SocketInjector delegate); diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/metrics/Metrics.java b/ProtocolLib/src/main/java/com/comphenix/protocol/metrics/Metrics.java index 296b8780..1e0cfb74 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/metrics/Metrics.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/metrics/Metrics.java @@ -268,7 +268,7 @@ public class Metrics { /** * Enables metrics for the server by setting "opt-out" to false in the config file and starting the metrics task. * - * @throws java.io.IOException + * @throws IOException If configuration saving fails */ public void enable() throws IOException { // This has to be synchronized or it can collide with the check in the task. @@ -289,7 +289,7 @@ public class Metrics { /** * Disables metrics for the server by setting "opt-out" to true in the config file and canceling the metrics task. * - * @throws java.io.IOException + * @throws IOException If configuration saving fails */ public void disable() throws IOException { // This has to be synchronized or it can collide with the check in the task. @@ -327,6 +327,8 @@ public class Metrics { /** * Generic method that posts a plugin to the metrics website + * + * @throws IOException If posting fails */ private void postPlugin(final boolean isPing) throws IOException { // Server software specific section @@ -496,8 +498,8 @@ public class Metrics { /** * GZip compress a string of bytes * - * @param input - * @return + * @param input Input to compress + * @return Compressed string */ public static byte[] gzip(String input) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); @@ -532,14 +534,7 @@ public class Metrics { } } - /** - * Appends a json encoded key/value pair to the given string builder. - * - * @param json - * @param key - * @param value - * @throws UnsupportedEncodingException - */ + // Appends a json encoded key/value pair to the given string builder. private static void appendJSONPair(StringBuilder json, String key, String value) throws UnsupportedEncodingException { boolean isValueNumeric = false; @@ -566,12 +561,7 @@ public class Metrics { } } - /** - * Escape a string to create a valid JSON string - * - * @param text - * @return - */ + // Escape a string to create a valid JSON string private static String escapeJSON(String text) { StringBuilder builder = new StringBuilder(); @@ -612,12 +602,7 @@ public class Metrics { return builder.toString(); } - /** - * Encode text as UTF-8 - * - * @param text the text to encode - * @return the encoded text, as UTF-8 - */ + // Encode text as UTF-8 private static String urlEncode(final String text) throws UnsupportedEncodingException { return URLEncoder.encode(text, "UTF-8"); } diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/ClassAnalyser.java b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/ClassAnalyser.java index 5f507b19..faa7adf7 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/ClassAnalyser.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/ClassAnalyser.java @@ -14,7 +14,7 @@ import com.comphenix.protocol.reflect.compiler.EmptyClassVisitor; import com.comphenix.protocol.reflect.compiler.EmptyMethodVisitor; import com.google.common.collect.Lists; -public class ClassAnalyser { +public class ClassAnalyser { /** * Represents a method in ASM. *

@@ -68,7 +68,7 @@ public class ClassAnalyser { /** * Retrieve the associated owner class. * @return The owner class. - * @throws ClassNotFoundException + * @throws ClassNotFoundException If the class was not found */ public Class getOwnerClass() throws ClassNotFoundException { return AsmMethod.class.getClassLoader().loadClass(getOwnerName().replace('/', '.')); diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/FuzzyReflection.java b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/FuzzyReflection.java index ef3efa79..de756e69 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/FuzzyReflection.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/FuzzyReflection.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 */ @@ -93,6 +93,7 @@ public class FuzzyReflection { /** * Retrieve the value of the first field of the given type. + * @param Type * @param instance - the instance to retrieve from. * @param fieldClass - type of the field to retrieve. * @param forceAccess - whether or not to look for private and protected fields. @@ -107,6 +108,7 @@ public class FuzzyReflection { /** * Retrieves the underlying class. + * @return The underlying class. */ public Class getSource() { return source; @@ -117,7 +119,7 @@ public class FuzzyReflection { * @return The singleton instance. * @throws IllegalStateException If the class has no singleton. */ - public Object getSingleton() { + public Object getSingleton() { Method method = null; Field field = null; @@ -203,12 +205,12 @@ public class FuzzyReflection { for (Method method : getMethods()) { if (match.matcher(method.getName()).matches()) { - // Right - this is probably it. + // Right - this is probably it. return method; } } - throw new IllegalArgumentException("Unable to find a method with the pattern " + + throw new IllegalArgumentException("Unable to find a method with the pattern " + nameRegex + " in " + source.getName()); } @@ -341,13 +343,13 @@ public class FuzzyReflection { for (Field field : getFields()) { if (match.matcher(field.getName()).matches()) { - // Right - this is probably it. + // Right - this is probably it. return field; } } // Looks like we're outdated. Too bad. - throw new IllegalArgumentException("Unable to find a field with the pattern " + + throw new IllegalArgumentException("Unable to find a field with the pattern " + nameRegex + " in " + source.getName()); } @@ -428,7 +430,7 @@ public class FuzzyReflection { /** * Retrieves a field by type. *

- * Note that the type is matched using the full canonical representation, i.e.: + * Note that the type is matched using the full canonical representation, i.e.: *

    *
  • java.util.List
  • *
  • net.comphenix.xp.ExperienceMod
  • @@ -451,14 +453,14 @@ public class FuzzyReflection { } // Looks like we're outdated. Too bad. - throw new IllegalArgumentException("Unable to find a field with the type " + + throw new IllegalArgumentException("Unable to find a field with the type " + typeRegex + " in " + source.getName()); } /** * Retrieves a field by type. *

    - * Note that the type is matched using the full canonical representation, i.e.: + * Note that the type is matched using the full canonical representation, i.e.: *

      *
    • java.util.List
    • *
    • net.comphenix.xp.ExperienceMod
    • @@ -483,7 +485,7 @@ public class FuzzyReflection { } // Looks like we're outdated. Too bad. - throw new IllegalArgumentException("Unable to find a field with the type " + + throw new IllegalArgumentException("Unable to find a field with the type " + typeRegex + " in " + source.getName()); } @@ -505,7 +507,7 @@ public class FuzzyReflection { } /** - * Retrieve every method as a map over names. + * Retrieve every method as a map over names. *

      * Note that overloaded methods will only occur once in the resulting map. * @param methods - every method. diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/MethodUtils.java b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/MethodUtils.java index 13d66c53..24a44de1 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/MethodUtils.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/MethodUtils.java @@ -38,10 +38,10 @@ import org.bukkit.Bukkit; * Reflection locates these methods fine and correctly assigns them as public. * However, an IllegalAccessException is thrown if the method is invoked.

      * - *

      MethodUtils contains a workaround for this situation. + *

      MethodUtils contains a workaround for this situation. * It will attempt to call setAccessible on this method. * If this call succeeds, then the method can be invoked as normal. - * This call will only succeed when the application has sufficient security privilages. + * This call will only succeed when the application has sufficient security privilages. * If this call fails then a warning will be logged and the method may fail.

      * * @author Craig R. McClanahan @@ -58,7 +58,7 @@ public class MethodUtils { // --------------------------------------------------------- Private Methods - /** + /** * Only log warning about accessibility work around once. *

      * Note that this is broken when this class is deployed via a shared @@ -71,7 +71,7 @@ public class MethodUtils { */ private static boolean loggedAccessibleWarning = false; - /** + /** * Indicates whether methods should be cached for improved performance. *

      * Note that when this class is deployed via a shared classloader in @@ -91,9 +91,9 @@ public class MethodUtils { *

      * The keys into this map only ever exist as temporary variables within * methods of this class, and are never exposed to users of this class. - * This means that the WeakHashMap is used only as a mechanism for + * This means that the WeakHashMap is used only as a mechanism for * limiting the size of the cache, ie a way to tell the garbage collector - * that the contents of the cache can be completely garbage-collected + * that the contents of the cache can be completely garbage-collected * whenever it needs the memory. Whether this is a good approach to * this problem is doubtful; something like the commons-collections * LRUMap may be more appropriate (though of course selecting an @@ -140,12 +140,12 @@ public class MethodUtils { /** *

      Invoke a named method whose parameter type matches the object type.

      * - *

      The behaviour of this method is less deterministic + *

      The behaviour of this method is less deterministic * than invokeExactMethod(). * It loops through all methods with names that match * and then executes the first it finds with compatable parameters.

      * - *

      This method supports calls to methods taking primitive parameters + *

      This method supports calls to methods taking primitive parameters * via passing in wrapping classes. So, for example, a Boolean class * would match a boolean primitive.

      * @@ -182,12 +182,12 @@ public class MethodUtils { /** *

      Invoke a named method whose parameter type matches the object type.

      * - *

      The behaviour of this method is less deterministic - * than {@link #invokeExactMethod(Object object,String methodName,Object [] args)}. + *

      The behaviour of this method is less deterministic + * than {@link #invokeExactMethod(Object object,String methodName,Object [] args)}. * It loops through all methods with names that match * and then executes the first it finds with compatable parameters.

      * - *

      This method supports calls to methods taking primitive parameters + *

      This method supports calls to methods taking primitive parameters * via passing in wrapping classes. So, for example, a Boolean class * would match a boolean primitive.

      * @@ -217,7 +217,7 @@ public class MethodUtils { if (args == null) { args = EMPTY_OBJECT_ARRAY; - } + } int arguments = args.length; Class[] parameterTypes = new Class[arguments]; for (int i = 0; i < arguments; i++) { @@ -231,13 +231,13 @@ public class MethodUtils { /** *

      Invoke a named method whose parameter type matches the object type.

      * - *

      The behaviour of this method is less deterministic - * than {@link - * #invokeExactMethod(Object object,String methodName,Object [] args,Class[] parameterTypes)}. + *

      The behaviour of this method is less deterministic + * than {@link + * #invokeExactMethod(Object object,String methodName,Object [] args,Class[] parameterTypes)}. * It loops through all methods with names that match * and then executes the first it finds with compatable parameters.

      * - *

      This method supports calls to methods taking primitive parameters + *

      This method supports calls to methods taking primitive parameters * via passing in wrapping classes. So, for example, a Boolean class * would match a boolean primitive.

      * @@ -266,10 +266,10 @@ public class MethodUtils { if (parameterTypes == null) { parameterTypes = EMPTY_CLASS_PARAMETERS; - } + } if (args == null) { args = EMPTY_OBJECT_ARRAY; - } + } Method method = getMatchingAccessibleMethod( object.getClass(), @@ -345,7 +345,7 @@ public class MethodUtils { InvocationTargetException { if (args == null) { args = EMPTY_OBJECT_ARRAY; - } + } int arguments = args.length; Class[] parameterTypes = new Class[arguments]; for (int i = 0; i < arguments; i++) { @@ -387,7 +387,7 @@ public class MethodUtils { if (args == null) { args = EMPTY_OBJECT_ARRAY; - } + } if (parameterTypes == null) { parameterTypes = EMPTY_CLASS_PARAMETERS; @@ -437,7 +437,7 @@ public class MethodUtils { if (args == null) { args = EMPTY_OBJECT_ARRAY; - } + } if (parameterTypes == null) { parameterTypes = EMPTY_CLASS_PARAMETERS; @@ -458,12 +458,12 @@ public class MethodUtils { /** *

      Invoke a named static method whose parameter type matches the object type.

      * - *

      The behaviour of this method is less deterministic - * than {@link #invokeExactMethod(Object, String, Object[], Class[])}. + *

      The behaviour of this method is less deterministic + * than {@link #invokeExactMethod(Object, String, Object[], Class[])}. * It loops through all methods with names that match * and then executes the first it finds with compatable parameters.

      * - *

      This method supports calls to methods taking primitive parameters + *

      This method supports calls to methods taking primitive parameters * via passing in wrapping classes. So, for example, a Boolean class * would match a boolean primitive.

      * @@ -501,12 +501,12 @@ public class MethodUtils { /** *

      Invoke a named static method whose parameter type matches the object type.

      * - *

      The behaviour of this method is less deterministic - * than {@link #invokeExactMethod(Object object,String methodName,Object [] args)}. + *

      The behaviour of this method is less deterministic + * than {@link #invokeExactMethod(Object object,String methodName,Object [] args)}. * It loops through all methods with names that match * and then executes the first it finds with compatable parameters.

      * - *

      This method supports calls to methods taking primitive parameters + *

      This method supports calls to methods taking primitive parameters * via passing in wrapping classes. So, for example, a Boolean class * would match a boolean primitive.

      * @@ -537,7 +537,7 @@ public class MethodUtils { if (args == null) { args = EMPTY_OBJECT_ARRAY; - } + } int arguments = args.length; Class[] parameterTypes = new Class[arguments]; for (int i = 0; i < arguments; i++) { @@ -551,13 +551,13 @@ public class MethodUtils { /** *

      Invoke a named static method whose parameter type matches the object type.

      * - *

      The behaviour of this method is less deterministic - * than {@link - * #invokeExactStaticMethod(Class objectClass,String methodName,Object [] args,Class[] parameterTypes)}. + *

      The behaviour of this method is less deterministic + * than {@link + * #invokeExactStaticMethod(Class objectClass,String methodName,Object [] args,Class[] parameterTypes)}. * It loops through all methods with names that match * and then executes the first it finds with compatable parameters.

      * - *

      This method supports calls to methods taking primitive parameters + *

      This method supports calls to methods taking primitive parameters * via passing in wrapping classes. So, for example, a Boolean class * would match a boolean primitive.

      * @@ -587,10 +587,10 @@ public class MethodUtils { if (parameterTypes == null) { parameterTypes = EMPTY_CLASS_PARAMETERS; - } + } if (args == null) { args = EMPTY_OBJECT_ARRAY; - } + } Method method = getMatchingAccessibleMethod( objectClass, @@ -668,7 +668,7 @@ public class MethodUtils { InvocationTargetException { if (args == null) { args = EMPTY_OBJECT_ARRAY; - } + } int arguments = args.length; Class[] parameterTypes = new Class[arguments]; for (int i = 0; i < arguments; i++) { @@ -890,16 +890,16 @@ public class MethodUtils { /** *

      Find an accessible method that matches the given name and has compatible parameters. - * Compatible parameters mean that every method parameter is assignable from + * Compatible parameters mean that every method parameter is assignable from * the given parameters. - * In other words, it finds a method with the given name - * that will take the parameters given.

      + * In other words, it finds a method with the given name + * that will take the parameters given.

      * - *

      This method is slightly undeterminstic since it loops + *

      This method is slightly undeterminstic since it loops * through methods names and return the first matching method.

      * - *

      This method is used by - * {@link + *

      This method is used by + * {@link * #invokeMethod(Object object,String methodName,Object [] args,Class[] parameterTypes)}. * *

      This method can match primitive parameter by passing in wrapper classes. @@ -908,7 +908,7 @@ public class MethodUtils { * * @param clazz find method in this class * @param methodName find method with this name - * @param parameterTypes find method with compatible parameters + * @param parameterTypes find method with compatible parameters * @return The accessible method */ @SuppressWarnings("unchecked") @@ -938,19 +938,19 @@ public class MethodUtils { } catch (NoSuchMethodException e) { /* SWALLOW */ } - // search through all methods + // search through all methods int paramSize = parameterTypes.length; Method bestMatch = null; Method[] methods = clazz.getMethods(); float bestMatchCost = Float.MAX_VALUE; float myCost = Float.MAX_VALUE; for (int i = 0, size = methods.length; i < size ; i++) { - if (methods[i].getName().equals(methodName)) { + if (methods[i].getName().equals(methodName)) { // compare parameters Class[] methodsParams = methods[i].getParameterTypes(); int methodParamSize = methodsParams.length; - if (methodParamSize == paramSize) { + if (methodParamSize == paramSize) { boolean match = true; for (int n = 0 ; n < methodParamSize; n++) { if (!isAssignmentCompatible(methodsParams[n], parameterTypes[n])) { @@ -986,7 +986,7 @@ public class MethodUtils { } } - return bestMatch; + return bestMatch; } /** @@ -1018,7 +1018,7 @@ public class MethodUtils { // modifer is public. // // The following workaround solves the problem but will only - // work from sufficiently privilages code. + // work from sufficiently privilages code. // // Better workarounds would be greatfully accepted. // @@ -1032,7 +1032,7 @@ public class MethodUtils { boolean vulnerableJVM = false; try { String specVersion = System.getProperty("java.specification.version"); - if (specVersion.charAt(0) == '1' && + if (specVersion.charAt(0) == '1' && (specVersion.charAt(2) == '0' || specVersion.charAt(2) == '1' || specVersion.charAt(2) == '2' || @@ -1074,8 +1074,8 @@ public class MethodUtils { } /** - * Gets the number of steps required needed to turn the source class into the - * destination class. This represents the number of steps in the object hierarchy + * Gets the number of steps required needed to turn the source class into the + * destination class. This represents the number of steps in the object hierarchy * graph. * @param srcClass The source class * @param destClass The destination class @@ -1085,9 +1085,9 @@ public class MethodUtils { float cost = 0.0f; while (destClass != null && !destClass.equals(srcClass)) { if (destClass.isInterface() && isAssignmentCompatible(destClass,srcClass)) { - // slight penalty for interface match. - // we still want an exact match to override an interface match, but - // an interface match should override anything where we have to get a + // slight penalty for interface match. + // we still want an exact match to override an interface match, but + // an interface match should override anything where we have to get a // superclass. cost += 0.25f; break; @@ -1097,7 +1097,7 @@ public class MethodUtils { } /* - * If the destination class is null, we've travelled all the way up to + * If the destination class is null, we've travelled all the way up to * an Object match. We'll penalize this by adding 1.5 to the cost. */ if (destClass == null) { @@ -1121,7 +1121,7 @@ public class MethodUtils { * For example, a Long will not match a int. * * @param parameterType the type of parameter accepted by the method - * @param parameterization the type of parameter being tested + * @param parameterization the type of parameter being tested * * @return true if the assignement is compatible. */ @@ -1148,7 +1148,7 @@ public class MethodUtils { * Gets the wrapper object class for the given primitive type class. * For example, passing boolean.class returns Boolean.class * @param primitiveType the primitive type class for which a match is to be found - * @return the wrapper type associated with the given primitive + * @return the wrapper type associated with the given primitive * or null if no match is found */ public static Class getPrimitiveWrapper(Class primitiveType) { @@ -1177,8 +1177,8 @@ public class MethodUtils { /** * Gets the class for the primitive type corresponding to the primitive wrapper class given. - * For example, an instance of Boolean.class returns a boolean.class. - * @param wrapperType the + * For example, an instance of Boolean.class returns a boolean.class. + * @param wrapperType the * @return the primitive type class corresponding to the given wrapper class, * null if no match is found */ @@ -1214,7 +1214,7 @@ public class MethodUtils { public static Class toNonPrimitiveClass(Class clazz) { if (clazz.isPrimitive()) { Class primitiveClazz = MethodUtils.getPrimitiveWrapper(clazz); - // the above method returns + // the above method returns if (primitiveClazz != null) { return primitiveClazz; } else { @@ -1298,7 +1298,8 @@ public class MethodUtils { * @param obj object to be tested for equality * @return true, if the object describes the same Method. */ - public boolean equals(Object obj) { + @Override + public boolean equals(Object obj) { if (!(obj instanceof MethodDescriptor)) { return false; } @@ -1318,7 +1319,8 @@ public class MethodUtils { * determine equality. * @return the string length of method name. */ - public int hashCode() { + @Override + public int hashCode() { return hashCode; } } diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/ObjectEnum.java b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/ObjectEnum.java index 09a05543..c7828895 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/ObjectEnum.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/ObjectEnum.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 */ @@ -36,16 +36,18 @@ import com.google.common.collect.HashBiMap; public class ObjectEnum implements Iterable { // Used to convert between IDs and names protected BiMap members = HashBiMap.create(); - + /** * Registers every declared integer field. + * @param fieldType Field type */ public ObjectEnum(Class fieldType) { registerAll(fieldType); } - + /** * Registers every public assignable static field as a member. + * @param fieldType Field type */ @SuppressWarnings("unchecked") protected void registerAll(Class fieldType) { @@ -56,7 +58,7 @@ public class ObjectEnum implements Iterable { T value = (T) entry.get(null); if (value == null) - throw new IllegalArgumentException("Field " + entry + " was NULL. Remember to " + + throw new IllegalArgumentException("Field " + entry + " was NULL. Remember to " + "construct the object after the field has been declared."); registerMember(value, entry.getName()); } @@ -77,7 +79,7 @@ public class ObjectEnum implements Iterable { */ public boolean registerMember(T instance, String name) { if (!members.containsKey(instance)) { - members.put(instance, name); + members.put(instance, name); return true; } return false; diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/PrettyPrinter.java b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/PrettyPrinter.java index 1b5ae557..09cb92c7 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/PrettyPrinter.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/PrettyPrinter.java @@ -62,10 +62,10 @@ public class PrettyPrinter { public final static int RECURSE_DEPTH = 3; /** - * Print the content of an object. + * Print the contents of an object. * @param object - the object to serialize. * @return String representation of the class. - * @throws IllegalAccessException + * @throws IllegalAccessException If the object is null */ public static String printObject(Object object) throws IllegalAccessException { if (object == null) @@ -75,11 +75,12 @@ public class PrettyPrinter { } /** - * Print the content of an object. + * Print the contents of an object. * @param object - the object to serialize. + * @param start - class to start at. * @param stop - superclass that will stop the process. - * @return String representation of the class. - * @throws IllegalAccessException + * @return String representation of the class + * @throws IllegalAccessException If the object is null */ public static String printObject(Object object, Class start, Class stop) throws IllegalAccessException { if (object == null) @@ -89,24 +90,27 @@ public class PrettyPrinter { } /** - * Print the content of an object. + * Print the contents of an object. * @param object - the object to serialize. + * @param start - class to start at. * @param stop - superclass that will stop the process. + * @param hierachyDepth - maximum recursion level. * @return String representation of the class. - * @throws IllegalAccessException + * @throws IllegalAccessException If the object is null */ public static String printObject(Object object, Class start, Class stop, int hierachyDepth) throws IllegalAccessException { return printObject(object, start, stop, hierachyDepth, ObjectPrinter.DEFAULT); } /** - * Print the content of an object. + * Print the contents of an object. * @param object - the object to serialize. + * @param start - class to start at. * @param stop - superclass that will stop the process. * @param hierachyDepth - maximum recursion level. * @param printer - a generic object printer. * @return String representation of the class. - * @throws IllegalAccessException + * @throws IllegalAccessException If the object is null */ public static String printObject(Object object, Class start, Class stop, int hierachyDepth, ObjectPrinter printer) throws IllegalAccessException { if (object == null) diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/StructureModifier.java b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/StructureModifier.java index 15025e19..55e31e82 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/StructureModifier.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/StructureModifier.java @@ -393,6 +393,7 @@ public class StructureModifier { /** * Retrieves a structure modifier that only reads and writes fields of a given type. + * @param Type * @param fieldType - the type, or supertype, of every field to modify. * @return A structure modifier for fields of this type. */ @@ -424,6 +425,7 @@ public class StructureModifier { /** * Retrieves a structure modifier that only reads and writes fields of a given type. + * @param Type * @param fieldType - the type, or supertype, of every field to modify. * @param converter - converts objects into the given type. * @return A structure modifier for fields of this type. @@ -507,10 +509,10 @@ public class StructureModifier { /** * Create a new structure modifier for the new field type. + * @param Type * @param fieldType - common type of each field. * @param filtered - list of fields after filtering the original modifier. * @param defaults - list of default values after filtering the original. - * @param converter - the new converter * @return A new structure modifier. */ protected StructureModifier withFieldType( @@ -520,6 +522,7 @@ public class StructureModifier { /** * Create a new structure modifier for the new field type. + * @param Type * @param fieldType - common type of each field. * @param filtered - list of fields after filtering the original modifier. * @param defaults - list of default values after filtering the original. diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/VolatileField.java b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/VolatileField.java index c4318c60..7efa2897 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/VolatileField.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/VolatileField.java @@ -200,6 +200,7 @@ public class VolatileField { /** * Determine whether or not we'll need to revert the value. + * @return True if it is set, false if not. */ public boolean isCurrentSet() { return currentSet; diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/accessors/Accessors.java b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/accessors/Accessors.java index d08d6685..b950593c 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/accessors/Accessors.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/accessors/Accessors.java @@ -78,7 +78,7 @@ public final class Accessors { /** * Retrieve an accessor for the first field of the given type. * @param instanceClass - the type of the instance to retrieve. - * @param fieldClass - type of the field to retrieve. + * @param fieldName - name of the field to retrieve. * @param forceAccess - whether or not to look for private and protected fields. * @return The value of that field. * @throws IllegalArgumentException If the field cannot be found. diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/cloning/SerializableCloner.java b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/cloning/SerializableCloner.java index 8617f3ea..58819caa 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/cloning/SerializableCloner.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/cloning/SerializableCloner.java @@ -26,6 +26,7 @@ public class SerializableCloner implements Cloner { /** * Clone the given object using serialization. + * @param Type * @param obj - the object to clone. * @return The cloned object. * @throws RuntimeException If we were unable to clone the object. diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/compiler/BackgroundCompiler.java b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/compiler/BackgroundCompiler.java index c207f579..cce76ffc 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/compiler/BackgroundCompiler.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/compiler/BackgroundCompiler.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 */ @@ -158,6 +158,7 @@ public class BackgroundCompiler { /** * Ensure that the given structure modifier is eventually compiled. + * @param Type * @param uncompiled - structure modifier to compile. * @param listener - listener responsible for responding to the compilation. */ @@ -181,7 +182,7 @@ public class BackgroundCompiler { List list = listeners.get(key); if (!listeners.containsKey(key)) { - listeners.put(key, (List) Lists.newArrayList(listener)); + listeners.put(key, (List) Lists.newArrayList(listener)); } else { // We're currently compiling list.add(listener); @@ -261,8 +262,8 @@ public class BackgroundCompiler { } } catch (RejectedExecutionException e) { - // Occures when the underlying queue is overflowing. Since the compilation - // is only an optmization and not really essential we'll just log this failure + // Occures when the underlying queue is overflowing. Since the compilation + // is only an optmization and not really essential we'll just log this failure // and move on. reporter.reportWarning(this, Report.newBuilder(REPORT_CANNOT_SCHEDULE_COMPILATION).error(e)); } @@ -271,6 +272,7 @@ public class BackgroundCompiler { /** * Add a compile listener if we are still waiting for the structure modifier to be compiled. + * @param Type * @param uncompiled - the structure modifier that may get compiled. * @param listener - the listener to invoke in that case. */ @@ -280,7 +282,7 @@ public class BackgroundCompiler { StructureKey key = new StructureKey(uncompiled); @SuppressWarnings("rawtypes") - List list = listeners.get(key); + List list = listeners.get(key); if (list != null) { list.add(listener); 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 a5b8f5eb..f8e52843 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 @@ -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 */ @@ -40,9 +40,9 @@ import com.google.common.base.Objects; import com.google.common.primitives.Primitives; // public class CompiledStructureModifierPacket20 extends CompiledStructureModifier { -// +// // private Packet20NamedEntitySpawn typedTarget; -// +// // public CompiledStructureModifierPacket20(StructureModifier other, StructureCompiler compiler) { // super(); // initialize(other); @@ -50,12 +50,12 @@ import com.google.common.primitives.Primitives; // this.typedTarget = (Packet20NamedEntitySpawn) target; // this.compiler = compiler; // } -// +// // @Override // protected Object readGenerated(int fieldIndex) throws FieldAccessException { -// +// // Packet20NamedEntitySpawn target = typedTarget; -// +// // switch (fieldIndex) { // case 0: return (Object) target.a; // case 1: return (Object) target.b; @@ -69,12 +69,12 @@ import com.google.common.primitives.Primitives; // throw new FieldAccessException("Invalid index " + fieldIndex); // } // } -// +// // @Override // protected StructureModifier writeGenerated(int index, Object value) throws FieldAccessException { -// +// // Packet20NamedEntitySpawn target = typedTarget; -// +// // switch (index) { // case 0: target.a = (Integer) value; break; // case 1: target.b = (String) value; break; @@ -87,7 +87,7 @@ import com.google.common.primitives.Primitives; // default: // throw new FieldAccessException("Invalid index " + index); // } -// +// // // Chaining // return this; // } @@ -157,6 +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 source - the structure modifier to look up. * @return TRUE if we successfully found a previously generated class, FALSE otherwise. */ @@ -179,7 +180,7 @@ public final class StructureCompiler { return true; } } catch (ClassNotFoundException e) { - // That's ok. + // That's ok. } // We need to compile the class @@ -189,7 +190,7 @@ public final class StructureCompiler { /** * Compiles the given structure modifier. *

      - * WARNING: Do NOT call this method in the main thread. Compiling may easily take 10 ms, which is already + * 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 source - structure modifier to compile. * @return A compiled structure modifier. @@ -233,7 +234,7 @@ public final class StructureCompiler { throw new RuntimeException("Error occured while instancing generated class.", e); } catch (NoSuchMethodException e) { throw new IllegalStateException("Cannot happen.", e); - } + } } /** @@ -254,8 +255,8 @@ public final class StructureCompiler { Class targetType = source.getTargetType(); // Concat class and field type - return "CompiledStructure$" + - getSafeTypeName(targetType) + "$" + + return "CompiledStructure$" + + getSafeTypeName(targetType) + "$" + getSafeTypeName(source.getFieldType()); } @@ -274,7 +275,7 @@ public final class StructureCompiler { String targetName = targetType.getName().replace('.', '/'); // Define class - cw.visit(Opcodes.V1_6, Opcodes.ACC_PUBLIC + Opcodes.ACC_SUPER, PACKAGE_NAME + "/" + className, + cw.visit(Opcodes.V1_6, Opcodes.ACC_PUBLIC + Opcodes.ACC_SUPER, PACKAGE_NAME + "/" + className, null, COMPILED_CLASS, null); createFields(cw, targetSignature); @@ -288,7 +289,7 @@ public final class StructureCompiler { // Call the define method try { if (defineMethod == null) { - Method defined = ClassLoader.class.getDeclaredMethod("defineClass", + Method defined = ClassLoader.class.getDeclaredMethod("defineClass", new Class[] { String.class, byte[].class, int.class, int.class }); // Awesome. Now, create and return it. @@ -351,7 +352,7 @@ public final class StructureCompiler { String methodDescriptor = "(ILjava/lang/Object;)L" + SUPER_CLASS + ";"; String methodSignature = "(ILjava/lang/Object;)L" + SUPER_CLASS + ";"; - MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PROTECTED, "writeGenerated", methodDescriptor, methodSignature, + MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PROTECTED, "writeGenerated", methodDescriptor, methodSignature, new String[] { FIELD_EXCEPTION_CLASS }); BoxingHelper boxingHelper = new BoxingHelper(mv); @@ -437,7 +438,7 @@ public final class StructureCompiler { } private void createReadMethod(ClassWriter cw, String className, List fields, String targetSignature, String targetName) { - MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PROTECTED, "readGenerated", "(I)Ljava/lang/Object;", null, + MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PROTECTED, "readGenerated", "(I)Ljava/lang/Object;", null, new String[] { "com/comphenix/protocol/reflect/FieldAccessException" }); BoxingHelper boxingHelper = new BoxingHelper(mv); @@ -508,8 +509,8 @@ public final class StructureCompiler { } private void createConstructor(ClassWriter cw, String className, String targetSignature, String targetName) { - MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "", - "(L" + SUPER_CLASS + ";L" + PACKAGE_NAME + "/StructureCompiler;)V", + MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "", + "(L" + SUPER_CLASS + ";L" + PACKAGE_NAME + "/StructureCompiler;)V", "(L" + SUPER_CLASS + ";L" + PACKAGE_NAME + "/StructureCompiler;)V", null); String fullClassName = PACKAGE_NAME + "/" + className; diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/fuzzy/AbstractFuzzyMember.java b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/fuzzy/AbstractFuzzyMember.java index a50dac2c..4523b30a 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/fuzzy/AbstractFuzzyMember.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/fuzzy/AbstractFuzzyMember.java @@ -87,7 +87,7 @@ public abstract class AbstractFuzzyMember extends AbstractFuzz /** * Set the exact name of the member we are matching. - * * This will overwrite the regular expression rule. * @param name - exact name. * @return This builder, for chaining. @@ -137,7 +137,7 @@ public abstract class AbstractFuzzyMember extends AbstractFuzz } /** - * Construct a new instance of the current type. + * Construct a new instance of the current type. * @return New instance. */ @Nonnull @@ -232,7 +232,7 @@ public abstract class AbstractFuzzyMember extends AbstractFuzz @Override protected int calculateRoundNumber() { // Sanity check - if (!sealed) + if (!sealed) throw new IllegalStateException("Cannot calculate round number during construction."); // NULL is zero @@ -255,7 +255,7 @@ public abstract class AbstractFuzzyMember extends AbstractFuzz // Build our representation if (modifiersRequired != Integer.MAX_VALUE || modifiersBanned != 0) { - map.put("modifiers", String.format("[required: %s, banned: %s]", + map.put("modifiers", String.format("[required: %s, banned: %s]", getBitView(modifiersRequired, 16), getBitView(modifiersBanned, 16)) ); @@ -298,7 +298,7 @@ public abstract class AbstractFuzzyMember extends AbstractFuzz @Override public int hashCode() { - return Objects.hashCode(modifiersBanned, modifiersRequired, + return Objects.hashCode(modifiersBanned, modifiersRequired, nameRegex != null ? nameRegex.pattern() : null, declaringMatcher); } } diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/fuzzy/FuzzyMethodContract.java b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/fuzzy/FuzzyMethodContract.java index 79f0eed4..e08b2db0 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/fuzzy/FuzzyMethodContract.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/fuzzy/FuzzyMethodContract.java @@ -26,7 +26,7 @@ public class FuzzyMethodContract extends AbstractFuzzyMember { private final Integer indexMatch; /** - * Construct a new parameter class matcher. + * Construct a new parameter class matcher. * @param typeMatcher - class type matcher. */ public ParameterClassMatcher(@Nonnull AbstractFuzzyMatcher> typeMatcher) { @@ -34,7 +34,7 @@ public class FuzzyMethodContract extends AbstractFuzzyMember { } /** - * Construct a new parameter class matcher. + * Construct a new parameter class matcher. * @param typeMatcher - class type matcher. * @param indexMatch - parameter index to match, or NULL for anything. */ @@ -49,7 +49,7 @@ public class FuzzyMethodContract extends AbstractFuzzyMember { /** * See if there's a match for this matcher. * @param used - parameters that have been matched before. - * @param parent - the container (member) that holds a reference to this parameter. + * @param parent - the container (member) that holds a reference to this parameter. * @param params - the type of each parameter. * @return TRUE if this matcher matches any of the given parameters, FALSE otherwise. */ @@ -93,8 +93,9 @@ public class FuzzyMethodContract extends AbstractFuzzyMember { * @author Kristian */ public static class Builder extends AbstractFuzzyMember.Builder { + @Override public Builder requireModifier(int modifier) { - super.requireModifier(modifier); + super.requireModifier(modifier); return this; } @@ -106,49 +107,49 @@ public class FuzzyMethodContract extends AbstractFuzzyMember { @Override public Builder banModifier(int modifier) { - super.banModifier(modifier); + super.banModifier(modifier); return this; } @Override public Builder nameRegex(String regex) { - super.nameRegex(regex); + super.nameRegex(regex); return this; } @Override public Builder nameRegex(Pattern pattern) { - super.nameRegex(pattern); + super.nameRegex(pattern); return this; } @Override public Builder nameExact(String name) { - super.nameExact(name); + super.nameExact(name); return this; } @Override public Builder declaringClassExactType(Class declaringClass) { - super.declaringClassExactType(declaringClass); + super.declaringClassExactType(declaringClass); return this; } @Override public Builder declaringClassSuperOf(Class declaringClass) { - super.declaringClassSuperOf(declaringClass); + super.declaringClassSuperOf(declaringClass); return this; } @Override public Builder declaringClassDerivedOf(Class declaringClass) { - super.declaringClassDerivedOf(declaringClass); + super.declaringClassDerivedOf(declaringClass); return this; } @Override public Builder declaringClassMatching(AbstractFuzzyMatcher> classMatcher) { - super.declaringClassMatching(classMatcher); + super.declaringClassMatching(classMatcher); return this; } @@ -209,7 +210,7 @@ public class FuzzyMethodContract extends AbstractFuzzyMember { /** * Add a new required parameters by type and order for any matching method. - * @param type - the types of every parameters in order. + * @param types - the types of every parameters in order. * @return This builder, for chaining. */ public Builder parameterExactArray(Class... types) { @@ -270,7 +271,7 @@ public class FuzzyMethodContract extends AbstractFuzzyMember { /** * Require a void method. - * @return This builder, for chaining. + * @return This builder, for chaining. */ public Builder returnTypeVoid() { return returnTypeExact(Void.TYPE); @@ -287,7 +288,7 @@ public class FuzzyMethodContract extends AbstractFuzzyMember { } /** - * Set the expected super class of the return type for every matching method. + * Set the expected super class of the return type for every matching method. * @param type - the return type, or a super class of it. * @return This builder, for chaining. */ @@ -429,7 +430,7 @@ public class FuzzyMethodContract extends AbstractFuzzyMember { /** * Retrieve an immutable list of every parameter matcher for this method. - * @return Immutable list of every parameter matcher. + * @return Immutable list of every parameter matcher. */ public ImmutableList getParamMatchers() { if (paramMatchers instanceof ImmutableList) @@ -440,7 +441,7 @@ public class FuzzyMethodContract extends AbstractFuzzyMember { /** * Retrieve an immutable list of every exception matcher for this method. - * @return Immutable list of every exception matcher. + * @return Immutable list of every exception matcher. */ public List getExceptionMatchers() { if (exceptionMatchers instanceof ImmutableList) @@ -478,7 +479,7 @@ public class FuzzyMethodContract extends AbstractFuzzyMember { return false; // Finally, check parameters and exceptions - return matchParameters(params, value, paramMatchers) && + return matchParameters(params, value, paramMatchers) && matchParameters(exceptions, value, exceptionMatchers); } // No match @@ -572,7 +573,7 @@ public class FuzzyMethodContract extends AbstractFuzzyMember { } else if (obj instanceof FuzzyMethodContract && super.equals(obj)) { FuzzyMethodContract other = (FuzzyMethodContract) obj; - return Objects.equal(paramCount, other.paramCount) && + return Objects.equal(paramCount, other.paramCount) && Objects.equal(returnMatcher, other.returnMatcher) && Objects.equal(paramMatchers, other.paramMatchers) && Objects.equal(exceptionMatchers, other.exceptionMatchers); diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/instances/DefaultInstances.java b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/instances/DefaultInstances.java index ee14eef3..299b6ddd 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/instances/DefaultInstances.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/instances/DefaultInstances.java @@ -156,8 +156,8 @@ public class DefaultInstances implements InstanceProvider { *

    • Enums. Returns the first declared element.
    • *
    • Collection interfaces, such as List and Set. Returns the most appropriate empty container.
    • *
    • Any type with a public constructor that has parameters with defaults.
    • - *
    *
+ * @param Type * @param type - the type to construct a default value. * @return A default value/instance, or NULL if not possible. */ @@ -167,6 +167,7 @@ public class DefaultInstances implements InstanceProvider { /** * Retrieve the constructor with the fewest number of parameters. + * @param Type * @param type - type to construct. * @return A constructor with the fewest number of parameters, or NULL if the type has no constructors. */ @@ -239,8 +240,8 @@ public class DefaultInstances implements InstanceProvider { *
  • Enums. Returns the first declared element.
  • *
  • Collection interfaces, such as List and Set. Returns the most appropriate empty container.
  • *
  • Any type with a public constructor that has parameters with defaults.
  • - * * + * @param Type * @param type - the type to construct a default value. * @param providers - instance providers used during the construction. * @return A default value/instance, or NULL if not possible. @@ -319,6 +320,7 @@ public class DefaultInstances implements InstanceProvider { /** * Used by the default instance provider to create a class from a given constructor. * The default method uses reflection. + * @param Type * @param type - the type to create. * @param constructor - the constructor to use. * @param types - type of each parameter in order. diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/instances/NotConstructableException.java b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/instances/NotConstructableException.java index 4a7f38e3..e5243c0d 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/instances/NotConstructableException.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/instances/NotConstructableException.java @@ -1,7 +1,7 @@ package com.comphenix.protocol.reflect.instances; /** - * Invoked when a instance provider indicates that a given type cannot or should not be + * Invoked when a instance provider indicates that a given type cannot or should not be * constructed under any circumstances. * * @author Kristian @@ -21,6 +21,7 @@ public class NotConstructableException extends IllegalArgumentException { /** * Construct a new not constructable exception with a custom message. + * @param message - detail message */ public NotConstructableException(String message) { super(message); @@ -28,6 +29,8 @@ public class NotConstructableException extends IllegalArgumentException { /** * Construct a new not constructable exception with a custom message and cause. + * @param message - detail message + * @param cause - cause */ public NotConstructableException(String message, Throwable cause) { super(message, cause); @@ -35,6 +38,7 @@ public class NotConstructableException extends IllegalArgumentException { /** * Construct a new not constructable exception with a custom cause. + * @param cause - cause */ public NotConstructableException(Throwable cause) { super( cause); diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/timing/StatisticsStream.java b/ProtocolLib/src/main/java/com/comphenix/protocol/timing/StatisticsStream.java index c231c521..1c6fc73e 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/timing/StatisticsStream.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/timing/StatisticsStream.java @@ -6,7 +6,7 @@ package com.comphenix.protocol.timing; */ public class StatisticsStream extends OnlineComputation { // This algorithm is due to Donald Knuth, as described in: - // Donald E. Knuth (1998). The Art of Computer Programming, volume 2: + // Donald E. Knuth (1998). The Art of Computer Programming, volume 2: // Seminumerical Algorithms, 3rd edn., p. 232. Boston: Addison-Wesley. private int count = 0; @@ -51,7 +51,7 @@ public class StatisticsStream extends OnlineComputation { // As per Knuth count++; mean += delta / count; - m2 += delta * (value - mean); + m2 += delta * (value - mean); // Update extremes if (value < minimum) @@ -107,6 +107,7 @@ public class StatisticsStream extends OnlineComputation { /** * Combine the two statistics. * @param other - the other statistics. + * @return Combined statistics */ public StatisticsStream add(StatisticsStream other) { // Special cases @@ -147,8 +148,8 @@ public class StatisticsStream extends OnlineComputation { if (count == 0) return "StatisticsStream [Nothing recorded]"; - return String.format("StatisticsStream [Average: %.3f, SD: %.3f, Min: %.3f, Max: %.3f, Count: %s]", - getMean(), getStandardDeviation(), + return String.format("StatisticsStream [Average: %.3f, SD: %.3f, Min: %.3f, Max: %.3f, Count: %s]", + getMean(), getStandardDeviation(), getMinimum(), getMaximum(), getCount()); } } \ No newline at end of file diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/timing/TimedTracker.java b/ProtocolLib/src/main/java/com/comphenix/protocol/timing/TimedTracker.java index 20121caf..0a44e0fb 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/timing/TimedTracker.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/timing/TimedTracker.java @@ -10,7 +10,7 @@ import com.google.common.collect.Maps; * Tracks the invocation time for a particular plugin against a list of packets. * @author Kristian */ -public class TimedTracker { +public class TimedTracker { // Table of packets and invocations private Map packets = Maps.newHashMap(); private int observations; @@ -26,7 +26,7 @@ public class TimedTracker { /** * Stop and record the execution time since the creation of the given tracking token. * @param trackingToken - the tracking token. - * @param packetId - the packet ID. + * @param type - the packet type. */ public synchronized void endTracking(long trackingToken, PacketType type) { StatisticsStream stream = packets.get(type); @@ -57,7 +57,7 @@ public class TimedTracker { for (Entry entry : packets.entrySet()) { clone.put( - entry.getKey(), + entry.getKey(), new StatisticsStream(entry.getValue()) ); } diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/utility/ChatExtensions.java b/ProtocolLib/src/main/java/com/comphenix/protocol/utility/ChatExtensions.java index 434b1999..4f6c25a3 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/utility/ChatExtensions.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/utility/ChatExtensions.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 */ @@ -66,7 +66,7 @@ public class ChatExtensions { * @param message - the message to send. * @throws InvocationTargetException If we were unable to send the message. */ - public void sendMessageSilently(CommandSender receiver, String message) throws InvocationTargetException { + public void sendMessageSilently(CommandSender receiver, String message) throws InvocationTargetException { if (receiver == null) throw new IllegalArgumentException("receiver cannot be NULL."); if (message == null) @@ -172,6 +172,7 @@ public class ChatExtensions { * @param marginChar - the character to use as margin. * @param marginWidth - the width (in characters) of the left and right margin. * @param marginHeight - the height (in characters) of the top and buttom margin. + * @return Flowerboxed message */ public static String[] toFlowerBox(String[] message, String marginChar, int marginWidth, int marginHeight) { String[] output = new String[message.length + marginHeight * 2]; 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 53d91303..f447668b 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/utility/HexDumper.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/utility/HexDumper.java @@ -23,6 +23,7 @@ public class HexDumper { /** * Retrieve a hex dumper tuned for lines of 80 characters: * + * * * * @@ -118,7 +119,7 @@ public class HexDumper { * Set the number of groups in each line. This is limited by the supply of bytes in the byte array. *

    * Use {@link Integer#MAX_VALUE} to effectively disable lines. - * @param groupLength - the length of each group. + * @param groupCount - the count of groups. * @return This instance, for chaining. */ public HexDumper groupCount(int groupCount) { @@ -132,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 start - the starting index of the data. * @param length - the number of bytes to dump. * @throws IOException Any underlying IO exception. */ @@ -158,8 +158,6 @@ public class HexDumper { * Append the hex dump of the given data to the string builder, using the current formatting settings. * @param builder - the builder. * @param data - the data to dump. - * @param start - the starting index of the data. - * @param length - the number of bytes to dump. */ public void appendTo(StringBuilder builder, byte[] data) { appendTo(builder, data, 0, data.length); diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/utility/MinecraftReflection.java b/ProtocolLib/src/main/java/com/comphenix/protocol/utility/MinecraftReflection.java index e8ea294a..7a3d4bb8 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/utility/MinecraftReflection.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/utility/MinecraftReflection.java @@ -1752,12 +1752,14 @@ public class MinecraftReflection { } private static MethodAccessor asCraftMirror; + private static MethodAccessor asCraftCopy; private static MethodAccessor asNMSCopy; /** - * Retrieve a CraftItemStack from a given ItemStack. - * @param bukkitItemStack - the Bukkit ItemStack to convert. - * @return A CraftItemStack as an ItemStack. + * Retrieve a CraftItemStack from a given NMS ItemStack. + * + * @param nmsItem - the NMS ItemStack to convert. + * @return A CraftItemStack as a NMS ItemStack. */ public static ItemStack getBukkitItemStack(Object nmsItem) { if (asCraftMirror == null) { @@ -1768,9 +1770,24 @@ public class MinecraftReflection { } /** - * Retrieve the Bukkit ItemStack from a given net.minecraft.server ItemStack. - * @param minecraftItemStack - the NMS ItemStack to wrap. - * @return The wrapped ItemStack. + * Retrieve a CraftItemStack from a given ItemStack. + * + * @param stack - the Bukkit ItemStack to convert. + * @return A CraftItemStack as an ItemStack. + */ + public static ItemStack getCraftItemStack(ItemStack stack) { + if (asCraftCopy == null) { + asCraftCopy = Accessors.getMethodAccessor(getCraftItemStackClass(), "asCraftCopy", ItemStack.class); + } + + return (ItemStack) asCraftCopy.invoke(null, stack); + } + + /** + * Retrieve the NMS ItemStack from a given ItemStack. + * + * @param stack - the ItemStack to convert. + * @return The NMS ItemStack. */ public static Object getMinecraftItemStack(ItemStack stack) { if (asNMSCopy == null) { 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 2cde37ae..99d6498e 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/utility/SafeCacheBuilder.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/utility/SafeCacheBuilder.java @@ -28,6 +28,8 @@ public class SafeCacheBuilder { /** * Construct a new safe cache builder. + * @param Key type + * @param Value type * * @return A new cache builder. */ @@ -54,9 +56,12 @@ public class SafeCacheBuilder { * Note:The default may change in the future. If you care about this * value, you should always choose it explicitly. * + * @param concurrencyLevel New concurrency level + * @return This for chaining + * * @throws IllegalArgumentException if {@code concurrencyLevel} is - * nonpositive - * @throws IllegalStateException if a concurrency level was already set + * nonpositive + * @throws IllegalStateExeption if a concurrency level was already set */ public SafeCacheBuilder concurrencyLevel(int concurrencyLevel) { builder.concurrencyLevel(concurrencyLevel); @@ -66,8 +71,7 @@ public class SafeCacheBuilder { /** * Specifies that each entry should be automatically removed from the cache * once a fixed duration has elapsed after the entry's creation, or last - * access. Access time is reset by {@link com.google.common.cache.Cache#get Cache.get()} and - * {@link com.google.common.cache.Cache#getUnchecked Cache.getUnchecked()}, + * access. Access time is reset by {@link com.google.common.cache.Cache#get Cache.get()}, * but not by operations on the view returned by * {@link com.google.common.cache.Cache#asMap() Cache.asMap()}. * @@ -86,6 +90,8 @@ public class SafeCacheBuilder { * @param duration the length of time after an entry is last accessed 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 idle or time to live was * already set @@ -280,7 +286,7 @@ public class SafeCacheBuilder { /** * Returns the cache wrapped as a ConcurrentMap. - * <> + *

    * We can't return the direct Cache instance as it changed in Guava 13. * @return The cache as a map. */ diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/AbstractWrapper.java b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/AbstractWrapper.java index 0da7d03b..d1f898e3 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/AbstractWrapper.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/AbstractWrapper.java @@ -12,7 +12,7 @@ public abstract class AbstractWrapper { /** * Construct a new NMS wrapper. - * @param handle - the wrapped NMS object. + * @param handleType - the NMS handle type. */ public AbstractWrapper(Class handleType) { this.handleType = Preconditions.checkNotNull(handleType, "handleType cannot be NULL"); 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 80efb3a8..9db4d779 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/BukkitConverters.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/BukkitConverters.java @@ -210,8 +210,8 @@ public class BukkitConverters { /** * Retrieve an equivalent converter for a map of generic keys and primitive values. - * @param genericItemType - the generic item type. - * @param itemConverter - an equivalent converter for the generic type. + * @param genericKeyType - the generic key type. + * @param keyConverter - an equivalent converter for the generic type. * @return An equivalent converter. */ public static EquivalentConverter> getMapConverter( @@ -1006,7 +1006,7 @@ public class BukkitConverters { } /** - * Retrieve every NMS <-> Bukkit converter as unwrappers. + * Retrieve every NMS to/from Bukkit converter as unwrappers. * @return Every unwrapper. */ public static List getUnwrappers() { diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/WrappedGameProfile.java b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/WrappedGameProfile.java index b4bc044d..b93a0949 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/WrappedGameProfile.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/WrappedGameProfile.java @@ -147,7 +147,7 @@ public class WrappedGameProfile extends AbstractWrapper { /** * Construct a wrapper around an existing game profile. * - * @param profile - the underlying profile, or NULL. + * @param handle - the underlying profile, or NULL. */ public static WrappedGameProfile fromHandle(Object handle) { if (handle == null) diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/WrappedServerPing.java b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/WrappedServerPing.java index dbd25fad..52e582ef 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/WrappedServerPing.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/WrappedServerPing.java @@ -175,7 +175,7 @@ public class WrappedServerPing extends AbstractWrapper { /** * Set the message of the day. - * @param description - the message. + * @param message - the message. */ public void setMotD(String message) { setMotD(WrappedChatComponent.fromText(message)); @@ -200,9 +200,9 @@ public class WrappedServerPing extends AbstractWrapper { /** * Retrieve the displayed number of online players. - * @see {@link #setPlayersOnline(int)} for more information. * @return The displayed number. * @throws IllegalStateException If the player count has been hidden via {@link #setPlayersVisible(boolean)}. + * @see #setPlayersOnline(int) */ public int getPlayersOnline() { if (players == null) @@ -225,9 +225,9 @@ public class WrappedServerPing extends AbstractWrapper { /** * Retrieve the displayed maximum number of players. - * @see {@link #setPlayersMaximum(int)} for more information. * @return The maximum number. * @throws IllegalStateException If the player maximum has been hidden via {@link #setPlayersVisible(boolean)}. + * @see #setPlayersMaximum(int) */ public int getPlayersMaximum() { if (players == null) diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/WrappedSignedProperty.java b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/WrappedSignedProperty.java index fd6f322b..bc478eda 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/WrappedSignedProperty.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/WrappedSignedProperty.java @@ -15,7 +15,6 @@ public class WrappedSignedProperty extends AbstractWrapper { * @param name - the name of the property. * @param value - the value of the property. * @param signature - the BASE64-encoded signature of the value. - * @return The signed property. */ public WrappedSignedProperty(String name, String value, String signature) { this(new Property(name, value, signature)); diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/WrappedStatistic.java b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/WrappedStatistic.java index ae01c5ed..c7e28240 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/WrappedStatistic.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/WrappedStatistic.java @@ -36,7 +36,7 @@ public class WrappedStatistic extends AbstractWrapper { } /** - * Construct a new wrapper from a given underlying statistics. + * Construct a new wrapper from a given underlying statistics. * @param handle - the statistics. * @return The wrapped statistics. */ @@ -46,7 +46,7 @@ public class WrappedStatistic extends AbstractWrapper { /** * Construct a wrapper around an existing game profile. - * @param profile - the underlying profile. + * @param name - statistic name. * @return The wrapped statistics, or NULL if not found. */ public static WrappedStatistic fromName(String name) { @@ -60,9 +60,10 @@ public class WrappedStatistic extends AbstractWrapper { */ public static Iterable values() { @SuppressWarnings("unchecked") - Map map = (Map) MAP_ACCESSOR.get(null); + Map map = (Map) MAP_ACCESSOR.get(null); return Iterables.transform(map.values(), new Function() { + @Override public WrappedStatistic apply(Object handle) { return fromHandle(handle); }; diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/WrappedWatchableObject.java b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/WrappedWatchableObject.java index cc99fa72..510b11f2 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/WrappedWatchableObject.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/WrappedWatchableObject.java @@ -186,6 +186,7 @@ public class WrappedWatchableObject extends AbstractWrapper { * Retrieve the type ID of a watchable object. *

    *

    Values
    PropertyValue
    + * * * * @@ -230,9 +231,9 @@ public class WrappedWatchableObject extends AbstractWrapper { /** * Set the type ID of a watchable object. - * @see {@link #getTypeID()} for more information. * @param id - the new ID. * @throws FieldAccessException Reflection failed. + * @see #getTypeID() */ public void setTypeID(int id) throws FieldAccessException { modifier.withType(int.class).write(0, id); 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 226d7b61..52e6b362 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 @@ -19,18 +19,18 @@ import javax.annotation.Nonnull; */ public interface NbtCompound extends NbtBase>>, Iterable> { @Override - @Deprecated() + @Deprecated public Map> getValue(); /** * Determine if an entry with the given key exists or not. - * @param key - the key to lookup. + * @param key - the key to lookup. * @return TRUE if an entry with the given key exists, FALSE otherwise. */ public abstract boolean containsKey(String key); /** - * Retrieve a Set view of the keys of each entry in this compound. + * Retrieve a Set view of the keys of each entry in this compound. * @return The keys of each entry. */ public abstract Set getKeys(); @@ -260,7 +260,7 @@ public interface NbtCompound extends NbtBase>>, Iterable< public abstract NbtCompound put(String key, int[] value); /** - * Associates a given Java primitive value, list, map or NbtBase with a certain key. + * Associates a given Java primitive value, list, map or NbtBase with a certain key. *

    * If the value is NULL, the corresponding key is removed. Any Map or List will be converted * to a corresponding NbtCompound or NbtList. @@ -341,5 +341,6 @@ public interface NbtCompound extends NbtBase>>, Iterable< * Retrieve an iterator view of the NBT tags stored in this compound. * @return The tags stored in this compound. */ + @Override public abstract Iterator> iterator(); } \ No newline at end of file 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 10b52775..99992c8c 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 @@ -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 */ @@ -130,8 +130,8 @@ public class NbtFactory { /** * Set the NBT compound tag of a given item stack. *

    - * The item stack must be a wrapper for a CraftItemStack. Use - * {@link MinecraftReflection#getBukkitItemStack(ItemStack)} if not. + * The item stack must be a wrapper for a CraftItemStack. Use + * {@link MinecraftReflection#getCraftItemStack(ItemStack)} if not. * @param stack - the item stack, cannot be air. * @param compound - the new NBT compound, or NULL to remove it. * @throws IllegalArgumentException If the stack is not a CraftItemStack, or it represents air. @@ -148,8 +148,8 @@ public class NbtFactory { * auxillary data such as enchanting, name and lore is stored. It doesn't include the items * material, damage value or count. *

    - * The item stack must be a wrapper for a CraftItemStack. Use - * {@link MinecraftReflection#getBukkitItemStack(ItemStack)} if not. + * The item stack must be a wrapper for a CraftItemStack. Use + * {@link MinecraftReflection#getCraftItemStack(ItemStack)} if not. * @param stack - the item stack. * @return A wrapper for its NBT tag. */ @@ -189,7 +189,7 @@ public class NbtFactory { // Would be nice to avoid this, but alas - we have to use Java 6 if (input != null) Closeables.close(input, swallow); else if (stream != null) Closeables.close(stream, swallow); - } + } } /** @@ -214,12 +214,12 @@ public class NbtFactory { // Note the order if (output != null) Closeables.close(output, swallow); else if (stream != null) Closeables.close(stream, swallow); - } + } } /** * Retrieve the NBT tile entity that represents the given block. - * @param state - the block state. + * @param block - the block. * @return The NBT compound, or NULL if the state doesn't have a tile entity. */ public static NbtCompound readBlockState(Block block) { @@ -274,7 +274,7 @@ public class NbtFactory { // Use the first and best NBT tag return itemStackModifier. withTarget(nmsStack). - withType(MinecraftReflection.getNBTBaseClass(), + withType(MinecraftReflection.getNBTBaseClass(), BukkitConverters.getNbtConverter()); } @@ -332,7 +332,7 @@ public class NbtFactory { /** * Constructs a NBT tag of type string. * @param name - name of the tag. - * @param value - value of the tag. + * @param value - value of the tag. * @return The constructed NBT tag. */ public static NbtBase of(String name, String value) { @@ -342,7 +342,7 @@ public class NbtFactory { /** * Constructs a NBT tag of type byte. * @param name - name of the tag. - * @param value - value of the tag. + * @param value - value of the tag. * @return The constructed NBT tag. */ public static NbtBase of(String name, byte value) { @@ -352,7 +352,7 @@ public class NbtFactory { /** * Constructs a NBT tag of type short. * @param name - name of the tag. - * @param value - value of the tag. + * @param value - value of the tag. * @return The constructed NBT tag. */ public static NbtBase of(String name, short value) { @@ -362,7 +362,7 @@ public class NbtFactory { /** * Constructs a NBT tag of type int. * @param name - name of the tag. - * @param value - value of the tag. + * @param value - value of the tag. * @return The constructed NBT tag. */ public static NbtBase of(String name, int value) { @@ -372,7 +372,7 @@ public class NbtFactory { /** * Constructs a NBT tag of type long. * @param name - name of the tag. - * @param value - value of the tag. + * @param value - value of the tag. * @return The constructed NBT tag. */ public static NbtBase of(String name, long value) { @@ -382,7 +382,7 @@ public class NbtFactory { /** * Constructs a NBT tag of type float. * @param name - name of the tag. - * @param value - value of the tag. + * @param value - value of the tag. * @return The constructed NBT tag. */ public static NbtBase of(String name, float value) { @@ -392,7 +392,7 @@ public class NbtFactory { /** * Constructs a NBT tag of type double. * @param name - name of the tag. - * @param value - value of the tag. + * @param value - value of the tag. * @return The constructed NBT tag. */ public static NbtBase of(String name, double value) { @@ -402,7 +402,7 @@ public class NbtFactory { /** * Constructs a NBT tag of type byte array. * @param name - name of the tag. - * @param value - value of the tag. + * @param value - value of the tag. * @return The constructed NBT tag. */ public static NbtBase of(String name, byte[] value) { @@ -412,7 +412,7 @@ public class NbtFactory { /** * Constructs a NBT tag of type int array. * @param name - name of the tag. - * @param value - value of the tag. + * @param value - value of the tag. * @return The constructed NBT tag. */ public static NbtBase of(String name, int[] value) { @@ -421,7 +421,7 @@ public class NbtFactory { /** * Construct a new NBT compound initialized with a given list of NBT values. - * @param name - the name of the compound wrapper. + * @param name - the name of the compound wrapper. * @param list - the list of elements to add. * @return The new wrapped NBT compound. */ @@ -431,7 +431,7 @@ public class NbtFactory { /** * Construct a new NBT compound wrapper. - * @param name - the name of the compound wrapper. + * @param name - the name of the compound wrapper. * @return The new wrapped NBT compound. */ public static NbtCompound ofCompound(String name) { @@ -519,7 +519,7 @@ public class NbtFactory { if (type == NbtType.TAG_COMPOUND) return (NbtWrapper) new WrappedCompound(handle); else if (type == NbtType.TAG_LIST) - return (NbtWrapper) new WrappedList(handle); + return new WrappedList(handle); else return new WrappedElement(handle); } @@ -532,7 +532,7 @@ public class NbtFactory { if (type == NbtType.TAG_COMPOUND) return (NbtWrapper) new WrappedCompound(handle, name); else if (type == NbtType.TAG_LIST) - return (NbtWrapper) new WrappedList(handle, name); + return new WrappedList(handle, name); else return new WrappedElement(handle, name); } 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 85ef13de..e5dfacc6 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 @@ -23,7 +23,7 @@ public interface NbtList extends NbtBase>>, Iterable< public static String EMPTY_NAME = ""; /** - * Get the type of each element. + * Get the type of each element. *

    * This will be {@link NbtType#TAG_END TAG_END} if the NBT list has just been created. * @return Element type. @@ -51,56 +51,56 @@ public interface NbtList extends NbtBase>>, Iterable< public abstract void add(NbtBase element); /** - * Add a new string element to the list. + * Add a new string element to the list. * @param value - the string element to add. * @throws IllegalArgumentException If this is not a list of strings. */ public abstract void add(String value); /** - * Add a new byte element to the list. + * Add a new byte element to the list. * @param value - the byte element to add. * @throws IllegalArgumentException If this is not a list of bytes. */ public abstract void add(byte value); /** - * Add a new short element to the list. + * Add a new short element to the list. * @param value - the short element to add. * @throws IllegalArgumentException If this is not a list of shorts. */ public abstract void add(short value); /** - * Add a new integer element to the list. + * Add a new integer element to the list. * @param value - the string element to add. * @throws IllegalArgumentException If this is not a list of integers. */ public abstract void add(int value); /** - * Add a new long element to the list. + * Add a new long element to the list. * @param value - the string element to add. * @throws IllegalArgumentException If this is not a list of longs. */ public abstract void add(long value); /** - * Add a new double element to the list. + * Add a new double element to the list. * @param value - the double element to add. * @throws IllegalArgumentException If this is not a list of doubles. */ public abstract void add(double value); /** - * Add a new byte array element to the list. + * Add a new byte array element to the list. * @param value - the byte array element to add. * @throws IllegalArgumentException If this is not a list of byte arrays. */ public abstract void add(byte[] value); /** - * Add a new int array element to the list. + * Add a new int array element to the list. * @param value - the int array element to add. * @throws IllegalArgumentException If this is not a list of int arrays. */ @@ -116,7 +116,7 @@ public interface NbtList extends NbtBase>>, Iterable< * Retrieve an element by index. * @param index - index of the element to retrieve. * @return The element to retrieve. - * @throws IndexOutOfBoundsException If the index is out of range (index < 0 || index >= size()) + * @throws IndexOutOfBoundsException If the index is out of range */ public abstract TType getValue(int index); @@ -135,5 +135,6 @@ public interface NbtList extends NbtBase>>, Iterable< /** * Iterate over all the elements in this list. */ + @Override public abstract Iterator iterator(); } \ No newline at end of file

    Type to Value
    Type ID