Adding packet constructors.

This should simplify a lot of code.
This commit is contained in:
Kristian S. Stangeland 2012-09-17 22:59:20 +02:00
parent 7a60c5aac7
commit fb15ee1b22
2 changed files with 14 additions and 0 deletions

View File

@ -25,6 +25,7 @@ import org.bukkit.plugin.Plugin;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketListener;
import com.comphenix.protocol.injector.PacketConstructor;
import com.google.common.collect.ImmutableSet;
/**
@ -124,6 +125,14 @@ public interface ProtocolManager {
*/
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.
* @return Every filtered server packet.

View File

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