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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.Optional<PacketBinding<?>>
binding(int opcode)
Gets thePacketBinding
for the given packet class, if the packet type is registered to this channel.<P extends Packet>
java.util.Optional<PacketBinding<P>>binding(java.lang.Class<P> packetClass)
Gets thePacketBinding
for the given packet class, if the packet type is registered to this channel.java.util.Collection<PacketBinding<?>>
bindings()
Gets a collection with all thePacketBinding
s.<P extends Packet>
HandlerPacketBinding<P>register(java.lang.Class<P> packetClass, int packetOpcode)
Register a packet class to this channel without a receiving handler.
-
-
-
Method Detail
-
register
<P extends Packet> HandlerPacketBinding<P> register(java.lang.Class<P> packetClass, int packetOpcode)
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
<P extends Packet> java.util.Optional<PacketBinding<P>> binding(java.lang.Class<P> packetClass)
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
java.util.Collection<PacketBinding<?>> bindings()
Gets a collection with all thePacketBinding
s.- Returns:
- The opcode bindings
-
binding
java.util.Optional<PacketBinding<?>> binding(int opcode)
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
-
-