Merge pull request #1189 from creeper123123321/master

Fix duplicate packet registering
This commit is contained in:
Myles 2019-02-10 16:41:39 +00:00 committed by GitHub
commit 102c1f99a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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