Interface PacketRegistry
- All Known Subinterfaces:
BasicPacketChannel
,PacketChannel
,TransactionalPacketRegistry
public interface PacketRegistry
A registry for packets and their bindings.
Used opcodes should always be positive values.
-
Method Summary
Modifier and TypeMethodDescriptionbinding
(int opcode) Gets thePacketBinding
for the given packet class, if the packet type is registered to this channel.<P extends Packet>
Optional<PacketBinding<P>>Gets thePacketBinding
for the given packet class, if the packet type is registered to this channel.bindings()
Gets a collection with all thePacketBinding
s.<P extends Packet>
HandlerPacketBinding<P>Register a packet class to this channel without a receiving handler.
-
Method Details
-
register
Register a packet class to this channel without a receiving handler. This will only allow the packet to be sent, this channel binding will not be able to receive the packet.RequestPacket
types may not be registered using this method, they are only supported byTransactionalPacketRegistry.registerTransactional(java.lang.Class<P>, java.lang.Class<R>, int)
.- Type Parameters:
P
- The type of the packet- Parameters:
packetClass
- The class of the packet being registered. Note: the class must have a no-args constructorpacketOpcode
- A unique opcode for this packet- Returns:
- The created packet binding
-
binding
Gets thePacketBinding
for the given packet class, if the packet type is registered to this channel.- Type Parameters:
P
- The type of the packet- Parameters:
packetClass
- The packet class- Returns:
- The packet binding, if found
-
bindings
Collection<PacketBinding<?>> bindings()Gets a collection with all thePacketBinding
s.- Returns:
- The opcode bindings
-
binding
Gets thePacketBinding
for the given packet class, if the packet type is registered to this channel.- Parameters:
opcode
- The opcode- Returns:
- The opcode binding, if found
-