2020-12-02 20:13:52 +01:00
|
|
|
From 682bb544387936931880d662162b2fe107a4289b Mon Sep 17 00:00:00 2001
|
2016-07-03 08:56:31 +02:00
|
|
|
From: Troy Frew <fuzzy_bot@arenaga.me>
|
2016-11-15 16:32:02 +01:00
|
|
|
Date: Tue, 15 Nov 2016 10:31:04 -0500
|
|
|
|
Subject: [PATCH] 1.7.x Protocol Patch
|
2016-07-03 08:56:31 +02:00
|
|
|
|
|
|
|
|
2017-01-05 02:04:39 +01:00
|
|
|
diff --git a/protocol/src/main/java/io/github/waterfallmc/travertine/protocol/MultiVersionPacketV17.java b/protocol/src/main/java/io/github/waterfallmc/travertine/protocol/MultiVersionPacketV17.java
|
|
|
|
new file mode 100644
|
2020-06-28 14:49:51 +02:00
|
|
|
index 00000000..90064112
|
2017-01-05 02:04:39 +01:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/protocol/src/main/java/io/github/waterfallmc/travertine/protocol/MultiVersionPacketV17.java
|
|
|
|
@@ -0,0 +1,90 @@
|
|
|
|
+package io.github.waterfallmc.travertine.protocol;
|
|
|
|
+
|
|
|
|
+import com.google.common.base.Preconditions;
|
|
|
|
+import io.netty.buffer.ByteBuf;
|
|
|
|
+
|
|
|
|
+import net.md_5.bungee.protocol.DefinedPacket;
|
|
|
|
+import net.md_5.bungee.protocol.ProtocolConstants;
|
|
|
|
+
|
|
|
|
+public abstract class MultiVersionPacketV17 extends DefinedPacket
|
|
|
|
+{
|
|
|
|
+
|
|
|
|
+ protected void v17Read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
|
|
+ {
|
|
|
|
+ v17Read( buf );
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void read0(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
|
|
+ {
|
|
|
|
+ switch ( protocolVersion )
|
|
|
|
+ {
|
|
|
|
+ case ProtocolConstants.MINECRAFT_1_7_2:
|
|
|
|
+ case ProtocolConstants.MINECRAFT_1_7_6:
|
|
|
|
+ v17Read(buf, direction, protocolVersion);
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ read(buf, direction, protocolVersion);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ protected void v17Write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
|
|
+ {
|
|
|
|
+ v17Write( buf );
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void write0(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
|
|
+ {
|
|
|
|
+ switch ( protocolVersion )
|
|
|
|
+ {
|
|
|
|
+ case ProtocolConstants.MINECRAFT_1_7_2:
|
|
|
|
+ case ProtocolConstants.MINECRAFT_1_7_6:
|
|
|
|
+ v17Write(buf, direction, protocolVersion);
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ write(buf, direction, protocolVersion);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ protected void v17Read(ByteBuf buf)
|
|
|
|
+ {
|
|
|
|
+ throw new UnsupportedOperationException( "Packet must implement read method" );
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ protected void v17Write(ByteBuf buf)
|
|
|
|
+ {
|
|
|
|
+ throw new UnsupportedOperationException( "Packet must implement write method" );
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static void v17writeArray(byte[] b, ByteBuf buf, boolean allowExtended)
|
|
|
|
+ {
|
|
|
|
+ // (Integer.MAX_VALUE & 0x1FFF9A ) = 2097050 - Forge's current upper limit
|
|
|
|
+ if ( allowExtended )
|
|
|
|
+ {
|
|
|
|
+ Preconditions.checkArgument( b.length <= ( Integer.MAX_VALUE & 0x1FFF9A ), "Cannot send array longer than 2097050 (got %s bytes)", b.length );
|
|
|
|
+ } else
|
|
|
|
+ {
|
|
|
|
+ Preconditions.checkArgument( b.length <= Short.MAX_VALUE, "Cannot send array longer than Short.MAX_VALUE (got %s bytes)", b.length );
|
|
|
|
+ }
|
|
|
|
+ // Write a 2 or 3 byte number that represents the length of the packet. (3 byte "shorts" for Forge only)
|
|
|
|
+ // No vanilla packet should give a 3 byte packet, this method will still retain vanilla behaviour.
|
|
|
|
+ writeVarShort( buf, b.length );
|
|
|
|
+ buf.writeBytes( b );
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static byte[] v17readArray(ByteBuf buf)
|
|
|
|
+ {
|
|
|
|
+ // Read in a 2 or 3 byte number that represents the length of the packet. (3 byte "shorts" for Forge only)
|
|
|
|
+ // No vanilla packet should give a 3 byte packet, this method will still retain vanilla behaviour.
|
|
|
|
+ int len = readVarShort( buf );
|
|
|
|
+
|
|
|
|
+ // (Integer.MAX_VALUE & 0x1FFF9A ) = 2097050 - Forge's current upper limit
|
|
|
|
+ Preconditions.checkArgument( len <= ( Integer.MAX_VALUE & 0x1FFF9A ), "Cannot receive array longer than 2097050 (got %s bytes)", len );
|
|
|
|
+
|
|
|
|
+ byte[] ret = new byte[ len ];
|
|
|
|
+ buf.readBytes( ret );
|
|
|
|
+ return ret;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/DefinedPacket.java b/protocol/src/main/java/net/md_5/bungee/protocol/DefinedPacket.java
|
2020-08-12 16:05:37 +02:00
|
|
|
index f6e4859f..6ba7ae70 100644
|
2017-01-05 02:04:39 +01:00
|
|
|
--- a/protocol/src/main/java/net/md_5/bungee/protocol/DefinedPacket.java
|
|
|
|
+++ b/protocol/src/main/java/net/md_5/bungee/protocol/DefinedPacket.java
|
2020-08-12 16:05:37 +02:00
|
|
|
@@ -267,6 +267,11 @@ public abstract class DefinedPacket
|
2017-01-05 02:04:39 +01:00
|
|
|
read( buf );
|
|
|
|
}
|
|
|
|
|
|
|
|
+ public void read0(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
|
|
+ {
|
|
|
|
+ read( buf, direction, protocolVersion );
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
public void write(ByteBuf buf)
|
|
|
|
{
|
|
|
|
throw new UnsupportedOperationException( "Packet must implement write method" );
|
2020-08-12 16:05:37 +02:00
|
|
|
@@ -277,6 +282,11 @@ public abstract class DefinedPacket
|
2017-01-05 02:04:39 +01:00
|
|
|
write( buf );
|
|
|
|
}
|
|
|
|
|
|
|
|
+ public void write0(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
|
|
+ {
|
|
|
|
+ write( buf, direction, protocolVersion );
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
public abstract void handle(AbstractPacketHandler handler) throws Exception;
|
|
|
|
|
|
|
|
@Override
|
|
|
|
diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java b/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java
|
2020-07-19 19:07:36 +02:00
|
|
|
index 1a647f2b..ec932e92 100644
|
2017-01-05 02:04:39 +01:00
|
|
|
--- a/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java
|
|
|
|
+++ b/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java
|
|
|
|
@@ -5,10 +5,11 @@ import io.netty.buffer.ByteBufUtil;
|
|
|
|
import io.netty.channel.ChannelHandlerContext;
|
|
|
|
import io.netty.handler.codec.DecoderException;
|
|
|
|
import io.netty.handler.codec.MessageToMessageDecoder;
|
|
|
|
-import java.util.List;
|
|
|
|
import lombok.AllArgsConstructor;
|
|
|
|
import lombok.Setter;
|
|
|
|
|
|
|
|
+import java.util.List;
|
|
|
|
+
|
|
|
|
@AllArgsConstructor
|
|
|
|
public class MinecraftDecoder extends MessageToMessageDecoder<ByteBuf>
|
|
|
|
{
|
2020-07-19 19:07:36 +02:00
|
|
|
@@ -56,7 +57,7 @@ public class MinecraftDecoder extends MessageToMessageDecoder<ByteBuf>
|
2017-01-05 02:04:39 +01:00
|
|
|
if ( packet != null )
|
|
|
|
{
|
|
|
|
packetTypeInfo = packet.getClass();
|
|
|
|
- packet.read( in, prot.getDirection(), protocolVersion );
|
|
|
|
+ packet.read0( in, prot.getDirection(), protocolVersion );
|
|
|
|
|
|
|
|
if ( in.isReadable() )
|
|
|
|
{
|
|
|
|
diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftEncoder.java b/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftEncoder.java
|
2020-06-28 14:49:51 +02:00
|
|
|
index d4b03843..9aac7ca9 100644
|
2017-01-05 02:04:39 +01:00
|
|
|
--- a/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftEncoder.java
|
|
|
|
+++ b/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftEncoder.java
|
|
|
|
@@ -21,6 +21,6 @@ public class MinecraftEncoder extends MessageToByteEncoder<DefinedPacket>
|
|
|
|
{
|
|
|
|
Protocol.DirectionData prot = ( server ) ? protocol.TO_CLIENT : protocol.TO_SERVER;
|
|
|
|
DefinedPacket.writeVarInt( prot.getId( msg.getClass(), protocolVersion ), out );
|
|
|
|
- msg.write( out, prot.getDirection(), protocolVersion );
|
|
|
|
+ msg.write0( out, prot.getDirection(), protocolVersion );
|
|
|
|
}
|
|
|
|
}
|
2016-07-03 08:56:31 +02:00
|
|
|
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
|
2020-08-12 16:05:37 +02:00
|
|
|
index d372933d..1feee418 100644
|
2016-07-03 08:56:31 +02:00
|
|
|
--- a/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java
|
|
|
|
+++ b/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java
|
2020-03-07 23:52:15 +01:00
|
|
|
@@ -55,7 +55,7 @@ public enum Protocol
|
2019-03-02 23:35:35 +01:00
|
|
|
TO_SERVER.registerPacket(
|
|
|
|
Handshake.class,
|
2019-08-17 22:58:37 +02:00
|
|
|
Handshake::new, // Waterfall - speed up packet construction
|
2019-03-02 23:35:35 +01:00
|
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x00 )
|
|
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x00 ) // Travertine
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
2020-03-07 23:52:15 +01:00
|
|
|
@@ -67,7 +67,7 @@ public enum Protocol
|
2019-03-02 23:35:35 +01:00
|
|
|
TO_CLIENT.registerPacket(
|
|
|
|
KeepAlive.class,
|
2019-08-17 22:58:37 +02:00
|
|
|
KeepAlive::new, // Waterfall - speed up packet construction
|
2019-03-02 23:35:35 +01:00
|
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x00 ),
|
|
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x00 ), // Travertine
|
|
|
|
map( ProtocolConstants.MINECRAFT_1_9, 0x1F ),
|
2019-04-23 10:34:01 +02:00
|
|
|
map( ProtocolConstants.MINECRAFT_1_13, 0x21 ),
|
2019-12-11 00:04:38 +01:00
|
|
|
map( ProtocolConstants.MINECRAFT_1_14, 0x20 ),
|
2020-08-12 16:05:37 +02:00
|
|
|
@@ -78,7 +78,7 @@ public enum Protocol
|
2019-03-02 23:35:35 +01:00
|
|
|
TO_CLIENT.registerPacket(
|
|
|
|
Login.class,
|
2019-08-17 22:58:37 +02:00
|
|
|
Login::new, // Waterfall - speed up packet construction
|
2019-03-02 23:35:35 +01:00
|
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x01 ),
|
|
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x01 ), // Travertine
|
|
|
|
map( ProtocolConstants.MINECRAFT_1_9, 0x23 ),
|
2019-12-11 00:04:38 +01:00
|
|
|
map( ProtocolConstants.MINECRAFT_1_13, 0x25 ),
|
2020-06-24 05:52:32 +02:00
|
|
|
map( ProtocolConstants.MINECRAFT_1_15, 0x26 ),
|
2020-08-12 16:05:37 +02:00
|
|
|
@@ -88,7 +88,7 @@ public enum Protocol
|
2019-03-02 23:35:35 +01:00
|
|
|
TO_CLIENT.registerPacket(
|
|
|
|
Chat.class,
|
2019-08-17 22:58:37 +02:00
|
|
|
Chat::new, // Waterfall - speed up packet construction
|
2019-03-02 23:35:35 +01:00
|
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x02 ),
|
|
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x02 ), // Travertine
|
|
|
|
map( ProtocolConstants.MINECRAFT_1_9, 0x0F ),
|
2019-12-11 00:04:38 +01:00
|
|
|
map( ProtocolConstants.MINECRAFT_1_13, 0x0E ),
|
2020-06-24 05:52:32 +02:00
|
|
|
map( ProtocolConstants.MINECRAFT_1_15, 0x0F ),
|
2020-08-12 16:05:37 +02:00
|
|
|
@@ -97,7 +97,7 @@ public enum Protocol
|
2019-03-02 23:35:35 +01:00
|
|
|
TO_CLIENT.registerPacket(
|
|
|
|
Respawn.class,
|
2019-08-17 22:58:37 +02:00
|
|
|
Respawn::new, // Waterfall - speed up packet construction
|
2019-03-02 23:35:35 +01:00
|
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x07 ),
|
|
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x07 ), // Travertine
|
|
|
|
map( ProtocolConstants.MINECRAFT_1_9, 0x33 ),
|
|
|
|
map( ProtocolConstants.MINECRAFT_1_12, 0x34 ),
|
|
|
|
map( ProtocolConstants.MINECRAFT_1_12_1, 0x35 ),
|
2020-08-12 16:05:37 +02:00
|
|
|
@@ -118,7 +118,7 @@ public enum Protocol
|
2019-03-02 23:35:35 +01:00
|
|
|
TO_CLIENT.registerPacket(
|
|
|
|
EntityEffect.class,
|
2019-08-17 22:58:37 +02:00
|
|
|
EntityEffect::new, // Waterfall - speed up packet construction
|
2019-03-02 23:35:35 +01:00
|
|
|
- map(ProtocolConstants.MINECRAFT_1_8, 0x1D),
|
|
|
|
+ map(ProtocolConstants.MINECRAFT_1_7_2, 0x1D), // Travertine
|
|
|
|
map(ProtocolConstants.MINECRAFT_1_9, 0x4C),
|
|
|
|
map(ProtocolConstants.MINECRAFT_1_9_4, 0x4B),
|
2019-03-03 03:15:06 +01:00
|
|
|
map(ProtocolConstants.MINECRAFT_1_12, 0x4E),
|
2020-08-12 16:05:37 +02:00
|
|
|
@@ -131,7 +131,7 @@ public enum Protocol
|
2019-03-02 23:35:35 +01:00
|
|
|
TO_CLIENT.registerPacket(
|
|
|
|
EntityRemoveEffect.class,
|
2019-08-17 22:58:37 +02:00
|
|
|
EntityRemoveEffect::new, // Waterfall - speed up packet construction
|
2019-03-02 23:35:35 +01:00
|
|
|
- map(ProtocolConstants.MINECRAFT_1_8, 0x1E),
|
|
|
|
+ map(ProtocolConstants.MINECRAFT_1_7_2, 0x1E), // Travertine
|
|
|
|
map(ProtocolConstants.MINECRAFT_1_9, 0x31),
|
|
|
|
map(ProtocolConstants.MINECRAFT_1_12, 0x32),
|
|
|
|
map(ProtocolConstants.MINECRAFT_1_12_1, 0x33),
|
2020-08-12 16:05:37 +02:00
|
|
|
@@ -144,8 +144,7 @@ public enum Protocol
|
2019-03-02 23:35:35 +01:00
|
|
|
// Waterfall end
|
|
|
|
TO_CLIENT.registerPacket(
|
|
|
|
PlayerListItem.class, // PlayerInfo
|
2019-08-17 22:58:37 +02:00
|
|
|
- PlayerListItem::new, // Waterfall - speed up packet construction
|
2019-03-02 23:35:35 +01:00
|
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x38 ),
|
|
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x38 ), // Travertine
|
|
|
|
map( ProtocolConstants.MINECRAFT_1_9, 0x2D ),
|
|
|
|
map( ProtocolConstants.MINECRAFT_1_12_1, 0x2E ),
|
2019-04-23 10:34:01 +02:00
|
|
|
map( ProtocolConstants.MINECRAFT_1_13, 0x30 ),
|
2020-08-12 16:05:37 +02:00
|
|
|
@@ -157,7 +156,7 @@ public enum Protocol
|
2019-03-02 23:35:35 +01:00
|
|
|
TO_CLIENT.registerPacket(
|
|
|
|
TabCompleteResponse.class,
|
2019-08-17 22:58:37 +02:00
|
|
|
TabCompleteResponse::new, // Waterfall - speed up packet construction
|
2019-03-02 23:35:35 +01:00
|
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x3A ),
|
|
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x3A ), // Travertine
|
|
|
|
map( ProtocolConstants.MINECRAFT_1_9, 0x0E ),
|
2019-12-11 00:04:38 +01:00
|
|
|
map( ProtocolConstants.MINECRAFT_1_13, 0x10 ),
|
2020-06-24 05:52:32 +02:00
|
|
|
map( ProtocolConstants.MINECRAFT_1_15, 0x11 ),
|
2020-08-12 16:05:37 +02:00
|
|
|
@@ -167,7 +166,7 @@ public enum Protocol
|
2019-03-02 23:35:35 +01:00
|
|
|
TO_CLIENT.registerPacket(
|
|
|
|
ScoreboardObjective.class,
|
2019-08-17 22:58:37 +02:00
|
|
|
ScoreboardObjective::new, // Waterfall - speed up packet construction
|
2019-03-02 23:35:35 +01:00
|
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x3B ),
|
|
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x3B ), // Travertine
|
|
|
|
map( ProtocolConstants.MINECRAFT_1_9, 0x3F ),
|
|
|
|
map( ProtocolConstants.MINECRAFT_1_12, 0x41 ),
|
|
|
|
map( ProtocolConstants.MINECRAFT_1_12_1, 0x42 ),
|
2020-08-12 16:05:37 +02:00
|
|
|
@@ -178,7 +177,7 @@ public enum Protocol
|
2019-03-02 23:35:35 +01:00
|
|
|
TO_CLIENT.registerPacket(
|
|
|
|
ScoreboardScore.class,
|
2019-08-17 22:58:37 +02:00
|
|
|
ScoreboardScore::new, // Waterfall - speed up packet construction
|
2019-03-02 23:35:35 +01:00
|
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x3C ),
|
|
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x3C ), // Travertine
|
|
|
|
map( ProtocolConstants.MINECRAFT_1_9, 0x42 ),
|
|
|
|
map( ProtocolConstants.MINECRAFT_1_12, 0x44 ),
|
|
|
|
map( ProtocolConstants.MINECRAFT_1_12_1, 0x45 ),
|
2020-08-12 16:05:37 +02:00
|
|
|
@@ -189,7 +188,7 @@ public enum Protocol
|
2019-03-02 23:35:35 +01:00
|
|
|
TO_CLIENT.registerPacket(
|
|
|
|
ScoreboardDisplay.class,
|
2019-08-17 22:58:37 +02:00
|
|
|
ScoreboardDisplay::new, // Waterfall - speed up packet construction
|
2019-03-02 23:35:35 +01:00
|
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x3D ),
|
|
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x3D ), // Travertine
|
|
|
|
map( ProtocolConstants.MINECRAFT_1_9, 0x38 ),
|
|
|
|
map( ProtocolConstants.MINECRAFT_1_12, 0x3A ),
|
|
|
|
map( ProtocolConstants.MINECRAFT_1_12_1, 0x3B ),
|
2020-08-12 16:05:37 +02:00
|
|
|
@@ -200,7 +199,7 @@ public enum Protocol
|
2019-03-02 23:35:35 +01:00
|
|
|
TO_CLIENT.registerPacket(
|
|
|
|
Team.class,
|
2019-08-17 22:58:37 +02:00
|
|
|
Team::new, // Waterfall - speed up packet construction
|
2019-03-02 23:35:35 +01:00
|
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x3E ),
|
|
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x3E ), // Travertine
|
|
|
|
map( ProtocolConstants.MINECRAFT_1_9, 0x41 ),
|
|
|
|
map( ProtocolConstants.MINECRAFT_1_12, 0x43 ),
|
|
|
|
map( ProtocolConstants.MINECRAFT_1_12_1, 0x44 ),
|
2020-08-12 16:05:37 +02:00
|
|
|
@@ -211,7 +210,7 @@ public enum Protocol
|
2019-03-02 23:35:35 +01:00
|
|
|
TO_CLIENT.registerPacket(
|
|
|
|
PluginMessage.class,
|
2019-08-17 22:58:37 +02:00
|
|
|
PluginMessage::new, // Waterfall - speed up packet construction
|
2019-03-02 23:35:35 +01:00
|
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x3F ),
|
|
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x3F ), // Travertine
|
|
|
|
map( ProtocolConstants.MINECRAFT_1_9, 0x18 ),
|
2019-04-23 10:34:01 +02:00
|
|
|
map( ProtocolConstants.MINECRAFT_1_13, 0x19 ),
|
2019-12-11 00:04:38 +01:00
|
|
|
map( ProtocolConstants.MINECRAFT_1_14, 0x18 ),
|
2020-08-12 16:05:37 +02:00
|
|
|
@@ -222,7 +221,7 @@ public enum Protocol
|
2019-03-02 23:35:35 +01:00
|
|
|
TO_CLIENT.registerPacket(
|
|
|
|
Kick.class,
|
2019-08-17 22:58:37 +02:00
|
|
|
Kick::new, // Waterfall - speed up packet construction
|
2019-03-02 23:35:35 +01:00
|
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x40 ),
|
|
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x40 ), // Travertine
|
|
|
|
map( ProtocolConstants.MINECRAFT_1_9, 0x1A ),
|
2019-04-23 10:34:01 +02:00
|
|
|
map( ProtocolConstants.MINECRAFT_1_13, 0x1B ),
|
2019-12-11 00:04:38 +01:00
|
|
|
map( ProtocolConstants.MINECRAFT_1_14, 0x1A ),
|
2020-08-12 16:05:37 +02:00
|
|
|
@@ -233,7 +232,7 @@ public enum Protocol
|
2019-03-02 23:35:35 +01:00
|
|
|
TO_CLIENT.registerPacket(
|
|
|
|
Title.class,
|
2019-08-17 22:58:37 +02:00
|
|
|
Title::new, // Waterfall - speed up packet construction
|
2019-03-02 23:35:35 +01:00
|
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x45 ),
|
|
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x45 ), // Travertine
|
|
|
|
map( ProtocolConstants.MINECRAFT_1_12, 0x47 ),
|
|
|
|
map( ProtocolConstants.MINECRAFT_1_12_1, 0x48 ),
|
2019-04-23 10:34:01 +02:00
|
|
|
map( ProtocolConstants.MINECRAFT_1_13, 0x4B ),
|
2020-08-12 16:05:37 +02:00
|
|
|
@@ -244,7 +243,7 @@ public enum Protocol
|
2019-03-02 23:35:35 +01:00
|
|
|
TO_CLIENT.registerPacket(
|
|
|
|
PlayerListHeaderFooter.class,
|
2019-08-17 22:58:37 +02:00
|
|
|
PlayerListHeaderFooter::new, // Waterfall - speed up packet construction
|
2019-03-02 23:35:35 +01:00
|
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x47 ),
|
|
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x47 ), // Travertine
|
|
|
|
map( ProtocolConstants.MINECRAFT_1_9, 0x48 ),
|
|
|
|
map( ProtocolConstants.MINECRAFT_1_9_4, 0x47 ),
|
|
|
|
map( ProtocolConstants.MINECRAFT_1_12, 0x49 ),
|
2020-08-12 16:05:37 +02:00
|
|
|
@@ -257,7 +256,7 @@ public enum Protocol
|
2019-03-02 23:35:35 +01:00
|
|
|
TO_CLIENT.registerPacket(
|
|
|
|
EntityStatus.class,
|
2019-08-17 22:58:37 +02:00
|
|
|
EntityStatus::new, // Waterfall - speed up packet construction
|
2019-03-02 23:35:35 +01:00
|
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x1A ),
|
2019-03-03 02:03:35 +01:00
|
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x1A ), // Travertine
|
2019-03-02 23:35:35 +01:00
|
|
|
map( ProtocolConstants.MINECRAFT_1_9, 0x1B ),
|
2019-04-23 10:34:01 +02:00
|
|
|
map( ProtocolConstants.MINECRAFT_1_13, 0x1C ),
|
2019-12-11 00:04:38 +01:00
|
|
|
map( ProtocolConstants.MINECRAFT_1_14, 0x1B ),
|
2020-08-12 16:05:37 +02:00
|
|
|
@@ -291,7 +290,7 @@ public enum Protocol
|
2019-03-02 23:35:35 +01:00
|
|
|
TO_SERVER.registerPacket(
|
|
|
|
KeepAlive.class,
|
2019-08-17 22:58:37 +02:00
|
|
|
KeepAlive::new, // Waterfall - speed up packet construction
|
2019-03-02 23:35:35 +01:00
|
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x00 ),
|
|
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x00 ), // Travertine
|
|
|
|
map( ProtocolConstants.MINECRAFT_1_9, 0x0B ),
|
|
|
|
map( ProtocolConstants.MINECRAFT_1_12, 0x0C ),
|
|
|
|
map( ProtocolConstants.MINECRAFT_1_12_1, 0x0B ),
|
2020-08-12 16:05:37 +02:00
|
|
|
@@ -302,7 +301,7 @@ public enum Protocol
|
2019-03-02 23:35:35 +01:00
|
|
|
TO_SERVER.registerPacket(
|
|
|
|
Chat.class,
|
2019-08-17 22:58:37 +02:00
|
|
|
Chat::new, // Waterfall - speed up packet construction
|
2019-03-02 23:35:35 +01:00
|
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x01 ),
|
|
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x01 ), // Travertine
|
|
|
|
map( ProtocolConstants.MINECRAFT_1_9, 0x02 ),
|
|
|
|
map( ProtocolConstants.MINECRAFT_1_12, 0x03 ),
|
2019-04-23 10:34:01 +02:00
|
|
|
map( ProtocolConstants.MINECRAFT_1_12_1, 0x02 ),
|
2020-08-12 16:05:37 +02:00
|
|
|
@@ -311,7 +310,7 @@ public enum Protocol
|
2019-03-02 23:35:35 +01:00
|
|
|
TO_SERVER.registerPacket(
|
|
|
|
TabCompleteRequest.class,
|
2019-08-17 22:58:37 +02:00
|
|
|
TabCompleteRequest::new, // Waterfall - speed up packet construction
|
2019-03-02 23:35:35 +01:00
|
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x14 ),
|
|
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x14 ), // Travertine
|
|
|
|
map( ProtocolConstants.MINECRAFT_1_9, 0x01 ),
|
|
|
|
map( ProtocolConstants.MINECRAFT_1_12, 0x02 ),
|
|
|
|
map( ProtocolConstants.MINECRAFT_1_12_1, 0x01 ),
|
2020-08-12 16:05:37 +02:00
|
|
|
@@ -321,7 +320,7 @@ public enum Protocol
|
2019-03-02 23:35:35 +01:00
|
|
|
TO_SERVER.registerPacket(
|
|
|
|
ClientSettings.class,
|
2019-08-17 22:58:37 +02:00
|
|
|
ClientSettings::new, // Waterfall - speed up packet construction
|
2019-03-02 23:35:35 +01:00
|
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x15 ),
|
|
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x15 ), // Travertine
|
|
|
|
map( ProtocolConstants.MINECRAFT_1_9, 0x04 ),
|
|
|
|
map( ProtocolConstants.MINECRAFT_1_12, 0x05 ),
|
2019-04-23 10:34:01 +02:00
|
|
|
map( ProtocolConstants.MINECRAFT_1_12_1, 0x04 ),
|
2020-08-12 16:05:37 +02:00
|
|
|
@@ -330,7 +329,7 @@ public enum Protocol
|
2019-03-02 23:35:35 +01:00
|
|
|
TO_SERVER.registerPacket(
|
|
|
|
PluginMessage.class,
|
2019-08-17 22:58:37 +02:00
|
|
|
PluginMessage::new, // Waterfall - speed up packet construction
|
2019-03-02 23:35:35 +01:00
|
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x17 ),
|
|
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x17 ), // Travertine
|
|
|
|
map( ProtocolConstants.MINECRAFT_1_9, 0x09 ),
|
|
|
|
map( ProtocolConstants.MINECRAFT_1_12, 0x0A ),
|
|
|
|
map( ProtocolConstants.MINECRAFT_1_12_1, 0x09 ),
|
2020-08-12 16:05:37 +02:00
|
|
|
@@ -347,23 +346,23 @@ public enum Protocol
|
2019-03-02 23:35:35 +01:00
|
|
|
TO_CLIENT.registerPacket(
|
|
|
|
StatusResponse.class,
|
2019-08-17 22:58:37 +02:00
|
|
|
StatusResponse::new, // Waterfall - speed up packet construction
|
2019-03-02 23:35:35 +01:00
|
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x00 )
|
2019-08-17 22:58:37 +02:00
|
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x00 ) // Travertine
|
2019-03-02 23:35:35 +01:00
|
|
|
);
|
|
|
|
TO_CLIENT.registerPacket(
|
|
|
|
PingPacket.class,
|
2019-08-17 22:58:37 +02:00
|
|
|
PingPacket::new, // Waterfall - speed up packet construction
|
2019-03-02 23:35:35 +01:00
|
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x01 )
|
|
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x01 ) // Travertine
|
|
|
|
);
|
|
|
|
|
|
|
|
TO_SERVER.registerPacket(
|
|
|
|
StatusRequest.class,
|
2019-08-17 22:58:37 +02:00
|
|
|
StatusRequest::new, // Waterfall - speed up packet construction
|
2019-03-02 23:35:35 +01:00
|
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x00 )
|
|
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x00 ) // Travertine
|
|
|
|
);
|
|
|
|
TO_SERVER.registerPacket(
|
|
|
|
PingPacket.class,
|
2019-08-17 22:58:37 +02:00
|
|
|
PingPacket::new, // Waterfall - speed up packet construction
|
2019-03-02 23:35:35 +01:00
|
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x01 )
|
|
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x01 ) // Travertine
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
2020-08-12 16:05:37 +02:00
|
|
|
@@ -375,22 +374,22 @@ public enum Protocol
|
2019-03-02 23:35:35 +01:00
|
|
|
TO_CLIENT.registerPacket(
|
|
|
|
Kick.class,
|
2019-08-17 22:58:37 +02:00
|
|
|
Kick::new, // Waterfall - speed up packet construction
|
2019-03-02 23:35:35 +01:00
|
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x00 )
|
|
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x00 ) // Travertine
|
|
|
|
);
|
|
|
|
TO_CLIENT.registerPacket(
|
|
|
|
EncryptionRequest.class,
|
2019-08-17 22:58:37 +02:00
|
|
|
EncryptionRequest::new, // Waterfall - speed up packet construction
|
2019-03-02 23:35:35 +01:00
|
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x01 )
|
|
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x01 ) // Travertine
|
|
|
|
);
|
|
|
|
TO_CLIENT.registerPacket(
|
|
|
|
LoginSuccess.class,
|
2019-08-17 22:58:37 +02:00
|
|
|
LoginSuccess::new, // Waterfall - speed up packet construction
|
2019-03-02 23:35:35 +01:00
|
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x02 )
|
|
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x02 ) // Travertine
|
|
|
|
);
|
|
|
|
TO_CLIENT.registerPacket(
|
|
|
|
SetCompression.class,
|
2019-08-17 22:58:37 +02:00
|
|
|
SetCompression::new, // Waterfall - speed up packet construction
|
2019-03-02 23:35:35 +01:00
|
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x03 )
|
|
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x03 ) // Travertine
|
|
|
|
);
|
|
|
|
TO_CLIENT.registerPacket(
|
|
|
|
LoginPayloadRequest.class,
|
2020-08-12 16:05:37 +02:00
|
|
|
@@ -401,12 +400,12 @@ public enum Protocol
|
2019-03-02 23:35:35 +01:00
|
|
|
TO_SERVER.registerPacket(
|
|
|
|
LoginRequest.class,
|
2019-08-17 22:58:37 +02:00
|
|
|
LoginRequest::new, // Waterfall - speed up packet construction
|
2019-03-02 23:35:35 +01:00
|
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x00 )
|
|
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x00 ) // Travertine
|
|
|
|
);
|
|
|
|
TO_SERVER.registerPacket(
|
|
|
|
EncryptionResponse.class,
|
2019-08-17 22:58:37 +02:00
|
|
|
EncryptionResponse::new, // Waterfall - speed up packet construction
|
2019-03-02 23:35:35 +01:00
|
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x01 )
|
|
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x01 ) // Travertine
|
|
|
|
);
|
|
|
|
TO_SERVER.registerPacket(
|
|
|
|
LoginPayloadResponse.class,
|
2020-08-12 16:05:37 +02:00
|
|
|
@@ -526,7 +525,11 @@ public enum Protocol
|
2016-07-31 21:04:17 +02:00
|
|
|
}
|
|
|
|
if ( !hasPacket(id, supportsForge) )
|
|
|
|
{
|
2017-01-05 02:04:39 +01:00
|
|
|
- throw new BadPacketException( "Packet with id " + id + " outside of range " );
|
2016-11-15 16:32:02 +01:00
|
|
|
+ if ( ProtocolConstants.isBeforeOrEq( version, ProtocolConstants.MINECRAFT_1_7_6 ) ) {
|
|
|
|
+ return null;
|
2017-01-05 02:04:39 +01:00
|
|
|
+ } else {
|
|
|
|
+ throw new BadPacketException( "Packet with id " + id + " outside of range " );
|
2016-11-15 16:32:02 +01:00
|
|
|
+ }
|
2016-07-31 21:04:17 +02:00
|
|
|
}
|
|
|
|
|
2019-08-17 22:58:37 +02:00
|
|
|
java.util.function.Supplier<? extends DefinedPacket> constructor = protocolData.packetConstructors[id]; // Waterfall - speed up packet construction
|
2017-01-05 02:04:39 +01:00
|
|
|
diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/ProtocolConstants.java b/protocol/src/main/java/net/md_5/bungee/protocol/ProtocolConstants.java
|
2020-11-23 05:48:18 +01:00
|
|
|
index 2202c4d3..6600185b 100644
|
2017-01-05 02:04:39 +01:00
|
|
|
--- a/protocol/src/main/java/net/md_5/bungee/protocol/ProtocolConstants.java
|
|
|
|
+++ b/protocol/src/main/java/net/md_5/bungee/protocol/ProtocolConstants.java
|
|
|
|
@@ -6,6 +6,8 @@ import java.util.List;
|
|
|
|
public class ProtocolConstants
|
|
|
|
{
|
|
|
|
|
|
|
|
+ public static final int MINECRAFT_1_7_2 = 4;
|
|
|
|
+ public static final int MINECRAFT_1_7_6 = 5;
|
|
|
|
public static final int MINECRAFT_1_8 = 47;
|
|
|
|
public static final int MINECRAFT_1_9 = 107;
|
|
|
|
public static final int MINECRAFT_1_9_1 = 108;
|
2020-11-02 21:01:49 +01:00
|
|
|
@@ -34,6 +36,7 @@ public class ProtocolConstants
|
2020-09-11 01:47:38 +02:00
|
|
|
public static final int MINECRAFT_1_16_3 = 753;
|
2020-11-23 05:48:18 +01:00
|
|
|
public static final int MINECRAFT_1_16_4 = 754;
|
2017-01-05 02:04:39 +01:00
|
|
|
public static final List<String> SUPPORTED_VERSIONS = Arrays.asList(
|
|
|
|
+ "1.7.x",
|
|
|
|
"1.8.x",
|
|
|
|
"1.9.x",
|
|
|
|
"1.10.x",
|
2020-11-02 21:01:49 +01:00
|
|
|
@@ -45,6 +48,8 @@ public class ProtocolConstants
|
2020-06-24 05:52:32 +02:00
|
|
|
"1.16.x"
|
2017-01-05 02:04:39 +01:00
|
|
|
);
|
|
|
|
public static final List<Integer> SUPPORTED_VERSION_IDS = Arrays.asList(
|
|
|
|
+ ProtocolConstants.MINECRAFT_1_7_2,
|
|
|
|
+ ProtocolConstants.MINECRAFT_1_7_6,
|
|
|
|
ProtocolConstants.MINECRAFT_1_8,
|
|
|
|
ProtocolConstants.MINECRAFT_1_9,
|
|
|
|
ProtocolConstants.MINECRAFT_1_9_1,
|
|
|
|
diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/Varint21FrameDecoder.java b/protocol/src/main/java/net/md_5/bungee/protocol/Varint21FrameDecoder.java
|
2020-07-19 19:07:36 +02:00
|
|
|
index c0d37142..a07e25b1 100644
|
2017-01-05 02:04:39 +01:00
|
|
|
--- a/protocol/src/main/java/net/md_5/bungee/protocol/Varint21FrameDecoder.java
|
|
|
|
+++ b/protocol/src/main/java/net/md_5/bungee/protocol/Varint21FrameDecoder.java
|
2019-04-23 10:34:01 +02:00
|
|
|
@@ -6,10 +6,12 @@ import io.netty.channel.ChannelHandlerContext;
|
|
|
|
import io.netty.handler.codec.ByteToMessageDecoder;
|
2017-01-05 02:04:39 +01:00
|
|
|
import io.netty.handler.codec.CorruptedFrameException;
|
|
|
|
import java.util.List;
|
|
|
|
+import java.util.concurrent.atomic.AtomicLong;
|
|
|
|
|
|
|
|
public class Varint21FrameDecoder extends ByteToMessageDecoder
|
|
|
|
{
|
|
|
|
|
|
|
|
+ private AtomicLong lastEmptyPacket = new AtomicLong(0); // Travertine
|
|
|
|
private static boolean DIRECT_WARNING;
|
2019-10-10 17:43:52 +02:00
|
|
|
|
|
|
|
@Override
|
2020-07-19 19:07:36 +02:00
|
|
|
@@ -44,7 +46,15 @@ public class Varint21FrameDecoder extends ByteToMessageDecoder
|
2019-02-04 19:06:59 +01:00
|
|
|
// Waterfall end
|
2019-10-10 17:43:52 +02:00
|
|
|
if ( false && length == 0) // Waterfall - ignore
|
2017-01-05 02:04:39 +01:00
|
|
|
{
|
|
|
|
- throw new CorruptedFrameException( "Empty Packet!" );
|
|
|
|
+ // Travertine start - vanilla 1.7 client sometimes sends empty packets.
|
|
|
|
+ long currentTime = System.currentTimeMillis();
|
|
|
|
+ long lastEmptyPacket = this.lastEmptyPacket.getAndSet(currentTime);
|
|
|
|
+
|
|
|
|
+ if (currentTime - lastEmptyPacket < 50L)
|
|
|
|
+ {
|
|
|
|
+ throw new CorruptedFrameException( "Too many empty packets" );
|
|
|
|
+ }
|
|
|
|
+ // Travertine end
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( in.readableBytes() < length )
|
|
|
|
diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/Chat.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/Chat.java
|
2020-11-02 21:01:49 +01:00
|
|
|
index 828a5dbe..195ec088 100644
|
2017-01-05 02:04:39 +01:00
|
|
|
--- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/Chat.java
|
|
|
|
+++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/Chat.java
|
2019-04-23 10:34:01 +02:00
|
|
|
@@ -1,5 +1,6 @@
|
2017-01-05 02:04:39 +01:00
|
|
|
package net.md_5.bungee.protocol.packet;
|
|
|
|
|
|
|
|
+import io.github.waterfallmc.travertine.protocol.MultiVersionPacketV17;
|
|
|
|
import io.netty.buffer.ByteBuf;
|
2020-06-24 05:52:32 +02:00
|
|
|
import java.util.UUID;
|
2020-11-02 21:01:49 +01:00
|
|
|
import lombok.Data;
|
|
|
|
@@ -12,7 +13,7 @@ import net.md_5.bungee.protocol.ProtocolConstants;
|
|
|
|
@Data
|
2017-01-05 02:04:39 +01:00
|
|
|
@NoArgsConstructor
|
|
|
|
@EqualsAndHashCode(callSuper = false)
|
|
|
|
-public class Chat extends DefinedPacket
|
|
|
|
+public class Chat extends MultiVersionPacketV17
|
|
|
|
{
|
|
|
|
|
2020-06-24 05:52:32 +02:00
|
|
|
private static final UUID EMPTY_UUID = new UUID( 0L, 0L );
|
2020-11-02 21:01:49 +01:00
|
|
|
@@ -36,6 +37,13 @@ public class Chat extends DefinedPacket
|
|
|
|
this.position = position;
|
|
|
|
this.sender = sender == null ? EMPTY_UUID : sender;
|
2017-01-05 02:04:39 +01:00
|
|
|
}
|
|
|
|
+ // Travertine start
|
|
|
|
+ @Override
|
|
|
|
+ public void v17Read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
|
|
+ {
|
|
|
|
+ message = readString( buf );
|
|
|
|
+ }
|
|
|
|
+ // Travertine end
|
2020-11-02 21:01:49 +01:00
|
|
|
|
2017-01-05 02:04:39 +01:00
|
|
|
@Override
|
|
|
|
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
2020-11-02 21:01:49 +01:00
|
|
|
@@ -56,6 +64,14 @@ public class Chat extends DefinedPacket
|
2017-01-05 02:04:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Travertine start
|
|
|
|
+ @Override
|
|
|
|
+ public void v17Write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
|
|
+ {
|
|
|
|
+ writeString( message, buf );
|
|
|
|
+ }
|
|
|
|
+ // Travertine end
|
|
|
|
+
|
|
|
|
@Override
|
|
|
|
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
|
|
{
|
|
|
|
diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/ClientSettings.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/ClientSettings.java
|
2020-06-28 14:49:51 +02:00
|
|
|
index 9daf7a73..b7640fcb 100644
|
2017-01-05 02:04:39 +01:00
|
|
|
--- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/ClientSettings.java
|
|
|
|
+++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/ClientSettings.java
|
2019-04-23 10:34:01 +02:00
|
|
|
@@ -1,5 +1,7 @@
|
2017-01-05 02:04:39 +01:00
|
|
|
package net.md_5.bungee.protocol.packet;
|
|
|
|
|
|
|
|
+import io.github.waterfallmc.travertine.protocol.MultiVersionPacketV17;
|
2019-04-23 10:34:01 +02:00
|
|
|
+import net.md_5.bungee.protocol.DefinedPacket;
|
2017-01-05 02:04:39 +01:00
|
|
|
import io.netty.buffer.ByteBuf;
|
|
|
|
import lombok.AllArgsConstructor;
|
2019-04-23 10:34:01 +02:00
|
|
|
import lombok.Data;
|
|
|
|
@@ -13,7 +15,7 @@ import net.md_5.bungee.protocol.ProtocolConstants;
|
2017-01-05 02:04:39 +01:00
|
|
|
@NoArgsConstructor
|
|
|
|
@AllArgsConstructor
|
|
|
|
@EqualsAndHashCode(callSuper = false)
|
|
|
|
-public class ClientSettings extends DefinedPacket
|
|
|
|
+public class ClientSettings extends MultiVersionPacketV17
|
|
|
|
{
|
|
|
|
|
|
|
|
private String locale;
|
2019-04-23 10:34:01 +02:00
|
|
|
@@ -24,6 +26,19 @@ public class ClientSettings extends DefinedPacket
|
2017-01-05 02:04:39 +01:00
|
|
|
private byte skinParts;
|
|
|
|
private int mainHand;
|
|
|
|
|
|
|
|
+ // Travertine start
|
|
|
|
+ @Override
|
|
|
|
+ public void v17Read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
|
|
+ {
|
|
|
|
+ locale = readString( buf );
|
|
|
|
+ viewDistance = buf.readByte();
|
|
|
|
+ chatFlags = buf.readUnsignedByte();
|
|
|
|
+ chatColours = buf.readBoolean();
|
|
|
|
+ skinParts = buf.readByte();
|
|
|
|
+ difficulty = buf.readByte();
|
|
|
|
+ }
|
|
|
|
+ // Travertine end
|
|
|
|
+
|
|
|
|
@Override
|
|
|
|
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
|
|
{
|
2019-04-23 10:34:01 +02:00
|
|
|
@@ -58,6 +73,19 @@ public class ClientSettings extends DefinedPacket
|
2017-01-05 02:04:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Travertine start
|
|
|
|
+ @Override
|
|
|
|
+ public void v17Write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
|
|
+ {
|
|
|
|
+ writeString( locale, buf );
|
|
|
|
+ buf.writeByte( viewDistance );
|
|
|
|
+ buf.writeByte( chatFlags );
|
|
|
|
+ buf.writeBoolean( chatColours );
|
|
|
|
+ buf.writeByte( skinParts );
|
|
|
|
+ buf.writeByte( difficulty );
|
|
|
|
+ }
|
|
|
|
+ // Travertine end
|
|
|
|
+
|
|
|
|
@Override
|
|
|
|
public void handle(AbstractPacketHandler handler) throws Exception
|
|
|
|
{
|
|
|
|
diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/EncryptionRequest.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/EncryptionRequest.java
|
2020-06-28 14:49:51 +02:00
|
|
|
index a29524ca..8d9f4ccb 100644
|
2017-01-05 02:04:39 +01:00
|
|
|
--- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/EncryptionRequest.java
|
|
|
|
+++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/EncryptionRequest.java
|
|
|
|
@@ -1,25 +1,35 @@
|
|
|
|
package net.md_5.bungee.protocol.packet;
|
|
|
|
|
|
|
|
+import io.github.waterfallmc.travertine.protocol.MultiVersionPacketV17;
|
|
|
|
import io.netty.buffer.ByteBuf;
|
|
|
|
import lombok.AllArgsConstructor;
|
|
|
|
import lombok.Data;
|
|
|
|
import lombok.EqualsAndHashCode;
|
|
|
|
import lombok.NoArgsConstructor;
|
|
|
|
import net.md_5.bungee.protocol.AbstractPacketHandler;
|
|
|
|
-import net.md_5.bungee.protocol.DefinedPacket;
|
|
|
|
import net.md_5.bungee.protocol.ProtocolConstants;
|
|
|
|
|
|
|
|
@Data
|
|
|
|
@NoArgsConstructor
|
|
|
|
@AllArgsConstructor
|
|
|
|
@EqualsAndHashCode(callSuper = false)
|
|
|
|
-public class EncryptionRequest extends DefinedPacket
|
|
|
|
+public class EncryptionRequest extends MultiVersionPacketV17
|
|
|
|
{
|
|
|
|
|
|
|
|
private String serverId;
|
|
|
|
private byte[] publicKey;
|
|
|
|
private byte[] verifyToken;
|
|
|
|
|
|
|
|
+ // Travertine start
|
|
|
|
+ @Override
|
|
|
|
+ public void v17Read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
|
|
+ {
|
|
|
|
+ serverId = readString( buf );
|
|
|
|
+ publicKey = v17readArray( buf );
|
|
|
|
+ verifyToken = v17readArray( buf );
|
|
|
|
+ }
|
|
|
|
+ // Travertine end
|
|
|
|
+
|
|
|
|
@Override
|
|
|
|
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
|
|
{
|
|
|
|
@@ -28,6 +38,16 @@ public class EncryptionRequest extends DefinedPacket
|
|
|
|
verifyToken = readArray( buf );
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Travertine start
|
|
|
|
+ @Override
|
|
|
|
+ public void v17Write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
|
|
+ {
|
|
|
|
+ writeString( serverId, buf );
|
|
|
|
+ v17writeArray( publicKey, buf, false );
|
|
|
|
+ v17writeArray( verifyToken, buf, false );
|
|
|
|
+ }
|
|
|
|
+ // Travertine end
|
|
|
|
+
|
|
|
|
@Override
|
|
|
|
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
|
|
{
|
|
|
|
diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/EncryptionResponse.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/EncryptionResponse.java
|
2020-06-28 14:49:51 +02:00
|
|
|
index 388f6cdb..7f124322 100644
|
2017-01-05 02:04:39 +01:00
|
|
|
--- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/EncryptionResponse.java
|
|
|
|
+++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/EncryptionResponse.java
|
2019-04-23 10:34:01 +02:00
|
|
|
@@ -1,5 +1,6 @@
|
2017-01-05 02:04:39 +01:00
|
|
|
package net.md_5.bungee.protocol.packet;
|
|
|
|
|
|
|
|
+import io.github.waterfallmc.travertine.protocol.MultiVersionPacketV17;
|
|
|
|
import io.netty.buffer.ByteBuf;
|
|
|
|
import lombok.AllArgsConstructor;
|
|
|
|
import lombok.Data;
|
2019-04-23 10:34:01 +02:00
|
|
|
@@ -13,12 +14,21 @@ import net.md_5.bungee.protocol.ProtocolConstants;
|
2017-01-05 02:04:39 +01:00
|
|
|
@NoArgsConstructor
|
|
|
|
@AllArgsConstructor
|
|
|
|
@EqualsAndHashCode(callSuper = false)
|
|
|
|
-public class EncryptionResponse extends DefinedPacket
|
|
|
|
+public class EncryptionResponse extends MultiVersionPacketV17
|
|
|
|
{
|
|
|
|
|
|
|
|
private byte[] sharedSecret;
|
|
|
|
private byte[] verifyToken;
|
|
|
|
|
|
|
|
+ // Travertine start
|
|
|
|
+ @Override
|
|
|
|
+ public void v17Read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
|
|
+ {
|
|
|
|
+ sharedSecret = v17readArray( buf );
|
|
|
|
+ verifyToken = v17readArray( buf );
|
|
|
|
+ }
|
|
|
|
+ // Travertine end
|
|
|
|
+
|
|
|
|
@Override
|
|
|
|
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
|
|
{
|
2019-04-23 10:34:01 +02:00
|
|
|
@@ -26,6 +36,15 @@ public class EncryptionResponse extends DefinedPacket
|
2017-01-05 02:04:39 +01:00
|
|
|
verifyToken = readArray( buf, 128 );
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Travertine start
|
|
|
|
+ @Override
|
|
|
|
+ public void v17Write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
|
|
+ {
|
|
|
|
+ v17writeArray( sharedSecret, buf, false );
|
|
|
|
+ v17writeArray( verifyToken, buf, false );
|
|
|
|
+ }
|
|
|
|
+ // Travertine end
|
|
|
|
+
|
|
|
|
@Override
|
|
|
|
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
|
|
{
|
|
|
|
diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/EntityEffect.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/EntityEffect.java
|
2020-06-28 14:49:51 +02:00
|
|
|
index d11a9ea9..07fc21b6 100644
|
2017-01-05 02:04:39 +01:00
|
|
|
--- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/EntityEffect.java
|
|
|
|
+++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/EntityEffect.java
|
|
|
|
@@ -1,18 +1,19 @@
|
|
|
|
package net.md_5.bungee.protocol.packet;
|
|
|
|
|
|
|
|
+import io.github.waterfallmc.travertine.protocol.MultiVersionPacketV17;
|
|
|
|
import io.netty.buffer.ByteBuf;
|
|
|
|
import lombok.AllArgsConstructor;
|
|
|
|
import lombok.Data;
|
|
|
|
import lombok.EqualsAndHashCode;
|
|
|
|
import lombok.NoArgsConstructor;
|
|
|
|
import net.md_5.bungee.protocol.AbstractPacketHandler;
|
|
|
|
-import net.md_5.bungee.protocol.DefinedPacket;
|
|
|
|
+import net.md_5.bungee.protocol.ProtocolConstants;
|
|
|
|
|
|
|
|
@Data
|
|
|
|
@NoArgsConstructor
|
|
|
|
@AllArgsConstructor
|
|
|
|
@EqualsAndHashCode(callSuper = false)
|
|
|
|
-public class EntityEffect extends DefinedPacket {
|
|
|
|
+public class EntityEffect extends MultiVersionPacketV17 {
|
|
|
|
|
|
|
|
private int entityId;
|
|
|
|
private int effectId;
|
2017-10-29 18:12:12 +01:00
|
|
|
@@ -20,6 +21,14 @@ public class EntityEffect extends DefinedPacket {
|
|
|
|
private int duration;
|
2017-01-05 02:04:39 +01:00
|
|
|
private boolean hideParticles;
|
|
|
|
|
2017-10-29 18:12:12 +01:00
|
|
|
+ @Override
|
2017-01-05 02:04:39 +01:00
|
|
|
+ protected void v17Read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) {
|
|
|
|
+ this.entityId = buf.readInt();
|
|
|
|
+ this.effectId = buf.readUnsignedByte();
|
|
|
|
+ this.amplifier = buf.readUnsignedByte();
|
|
|
|
+ this.duration = buf.readShort();
|
|
|
|
+ }
|
|
|
|
+
|
2017-10-29 18:12:12 +01:00
|
|
|
@Override
|
2017-01-05 02:04:39 +01:00
|
|
|
public void read(ByteBuf buf) {
|
|
|
|
this.entityId = readVarInt(buf);
|
2017-10-29 18:12:12 +01:00
|
|
|
@@ -29,6 +38,14 @@ public class EntityEffect extends DefinedPacket {
|
|
|
|
this.hideParticles = buf.readBoolean();
|
2017-01-05 02:04:39 +01:00
|
|
|
}
|
|
|
|
|
2017-10-29 18:12:12 +01:00
|
|
|
+ @Override
|
2017-01-05 02:04:39 +01:00
|
|
|
+ protected void v17Write(ByteBuf buf) {
|
|
|
|
+ buf.writeInt(effectId);
|
|
|
|
+ buf.writeByte(effectId);
|
|
|
|
+ buf.writeByte(amplifier);
|
|
|
|
+ buf.writeShort(duration);
|
|
|
|
+ }
|
|
|
|
+
|
2017-10-29 18:12:12 +01:00
|
|
|
@Override
|
2017-01-05 02:04:39 +01:00
|
|
|
public void write(ByteBuf buf) {
|
|
|
|
writeVarInt(this.entityId, buf);
|
|
|
|
diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/EntityRemoveEffect.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/EntityRemoveEffect.java
|
2020-06-28 14:49:51 +02:00
|
|
|
index 7ed2dc3a..9f8d56fc 100644
|
2017-01-05 02:04:39 +01:00
|
|
|
--- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/EntityRemoveEffect.java
|
|
|
|
+++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/EntityRemoveEffect.java
|
|
|
|
@@ -1,18 +1,18 @@
|
|
|
|
package net.md_5.bungee.protocol.packet;
|
|
|
|
|
|
|
|
+import io.github.waterfallmc.travertine.protocol.MultiVersionPacketV17;
|
|
|
|
import io.netty.buffer.ByteBuf;
|
|
|
|
import lombok.AllArgsConstructor;
|
|
|
|
import lombok.Data;
|
|
|
|
import lombok.EqualsAndHashCode;
|
|
|
|
import lombok.NoArgsConstructor;
|
|
|
|
import net.md_5.bungee.protocol.AbstractPacketHandler;
|
|
|
|
-import net.md_5.bungee.protocol.DefinedPacket;
|
|
|
|
|
|
|
|
@Data
|
|
|
|
@NoArgsConstructor
|
|
|
|
@AllArgsConstructor
|
|
|
|
@EqualsAndHashCode(callSuper = false)
|
|
|
|
-public class EntityRemoveEffect extends DefinedPacket {
|
|
|
|
+public class EntityRemoveEffect extends MultiVersionPacketV17 {
|
|
|
|
|
|
|
|
private int entityId;
|
|
|
|
private int effectId;
|
2017-10-29 18:12:12 +01:00
|
|
|
@@ -23,9 +23,15 @@ public class EntityRemoveEffect extends DefinedPacket {
|
|
|
|
this.effectId = buf.readUnsignedByte();
|
2017-01-05 02:04:39 +01:00
|
|
|
}
|
|
|
|
|
2017-10-29 18:12:12 +01:00
|
|
|
+ @Override
|
2017-01-05 02:04:39 +01:00
|
|
|
+ protected void v17Read(ByteBuf buf) {
|
|
|
|
+ this.entityId = buf.readInt();
|
|
|
|
+ this.effectId = buf.readUnsignedByte();
|
|
|
|
+ }
|
|
|
|
+
|
2017-10-29 18:12:12 +01:00
|
|
|
@Override
|
2017-01-05 02:04:39 +01:00
|
|
|
public void write(ByteBuf buf) {
|
|
|
|
- writeVarInt(this.entityId, buf);
|
|
|
|
+ writeVarInt(entityId, buf);
|
2017-05-15 09:01:52 +02:00
|
|
|
buf.writeByte(effectId);
|
|
|
|
}
|
|
|
|
|
|
|
|
@@ -33,4 +39,10 @@ public class EntityRemoveEffect extends DefinedPacket {
|
|
|
|
public void handle(AbstractPacketHandler handler) throws Exception {
|
|
|
|
handler.handle(this);
|
|
|
|
}
|
2017-01-05 02:04:39 +01:00
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ protected void v17Write(ByteBuf buf) {
|
|
|
|
+ buf.writeInt(entityId);
|
2017-05-15 09:01:52 +02:00
|
|
|
+ buf.writeByte(effectId);
|
|
|
|
+ }
|
|
|
|
}
|
2017-01-05 02:04:39 +01:00
|
|
|
diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/KeepAlive.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/KeepAlive.java
|
2020-06-28 14:49:51 +02:00
|
|
|
index b004bc41..0c2eb022 100644
|
2017-01-05 02:04:39 +01:00
|
|
|
--- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/KeepAlive.java
|
|
|
|
+++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/KeepAlive.java
|
2019-04-23 10:34:01 +02:00
|
|
|
@@ -1,5 +1,6 @@
|
2017-01-05 02:04:39 +01:00
|
|
|
package net.md_5.bungee.protocol.packet;
|
|
|
|
|
|
|
|
+import io.github.waterfallmc.travertine.protocol.MultiVersionPacketV17;
|
|
|
|
import io.netty.buffer.ByteBuf;
|
|
|
|
import lombok.AllArgsConstructor;
|
|
|
|
import lombok.Data;
|
2019-04-23 10:34:01 +02:00
|
|
|
@@ -13,17 +14,33 @@ import net.md_5.bungee.protocol.ProtocolConstants;
|
2017-01-05 02:04:39 +01:00
|
|
|
@NoArgsConstructor
|
|
|
|
@AllArgsConstructor
|
|
|
|
@EqualsAndHashCode(callSuper = false)
|
|
|
|
-public class KeepAlive extends DefinedPacket
|
|
|
|
+public class KeepAlive extends MultiVersionPacketV17
|
|
|
|
{
|
|
|
|
|
2017-10-29 18:12:12 +01:00
|
|
|
private long randomId;
|
2017-01-05 02:04:39 +01:00
|
|
|
|
|
|
|
+ // Travertine start
|
|
|
|
+ @Override
|
|
|
|
+ public void v17Read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
|
|
+ {
|
|
|
|
+ randomId = buf.readInt();
|
|
|
|
+ }
|
|
|
|
+ // Travertine end
|
|
|
|
+
|
|
|
|
@Override
|
|
|
|
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
|
|
{
|
2017-10-29 18:12:12 +01:00
|
|
|
randomId = ( protocolVersion >= ProtocolConstants.MINECRAFT_1_12_2 ) ? buf.readLong() : readVarInt( buf );
|
2017-01-05 02:04:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
+ // Travertine start
|
|
|
|
+ @Override
|
|
|
|
+ public void v17Write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
|
|
+ {
|
2017-10-29 18:12:12 +01:00
|
|
|
+ buf.writeInt((int) randomId);
|
2017-01-05 02:04:39 +01:00
|
|
|
+ }
|
|
|
|
+ // Travertine end
|
|
|
|
+
|
|
|
|
@Override
|
|
|
|
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
|
|
{
|
2020-06-24 05:52:32 +02:00
|
|
|
diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/LoginSuccess.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/LoginSuccess.java
|
2020-06-28 14:49:51 +02:00
|
|
|
index 551bd104..ac8751f6 100644
|
2020-06-24 05:52:32 +02:00
|
|
|
--- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/LoginSuccess.java
|
|
|
|
+++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/LoginSuccess.java
|
|
|
|
@@ -23,6 +23,11 @@ public class LoginSuccess extends DefinedPacket
|
|
|
|
@Override
|
|
|
|
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
|
|
{
|
|
|
|
+ // Travertine start
|
|
|
|
+ if ( protocolVersion <= ProtocolConstants.MINECRAFT_1_7_2 ) {
|
|
|
|
+ uuid = readUndashedUUID( buf );
|
|
|
|
+ } else
|
|
|
|
+ // Travertine end
|
|
|
|
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_16 )
|
|
|
|
{
|
|
|
|
uuid = readUUID( buf );
|
|
|
|
@@ -36,6 +41,11 @@ public class LoginSuccess extends DefinedPacket
|
|
|
|
@Override
|
|
|
|
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
|
|
{
|
|
|
|
+ // Travertine start
|
|
|
|
+ if ( protocolVersion <= ProtocolConstants.MINECRAFT_1_7_2 ) {
|
|
|
|
+ writeUndashedUUID( uuid.toString(), buf );
|
|
|
|
+ } else
|
|
|
|
+ // Travertine end
|
|
|
|
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_16 )
|
|
|
|
{
|
|
|
|
writeUUID( uuid, buf );
|
|
|
|
@@ -51,4 +61,14 @@ public class LoginSuccess extends DefinedPacket
|
|
|
|
{
|
|
|
|
handler.handle( this );
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ // Travertine start
|
|
|
|
+ private static UUID readUndashedUUID(ByteBuf buf) {
|
|
|
|
+ return UUID.fromString( new StringBuilder( readString( buf ) ).insert( 20, '-' ).insert( 16, '-' ).insert( 12, '-' ).insert( 8, '-' ).toString() );
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private static void writeUndashedUUID(String uuid, ByteBuf buf) {
|
|
|
|
+ writeString( new StringBuilder( 32 ).append( uuid, 0, 8 ).append( uuid, 9, 13 ).append( uuid, 14, 18 ).append( uuid, 19, 23 ).append( uuid, 24, 36 ).toString(), buf );
|
|
|
|
+ }
|
|
|
|
+ // Travertine end
|
|
|
|
}
|
2017-01-05 02:04:39 +01:00
|
|
|
diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/PlayerListItem.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/PlayerListItem.java
|
2020-06-28 14:49:51 +02:00
|
|
|
index 92bacc7c..c919f961 100644
|
2017-01-05 02:04:39 +01:00
|
|
|
--- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/PlayerListItem.java
|
|
|
|
+++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/PlayerListItem.java
|
2019-04-23 10:34:01 +02:00
|
|
|
@@ -1,5 +1,7 @@
|
2017-01-05 02:04:39 +01:00
|
|
|
package net.md_5.bungee.protocol.packet;
|
|
|
|
|
|
|
|
+import io.github.waterfallmc.travertine.protocol.MultiVersionPacketV17;
|
2019-04-23 10:34:01 +02:00
|
|
|
+import net.md_5.bungee.protocol.DefinedPacket;
|
2017-01-05 02:04:39 +01:00
|
|
|
import io.netty.buffer.ByteBuf;
|
2019-04-23 10:34:01 +02:00
|
|
|
import java.util.UUID;
|
2017-01-05 02:04:39 +01:00
|
|
|
import lombok.Data;
|
2019-04-23 10:34:01 +02:00
|
|
|
@@ -12,12 +14,24 @@ import net.md_5.bungee.protocol.ProtocolConstants;
|
2017-01-05 02:04:39 +01:00
|
|
|
@Data
|
|
|
|
@NoArgsConstructor
|
|
|
|
@EqualsAndHashCode(callSuper = false)
|
|
|
|
-public class PlayerListItem extends DefinedPacket
|
|
|
|
+public class PlayerListItem extends MultiVersionPacketV17
|
|
|
|
{
|
|
|
|
|
|
|
|
private Action action;
|
|
|
|
private Item[] items;
|
|
|
|
|
|
|
|
+ // Travertine start
|
|
|
|
+ @Override
|
|
|
|
+ public void v17Read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
|
|
+ {
|
|
|
|
+ items = new Item[ 1 ];
|
|
|
|
+ Item item = items[ 0 ] = new Item();
|
|
|
|
+ item.displayName = item.username = readString( buf );
|
|
|
|
+ action = !buf.readBoolean() ? Action.REMOVE_PLAYER : Action.ADD_PLAYER;
|
|
|
|
+ item.ping = buf.readShort();
|
|
|
|
+ }
|
|
|
|
+ // Travertine end
|
|
|
|
+
|
|
|
|
@Override
|
|
|
|
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
|
|
{
|
2019-04-23 10:34:01 +02:00
|
|
|
@@ -72,6 +86,17 @@ public class PlayerListItem extends DefinedPacket
|
2017-01-05 02:04:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Travertine start
|
|
|
|
+ @Override
|
|
|
|
+ public void v17Write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
|
|
+ {
|
|
|
|
+ Item item = items[0]; // Only one at a time
|
|
|
|
+ writeString( item.displayName, buf ); // TODO: Server unique only!
|
|
|
|
+ buf.writeBoolean( action != Action.REMOVE_PLAYER );
|
|
|
|
+ buf.writeShort( item.ping );
|
|
|
|
+ }
|
|
|
|
+ // Travertine end
|
|
|
|
+
|
|
|
|
@Override
|
|
|
|
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
|
|
{
|
|
|
|
diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/PluginMessage.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/PluginMessage.java
|
2020-06-28 14:49:51 +02:00
|
|
|
index 17e12655..c49c5a56 100644
|
2017-01-05 02:04:39 +01:00
|
|
|
--- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/PluginMessage.java
|
|
|
|
+++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/PluginMessage.java
|
2019-04-23 10:34:01 +02:00
|
|
|
@@ -3,6 +3,8 @@ package net.md_5.bungee.protocol.packet;
|
2018-07-20 04:23:11 +02:00
|
|
|
import com.google.common.base.Function;
|
2017-01-05 02:04:39 +01:00
|
|
|
import com.google.common.base.Preconditions;
|
|
|
|
import com.google.common.base.Predicate;
|
|
|
|
+import io.github.waterfallmc.travertine.protocol.MultiVersionPacketV17;
|
2019-04-23 10:34:01 +02:00
|
|
|
+import io.netty.buffer.ByteBufUtil;
|
2017-01-05 02:04:39 +01:00
|
|
|
import io.netty.buffer.ByteBuf;
|
2019-04-23 10:34:01 +02:00
|
|
|
import io.netty.buffer.ByteBufUtil; // Waterfall
|
2017-01-05 02:04:39 +01:00
|
|
|
import java.io.ByteArrayInputStream;
|
2019-04-23 10:34:01 +02:00
|
|
|
@@ -21,7 +23,7 @@ import net.md_5.bungee.protocol.ProtocolConstants;
|
2017-01-05 02:04:39 +01:00
|
|
|
@NoArgsConstructor
|
|
|
|
@AllArgsConstructor
|
|
|
|
@EqualsAndHashCode(callSuper = false)
|
|
|
|
-public class PluginMessage extends DefinedPacket
|
|
|
|
+public class PluginMessage extends MultiVersionPacketV17
|
|
|
|
{
|
|
|
|
|
2018-07-20 04:23:11 +02:00
|
|
|
public static final Function<String, String> MODERNISE = new Function<String, String>()
|
2019-04-23 10:34:01 +02:00
|
|
|
@@ -79,6 +81,15 @@ public class PluginMessage extends DefinedPacket
|
2017-01-05 02:04:39 +01:00
|
|
|
*/
|
|
|
|
private boolean allowExtendedPacket = false;
|
|
|
|
|
|
|
|
+ // Travertine start
|
|
|
|
+ @Override
|
|
|
|
+ public void v17Read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
|
|
+ {
|
|
|
|
+ tag = readString( buf );
|
|
|
|
+ data = v17readArray( buf );
|
|
|
|
+ }
|
|
|
|
+ // Travertine end
|
|
|
|
+
|
|
|
|
@Override
|
|
|
|
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
|
|
{
|
2019-04-23 10:34:01 +02:00
|
|
|
@@ -89,6 +100,15 @@ public class PluginMessage extends DefinedPacket
|
2017-01-05 02:04:39 +01:00
|
|
|
buf.readBytes( data );
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Travertine start
|
|
|
|
+ @Override
|
|
|
|
+ public void v17Write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
|
|
+ {
|
|
|
|
+ writeString( tag, buf );
|
|
|
|
+ v17writeArray( data, buf, allowExtendedPacket );
|
|
|
|
+ }
|
|
|
|
+ // Travertine end
|
|
|
|
+
|
|
|
|
@Override
|
|
|
|
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
|
|
{
|
|
|
|
diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/ScoreboardObjective.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/ScoreboardObjective.java
|
2020-06-28 14:49:51 +02:00
|
|
|
index 3c7905d5..fe290fa3 100644
|
2017-01-05 02:04:39 +01:00
|
|
|
--- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/ScoreboardObjective.java
|
|
|
|
+++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/ScoreboardObjective.java
|
2019-04-23 10:34:01 +02:00
|
|
|
@@ -1,5 +1,6 @@
|
2018-07-25 20:14:35 +02:00
|
|
|
package net.md_5.bungee.protocol.packet;
|
|
|
|
|
2017-01-05 02:04:39 +01:00
|
|
|
+import io.github.waterfallmc.travertine.protocol.MultiVersionPacketV17;
|
|
|
|
import io.netty.buffer.ByteBuf;
|
2018-07-20 04:23:11 +02:00
|
|
|
import java.util.Locale;
|
2017-01-05 02:04:39 +01:00
|
|
|
import lombok.AllArgsConstructor;
|
2018-07-25 20:14:35 +02:00
|
|
|
@@ -14,7 +15,7 @@ import net.md_5.bungee.protocol.ProtocolConstants;
|
2017-01-05 02:04:39 +01:00
|
|
|
@NoArgsConstructor
|
|
|
|
@AllArgsConstructor
|
|
|
|
@EqualsAndHashCode(callSuper = false)
|
|
|
|
-public class ScoreboardObjective extends DefinedPacket
|
|
|
|
+public class ScoreboardObjective extends MultiVersionPacketV17
|
|
|
|
{
|
|
|
|
|
|
|
|
private String name;
|
2018-07-25 20:14:35 +02:00
|
|
|
@@ -25,6 +26,16 @@ public class ScoreboardObjective extends DefinedPacket
|
2017-01-05 02:04:39 +01:00
|
|
|
*/
|
|
|
|
private byte action;
|
|
|
|
|
|
|
|
+ // Travertine start
|
|
|
|
+ @Override
|
|
|
|
+ public void v17Read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
|
|
+ {
|
|
|
|
+ name = readString( buf );
|
|
|
|
+ value = readString( buf );
|
|
|
|
+ action = buf.readByte();
|
|
|
|
+ }
|
|
|
|
+ // Travertine end
|
|
|
|
+
|
|
|
|
@Override
|
|
|
|
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
|
|
{
|
2018-07-25 20:14:35 +02:00
|
|
|
@@ -43,6 +54,16 @@ public class ScoreboardObjective extends DefinedPacket
|
2017-01-05 02:04:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Travertine start
|
|
|
|
+ @Override
|
|
|
|
+ public void v17Write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
|
|
+ {
|
|
|
|
+ writeString( name, buf );
|
|
|
|
+ writeString( value, buf );
|
|
|
|
+ buf.writeByte( action );
|
|
|
|
+ }
|
|
|
|
+ // Travertine end
|
|
|
|
+
|
|
|
|
@Override
|
|
|
|
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
|
|
{
|
|
|
|
diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/ScoreboardScore.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/ScoreboardScore.java
|
2020-06-28 14:49:51 +02:00
|
|
|
index 0b27fc86..74066702 100644
|
2017-01-05 02:04:39 +01:00
|
|
|
--- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/ScoreboardScore.java
|
|
|
|
+++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/ScoreboardScore.java
|
2019-04-23 10:34:01 +02:00
|
|
|
@@ -1,5 +1,6 @@
|
2017-01-05 02:04:39 +01:00
|
|
|
package net.md_5.bungee.protocol.packet;
|
|
|
|
|
|
|
|
+import io.github.waterfallmc.travertine.protocol.MultiVersionPacketV17;
|
|
|
|
import io.netty.buffer.ByteBuf;
|
|
|
|
import lombok.AllArgsConstructor;
|
|
|
|
import lombok.Data;
|
2019-04-23 10:34:01 +02:00
|
|
|
@@ -13,7 +14,7 @@ import net.md_5.bungee.protocol.ProtocolConstants;
|
2017-01-05 02:04:39 +01:00
|
|
|
@NoArgsConstructor
|
|
|
|
@AllArgsConstructor
|
|
|
|
@EqualsAndHashCode(callSuper = false)
|
|
|
|
-public class ScoreboardScore extends DefinedPacket
|
|
|
|
+public class ScoreboardScore extends MultiVersionPacketV17
|
|
|
|
{
|
|
|
|
|
|
|
|
private String itemName;
|
2019-04-23 10:34:01 +02:00
|
|
|
@@ -24,6 +25,20 @@ public class ScoreboardScore extends DefinedPacket
|
2017-01-05 02:04:39 +01:00
|
|
|
private String scoreName;
|
|
|
|
private int value;
|
|
|
|
|
|
|
|
+ // Travertine start
|
|
|
|
+ @Override
|
|
|
|
+ public void v17Read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
|
|
+ {
|
|
|
|
+ itemName = readString( buf );
|
|
|
|
+ action = buf.readByte();
|
|
|
|
+ if ( action != 1 )
|
|
|
|
+ {
|
|
|
|
+ scoreName = readString( buf );
|
|
|
|
+ value = buf.readInt();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // Travertine end
|
|
|
|
+
|
|
|
|
@Override
|
|
|
|
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
|
|
{
|
2019-04-23 10:34:01 +02:00
|
|
|
@@ -36,6 +51,20 @@ public class ScoreboardScore extends DefinedPacket
|
2017-01-05 02:04:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Travertine start
|
|
|
|
+ @Override
|
|
|
|
+ public void v17Write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
|
|
+ {
|
|
|
|
+ writeString( itemName, buf );
|
|
|
|
+ buf.writeByte( action );
|
|
|
|
+ if ( action != 1 )
|
|
|
|
+ {
|
|
|
|
+ writeString( scoreName, buf );
|
|
|
|
+ buf.writeInt( value );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // Travertine end
|
|
|
|
+
|
|
|
|
@Override
|
|
|
|
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
|
|
{
|
|
|
|
diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/TabCompleteRequest.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/TabCompleteRequest.java
|
2020-08-12 16:05:37 +02:00
|
|
|
index 3e4ea192..421805e6 100644
|
2017-01-05 02:04:39 +01:00
|
|
|
--- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/TabCompleteRequest.java
|
|
|
|
+++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/TabCompleteRequest.java
|
2019-04-23 10:34:01 +02:00
|
|
|
@@ -1,5 +1,6 @@
|
2017-01-05 02:04:39 +01:00
|
|
|
package net.md_5.bungee.protocol.packet;
|
|
|
|
|
|
|
|
+import io.github.waterfallmc.travertine.protocol.MultiVersionPacketV17;
|
|
|
|
import io.netty.buffer.ByteBuf;
|
|
|
|
import lombok.Data;
|
2018-07-20 04:23:11 +02:00
|
|
|
import lombok.EqualsAndHashCode;
|
2019-04-23 10:34:01 +02:00
|
|
|
@@ -11,7 +12,7 @@ import net.md_5.bungee.protocol.ProtocolConstants;
|
2018-07-20 04:23:11 +02:00
|
|
|
@Data
|
2017-01-05 02:04:39 +01:00
|
|
|
@NoArgsConstructor
|
|
|
|
@EqualsAndHashCode(callSuper = false)
|
|
|
|
-public class TabCompleteRequest extends DefinedPacket
|
|
|
|
+public class TabCompleteRequest extends MultiVersionPacketV17
|
|
|
|
{
|
|
|
|
|
2018-07-20 04:23:11 +02:00
|
|
|
private int transactionId;
|
2019-04-23 10:34:01 +02:00
|
|
|
@@ -33,6 +34,13 @@ public class TabCompleteRequest extends DefinedPacket
|
2018-07-20 04:23:11 +02:00
|
|
|
this.hasPositon = hasPosition;
|
|
|
|
this.position = position;
|
|
|
|
}
|
2017-01-05 02:04:39 +01:00
|
|
|
+ // Travertine start
|
|
|
|
+ @Override
|
|
|
|
+ public void v17Read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
|
|
+ {
|
|
|
|
+ cursor = readString( buf );
|
|
|
|
+ }
|
|
|
|
+ // Travertine end
|
2018-07-20 04:23:11 +02:00
|
|
|
|
2017-01-05 02:04:39 +01:00
|
|
|
@Override
|
|
|
|
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
2019-04-23 10:34:01 +02:00
|
|
|
@@ -57,6 +65,14 @@ public class TabCompleteRequest extends DefinedPacket
|
2017-01-05 02:04:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Travertine start
|
|
|
|
+ @Override
|
|
|
|
+ public void v17Write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
|
|
+ {
|
|
|
|
+ writeString( cursor, buf );
|
|
|
|
+ }
|
|
|
|
+ // Travertine end
|
|
|
|
+
|
|
|
|
@Override
|
|
|
|
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
|
|
{
|
|
|
|
diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/Team.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/Team.java
|
2020-06-28 14:49:51 +02:00
|
|
|
index a5555f6a..415a4bcd 100644
|
2017-01-05 02:04:39 +01:00
|
|
|
--- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/Team.java
|
|
|
|
+++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/Team.java
|
2019-04-23 10:34:01 +02:00
|
|
|
@@ -1,5 +1,6 @@
|
2018-07-25 20:14:35 +02:00
|
|
|
package net.md_5.bungee.protocol.packet;
|
|
|
|
|
2017-01-05 02:04:39 +01:00
|
|
|
+import io.github.waterfallmc.travertine.protocol.MultiVersionPacketV17;
|
|
|
|
import io.netty.buffer.ByteBuf;
|
|
|
|
import lombok.AllArgsConstructor;
|
|
|
|
import lombok.Data;
|
2018-07-25 20:14:35 +02:00
|
|
|
@@ -13,7 +14,7 @@ import net.md_5.bungee.protocol.ProtocolConstants;
|
2017-01-05 02:04:39 +01:00
|
|
|
@NoArgsConstructor
|
|
|
|
@AllArgsConstructor
|
|
|
|
@EqualsAndHashCode(callSuper = false)
|
|
|
|
-public class Team extends DefinedPacket
|
|
|
|
+public class Team extends MultiVersionPacketV17
|
|
|
|
{
|
|
|
|
|
|
|
|
private String name;
|
2020-01-06 20:57:49 +01:00
|
|
|
@@ -41,6 +42,31 @@ public class Team extends DefinedPacket
|
2017-01-05 02:04:39 +01:00
|
|
|
this.mode = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Travertine start
|
|
|
|
+ @Override
|
|
|
|
+ public void v17Read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
|
|
+ {
|
|
|
|
+ name = readString( buf );
|
|
|
|
+ mode = buf.readByte();
|
|
|
|
+ if ( mode == 0 || mode == 2 )
|
|
|
|
+ {
|
|
|
|
+ displayName = readString( buf );
|
|
|
|
+ prefix = readString( buf );
|
|
|
|
+ suffix = readString( buf );
|
|
|
|
+ friendlyFire = buf.readByte();
|
|
|
|
+ }
|
|
|
|
+ if ( mode == 0 || mode == 3 || mode == 4 )
|
|
|
|
+ {
|
|
|
|
+ int len = buf.readShort();
|
|
|
|
+ players = new String[ len ];
|
|
|
|
+ for ( int i = 0; i < len; i++ )
|
|
|
|
+ {
|
|
|
|
+ players[i] = readString( buf );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // Travertine end
|
|
|
|
+
|
|
|
|
@Override
|
|
|
|
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
|
|
{
|
2020-01-06 20:57:49 +01:00
|
|
|
@@ -78,6 +104,30 @@ public class Team extends DefinedPacket
|
2017-01-05 02:04:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Travertine start
|
|
|
|
+ @Override
|
|
|
|
+ public void v17Write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
|
|
+ {
|
|
|
|
+ writeString( name, buf );
|
|
|
|
+ buf.writeByte( mode );
|
|
|
|
+ if ( mode == 0 || mode == 2 )
|
|
|
|
+ {
|
|
|
|
+ writeString( displayName, buf );
|
|
|
|
+ writeString( prefix, buf );
|
|
|
|
+ writeString( suffix, buf );
|
|
|
|
+ buf.writeByte( friendlyFire );
|
|
|
|
+ }
|
|
|
|
+ if ( mode == 0 || mode == 3 || mode == 4 )
|
|
|
|
+ {
|
|
|
|
+ buf.writeShort( players.length );
|
|
|
|
+ for ( String player : players )
|
|
|
|
+ {
|
|
|
|
+ writeString( player, buf );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // Travertine end
|
|
|
|
+
|
|
|
|
@Override
|
|
|
|
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
|
|
{
|
|
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
|
2020-07-01 11:44:36 +02:00
|
|
|
index f7f1e7cc..a17ed68e 100644
|
2017-01-05 02:04:39 +01:00
|
|
|
--- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
|
|
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
|
2020-07-01 11:44:36 +02:00
|
|
|
@@ -170,6 +170,14 @@ public class BungeeCord extends ProxyServer
|
2018-03-06 22:12:24 +01:00
|
|
|
.registerTypeAdapter( SelectorComponent.class, new SelectorComponentSerializer() )
|
2017-01-05 02:04:39 +01:00
|
|
|
.registerTypeAdapter( ServerPing.PlayerInfo.class, new PlayerInfoSerializer() )
|
|
|
|
.registerTypeAdapter( Favicon.class, Favicon.getFaviconTypeAdapter() ).create();
|
|
|
|
+ // Travertine start
|
|
|
|
+ public final Gson gsonLegacy = new GsonBuilder()
|
|
|
|
+ .registerTypeAdapter( BaseComponent.class, new ComponentSerializer() )
|
|
|
|
+ .registerTypeAdapter( TextComponent.class, new TextComponentSerializer() )
|
|
|
|
+ .registerTypeAdapter( TranslatableComponent.class, new TranslatableComponentSerializer() )
|
|
|
|
+ .registerTypeAdapter( ServerPing.PlayerInfo.class, new PlayerInfoSerializer( ProtocolConstants.MINECRAFT_1_7_2 ) )
|
|
|
|
+ .registerTypeAdapter( Favicon.class, Favicon.getFaviconTypeAdapter() ).create();
|
|
|
|
+ // Travertine end
|
|
|
|
@Getter
|
|
|
|
private ConnectionThrottle connectionThrottle;
|
|
|
|
private final ModuleManager moduleManager = new ModuleManager();
|
|
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeTitle.java b/proxy/src/main/java/net/md_5/bungee/BungeeTitle.java
|
2020-06-28 14:49:51 +02:00
|
|
|
index 494213db..1d89acf5 100644
|
2017-01-05 02:04:39 +01:00
|
|
|
--- a/proxy/src/main/java/net/md_5/bungee/BungeeTitle.java
|
|
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/BungeeTitle.java
|
|
|
|
@@ -5,6 +5,7 @@ import net.md_5.bungee.api.chat.BaseComponent;
|
|
|
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|
|
|
import net.md_5.bungee.chat.ComponentSerializer;
|
|
|
|
import net.md_5.bungee.protocol.DefinedPacket;
|
|
|
|
+import net.md_5.bungee.protocol.ProtocolConstants;
|
|
|
|
import net.md_5.bungee.protocol.packet.Title.Action;
|
|
|
|
|
|
|
|
public class BungeeTitle implements Title
|
|
|
|
@@ -151,6 +152,7 @@ public class BungeeTitle implements Title
|
|
|
|
@Override
|
|
|
|
public Title send(ProxiedPlayer player)
|
|
|
|
{
|
|
|
|
+ if ( ProtocolConstants.isBeforeOrEq( player.getPendingConnection().getVersion(), ProtocolConstants.MINECRAFT_1_7_6 ) ) return this;
|
|
|
|
sendPacket( player, clear );
|
|
|
|
sendPacket( player, reset );
|
|
|
|
sendPacket( player, times );
|
|
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/PlayerInfoSerializer.java b/proxy/src/main/java/net/md_5/bungee/PlayerInfoSerializer.java
|
2020-06-28 14:49:51 +02:00
|
|
|
index 491cf1a1..299a216c 100644
|
2017-01-05 02:04:39 +01:00
|
|
|
--- a/proxy/src/main/java/net/md_5/bungee/PlayerInfoSerializer.java
|
|
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/PlayerInfoSerializer.java
|
|
|
|
@@ -10,17 +10,32 @@ import com.google.gson.JsonSerializer;
|
|
|
|
import java.lang.reflect.Type;
|
|
|
|
import java.util.UUID;
|
|
|
|
import net.md_5.bungee.api.ServerPing;
|
|
|
|
+import net.md_5.bungee.protocol.ProtocolConstants;
|
|
|
|
|
|
|
|
public class PlayerInfoSerializer implements JsonSerializer<ServerPing.PlayerInfo>, JsonDeserializer<ServerPing.PlayerInfo>
|
|
|
|
{
|
|
|
|
|
|
|
|
+ // Travertine start
|
|
|
|
+ private final int protocol;
|
|
|
|
+
|
|
|
|
+ public PlayerInfoSerializer()
|
|
|
|
+ {
|
|
|
|
+ this.protocol = ProtocolConstants.MINECRAFT_1_7_6;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public PlayerInfoSerializer(int protocol)
|
|
|
|
+ {
|
|
|
|
+ this.protocol = protocol;
|
|
|
|
+ }
|
|
|
|
+ // Travertine end
|
|
|
|
+
|
|
|
|
@Override
|
|
|
|
public ServerPing.PlayerInfo deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
|
|
|
|
{
|
|
|
|
JsonObject js = json.getAsJsonObject();
|
|
|
|
ServerPing.PlayerInfo info = new ServerPing.PlayerInfo( js.get( "name" ).getAsString(), (UUID) null );
|
|
|
|
String id = js.get( "id" ).getAsString();
|
|
|
|
- if ( !id.contains( "-" ) )
|
|
|
|
+ if ( ProtocolConstants.isBeforeOrEq( protocol, ProtocolConstants.MINECRAFT_1_7_2 ) || !id.contains( "-" ) ) // Travertine
|
|
|
|
{
|
|
|
|
info.setId( id );
|
|
|
|
} else
|
|
|
|
@@ -35,7 +50,15 @@ public class PlayerInfoSerializer implements JsonSerializer<ServerPing.PlayerInf
|
|
|
|
{
|
|
|
|
JsonObject out = new JsonObject();
|
|
|
|
out.addProperty( "name", src.getName() );
|
|
|
|
- out.addProperty( "id", src.getUniqueId().toString() );
|
|
|
|
+ // Travertine start
|
|
|
|
+ if ( ProtocolConstants.isBeforeOrEq( protocol, ProtocolConstants.MINECRAFT_1_7_2 ) )
|
|
|
|
+ {
|
|
|
|
+ out.addProperty( "id", src.getId() );
|
|
|
|
+ } else
|
|
|
|
+ {
|
|
|
|
+ out.addProperty( "id", src.getUniqueId().toString() );
|
|
|
|
+ }
|
|
|
|
+ // Travertine end
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java
|
2020-08-12 16:05:37 +02:00
|
|
|
index b486f2aa..c12085e1 100644
|
2017-01-05 02:04:39 +01:00
|
|
|
--- a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java
|
|
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java
|
2020-01-21 18:41:57 +01:00
|
|
|
@@ -6,6 +6,7 @@ import io.netty.buffer.ByteBufAllocator;
|
|
|
|
import java.net.InetSocketAddress;
|
2018-11-11 13:29:39 +01:00
|
|
|
import java.util.Locale;
|
|
|
|
import java.util.Arrays; // Waterfall
|
2018-11-11 15:28:05 +01:00
|
|
|
+import java.nio.charset.StandardCharsets; // Travertine
|
2017-01-05 02:04:39 +01:00
|
|
|
import java.util.Queue;
|
|
|
|
import java.util.Set;
|
2018-11-11 13:29:39 +01:00
|
|
|
import java.util.UUID;
|
2020-06-28 14:49:51 +02:00
|
|
|
@@ -268,10 +269,20 @@ public class ServerConnector extends PacketHandler
|
|
|
|
user.getServer().disconnect( "Quitting" );
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
- ByteBuf brand = ByteBufAllocator.DEFAULT.heapBuffer();
|
|
|
|
- DefinedPacket.writeString( bungee.getName() + " (" + bungee.getVersion() + ")", brand );
|
|
|
|
- user.unsafe().sendPacket( new PluginMessage( user.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_13 ? "minecraft:brand" : "MC|Brand", brand, handshakeHandler.isServerForge() ) );
|
|
|
|
- brand.release();
|
|
|
|
+ // Travertine start
|
|
|
|
+ String brandString = bungee.getName() + " (" + bungee.getVersion() + ")";
|
2017-01-05 02:04:39 +01:00
|
|
|
+
|
2020-06-28 14:49:51 +02:00
|
|
|
+ if ( ProtocolConstants.isBeforeOrEq( user.getPendingConnection().getVersion(), ProtocolConstants.MINECRAFT_1_7_6 ) )
|
|
|
|
+ {
|
|
|
|
+ user.unsafe().sendPacket( new PluginMessage( "MC|Brand", brandString.getBytes( StandardCharsets.UTF_8 ), handshakeHandler.isServerForge() ) );
|
|
|
|
+ } else
|
|
|
|
+ {
|
|
|
|
+ ByteBuf brand = ByteBufAllocator.DEFAULT.heapBuffer();
|
|
|
|
+ DefinedPacket.writeString(brandString, brand);
|
|
|
|
+ user.unsafe().sendPacket( new PluginMessage( user.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_13 ? "minecraft:brand" : "MC|Brand", brand, handshakeHandler.isServerForge() ) );
|
|
|
|
+ brand.release();
|
|
|
|
+ }
|
|
|
|
+ // Travertine end
|
|
|
|
}
|
2017-01-05 02:04:39 +01:00
|
|
|
|
|
|
|
user.setDimension( login.getDimension() );
|
2020-06-28 14:49:51 +02:00
|
|
|
@@ -284,7 +295,7 @@ public class ServerConnector extends PacketHandler
|
2019-02-04 19:06:59 +01:00
|
|
|
if ( !user.isDisableEntityMetadataRewrite() ) { // Waterfall
|
2018-07-24 02:48:55 +02:00
|
|
|
for ( Objective objective : serverScoreboard.getObjectives() )
|
|
|
|
{
|
|
|
|
- user.unsafe().sendPacket( new ScoreboardObjective( objective.getName(), objective.getValue(), ScoreboardObjective.HealthDisplay.fromString( objective.getType() ), (byte) 1 ) );
|
|
|
|
+ user.unsafe().sendPacket( new ScoreboardObjective( objective.getName(), objective.getValue(), objective.getType() == null ? null : ScoreboardObjective.HealthDisplay.fromString(objective.getType()), (byte) 1 ) ); // Travertine - 1.7
|
|
|
|
}
|
|
|
|
for ( Score score : serverScoreboard.getScores() )
|
|
|
|
{
|
2020-06-28 14:49:51 +02:00
|
|
|
@@ -454,6 +465,14 @@ public class ServerConnector extends PacketHandler
|
2018-06-09 12:52:32 +02:00
|
|
|
{
|
|
|
|
this.handshakeHandler.handle( pluginMessage );
|
2017-01-05 02:04:39 +01:00
|
|
|
|
2018-06-09 12:52:32 +02:00
|
|
|
+ // Travertine start
|
|
|
|
+ if ( user.getForgeClientHandler().checkUserOutdated() )
|
|
|
|
+ {
|
|
|
|
+ ch.close();
|
|
|
|
+ user.getPendingConnects().remove(target);
|
|
|
|
+ }
|
|
|
|
+ // Travertine end
|
2017-01-05 02:04:39 +01:00
|
|
|
+
|
2018-06-09 12:52:32 +02:00
|
|
|
// We send the message as part of the handler, so don't send it here.
|
|
|
|
throw CancelSendSignal.INSTANCE;
|
|
|
|
}
|
2017-01-05 02:04:39 +01:00
|
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/UserConnection.java b/proxy/src/main/java/net/md_5/bungee/UserConnection.java
|
2020-11-02 21:01:49 +01:00
|
|
|
index 7ec119ea..986a9d05 100644
|
2017-01-05 02:04:39 +01:00
|
|
|
--- a/proxy/src/main/java/net/md_5/bungee/UserConnection.java
|
|
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/UserConnection.java
|
2020-01-24 23:44:24 +01:00
|
|
|
@@ -193,6 +193,7 @@ public final class UserConnection implements ProxiedPlayer
|
2017-01-05 02:04:39 +01:00
|
|
|
public void setDisplayName(String name)
|
|
|
|
{
|
|
|
|
Preconditions.checkNotNull( name, "displayName" );
|
|
|
|
+ Preconditions.checkArgument( name.length() <= 16, "Display name cannot be longer than 16 characters" ); // Travertine
|
|
|
|
displayName = name;
|
|
|
|
}
|
|
|
|
|
2020-11-02 21:01:49 +01:00
|
|
|
@@ -497,7 +498,8 @@ public final class UserConnection implements ProxiedPlayer
|
2020-01-06 20:57:49 +01:00
|
|
|
// transform score components
|
2020-07-01 11:44:36 +02:00
|
|
|
message = ChatComponentTransformer.getInstance().transform( this, true, message );
|
2018-03-06 22:12:24 +01:00
|
|
|
|
2017-06-13 05:14:59 +02:00
|
|
|
- if ( position == ChatMessageType.ACTION_BAR )
|
2020-01-06 20:57:49 +01:00
|
|
|
+ // Action bar doesn't display the new JSON formattings, legacy works - send it using this for now
|
2017-06-13 05:14:59 +02:00
|
|
|
+ if ( position == ChatMessageType.ACTION_BAR && getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_8 ) // Travertine
|
2017-01-05 02:04:39 +01:00
|
|
|
{
|
2020-01-06 20:57:49 +01:00
|
|
|
// Versions older than 1.11 cannot send the Action bar with the new JSON formattings
|
|
|
|
// Fix by converting to a legacy message, see https://bugs.mojang.com/browse/MC-119145
|
2020-11-02 21:01:49 +01:00
|
|
|
@@ -693,6 +695,7 @@ public final class UserConnection implements ProxiedPlayer
|
2017-01-05 02:04:39 +01:00
|
|
|
@Override
|
|
|
|
public void setTabHeader(BaseComponent header, BaseComponent footer)
|
|
|
|
{
|
|
|
|
+ if ( ProtocolConstants.isBeforeOrEq( pendingConnection.getVersion(), ProtocolConstants.MINECRAFT_1_7_6 ) ) return; // Travertine
|
2020-07-01 11:44:36 +02:00
|
|
|
header = ChatComponentTransformer.getInstance().transform( this, true, header )[0];
|
|
|
|
footer = ChatComponentTransformer.getInstance().transform( this, true, footer )[0];
|
2018-03-06 22:12:24 +01:00
|
|
|
|
2020-11-02 21:01:49 +01:00
|
|
|
@@ -705,6 +708,7 @@ public final class UserConnection implements ProxiedPlayer
|
2017-01-05 02:04:39 +01:00
|
|
|
@Override
|
|
|
|
public void setTabHeader(BaseComponent[] header, BaseComponent[] footer)
|
|
|
|
{
|
|
|
|
+ if ( ProtocolConstants.isBeforeOrEq( pendingConnection.getVersion(), ProtocolConstants.MINECRAFT_1_7_6 ) ) return; // Travertine
|
2020-07-01 11:44:36 +02:00
|
|
|
header = ChatComponentTransformer.getInstance().transform( this, true, header );
|
|
|
|
footer = ChatComponentTransformer.getInstance().transform( this, true, footer );
|
2018-03-06 22:12:24 +01:00
|
|
|
|
2020-11-02 21:01:49 +01:00
|
|
|
@@ -734,6 +738,7 @@ public final class UserConnection implements ProxiedPlayer
|
2017-01-05 02:04:39 +01:00
|
|
|
|
|
|
|
public void setCompressionThreshold(int compressionThreshold)
|
|
|
|
{
|
|
|
|
+ if ( ProtocolConstants.isBeforeOrEq( pendingConnection.getVersion(), ProtocolConstants.MINECRAFT_1_7_6 ) ) return; // Travertine
|
2017-01-17 16:10:10 +01:00
|
|
|
if ( !ch.isClosing() && this.compressionThreshold == -1 && compressionThreshold >= 0 )
|
2017-01-05 02:04:39 +01:00
|
|
|
{
|
|
|
|
this.compressionThreshold = compressionThreshold;
|
|
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java
|
2020-09-15 19:15:17 +02:00
|
|
|
index 9e180c30..d54d8539 100644
|
2017-01-05 02:04:39 +01:00
|
|
|
--- a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java
|
|
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java
|
2020-06-20 19:31:12 +02:00
|
|
|
@@ -20,6 +20,7 @@ import io.netty.buffer.Unpooled;
|
|
|
|
import io.netty.channel.unix.DomainSocketAddress;
|
|
|
|
import java.io.DataInput;
|
|
|
|
import java.net.InetSocketAddress;
|
|
|
|
+import java.nio.charset.StandardCharsets; // Waterfall
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.HashMap; // Waterfall
|
|
|
|
import java.util.List;
|
2020-09-15 19:15:17 +02:00
|
|
|
@@ -179,7 +180,7 @@ public class DownstreamBridge extends PacketHandler
|
2018-07-20 07:17:40 +02:00
|
|
|
switch ( objective.getAction() )
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
- serverScoreboard.addObjective( new Objective( objective.getName(), objective.getValue(), objective.getType().toString() ) );
|
|
|
|
+ serverScoreboard.addObjective( new Objective( objective.getName(), objective.getValue(), objective.getType() != null ? objective.getType().toString() : null) ); // Travertine - 1.7 protocol support
|
2018-07-20 15:16:11 +02:00
|
|
|
break;
|
2018-07-20 07:17:40 +02:00
|
|
|
case 1:
|
|
|
|
serverScoreboard.removeObjective( objective.getName() );
|
2020-09-15 19:15:17 +02:00
|
|
|
@@ -189,7 +190,7 @@ public class DownstreamBridge extends PacketHandler
|
2018-07-20 07:17:40 +02:00
|
|
|
if ( oldObjective != null )
|
|
|
|
{
|
|
|
|
oldObjective.setValue( objective.getValue() );
|
|
|
|
- oldObjective.setType( objective.getType().toString() );
|
|
|
|
+ oldObjective.setType( objective.getType() != null ? objective.getType().toString() : null ); // Travertine - 1.7 protocol support
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2020-09-15 19:15:17 +02:00
|
|
|
@@ -286,16 +287,28 @@ public class DownstreamBridge extends PacketHandler
|
2017-01-05 02:04:39 +01:00
|
|
|
|
2018-07-20 04:23:11 +02:00
|
|
|
if ( pluginMessage.getTag().equals( con.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_13 ? "minecraft:brand" : "MC|Brand" ) )
|
2017-01-05 02:04:39 +01:00
|
|
|
{
|
|
|
|
- ByteBuf brand = Unpooled.wrappedBuffer( pluginMessage.getData() );
|
|
|
|
- String serverBrand = DefinedPacket.readString( brand );
|
|
|
|
- brand.release();
|
|
|
|
-
|
|
|
|
- Preconditions.checkState( !serverBrand.contains( bungee.getName() ), "Cannot connect proxy to itself!" );
|
|
|
|
-
|
|
|
|
- brand = ByteBufAllocator.DEFAULT.heapBuffer();
|
2020-06-20 19:31:12 +02:00
|
|
|
- DefinedPacket.writeString( bungee.getName() + " <- " + serverBrand, brand ); // Waterfall
|
2017-01-05 02:04:39 +01:00
|
|
|
- pluginMessage.setData( brand );
|
|
|
|
- brand.release();
|
|
|
|
+ // Travertine start
|
|
|
|
+ if ( ProtocolConstants.isAfterOrEq( con.getPendingConnection().getVersion(), ProtocolConstants.MINECRAFT_1_8 ) )
|
|
|
|
+ {
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ ByteBuf brand = Unpooled.wrappedBuffer(pluginMessage.getData());
|
|
|
|
+ String serverBrand = DefinedPacket.readString(brand);
|
|
|
|
+ brand.release();
|
|
|
|
+ brand = ByteBufAllocator.DEFAULT.heapBuffer();
|
2020-06-20 19:31:12 +02:00
|
|
|
+ DefinedPacket.writeString(bungee.getName() + " <- " + serverBrand, brand ); // Waterfall
|
2017-01-05 02:04:39 +01:00
|
|
|
+ pluginMessage.setData(brand);
|
|
|
|
+ brand.release();
|
|
|
|
+ } catch (Exception ProtocolHacksSuck)
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ } else
|
|
|
|
+ {
|
2020-06-20 19:31:12 +02:00
|
|
|
+ String serverBrand = new String( pluginMessage.getData(), StandardCharsets.UTF_8);
|
|
|
|
+ pluginMessage.setData( ( bungee.getName() + " <- " + serverBrand ).getBytes(StandardCharsets.UTF_8) ); // Travertine
|
2017-01-05 02:04:39 +01:00
|
|
|
+ }
|
|
|
|
+ // Travertine end
|
|
|
|
// changes in the packet are ignored so we need to send it manually
|
|
|
|
con.unsafe().sendPacket( pluginMessage );
|
|
|
|
throw CancelSendSignal.INSTANCE;
|
|
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
|
2020-12-02 20:13:52 +01:00
|
|
|
index b7ecd828..3b82219d 100644
|
2017-01-05 02:04:39 +01:00
|
|
|
--- a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
|
|
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
|
2020-12-02 20:13:52 +01:00
|
|
|
@@ -3,6 +3,8 @@ package net.md_5.bungee.connection;
|
|
|
|
import com.google.common.base.Charsets;
|
|
|
|
import com.google.common.base.Preconditions;
|
|
|
|
import com.google.gson.Gson;
|
2017-01-05 02:04:39 +01:00
|
|
|
+import com.google.gson.JsonElement;
|
|
|
|
+import com.google.gson.JsonObject;
|
2020-12-02 20:13:52 +01:00
|
|
|
import java.math.BigInteger;
|
|
|
|
import java.net.InetSocketAddress;
|
|
|
|
import java.net.SocketAddress;
|
|
|
|
@@ -257,12 +259,28 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
2017-01-05 02:04:39 +01:00
|
|
|
@Override
|
|
|
|
public void done(ProxyPingEvent pingResult, Throwable error)
|
|
|
|
{
|
|
|
|
- Gson gson = BungeeCord.getInstance().gson;
|
|
|
|
- unsafe.sendPacket( new StatusResponse( gson.toJson( pingResult.getResponse() ) ) );
|
|
|
|
+ Gson gson = handshake.getProtocolVersion() == ProtocolConstants.MINECRAFT_1_7_2 ? BungeeCord.getInstance().gsonLegacy : BungeeCord.getInstance().gson; // Travertine
|
2018-12-27 00:46:48 +01:00
|
|
|
if ( bungee.getConnectionThrottle() != null )
|
|
|
|
{
|
2020-01-21 18:41:57 +01:00
|
|
|
bungee.getConnectionThrottle().unthrottle( getSocketAddress() );
|
2018-12-27 00:46:48 +01:00
|
|
|
}
|
2017-01-05 02:04:39 +01:00
|
|
|
+ // Travertine start
|
|
|
|
+ if ( ProtocolConstants.isBeforeOrEq( handshake.getProtocolVersion() , ProtocolConstants.MINECRAFT_1_8 ) )
|
|
|
|
+ {
|
|
|
|
+ // Minecraft < 1.9 doesn't send string server descriptions as chat components. Older 1.7
|
|
|
|
+ // clients even crash when encountering a chat component instead of a string. To be on the
|
|
|
|
+ // safe side, always send legacy descriptions for < 1.9 clients.
|
|
|
|
+ JsonElement element = gson.toJsonTree(pingResult.getResponse());
|
|
|
|
+ Preconditions.checkArgument(element.isJsonObject(), "Response is not a JSON object");
|
|
|
|
+ JsonObject object = element.getAsJsonObject();
|
|
|
|
+ object.addProperty("description", pingResult.getResponse().getDescription());
|
|
|
|
+
|
|
|
|
+ unsafe.sendPacket(new StatusResponse(gson.toJson(element)));
|
|
|
|
+ } else
|
|
|
|
+ {
|
|
|
|
+ unsafe.sendPacket( new StatusResponse( gson.toJson( pingResult.getResponse() ) ) );
|
|
|
|
+ }
|
|
|
|
+ // Travertine end
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/connection/PingHandler.java b/proxy/src/main/java/net/md_5/bungee/connection/PingHandler.java
|
2020-06-28 14:49:51 +02:00
|
|
|
index 6df3f3dd..6cd71071 100644
|
2017-01-05 02:04:39 +01:00
|
|
|
--- a/proxy/src/main/java/net/md_5/bungee/connection/PingHandler.java
|
|
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/connection/PingHandler.java
|
2020-01-24 23:44:24 +01:00
|
|
|
@@ -16,6 +16,7 @@ import net.md_5.bungee.protocol.MinecraftDecoder;
|
2017-01-05 02:04:39 +01:00
|
|
|
import net.md_5.bungee.protocol.MinecraftEncoder;
|
2018-07-20 04:23:11 +02:00
|
|
|
import net.md_5.bungee.protocol.PacketWrapper;
|
2017-01-05 02:04:39 +01:00
|
|
|
import net.md_5.bungee.protocol.Protocol;
|
|
|
|
+import net.md_5.bungee.protocol.ProtocolConstants;
|
|
|
|
import net.md_5.bungee.protocol.packet.Handshake;
|
|
|
|
import net.md_5.bungee.protocol.packet.StatusRequest;
|
|
|
|
import net.md_5.bungee.protocol.packet.StatusResponse;
|
2020-01-24 23:44:24 +01:00
|
|
|
@@ -65,7 +66,7 @@ public class PingHandler extends PacketHandler
|
2017-01-05 02:04:39 +01:00
|
|
|
@SuppressFBWarnings("UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR")
|
|
|
|
public void handle(StatusResponse statusResponse) throws Exception
|
|
|
|
{
|
|
|
|
- Gson gson = BungeeCord.getInstance().gson;
|
|
|
|
+ Gson gson = protocol == ProtocolConstants.MINECRAFT_1_7_2 ? BungeeCord.getInstance().gsonLegacy : BungeeCord.getInstance().gson; // Travertine
|
2020-01-24 23:44:24 +01:00
|
|
|
ServerPing serverPing = gson.fromJson( statusResponse.getResponse(), ServerPing.class );
|
|
|
|
( (BungeeServerInfo) target ).cachePing( serverPing );
|
|
|
|
callback.done( serverPing, null );
|
2017-01-05 02:04:39 +01:00
|
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java b/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java
|
2020-08-12 16:05:37 +02:00
|
|
|
index 4d7b1b23..ad3bdee5 100644
|
2017-01-05 02:04:39 +01:00
|
|
|
--- a/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java
|
|
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java
|
2020-08-12 16:05:37 +02:00
|
|
|
@@ -85,7 +85,12 @@ public class UpstreamBridge extends PacketHandler
|
2017-01-05 02:04:39 +01:00
|
|
|
} );
|
|
|
|
for ( ProxiedPlayer player : con.getServer().getInfo().getPlayers() )
|
|
|
|
{
|
|
|
|
- player.unsafe().sendPacket( packet );
|
|
|
|
+ // Travertine start
|
|
|
|
+ if ( ProtocolConstants.isAfterOrEq( player.getPendingConnection().getVersion(), ProtocolConstants.MINECRAFT_1_8 ) )
|
|
|
|
+ {
|
|
|
|
+ player.unsafe().sendPacket( packet );
|
|
|
|
+ }
|
|
|
|
+ // Travertine end
|
|
|
|
}
|
|
|
|
con.getServer().disconnect( "Quitting" );
|
2017-01-17 16:10:10 +01:00
|
|
|
}
|
2017-01-05 02:04:39 +01:00
|
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java
|
2020-11-23 05:48:18 +01:00
|
|
|
index db93d883..a3a12e19 100644
|
2017-01-05 02:04:39 +01:00
|
|
|
--- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java
|
|
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java
|
2020-05-10 03:54:00 +02:00
|
|
|
@@ -35,6 +35,10 @@ public abstract class EntityMap
|
2019-12-03 08:20:03 +01:00
|
|
|
// Waterfall end
|
2017-01-05 02:04:39 +01:00
|
|
|
switch ( version )
|
|
|
|
{
|
|
|
|
+ case ProtocolConstants.MINECRAFT_1_7_2:
|
|
|
|
+ return EntityMap_1_7_2.INSTANCE;
|
|
|
|
+ case ProtocolConstants.MINECRAFT_1_7_6:
|
|
|
|
+ return EntityMap_1_7_6.INSTANCE;
|
|
|
|
case ProtocolConstants.MINECRAFT_1_8:
|
|
|
|
return EntityMap_1_8.INSTANCE;
|
|
|
|
case ProtocolConstants.MINECRAFT_1_9:
|
|
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_7_2.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_7_2.java
|
|
|
|
new file mode 100644
|
2020-06-28 14:49:51 +02:00
|
|
|
index 00000000..65c1a9ec
|
2017-01-05 02:04:39 +01:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_7_2.java
|
|
|
|
@@ -0,0 +1,102 @@
|
|
|
|
+// Travertine start
|
|
|
|
+package net.md_5.bungee.entitymap;
|
|
|
|
+
|
|
|
|
+import io.netty.buffer.ByteBuf;
|
|
|
|
+import net.md_5.bungee.protocol.DefinedPacket;
|
|
|
|
+import net.md_5.bungee.protocol.ProtocolConstants;
|
|
|
|
+
|
|
|
|
+class EntityMap_1_7_2 extends EntityMap
|
|
|
|
+{
|
|
|
|
+
|
|
|
|
+ static final EntityMap INSTANCE = new EntityMap_1_7_2();
|
|
|
|
+
|
|
|
|
+ EntityMap_1_7_2()
|
|
|
|
+ {
|
|
|
|
+ addRewrite( 0x04, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Equipment
|
|
|
|
+ addRewrite( 0x0A, ProtocolConstants.Direction.TO_CLIENT, false ); // Use bed
|
|
|
|
+ addRewrite( 0x0B, ProtocolConstants.Direction.TO_CLIENT, true ); // Animation
|
|
|
|
+ addRewrite( 0x0C, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Player
|
|
|
|
+ addRewrite( 0x0D, ProtocolConstants.Direction.TO_CLIENT, false ); // Collect Item
|
|
|
|
+ addRewrite( 0x0E, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Object
|
|
|
|
+ addRewrite( 0x0F, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Mob
|
|
|
|
+ addRewrite( 0x10, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Painting
|
|
|
|
+ addRewrite( 0x11, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Experience Orb
|
|
|
|
+ addRewrite( 0x12, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Velocity
|
|
|
|
+ addRewrite( 0x14, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity
|
|
|
|
+ addRewrite( 0x15, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Relative Move
|
|
|
|
+ addRewrite( 0x16, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Look
|
|
|
|
+ addRewrite( 0x17, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Look and Relative Move
|
|
|
|
+ addRewrite( 0x18, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Teleport
|
|
|
|
+ addRewrite( 0x19, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Head Look
|
|
|
|
+ addRewrite( 0x1A, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Status
|
|
|
|
+ addRewrite( 0x1B, ProtocolConstants.Direction.TO_CLIENT, false ); // Attach Entity
|
|
|
|
+ addRewrite( 0x1C, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Metadata
|
|
|
|
+ addRewrite( 0x1D, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Effect
|
|
|
|
+ addRewrite( 0x1E, ProtocolConstants.Direction.TO_CLIENT, false ); // Remove Entity Effect
|
|
|
|
+ addRewrite( 0x20, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Properties
|
|
|
|
+ addRewrite( 0x25, ProtocolConstants.Direction.TO_CLIENT, true ); // Block Break Animation
|
|
|
|
+ addRewrite( 0x2C, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Global Entity
|
|
|
|
+
|
|
|
|
+ addRewrite( 0x02, ProtocolConstants.Direction.TO_SERVER, false ); // Use Entity
|
|
|
|
+ addRewrite( 0x0A, ProtocolConstants.Direction.TO_SERVER, false ); // Animation
|
|
|
|
+ addRewrite( 0x0B, ProtocolConstants.Direction.TO_SERVER, false ); // Entity Action
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void rewriteClientbound(ByteBuf packet, int oldId, int newId)
|
|
|
|
+ {
|
|
|
|
+ super.rewriteClientbound( packet, oldId, newId );
|
|
|
|
+
|
|
|
|
+ //Special cases
|
|
|
|
+ int readerIndex = packet.readerIndex();
|
|
|
|
+ int packetId = DefinedPacket.readVarInt( packet );
|
|
|
|
+ int packetIdLength = packet.readerIndex() - readerIndex;
|
|
|
|
+ if ( packetId == 0x0D /* Collect Item */ || packetId == 0x1B /* Attach Entity */ )
|
|
|
|
+ {
|
|
|
|
+ rewriteInt( packet, oldId, newId, readerIndex + packetIdLength + 4 );
|
|
|
|
+ } else if ( packetId == 0x13 /* Destroy Entities */ )
|
|
|
|
+ {
|
|
|
|
+ int count = packet.getByte( packetIdLength );
|
|
|
|
+ for ( int i = 0; i < count; i++ )
|
|
|
|
+ {
|
|
|
|
+ rewriteInt( packet, oldId, newId, packetIdLength + 1 + i * 4 );
|
|
|
|
+ }
|
|
|
|
+ } else if ( packetId == 0x0E /* Spawn Object */ )
|
|
|
|
+ {
|
|
|
|
+ DefinedPacket.readVarInt( packet );
|
|
|
|
+ int type = packet.readUnsignedByte();
|
|
|
|
+
|
|
|
|
+ if ( type == 60 || type == 90 )
|
|
|
|
+ {
|
|
|
|
+ packet.skipBytes( 14 );
|
|
|
|
+ int position = packet.readerIndex();
|
|
|
|
+ int readId = packet.readInt();
|
|
|
|
+ int changedId = -1;
|
|
|
|
+ if ( readId == oldId )
|
|
|
|
+ {
|
|
|
|
+ packet.setInt( position, newId );
|
|
|
|
+ changedId = newId;
|
|
|
|
+ } else if ( readId == newId )
|
|
|
|
+ {
|
|
|
|
+ packet.setInt( position, oldId );
|
|
|
|
+ changedId = oldId;
|
|
|
|
+ }
|
|
|
|
+ if ( changedId != -1 )
|
|
|
|
+ {
|
|
|
|
+ if ( changedId == 0 && readId != 0 )
|
|
|
|
+ { // Trim off the extra data
|
|
|
|
+ packet.readerIndex( readerIndex );
|
|
|
|
+ packet.writerIndex( packet.readableBytes() - 6 );
|
|
|
|
+ } else if ( changedId != 0 && readId == 0 )
|
|
|
|
+ { // Add on the extra data
|
|
|
|
+ packet.readerIndex( readerIndex );
|
|
|
|
+ packet.capacity( packet.readableBytes() + 6 );
|
|
|
|
+ packet.writerIndex( packet.readableBytes() + 6 );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ packet.readerIndex( readerIndex );
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+// Travertine end
|
|
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_7_6.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_7_6.java
|
|
|
|
new file mode 100644
|
2020-06-28 14:49:51 +02:00
|
|
|
index 00000000..6755fe84
|
2017-01-05 02:04:39 +01:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_7_6.java
|
|
|
|
@@ -0,0 +1,62 @@
|
|
|
|
+// Travertine start
|
|
|
|
+package net.md_5.bungee.entitymap;
|
|
|
|
+
|
|
|
|
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
|
|
|
+import io.netty.buffer.ByteBuf;
|
|
|
|
+import net.md_5.bungee.BungeeCord;
|
|
|
|
+import net.md_5.bungee.UserConnection;
|
|
|
|
+import net.md_5.bungee.connection.LoginResult;
|
|
|
|
+import net.md_5.bungee.protocol.DefinedPacket;
|
|
|
|
+
|
|
|
|
+class EntityMap_1_7_6 extends EntityMap_1_7_2
|
|
|
|
+{
|
|
|
|
+
|
|
|
|
+ static final EntityMap_1_7_6 INSTANCE = new EntityMap_1_7_6();
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ @SuppressFBWarnings("DLS_DEAD_LOCAL_STORE")
|
|
|
|
+ public void rewriteClientbound(ByteBuf packet, int oldId, int newId)
|
|
|
|
+ {
|
|
|
|
+ super.rewriteClientbound( packet, oldId, newId );
|
|
|
|
+
|
|
|
|
+ int readerIndex = packet.readerIndex();
|
|
|
|
+ int packetId = DefinedPacket.readVarInt( packet );
|
|
|
|
+ int packetIdLength = packet.readerIndex() - readerIndex;
|
|
|
|
+ if ( packetId == 0x0C /* Spawn Player */ )
|
|
|
|
+ {
|
|
|
|
+ DefinedPacket.readVarInt( packet );
|
|
|
|
+ int idLength = packet.readerIndex() - readerIndex - packetIdLength;
|
|
|
|
+ String uuid = DefinedPacket.readString( packet );
|
|
|
|
+ String username = DefinedPacket.readString( packet );
|
|
|
|
+ int props = DefinedPacket.readVarInt( packet );
|
|
|
|
+ if ( props == 0 )
|
|
|
|
+ {
|
|
|
|
+ UserConnection player = (UserConnection) BungeeCord.getInstance().getPlayer( username );
|
|
|
|
+ if ( player != null )
|
|
|
|
+ {
|
|
|
|
+ LoginResult profile = player.getPendingConnection().getLoginProfile();
|
|
|
|
+ if ( profile != null && profile.getProperties() != null
|
|
|
|
+ && profile.getProperties().length >= 1 )
|
|
|
|
+ {
|
|
|
|
+ ByteBuf rest = packet.copy();
|
|
|
|
+ packet.readerIndex( readerIndex );
|
|
|
|
+ packet.writerIndex( readerIndex + packetIdLength + idLength );
|
|
|
|
+ DefinedPacket.writeString( player.getUniqueId().toString(), packet );
|
|
|
|
+ DefinedPacket.writeString( username, packet );
|
|
|
|
+ DefinedPacket.writeVarInt( profile.getProperties().length, packet );
|
|
|
|
+ for ( LoginResult.Property property : profile.getProperties() )
|
|
|
|
+ {
|
|
|
|
+ DefinedPacket.writeString( property.getName(), packet );
|
|
|
|
+ DefinedPacket.writeString( property.getValue(), packet );
|
|
|
|
+ DefinedPacket.writeString( property.getSignature(), packet );
|
|
|
|
+ }
|
|
|
|
+ packet.writeBytes( rest );
|
|
|
|
+ rest.release();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ packet.readerIndex( readerIndex );
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+// Travertine end
|
|
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/forge/ForgeClientHandler.java b/proxy/src/main/java/net/md_5/bungee/forge/ForgeClientHandler.java
|
2020-06-28 14:49:51 +02:00
|
|
|
index bea2bbff..f61de127 100644
|
2017-01-05 02:04:39 +01:00
|
|
|
--- a/proxy/src/main/java/net/md_5/bungee/forge/ForgeClientHandler.java
|
|
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/forge/ForgeClientHandler.java
|
2018-06-08 12:46:31 +02:00
|
|
|
@@ -8,6 +8,7 @@ import lombok.Getter;
|
2017-01-05 02:04:39 +01:00
|
|
|
import lombok.NonNull;
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
import lombok.Setter;
|
|
|
|
+import net.md_5.bungee.BungeeCord;
|
|
|
|
import net.md_5.bungee.UserConnection;
|
|
|
|
import net.md_5.bungee.protocol.ProtocolConstants;
|
|
|
|
import net.md_5.bungee.protocol.packet.EntityRemoveEffect;
|
2018-06-08 12:46:31 +02:00
|
|
|
@@ -23,6 +24,12 @@ public class ForgeClientHandler
|
2017-01-05 02:04:39 +01:00
|
|
|
@NonNull
|
|
|
|
private final UserConnection con;
|
|
|
|
|
|
|
|
+ // Travertine start
|
|
|
|
+ @Getter
|
|
|
|
+ @Setter(AccessLevel.PACKAGE)
|
|
|
|
+ private boolean forgeOutdated = false;
|
|
|
|
+ // Travertine end
|
|
|
|
+
|
|
|
|
/**
|
|
|
|
* The users' mod list.
|
|
|
|
*/
|
2020-01-06 20:57:49 +01:00
|
|
|
@@ -175,4 +182,22 @@ public class ForgeClientHandler
|
2017-01-05 02:04:39 +01:00
|
|
|
{
|
|
|
|
return fmlTokenInHandshake || clientModList != null;
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ // Travertine start
|
|
|
|
+ /**
|
|
|
|
+ * Checks to see if a user is using an outdated FML build, and takes
|
|
|
|
+ * appropriate action on the User side. This should only be called during a
|
|
|
|
+ * server connection, by the ServerConnector
|
|
|
|
+ *
|
|
|
|
+ * @return <code>true</code> if the user's FML build is outdated, otherwise
|
|
|
|
+ * <code>false</code>
|
|
|
|
+ */
|
|
|
|
+ public boolean checkUserOutdated() {
|
|
|
|
+ if (forgeOutdated) {
|
|
|
|
+ con.disconnect( BungeeCord.getInstance().getTranslation("connect_kick_outdated_forge") );
|
|
|
|
+ }
|
|
|
|
+ return forgeOutdated;
|
|
|
|
+ }
|
|
|
|
+ // Travertine end
|
|
|
|
+
|
|
|
|
}
|
|
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/forge/ForgeClientHandshakeState.java b/proxy/src/main/java/net/md_5/bungee/forge/ForgeClientHandshakeState.java
|
2020-06-28 14:49:51 +02:00
|
|
|
index 5e02f8c8..e3c1b9b9 100644
|
2017-01-05 02:04:39 +01:00
|
|
|
--- a/proxy/src/main/java/net/md_5/bungee/forge/ForgeClientHandshakeState.java
|
|
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/forge/ForgeClientHandshakeState.java
|
|
|
|
@@ -3,6 +3,7 @@ package net.md_5.bungee.forge;
|
|
|
|
import java.util.Map;
|
|
|
|
import net.md_5.bungee.ServerConnector;
|
|
|
|
import net.md_5.bungee.UserConnection;
|
|
|
|
+import net.md_5.bungee.protocol.ProtocolConstants;
|
|
|
|
import net.md_5.bungee.protocol.packet.PluginMessage;
|
|
|
|
|
|
|
|
/**
|
|
|
|
@@ -84,6 +85,22 @@ enum ForgeClientHandshakeState implements IForgeClientPacketHandler<ForgeClientH
|
|
|
|
// Once we've done it, no point doing it again.
|
|
|
|
Map<String, String> clientModList = ForgeUtils.readModList( message );
|
|
|
|
con.getForgeClientHandler().setClientModList( clientModList );
|
|
|
|
+ // Travertine start
|
|
|
|
+ // If the user is below 1.8, we need to check the version of FML - it's not always an OK version.
|
|
|
|
+ if ( ProtocolConstants.isBeforeOrEq( con.getPendingConnection().getVersion(), ProtocolConstants.MINECRAFT_1_7_6 ) )
|
|
|
|
+ {
|
|
|
|
+ // Get the version from the mod list.
|
|
|
|
+ int buildNumber = ForgeUtils.getFmlBuildNumber( clientModList );
|
|
|
|
+
|
|
|
|
+ // If we get 0, we're probably using a testing build, so let it though. Otherwise, check the build number.
|
|
|
|
+ if ( buildNumber < ForgeConstants.FML_MIN_BUILD_VERSION && buildNumber != 0 )
|
|
|
|
+ {
|
|
|
|
+ // Mark the user as an old Forge user. This will then cause any Forge ServerConnectors to cancel any
|
|
|
|
+ // connections to it.
|
|
|
|
+ con.getForgeClientHandler().setForgeOutdated( true );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // Travertine end
|
|
|
|
}
|
|
|
|
|
|
|
|
return WAITINGSERVERDATA;
|
|
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/tab/ServerUnique.java b/proxy/src/main/java/net/md_5/bungee/tab/ServerUnique.java
|
2020-06-28 14:49:51 +02:00
|
|
|
index daf12f74..e33861ab 100644
|
2017-01-05 02:04:39 +01:00
|
|
|
--- a/proxy/src/main/java/net/md_5/bungee/tab/ServerUnique.java
|
|
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/tab/ServerUnique.java
|
|
|
|
@@ -4,12 +4,14 @@ import java.util.Collection;
|
|
|
|
import java.util.HashSet;
|
|
|
|
import java.util.UUID;
|
|
|
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|
|
|
+import net.md_5.bungee.protocol.ProtocolConstants;
|
|
|
|
import net.md_5.bungee.protocol.packet.PlayerListItem;
|
|
|
|
|
|
|
|
public class ServerUnique extends TabList
|
|
|
|
{
|
|
|
|
|
|
|
|
private final Collection<UUID> uuids = new HashSet<>();
|
|
|
|
+ private final Collection<String> usernames = new HashSet<>(); // Travertine - Support for <=1.7.9
|
|
|
|
|
|
|
|
public ServerUnique(ProxiedPlayer player)
|
|
|
|
{
|
|
|
|
@@ -23,10 +25,26 @@ public class ServerUnique extends TabList
|
|
|
|
{
|
|
|
|
if ( playerListItem.getAction() == PlayerListItem.Action.ADD_PLAYER )
|
|
|
|
{
|
|
|
|
- uuids.add( item.getUuid() );
|
|
|
|
+ // Travertine start
|
|
|
|
+ if ( item.getUuid() != null )
|
|
|
|
+ {
|
|
|
|
+ uuids.add( item.getUuid() );
|
|
|
|
+ } else
|
|
|
|
+ {
|
|
|
|
+ usernames.add( item.getUsername() );
|
|
|
|
+ }
|
|
|
|
+ // Travertine end
|
|
|
|
} else if ( playerListItem.getAction() == PlayerListItem.Action.REMOVE_PLAYER )
|
|
|
|
{
|
|
|
|
- uuids.remove( item.getUuid() );
|
|
|
|
+ // Travertine start
|
|
|
|
+ if ( item.getUuid() != null )
|
|
|
|
+ {
|
|
|
|
+ uuids.remove( item.getUuid() );
|
|
|
|
+ } else
|
|
|
|
+ {
|
|
|
|
+ usernames.remove( item.getUsername() );
|
|
|
|
+ }
|
|
|
|
+ // Travertine end
|
|
|
|
}
|
|
|
|
}
|
|
|
|
player.unsafe().sendPacket( playerListItem );
|
|
|
|
@@ -43,16 +61,44 @@ public class ServerUnique extends TabList
|
|
|
|
{
|
|
|
|
PlayerListItem packet = new PlayerListItem();
|
|
|
|
packet.setAction( PlayerListItem.Action.REMOVE_PLAYER );
|
|
|
|
- PlayerListItem.Item[] items = new PlayerListItem.Item[ uuids.size() ];
|
|
|
|
+ PlayerListItem.Item[] items = new PlayerListItem.Item[ uuids.size() + usernames.size() ]; // Travertine
|
|
|
|
int i = 0;
|
|
|
|
for ( UUID uuid : uuids )
|
|
|
|
{
|
|
|
|
PlayerListItem.Item item = items[i++] = new PlayerListItem.Item();
|
|
|
|
item.setUuid( uuid );
|
|
|
|
}
|
|
|
|
+ // Travertine start
|
|
|
|
+ for ( String username : usernames )
|
|
|
|
+ {
|
|
|
|
+ PlayerListItem.Item item = items[i++] = new PlayerListItem.Item();
|
|
|
|
+ item.setUsername( username );
|
|
|
|
+ item.setDisplayName( username );
|
|
|
|
+ }
|
|
|
|
+ // Travertine end
|
|
|
|
packet.setItems( items );
|
|
|
|
- player.unsafe().sendPacket( packet );
|
|
|
|
+ // Travertine start
|
|
|
|
+ if ( ProtocolConstants.isAfterOrEq( player.getPendingConnection().getVersion(), ProtocolConstants.MINECRAFT_1_8 ) )
|
|
|
|
+ {
|
|
|
|
+ player.unsafe().sendPacket( packet );
|
|
|
|
+ } else
|
|
|
|
+ {
|
|
|
|
+ // Split up the packet
|
|
|
|
+ for ( PlayerListItem.Item item : packet.getItems() )
|
|
|
|
+ {
|
|
|
|
+ PlayerListItem p2 = new PlayerListItem();
|
|
|
|
+ p2.setAction( packet.getAction() );
|
|
|
|
+
|
|
|
|
+ p2.setItems( new PlayerListItem.Item[]
|
|
|
|
+ {
|
|
|
|
+ item
|
|
|
|
+ } );
|
|
|
|
+ player.unsafe().sendPacket( p2 );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // Travertine end
|
|
|
|
uuids.clear();
|
|
|
|
+ usernames.clear(); // Travertine
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2016-07-03 08:56:31 +02:00
|
|
|
--
|
2020-11-23 05:48:18 +01:00
|
|
|
2.29.2
|
2016-07-03 08:56:31 +02:00
|
|
|
|