| Constructor and Description |
|---|
PacketProtocol() |
| Modifier and Type | Method and Description |
|---|---|
void |
clearPackets()
Clears all currently registered packets.
|
Packet |
createClientboundPacket(int id,
NetInput in)
Creates a new instance of a clientbound packet with the given id and read the clientbound input.
|
Packet |
createServerboundPacket(int id,
NetInput in)
Creates a new instance of a serverbound packet with the given id and read the serverbound input.
|
Class<? extends Packet> |
getClientboundClass(int id)
Gets the packet class for a packet id.
|
int |
getClientboundId(Class<? extends Packet> packetClass)
Gets the registered id of a clientbound packet class.
|
int |
getClientboundId(Packet packet)
Gets the registered id of a clientbound
Packet instance. |
abstract PacketEncryption |
getEncryption()
Gets this protocol's active packet encryption.
|
abstract PacketHeader |
getPacketHeader()
Gets the packet header of this protocol.
|
Class<? extends Packet> |
getServerboundClass(int id)
Gets the packet class for a packet id.
|
int |
getServerboundId(Class<? extends Packet> packetClass)
Gets the registered id of a serverbound packet class.
|
int |
getServerboundId(Packet packet)
Gets the registered id of a serverbound
Packet instance. |
abstract String |
getSRVRecordPrefix()
Gets the prefix used when locating SRV records for this protocol.
|
abstract void |
newClientSession(Session session)
Called when a client session is created with this protocol.
|
abstract void |
newServerSession(Server server,
Session session)
Called when a server session is created with this protocol.
|
<T extends Packet> |
register(int id,
Class<T> packet,
PacketFactory<T> factory)
Registers a packet to this protocol as both serverbound and clientbound.
|
void |
register(PacketDefinition<? extends Packet> definition)
Registers a packet to this protocol as both serverbound and clientbound.
|
<T extends Packet> |
registerClientbound(int id,
Class<T> packet,
PacketFactory<T> factory)
Registers a clientbound packet to this protocol.
|
void |
registerClientbound(PacketDefinition<? extends Packet> definition)
Registers a clientbound packet to this protocol.
|
<T extends Packet> |
registerServerbound(int id,
Class<T> packet,
PacketFactory<T> factory)
Registers a serverbound packet to this protocol.
|
void |
registerServerbound(PacketDefinition<? extends Packet> definition)
Registers a serverbound packet to this protocol.
|
public abstract String getSRVRecordPrefix()
public abstract PacketHeader getPacketHeader()
public abstract PacketEncryption getEncryption()
public abstract void newClientSession(Session session)
session - The created session.public abstract void newServerSession(Server server, Session session)
server - The server that the session belongs to.session - The created session.public final void clearPackets()
public final <T extends Packet> void register(int id, Class<T> packet, PacketFactory<T> factory)
id - Id to register the packet to.packet - Packet to register.factory - The packet factory.IllegalArgumentException - If the packet fails a test creation when being registered as serverbound.public final void register(PacketDefinition<? extends Packet> definition)
definition - The packet definition.IllegalArgumentException - If the packet fails a test creation when being registered as serverbound.public final <T extends Packet> void registerServerbound(int id, Class<T> packet, PacketFactory<T> factory)
id - Id to register the packet to.packet - Packet to register.factory - The packet factory.IllegalArgumentException - If the packet fails a test creation.public final void registerServerbound(PacketDefinition<? extends Packet> definition)
definition - The packet definition.public final <T extends Packet> void registerClientbound(int id, Class<T> packet, PacketFactory<T> factory)
id - Id to register the packet to.packet - Packet to register.factory - The packet factory.public final void registerClientbound(PacketDefinition<? extends Packet> definition)
definition - The packet definition.public Packet createClientboundPacket(int id, NetInput in) throws IOException
id - Id of the packet to create.IOException - if there was an IO error whilst reading the packet.IllegalArgumentException - If the packet ID is not registered.public int getClientboundId(Class<? extends Packet> packetClass)
packetClass - Class of the packet to get the id for.IllegalArgumentException - If the packet is not registered.public int getClientboundId(Packet packet)
Packet instance.packet - Instance of Packet to get the id for.IllegalArgumentException - If the packet is not registered.public Class<? extends Packet> getClientboundClass(int id)
id - The packet id.IllegalArgumentException - If the packet ID is not registered.public Packet createServerboundPacket(int id, NetInput in) throws IOException
id - Id of the packet to create.IOException - if there was an IO error whilst reading the packet.IllegalArgumentException - If the packet ID is not registered.public int getServerboundId(Class<? extends Packet> packetClass)
packetClass - Class of the packet to get the id for.IllegalArgumentException - If the packet is not registered.public int getServerboundId(Packet packet)
Packet instance.packet - Instance of Packet to get the id for.IllegalArgumentException - If the packet is not registered.public Class<? extends Packet> getServerboundClass(int id)
id - The packet id.IllegalArgumentException - If the packet ID is not registered.Copyright © 2021. All rights reserved.