Fix duplicate packet registering

This commit is contained in:
creeper123123321 2019-02-10 14:05:58 -02:00
parent 73f6418db3
commit ae3434cb89
No known key found for this signature in database
GPG Key ID: 0AC57D54786721D1
3 changed files with 14 additions and 16 deletions

View File

@ -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);
}
/**

View File

@ -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

View File

@ -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