Archiviert
13
0

Adding packet constructors.

This should simplify a lot of code.
Dieser Commit ist enthalten in:
Kristian S. Stangeland 2012-09-17 22:59:20 +02:00
Ursprung 7a60c5aac7
Commit fb15ee1b22
2 geänderte Dateien mit 14 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -25,6 +25,7 @@ import org.bukkit.plugin.Plugin;
import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketListener; import com.comphenix.protocol.events.PacketListener;
import com.comphenix.protocol.injector.PacketConstructor;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
/** /**
@ -124,6 +125,14 @@ public interface ProtocolManager {
*/ */
public PacketContainer createPacket(int id, boolean forceDefaults); public PacketContainer createPacket(int id, boolean forceDefaults);
/**
* Construct a packet using the special builtin Minecraft constructors.
* @param id - the packet ID.
* @param argumentTypes - type of each argument to pass to Minecraft.
* @return The packet constructor.
*/
public PacketConstructor createPacketConstructor(int id, Class<?>[] argumentTypes);
/** /**
* Retrieves a immutable set containing the ID of the sent server packets that will be observed by listeners. * Retrieves a immutable set containing the ID of the sent server packets that will be observed by listeners.
* @return Every filtered server packet. * @return Every filtered server packet.

Datei anzeigen

@ -325,6 +325,11 @@ public final class PacketFilterManager implements ProtocolManager {
return packet; return packet;
} }
@Override
public PacketConstructor createPacketConstructor(int id, Class<?>[] argumentTypes) {
return PacketConstructor.DEFAUALT.withPacket(id, argumentTypes);
}
@Override @Override
public Set<Integer> getSendingFilters() { public Set<Integer> getSendingFilters() {
return ImmutableSet.copyOf(sendingFilters); return ImmutableSet.copyOf(sendingFilters);