mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-11-12 13:24:00 +01:00
Fix duplicate packet registering
This commit is contained in:
parent
73f6418db3
commit
ae3434cb89
@ -98,8 +98,14 @@ public abstract class Protocol {
|
||||
* @param packetRemapper The remapper to use for the packet
|
||||
*/
|
||||
public void registerIncoming(State state, int oldPacketID, int newPacketID, PacketRemapper packetRemapper) {
|
||||
registerIncoming(state, oldPacketID, newPacketID, packetRemapper, false);
|
||||
}
|
||||
|
||||
public void registerIncoming(State state, int oldPacketID, int newPacketID, PacketRemapper packetRemapper, boolean override) {
|
||||
ProtocolPacket protocolPacket = new ProtocolPacket(state, oldPacketID, newPacketID, packetRemapper);
|
||||
incoming.put(new Pair<>(state, newPacketID), protocolPacket);
|
||||
Pair<State, Integer> pair = new Pair<>(state, newPacketID);
|
||||
if (!override && incoming.containsKey(pair)) throw new IllegalArgumentException(pair + " already registered");
|
||||
incoming.put(pair, protocolPacket);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -122,8 +128,14 @@ public abstract class Protocol {
|
||||
* @param packetRemapper The remapper to use for the packet
|
||||
*/
|
||||
public void registerOutgoing(State state, int oldPacketID, int newPacketID, PacketRemapper packetRemapper) {
|
||||
registerOutgoing(state, oldPacketID, newPacketID, packetRemapper, false);
|
||||
}
|
||||
|
||||
public void registerOutgoing(State state, int oldPacketID, int newPacketID, PacketRemapper packetRemapper, boolean override) {
|
||||
ProtocolPacket protocolPacket = new ProtocolPacket(state, oldPacketID, newPacketID, packetRemapper);
|
||||
outgoing.put(new Pair<>(state, oldPacketID), protocolPacket);
|
||||
Pair<State, Integer> pair = new Pair<>(state, oldPacketID);
|
||||
if (!override && outgoing.containsKey(pair)) throw new IllegalArgumentException(pair + " already registered");
|
||||
outgoing.put(pair, protocolPacket);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -344,7 +344,6 @@ public class Protocol1_13To1_12_2 extends Protocol {
|
||||
registerOutgoing(State.PLAY, 0x1B, 0x1C);
|
||||
// New packet 0x1D - NBT Query
|
||||
registerOutgoing(State.PLAY, 0x1C, 0x1E);
|
||||
registerOutgoing(State.PLAY, 0x1D, 0x1F);
|
||||
registerOutgoing(State.PLAY, 0x1E, 0x20);
|
||||
registerOutgoing(State.PLAY, 0x1F, 0x21);
|
||||
// WorldPackets 0x20 -> 0x22
|
||||
|
@ -392,19 +392,6 @@ public class PlayerPackets {
|
||||
|
||||
/* Removed packets */
|
||||
|
||||
// Map Bulk
|
||||
protocol.registerOutgoing(State.PLAY, 0x26, 0x26, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.cancel();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Set Compression
|
||||
protocol.registerOutgoing(State.PLAY, 0x46, 0x46, new PacketRemapper() {
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user