Add missing ViewDistance packet supplier (#436)

This commit is contained in:
Mark Vainomaa 2019-12-10 21:58:34 +02:00 committed by Shane Freeder
parent 337ca7f887
commit f708bf18d8

View File

@ -1,11 +1,11 @@
From 82ea2adbd242f2a04655208bdb2de26ef4d2634d Mon Sep 17 00:00:00 2001
From 05d153a18c69bacd5fe495a3bacd8065924bf95f Mon Sep 17 00:00:00 2001
From: Mark Vainomaa <mikroskeem@mikroskeem.eu>
Date: Wed, 17 Apr 2019 09:24:38 +0300
Subject: [PATCH] Speed up packet construction
diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java b/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java
index 87093807..c2b0e12c 100644
index 87093807..f55b846a 100644
--- a/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java
+++ b/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java
@@ -53,6 +53,7 @@ public enum Protocol
@ -155,7 +155,7 @@ index 87093807..c2b0e12c 100644
map( ProtocolConstants.MINECRAFT_1_8, 0x1A ),
map( ProtocolConstants.MINECRAFT_1_9, 0x1B ),
map( ProtocolConstants.MINECRAFT_1_13, 0x1C ),
@@ -206,6 +225,7 @@ public enum Protocol
@@ -206,15 +225,18 @@ public enum Protocol
);
TO_CLIENT.registerPacket(
Commands.class,
@ -163,7 +163,10 @@ index 87093807..c2b0e12c 100644
map( ProtocolConstants.MINECRAFT_1_13, 0x11 )
);
TO_CLIENT.registerPacket(
@@ -215,6 +235,7 @@ public enum Protocol
ViewDistance.class,
+ ViewDistance::new, // Waterfall - speed up packet construction
map( ProtocolConstants.MINECRAFT_1_14, 0x41 )
);
TO_SERVER.registerPacket(
KeepAlive.class,
@ -171,7 +174,7 @@ index 87093807..c2b0e12c 100644
map( ProtocolConstants.MINECRAFT_1_8, 0x00 ),
map( ProtocolConstants.MINECRAFT_1_9, 0x0B ),
map( ProtocolConstants.MINECRAFT_1_12, 0x0C ),
@@ -224,6 +245,7 @@ public enum Protocol
@@ -224,6 +246,7 @@ public enum Protocol
);
TO_SERVER.registerPacket(
Chat.class,
@ -179,7 +182,7 @@ index 87093807..c2b0e12c 100644
map( ProtocolConstants.MINECRAFT_1_8, 0x01 ),
map( ProtocolConstants.MINECRAFT_1_9, 0x02 ),
map( ProtocolConstants.MINECRAFT_1_12, 0x03 ),
@@ -232,6 +254,7 @@ public enum Protocol
@@ -232,6 +255,7 @@ public enum Protocol
);
TO_SERVER.registerPacket(
TabCompleteRequest.class,
@ -187,7 +190,7 @@ index 87093807..c2b0e12c 100644
map( ProtocolConstants.MINECRAFT_1_8, 0x14 ),
map( ProtocolConstants.MINECRAFT_1_9, 0x01 ),
map( ProtocolConstants.MINECRAFT_1_12, 0x02 ),
@@ -241,6 +264,7 @@ public enum Protocol
@@ -241,6 +265,7 @@ public enum Protocol
);
TO_SERVER.registerPacket(
ClientSettings.class,
@ -195,7 +198,7 @@ index 87093807..c2b0e12c 100644
map( ProtocolConstants.MINECRAFT_1_8, 0x15 ),
map( ProtocolConstants.MINECRAFT_1_9, 0x04 ),
map( ProtocolConstants.MINECRAFT_1_12, 0x05 ),
@@ -249,6 +273,7 @@ public enum Protocol
@@ -249,6 +274,7 @@ public enum Protocol
);
TO_SERVER.registerPacket(
PluginMessage.class,
@ -203,7 +206,7 @@ index 87093807..c2b0e12c 100644
map( ProtocolConstants.MINECRAFT_1_8, 0x17 ),
map( ProtocolConstants.MINECRAFT_1_9, 0x09 ),
map( ProtocolConstants.MINECRAFT_1_12, 0x0A ),
@@ -265,19 +290,23 @@ public enum Protocol
@@ -265,19 +291,23 @@ public enum Protocol
{
TO_CLIENT.registerPacket(
StatusResponse.class,
@ -227,7 +230,7 @@ index 87093807..c2b0e12c 100644
map( ProtocolConstants.MINECRAFT_1_8, 0x01 )
);
}
@@ -289,35 +318,43 @@ public enum Protocol
@@ -289,35 +319,43 @@ public enum Protocol
{
TO_CLIENT.registerPacket(
Kick.class,
@ -271,7 +274,7 @@ index 87093807..c2b0e12c 100644
map( ProtocolConstants.MINECRAFT_1_13, 0x02 )
);
}
@@ -368,7 +405,7 @@ public enum Protocol
@@ -368,7 +406,7 @@ public enum Protocol
private final int protocolVersion;
private final TObjectIntMap<Class<? extends DefinedPacket>> packetMap = new TObjectIntHashMap<>( MAX_PACKET_ID );
@ -280,7 +283,7 @@ index 87093807..c2b0e12c 100644
}
@Data
@@ -436,21 +473,24 @@ public enum Protocol
@@ -436,21 +474,24 @@ public enum Protocol
throw new BadPacketException( "Packet with id " + id + " outside of range " );
}
@ -309,7 +312,7 @@ index 87093807..c2b0e12c 100644
int mappingIndex = 0;
ProtocolMapping mapping = mappings[mappingIndex];
@@ -479,11 +519,32 @@ public enum Protocol
@@ -479,11 +520,32 @@ public enum Protocol
data.packetMap.put( packetClass, mapping.packetID );
data.packetConstructors[mapping.packetID] = constructor;
}