C1
- old clientbound packet typesC2
- new clientbound packet typesS1
- old serverbound packet typesS2
- new serverbound packet typespublic abstract class Protocol<C1 extends ClientboundPacketType,C2 extends ClientboundPacketType,S1 extends ServerboundPacketType,S2 extends ServerboundPacketType> extends Object
Modifier and Type | Class and Description |
---|---|
static class |
Protocol.Packet |
static class |
Protocol.ProtocolPacket |
Modifier and Type | Field and Description |
---|---|
protected Class<C2> |
newClientboundPacketEnum |
protected Class<S2> |
newServerboundPacketEnum |
protected Class<C1> |
oldClientboundPacketEnum |
protected Class<S1> |
oldServerboundPacketEnum |
Modifier | Constructor and Description |
---|---|
protected |
Protocol() |
protected |
Protocol(@Nullable Class<C1> oldClientboundPacketEnum,
@Nullable Class<C2> clientboundPacketEnum,
@Nullable Class<S1> oldServerboundPacketEnum,
@Nullable Class<S2> serverboundPacketEnum)
Creates a protocol with automated id mapping if the respective enums are not null.
|
Modifier and Type | Method and Description |
---|---|
void |
cancelIncoming(S2 packetType) |
void |
cancelIncoming(State state,
int newPacketID) |
void |
cancelIncoming(State state,
int oldPacketID,
int newPacketID) |
void |
cancelOutgoing(C1 packetType) |
void |
cancelOutgoing(State state,
int oldPacketID) |
void |
cancelOutgoing(State state,
int oldPacketID,
int newPacketID) |
protected void |
filterPacket(UserConnection info,
Object packet,
List output)
Filter a packet into the output
|
<T> T |
get(Class<T> objectClass) |
@Nullable MappingData |
getMappingData() |
boolean |
hasMappingDataToLoad()
Returns true if this Protocol's
loadMappingData() method should be called. |
boolean |
hasRegisteredIncoming(State state,
int newPacketId)
Checks if an incoming packet has already been registered.
|
boolean |
hasRegisteredOutgoing(State state,
int oldPacketID)
Checks if an outgoing packet has already been registered.
|
void |
init(UserConnection userConnection)
Initialise a user for this protocol setting up objects.
|
boolean |
isFiltered(Class packetClass)
Should this protocol filter an object packet from this class.
|
protected void |
loadMappingData()
Loads the mappingdata.
|
protected void |
onMappingDataLoaded()
Called after
loadMappingData() is called; load extra mapping data for the protocol. |
void |
put(Object object) |
protected void |
register(ViaProviders providers)
Handle protocol registration phase, use this to register providers / tasks.
|
void |
registerIncoming(S2 packetType,
@Nullable PacketRemapper packetRemapper)
Registers an incoming protocol and automatically maps it to the server's id.
|
void |
registerIncoming(S2 packetType,
S1 mappedPacketType,
@Nullable PacketRemapper packetRemapper)
Registers an incoming protocol.
|
void |
registerIncoming(State state,
int oldPacketID,
int newPacketID)
Register an incoming packet, with simple id transformation.
|
void |
registerIncoming(State state,
int oldPacketID,
int newPacketID,
PacketRemapper packetRemapper)
Register an incoming packet, with id transformation and remapper.
|
void |
registerIncoming(State state,
int oldPacketID,
int newPacketID,
PacketRemapper packetRemapper,
boolean override) |
protected void |
registerIncomingChannelIdChanges() |
void |
registerOutgoing(C1 packetType,
C2 mappedPacketType)
Maps a packet type to another packet type without a packet handler.
|
void |
registerOutgoing(C1 packetType,
C2 mappedPacketType,
@Nullable PacketRemapper packetRemapper)
Registers an outgoing protocol.
|
void |
registerOutgoing(C1 packetType,
@Nullable PacketRemapper packetRemapper)
Registers an outgoing protocol and automatically maps it to the new id.
|
void |
registerOutgoing(State state,
int oldPacketID,
int newPacketID)
Register an outgoing packet, with simple id transformation.
|
void |
registerOutgoing(State state,
int oldPacketID,
int newPacketID,
PacketRemapper packetRemapper)
Register an outgoing packet, with id transformation and remapper.
|
void |
registerOutgoing(State state,
int oldPacketID,
int newPacketID,
PacketRemapper packetRemapper,
boolean override) |
protected void |
registerOutgoingChannelIdChanges() |
protected void |
registerPackets()
Register the packets for this protocol.
|
String |
toString() |
void |
transform(Direction direction,
State state,
PacketWrapper packetWrapper)
Transform a packet using this protocol
|
protected final Class<C1 extends ClientboundPacketType> oldClientboundPacketEnum
protected final Class<C2 extends ClientboundPacketType> newClientboundPacketEnum
protected final Class<S1 extends ServerboundPacketType> oldServerboundPacketEnum
protected final Class<S2 extends ServerboundPacketType> newServerboundPacketEnum
protected Protocol()
protected Protocol(@Nullable @Nullable Class<C1> oldClientboundPacketEnum, @Nullable @Nullable Class<C2> clientboundPacketEnum, @Nullable @Nullable Class<S1> oldServerboundPacketEnum, @Nullable @Nullable Class<S2> serverboundPacketEnum)
protected void registerOutgoingChannelIdChanges()
protected void registerIncomingChannelIdChanges()
public boolean isFiltered(Class packetClass)
packetClass
- The class of the current inputprotected void filterPacket(UserConnection info, Object packet, List output) throws Exception
info
- The current user connectionpacket
- The input packet as an object (NMS)output
- The list to put the object into.Exception
- Throws exception if cancelled / error.protected void registerPackets()
protected final void loadMappingData()
protected void onMappingDataLoaded()
loadMappingData()
is called; load extra mapping data for the protocol.
To be overridden if needed.
protected void register(ViaProviders providers)
To be overridden if needed.
providers
- The current providerspublic void init(UserConnection userConnection)
UserConnection
To be overridden if needed.
userConnection
- The user to initialisepublic void registerIncoming(State state, int oldPacketID, int newPacketID)
state
- The state which the packet is sent in.oldPacketID
- The old packet IDnewPacketID
- The new packet IDpublic void registerIncoming(State state, int oldPacketID, int newPacketID, PacketRemapper packetRemapper)
state
- The state which the packet is sent in.oldPacketID
- The old packet IDnewPacketID
- The new packet IDpacketRemapper
- The remapper to use for the packetpublic void registerIncoming(State state, int oldPacketID, int newPacketID, PacketRemapper packetRemapper, boolean override)
public void cancelIncoming(State state, int oldPacketID, int newPacketID)
public void cancelIncoming(State state, int newPacketID)
public void registerOutgoing(State state, int oldPacketID, int newPacketID)
state
- The state which the packet is sent in.oldPacketID
- The old packet IDnewPacketID
- The new packet IDpublic void registerOutgoing(State state, int oldPacketID, int newPacketID, PacketRemapper packetRemapper)
state
- The state which the packet is sent in.oldPacketID
- The old packet IDnewPacketID
- The new packet IDpacketRemapper
- The remapper to use for the packetpublic void cancelOutgoing(State state, int oldPacketID, int newPacketID)
public void cancelOutgoing(State state, int oldPacketID)
public void registerOutgoing(State state, int oldPacketID, int newPacketID, PacketRemapper packetRemapper, boolean override)
public void registerOutgoing(C1 packetType, @Nullable @Nullable PacketRemapper packetRemapper)
packetType
- clientbound packet type the server sendspacketRemapper
- remapperpublic void registerOutgoing(C1 packetType, @Nullable C2 mappedPacketType, @Nullable @Nullable PacketRemapper packetRemapper)
packetType
- clientbound packet type the server initially sendsmappedPacketType
- clientbound packet type after transforming for the clientpacketRemapper
- remapperpublic void registerOutgoing(C1 packetType, @Nullable C2 mappedPacketType)
packetType
- clientbound packet type the server initially sendsmappedPacketType
- clientbound packet type after transforming for the clientpublic void cancelOutgoing(C1 packetType)
public void registerIncoming(S2 packetType, @Nullable @Nullable PacketRemapper packetRemapper)
packetType
- serverbound packet type the client sendspacketRemapper
- remapperpublic void registerIncoming(S2 packetType, @Nullable S1 mappedPacketType, @Nullable @Nullable PacketRemapper packetRemapper)
packetType
- serverbound packet type initially sent by the clientmappedPacketType
- serverbound packet type after transforming for the serverpacketRemapper
- remapperpublic void cancelIncoming(S2 packetType)
public boolean hasRegisteredOutgoing(State state, int oldPacketID)
state
- state which the packet is sent inoldPacketID
- old packet IDpublic boolean hasRegisteredIncoming(State state, int newPacketId)
state
- state which the packet is sent innewPacketId
- packet IDpublic void transform(Direction direction, State state, PacketWrapper packetWrapper) throws Exception
direction
- The direction the packet is going instate
- The current protocol statepacketWrapper
- The packet wrapper to transformException
- Throws exception if it fails to transform@Nullable public <T> T get(Class<T> objectClass)
public void put(Object object)
public boolean hasMappingDataToLoad()
loadMappingData()
method should be called.
This does *not* necessarily mean that getMappingData()
is non-null, since this may be
overriden, depending on special cases.
loadMappingData()
method should be called@Nullable public @Nullable MappingData getMappingData()
Copyright © 2016–2021. All rights reserved.