Archiviert
13
0

Merge branch 'master' into gh-pages

Dieser Commit ist enthalten in:
Kristian S. Stangeland 2013-02-05 23:32:34 +01:00
Commit 52adb8b9fd
6 geänderte Dateien mit 64 neuen und 12 gelöschten Zeilen

Datei anzeigen

@ -42,7 +42,7 @@ import com.comphenix.protocol.injector.PacketFilterManager.PlayerInjectHooks;
import com.comphenix.protocol.injector.player.TemporaryPlayerFactory.InjectContainer; 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 * @author Kristian
*/ */
@ -59,6 +59,17 @@ public class NetworkObjectInjector extends PlayerInjector {
// Temporary player factory // Temporary player factory
private static volatile TemporaryPlayerFactory tempPlayerFactory; private static volatile TemporaryPlayerFactory tempPlayerFactory;
/**
* Create a new network object injector.
* <p>
* 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, public NetworkObjectInjector(ClassLoader classLoader, ErrorReporter reporter, Player player,
ListenerInvoker invoker, IntegerSet sendingFilters) throws IllegalAccessException { ListenerInvoker invoker, IntegerSet sendingFilters) throws IllegalAccessException {
super(reporter, player, invoker); super(reporter, player, invoker);

Datei anzeigen

@ -9,7 +9,12 @@ import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketEvent; import com.comphenix.protocol.events.PacketEvent;
import com.comphenix.protocol.injector.packet.PacketInjector; import com.comphenix.protocol.injector.packet.PacketInjector;
public class DummyPacketInjector implements PacketInjector { /**
* Dummy packet injector that simply delegates to its parent Spigot packet injector or receiving filters.
*
* @author Kristian
*/
class DummyPacketInjector implements PacketInjector {
private SpigotPacketInjector injector; private SpigotPacketInjector injector;
private IntegerSet reveivedFilters; private IntegerSet reveivedFilters;

Datei anzeigen

@ -15,6 +15,11 @@ import com.comphenix.protocol.injector.GamePhase;
import com.comphenix.protocol.injector.PacketFilterManager.PlayerInjectHooks; import com.comphenix.protocol.injector.PacketFilterManager.PlayerInjectHooks;
import com.comphenix.protocol.injector.player.PlayerInjectionHandler; import com.comphenix.protocol.injector.player.PlayerInjectionHandler;
/**
* Dummy player handler that simply delegates to its parent Spigot packet injector.
*
* @author Kristian
*/
class DummyPlayerHandler implements PlayerInjectionHandler { class DummyPlayerHandler implements PlayerInjectionHandler {
private SpigotPacketInjector injector; private SpigotPacketInjector injector;
private IntegerSet sendingFilters; private IntegerSet sendingFilters;

Datei anzeigen

@ -141,6 +141,11 @@ public class SpigotPacketInjector implements SpigotPacketListener {
this.reveivedFilters = new IntegerSet(Packets.MAXIMUM_PACKET_ID + 1); 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) { public boolean register(Plugin plugin) {
if (hasRegistered()) if (hasRegistered())
return false; return false;
@ -225,14 +230,26 @@ public class SpigotPacketInjector implements SpigotPacketListener {
isMatch(MethodInfo.fromMethod(method), null); isMatch(MethodInfo.fromMethod(method), null);
} }
/**
* Determine if the Spigot packet listener has been registered.
* @return TRUE if it has, FALSE otherwise.
*/
public boolean hasRegistered() { public boolean hasRegistered() {
return dynamicListener != null; return dynamicListener != null;
} }
/**
* Retrieve the dummy player injection handler.
* @return Dummy player injection handler.
*/
public PlayerInjectionHandler getPlayerHandler() { public PlayerInjectionHandler getPlayerHandler() {
return new DummyPlayerHandler(this, queuedFilters); return new DummyPlayerHandler(this, queuedFilters);
} }
/**
* Retrieve the dummy packet injection handler.
* @return Dummy packet injection handler.
*/
public PacketInjector getPacketInjector() { public PacketInjector getPacketInjector() {
return new DummyPacketInjector(this, reveivedFilters); return new DummyPacketInjector(this, reveivedFilters);
} }

Datei anzeigen

@ -13,21 +13,21 @@ interface SpigotPacketListener {
* The returned packet will be the packet passed on for handling, or in the case of * The returned packet will be the packet passed on for handling, or in the case of
* null being returned, not handled at all. * null being returned, not handled at all.
* *
* @param networkManager the NetworkManager receiving the packet * @param networkManager - the NetworkManager receiving the packet
* @param connection the connection which will handle the packet * @param connection - the connection which will handle the packet
* @param packet the received packet * @param packet - the received packet
* @return the packet to be handled, or null to cancel * @return the packet to be handled, or null to cancel
*/ */
public Object packetReceived(Object networkManager, Object connection, Object packet); public Object packetReceived(Object networkManager, Object connection, Object packet);
/** /**
* Called when a packet is queued to be sent.The returned packet will be * Called when a packet is queued to be sent.
* the packet sent. In the case of null being returned, the packet will not * <p>
* 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 networkManager - the NetworkManager which will send the packet
* @param connection the connection which queued the packet * @param connection - the connection which queued the packet
* @param packet the queue packet * @param packet - the queue packet
* @return the packet to be sent, or null if the packet will not be sent. * @return the packet to be sent, or null if the packet will not be sent.
*/ */
public Object packetQueued(Object networkManager, Object connection, Object packet); public Object packetQueued(Object networkManager, Object connection, Object packet);

Datei anzeigen

@ -0,0 +1,14 @@
/**
* Contains classes for retrieving the main {@link ProtocolMananger} object.
* <p>
* This allows plugins to reliably and easily read and modify the packet stream of any CraftBukkit-derivative
* (or specifically compatible) Minecraft-server.
* <p>
* This manager can be retrieved throught a static method in {@link ProtocolLibrary}:
* <pre>
* {@code
* ProtocolManager manager = ProtocolLibrary.getProtocolManager();
* }
* </pre>
*/
package com.comphenix.protocol;