From 75eac1c9aa020e0a567a81d2020fc61984bbd084 Mon Sep 17 00:00:00 2001 From: "Kristian S. Stangeland" Date: Tue, 5 Feb 2013 23:28:27 +0100 Subject: [PATCH] Improve documentation. --- .../player/NetworkObjectInjector.java | 13 +++++++++++- .../injector/spigot/SpigotPacketInjector.java | 17 ++++++++++++++++ .../injector/spigot/SpigotPacketListener.java | 20 +++++++++---------- .../com/comphenix/protocol/package-info.java | 14 +++++++++++++ 4 files changed, 53 insertions(+), 11 deletions(-) create mode 100644 ProtocolLib/src/main/java/com/comphenix/protocol/package-info.java diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/injector/player/NetworkObjectInjector.java b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/player/NetworkObjectInjector.java index 8fa193a4..855e2390 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/injector/player/NetworkObjectInjector.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/player/NetworkObjectInjector.java @@ -42,7 +42,7 @@ import com.comphenix.protocol.injector.PacketFilterManager.PlayerInjectHooks; import com.comphenix.protocol.injector.player.TemporaryPlayerFactory.InjectContainer; /** - * Injection method that overrides the NetworkHandler itself, and it's queue-method. + * Injection method that overrides the NetworkHandler itself, and its queue-method. * * @author Kristian */ @@ -59,6 +59,17 @@ public class NetworkObjectInjector extends PlayerInjector { // Temporary player factory private static volatile TemporaryPlayerFactory tempPlayerFactory; + /** + * Create a new network object injector. + *

+ * Note: This class is intended to be internal. Do not use. + * @param classLoader - the class loader. + * @param reporter - the error reporter. + * @param player - the player Bukkit entity. + * @param invoker - the packet invoker. + * @param sendingFilters - list of permitted packet IDs. + * @throws IllegalAccessException If reflection failed. + */ public NetworkObjectInjector(ClassLoader classLoader, ErrorReporter reporter, Player player, ListenerInvoker invoker, IntegerSet sendingFilters) throws IllegalAccessException { super(reporter, player, invoker); diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/injector/spigot/SpigotPacketInjector.java b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/spigot/SpigotPacketInjector.java index e52bd2e4..8dcc6014 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/injector/spigot/SpigotPacketInjector.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/spigot/SpigotPacketInjector.java @@ -141,6 +141,11 @@ public class SpigotPacketInjector implements SpigotPacketListener { this.reveivedFilters = new IntegerSet(Packets.MAXIMUM_PACKET_ID + 1); } + /** + * Register the Spigot packet injector. + * @param plugin - the parent plugin. + * @return TRUE if we registered the plugin, FALSE otherwise. + */ public boolean register(Plugin plugin) { if (hasRegistered()) return false; @@ -225,14 +230,26 @@ public class SpigotPacketInjector implements SpigotPacketListener { isMatch(MethodInfo.fromMethod(method), null); } + /** + * Determine if the Spigot packet listener has been registered. + * @return TRUE if it has, FALSE otherwise. + */ public boolean hasRegistered() { return dynamicListener != null; } + /** + * Retrieve the dummy player injection handler. + * @return Dummy player injection handler. + */ public PlayerInjectionHandler getPlayerHandler() { return new DummyPlayerHandler(this, queuedFilters); } + /** + * Retrieve the dummy packet injection handler. + * @return Dummy packet injection handler. + */ public PacketInjector getPacketInjector() { return new DummyPacketInjector(this, reveivedFilters); } diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/injector/spigot/SpigotPacketListener.java b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/spigot/SpigotPacketListener.java index 6a38fb68..ce9e3b83 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/injector/spigot/SpigotPacketListener.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/spigot/SpigotPacketListener.java @@ -13,21 +13,21 @@ interface SpigotPacketListener { * The returned packet will be the packet passed on for handling, or in the case of * null being returned, not handled at all. * - * @param networkManager the NetworkManager receiving the packet - * @param connection the connection which will handle the packet - * @param packet the received packet + * @param networkManager - the NetworkManager receiving the packet + * @param connection - the connection which will handle the packet + * @param packet - the received packet * @return the packet to be handled, or null to cancel */ public Object packetReceived(Object networkManager, Object connection, Object packet); /** - * Called when a packet is queued to be sent.The returned packet will be - * the packet sent. In the case of null being returned, the packet will not - * be sent. - * - * @param networkManager the NetworkManager which will send the packet - * @param connection the connection which queued the packet - * @param packet the queue packet + * Called when a packet is queued to be sent. + *

+ * The returned packet will be the packet sent. In the case of null being returned, + * the packet will not be sent. + * @param networkManager - the NetworkManager which will send the packet + * @param connection - the connection which queued the packet + * @param packet - the queue packet * @return the packet to be sent, or null if the packet will not be sent. */ public Object packetQueued(Object networkManager, Object connection, Object packet); diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/package-info.java b/ProtocolLib/src/main/java/com/comphenix/protocol/package-info.java new file mode 100644 index 00000000..3957ae0d --- /dev/null +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/package-info.java @@ -0,0 +1,14 @@ +/** + * Contains classes for retrieving the main {@link ProtocolMananger} object. + *

+ * This allows plugins to reliably and easily read and modify the packet stream of any CraftBukkit-derivative + * (or specifically compatible) Minecraft-server. + *

+ * This manager can be retrieved throught a static method in {@link ProtocolLibrary}: + *

+ * {@code
+ * ProtocolManager manager = ProtocolLibrary.getProtocolManager();
+ * }
+ * 
+ */ +package com.comphenix.protocol; \ No newline at end of file