mirror of
https://github.com/PaperMC/Waterfall.git
synced 2024-11-18 16:25:14 +01:00
2509 lines
110 KiB
Diff
2509 lines
110 KiB
Diff
From 8369e2e37828ebdb3448b61a3a484dcf25e813a7 Mon Sep 17 00:00:00 2001
|
|
From: LinsaFTW <25271111+linsaftw@users.noreply.github.com>
|
|
Date: Thu, 30 Sep 2021 19:54:33 -0300
|
|
Subject: [PATCH] 1.7.x support
|
|
|
|
|
|
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
|
|
index a310844d..d07b88b8 100644
|
|
--- a/protocol/src/main/java/net/md_5/bungee/protocol/DefinedPacket.java
|
|
+++ b/protocol/src/main/java/net/md_5/bungee/protocol/DefinedPacket.java
|
|
@@ -303,4 +303,36 @@ public abstract class DefinedPacket
|
|
return 0;
|
|
}
|
|
// Waterfall end
|
|
+
|
|
+ // FlameCord start - 1.7.x support
|
|
+ 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;
|
|
+ }
|
|
+
|
|
+ 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 );
|
|
+ }
|
|
+ // FlameCord end - 1.7.x support
|
|
}
|
|
diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java b/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java
|
|
index 7f0b71c9..04851233 100644
|
|
--- a/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java
|
|
+++ b/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java
|
|
@@ -58,7 +58,7 @@ public enum Protocol
|
|
TO_SERVER.registerPacket(
|
|
Handshake.class,
|
|
Handshake::new,
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x00 )
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x00 ) // FlameCord - 1.7.x support
|
|
);
|
|
}
|
|
},
|
|
@@ -70,7 +70,7 @@ public enum Protocol
|
|
TO_CLIENT.registerPacket(
|
|
KeepAlive.class,
|
|
KeepAlive::new,
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x00 ),
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x00 ), // FlameCord - 1.7.x support
|
|
map( ProtocolConstants.MINECRAFT_1_9, 0x1F ),
|
|
map( ProtocolConstants.MINECRAFT_1_13, 0x21 ),
|
|
map( ProtocolConstants.MINECRAFT_1_14, 0x20 ),
|
|
@@ -82,7 +82,7 @@ public enum Protocol
|
|
TO_CLIENT.registerPacket(
|
|
Login.class,
|
|
Login::new,
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x01 ),
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x01 ), // FlameCord - 1.7.x support
|
|
map( ProtocolConstants.MINECRAFT_1_9, 0x23 ),
|
|
map( ProtocolConstants.MINECRAFT_1_13, 0x25 ),
|
|
map( ProtocolConstants.MINECRAFT_1_15, 0x26 ),
|
|
@@ -93,7 +93,7 @@ public enum Protocol
|
|
TO_CLIENT.registerPacket(
|
|
Chat.class,
|
|
Chat::new,
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x02 ),
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x02 ), // FlameCord - 1.7.x support
|
|
map( ProtocolConstants.MINECRAFT_1_9, 0x0F ),
|
|
map( ProtocolConstants.MINECRAFT_1_13, 0x0E ),
|
|
map( ProtocolConstants.MINECRAFT_1_15, 0x0F ),
|
|
@@ -103,7 +103,7 @@ public enum Protocol
|
|
TO_CLIENT.registerPacket(
|
|
Respawn.class,
|
|
Respawn::new,
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x07 ),
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x07 ), // FlameCord - 1.7.x support
|
|
map( ProtocolConstants.MINECRAFT_1_9, 0x33 ),
|
|
map( ProtocolConstants.MINECRAFT_1_12, 0x34 ),
|
|
map( ProtocolConstants.MINECRAFT_1_12_1, 0x35 ),
|
|
@@ -126,20 +126,20 @@ public enum Protocol
|
|
TO_CLIENT.registerPacket(
|
|
EntityEffect.class,
|
|
EntityEffect::new,
|
|
- map(ProtocolConstants.MINECRAFT_1_8, 0x1D),
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x1D ), // FlameCord - 1.7.x support
|
|
map(ProtocolConstants.MINECRAFT_1_9, Integer.MIN_VALUE)
|
|
);
|
|
TO_CLIENT.registerPacket(
|
|
EntityRemoveEffect.class,
|
|
EntityRemoveEffect::new,
|
|
- map(ProtocolConstants.MINECRAFT_1_8, 0x1E),
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x1E ), // FlameCord - 1.7.x support
|
|
map(ProtocolConstants.MINECRAFT_1_9, Integer.MIN_VALUE)
|
|
);
|
|
// Waterfall end
|
|
TO_CLIENT.registerPacket(
|
|
PlayerListItem.class, // PlayerInfo
|
|
PlayerListItem::new,
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x38 ),
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x38 ), // FlameCord - 1.7.x support
|
|
map( ProtocolConstants.MINECRAFT_1_9, 0x2D ),
|
|
map( ProtocolConstants.MINECRAFT_1_12_1, 0x2E ),
|
|
map( ProtocolConstants.MINECRAFT_1_13, 0x30 ),
|
|
@@ -152,7 +152,7 @@ public enum Protocol
|
|
TO_CLIENT.registerPacket(
|
|
TabCompleteResponse.class,
|
|
TabCompleteResponse::new,
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x3A ),
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x3A ), // FlameCord - 1.7.x support
|
|
map( ProtocolConstants.MINECRAFT_1_9, 0x0E ),
|
|
map( ProtocolConstants.MINECRAFT_1_13, 0x10 ),
|
|
map( ProtocolConstants.MINECRAFT_1_15, 0x11 ),
|
|
@@ -163,7 +163,7 @@ public enum Protocol
|
|
TO_CLIENT.registerPacket(
|
|
ScoreboardObjective.class,
|
|
ScoreboardObjective::new,
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x3B ),
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x3B ), // FlameCord - 1.7.x support
|
|
map( ProtocolConstants.MINECRAFT_1_9, 0x3F ),
|
|
map( ProtocolConstants.MINECRAFT_1_12, 0x41 ),
|
|
map( ProtocolConstants.MINECRAFT_1_12_1, 0x42 ),
|
|
@@ -175,7 +175,7 @@ public enum Protocol
|
|
TO_CLIENT.registerPacket(
|
|
ScoreboardScore.class,
|
|
ScoreboardScore::new,
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x3C ),
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x3C ), // FlameCord - 1.7.x support
|
|
map( ProtocolConstants.MINECRAFT_1_9, 0x42 ),
|
|
map( ProtocolConstants.MINECRAFT_1_12, 0x44 ),
|
|
map( ProtocolConstants.MINECRAFT_1_12_1, 0x45 ),
|
|
@@ -187,7 +187,7 @@ public enum Protocol
|
|
TO_CLIENT.registerPacket(
|
|
ScoreboardDisplay.class,
|
|
ScoreboardDisplay::new,
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x3D ),
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x3D ), // FlameCord - 1.7.x support
|
|
map( ProtocolConstants.MINECRAFT_1_9, 0x38 ),
|
|
map( ProtocolConstants.MINECRAFT_1_12, 0x3A ),
|
|
map( ProtocolConstants.MINECRAFT_1_12_1, 0x3B ),
|
|
@@ -199,7 +199,7 @@ public enum Protocol
|
|
TO_CLIENT.registerPacket(
|
|
Team.class,
|
|
Team::new,
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x3E ),
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x3E ), // FlameCord - 1.7.x support
|
|
map( ProtocolConstants.MINECRAFT_1_9, 0x41 ),
|
|
map( ProtocolConstants.MINECRAFT_1_12, 0x43 ),
|
|
map( ProtocolConstants.MINECRAFT_1_12_1, 0x44 ),
|
|
@@ -211,7 +211,7 @@ public enum Protocol
|
|
TO_CLIENT.registerPacket(
|
|
PluginMessage.class,
|
|
PluginMessage::new,
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x3F ),
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x3F ), // FlameCord - 1.7.x support
|
|
map( ProtocolConstants.MINECRAFT_1_9, 0x18 ),
|
|
map( ProtocolConstants.MINECRAFT_1_13, 0x19 ),
|
|
map( ProtocolConstants.MINECRAFT_1_14, 0x18 ),
|
|
@@ -223,7 +223,7 @@ public enum Protocol
|
|
TO_CLIENT.registerPacket(
|
|
Kick.class,
|
|
Kick::new,
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x40 ),
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x40 ), // FlameCord - 1.7.x support
|
|
map( ProtocolConstants.MINECRAFT_1_9, 0x1A ),
|
|
map( ProtocolConstants.MINECRAFT_1_13, 0x1B ),
|
|
map( ProtocolConstants.MINECRAFT_1_14, 0x1A ),
|
|
@@ -235,7 +235,7 @@ public enum Protocol
|
|
TO_CLIENT.registerPacket(
|
|
Title.class,
|
|
Title::new,
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x45 ),
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x45 ), // FlameCord - 1.7.x support
|
|
map( ProtocolConstants.MINECRAFT_1_12, 0x47 ),
|
|
map( ProtocolConstants.MINECRAFT_1_12_1, 0x48 ),
|
|
map( ProtocolConstants.MINECRAFT_1_13, 0x4B ),
|
|
@@ -265,7 +265,7 @@ public enum Protocol
|
|
TO_CLIENT.registerPacket(
|
|
PlayerListHeaderFooter.class,
|
|
PlayerListHeaderFooter::new,
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x47 ),
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x47 ), // FlameCord - 1.7.x support
|
|
map( ProtocolConstants.MINECRAFT_1_9, 0x48 ),
|
|
map( ProtocolConstants.MINECRAFT_1_9_4, 0x47 ),
|
|
map( ProtocolConstants.MINECRAFT_1_12, 0x49 ),
|
|
@@ -280,7 +280,7 @@ public enum Protocol
|
|
TO_CLIENT.registerPacket(
|
|
EntityStatus.class,
|
|
EntityStatus::new,
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x1A ),
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x1A ), // FlameCord - 1.7.x support
|
|
map( ProtocolConstants.MINECRAFT_1_9, 0x1B ),
|
|
map( ProtocolConstants.MINECRAFT_1_13, 0x1C ),
|
|
map( ProtocolConstants.MINECRAFT_1_14, 0x1B ),
|
|
@@ -318,7 +318,7 @@ public enum Protocol
|
|
TO_SERVER.registerPacket(
|
|
KeepAlive.class,
|
|
KeepAlive::new,
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x00 ),
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x00 ), // FlameCord - 1.7.x support
|
|
map( ProtocolConstants.MINECRAFT_1_9, 0x0B ),
|
|
map( ProtocolConstants.MINECRAFT_1_12, 0x0C ),
|
|
map( ProtocolConstants.MINECRAFT_1_12_1, 0x0B ),
|
|
@@ -330,7 +330,7 @@ public enum Protocol
|
|
TO_SERVER.registerPacket(
|
|
Chat.class,
|
|
Chat::new,
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x01 ),
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x01 ), // FlameCord - 1.7.x support
|
|
map( ProtocolConstants.MINECRAFT_1_9, 0x02 ),
|
|
map( ProtocolConstants.MINECRAFT_1_12, 0x03 ),
|
|
map( ProtocolConstants.MINECRAFT_1_12_1, 0x02 ),
|
|
@@ -339,7 +339,7 @@ public enum Protocol
|
|
TO_SERVER.registerPacket(
|
|
TabCompleteRequest.class,
|
|
TabCompleteRequest::new,
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x14 ),
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x14 ), // FlameCord - 1.7.x support
|
|
map( ProtocolConstants.MINECRAFT_1_9, 0x01 ),
|
|
map( ProtocolConstants.MINECRAFT_1_12, 0x02 ),
|
|
map( ProtocolConstants.MINECRAFT_1_12_1, 0x01 ),
|
|
@@ -349,7 +349,7 @@ public enum Protocol
|
|
TO_SERVER.registerPacket(
|
|
ClientSettings.class,
|
|
ClientSettings::new,
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x15 ),
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x15 ), // FlameCord - 1.7.x support
|
|
map( ProtocolConstants.MINECRAFT_1_9, 0x04 ),
|
|
map( ProtocolConstants.MINECRAFT_1_12, 0x05 ),
|
|
map( ProtocolConstants.MINECRAFT_1_12_1, 0x04 ),
|
|
@@ -358,7 +358,7 @@ public enum Protocol
|
|
TO_SERVER.registerPacket(
|
|
PluginMessage.class,
|
|
PluginMessage::new,
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x17 ),
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x17 ), // FlameCord - 1.7.x support
|
|
map( ProtocolConstants.MINECRAFT_1_9, 0x09 ),
|
|
map( ProtocolConstants.MINECRAFT_1_12, 0x0A ),
|
|
map( ProtocolConstants.MINECRAFT_1_12_1, 0x09 ),
|
|
@@ -376,23 +376,23 @@ public enum Protocol
|
|
TO_CLIENT.registerPacket(
|
|
StatusResponse.class,
|
|
StatusResponse::new,
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x00 )
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x00 ) // FlameCord - 1.7.x support
|
|
);
|
|
TO_CLIENT.registerPacket(
|
|
PingPacket.class,
|
|
PingPacket::new,
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x01 )
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x01 ) // FlameCord - 1.7.x support
|
|
);
|
|
|
|
TO_SERVER.registerPacket(
|
|
StatusRequest.class,
|
|
StatusRequest::new,
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x00 )
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x00 ) // FlameCord - 1.7.x support
|
|
);
|
|
TO_SERVER.registerPacket(
|
|
PingPacket.class,
|
|
PingPacket::new,
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x01 )
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x01 ) // FlameCord - 1.7.x support
|
|
);
|
|
}
|
|
},
|
|
@@ -404,22 +404,22 @@ public enum Protocol
|
|
TO_CLIENT.registerPacket(
|
|
Kick.class,
|
|
Kick::new,
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x00 )
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x00 ) // FlameCord - 1.7.x support
|
|
);
|
|
TO_CLIENT.registerPacket(
|
|
EncryptionRequest.class,
|
|
EncryptionRequest::new,
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x01 )
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x01 ) // FlameCord - 1.7.x support
|
|
);
|
|
TO_CLIENT.registerPacket(
|
|
LoginSuccess.class,
|
|
LoginSuccess::new,
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x02 )
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x02 ) // FlameCord - 1.7.x support
|
|
);
|
|
TO_CLIENT.registerPacket(
|
|
SetCompression.class,
|
|
SetCompression::new,
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x03 )
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x03 ) // FlameCord - 1.7.x support
|
|
);
|
|
TO_CLIENT.registerPacket(
|
|
LoginPayloadRequest.class,
|
|
@@ -430,12 +430,12 @@ public enum Protocol
|
|
TO_SERVER.registerPacket(
|
|
LoginRequest.class,
|
|
LoginRequest::new,
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x00 )
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x00 ) // FlameCord - 1.7.x support
|
|
);
|
|
TO_SERVER.registerPacket(
|
|
EncryptionResponse.class,
|
|
EncryptionResponse::new,
|
|
- map( ProtocolConstants.MINECRAFT_1_8, 0x01 )
|
|
+ map( ProtocolConstants.MINECRAFT_1_7_2, 0x01 ) // FlameCord - 1.7.x support
|
|
);
|
|
TO_SERVER.registerPacket(
|
|
LoginPayloadResponse.class,
|
|
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
|
|
index 6360818c..5e4f3d64 100644
|
|
--- a/protocol/src/main/java/net/md_5/bungee/protocol/ProtocolConstants.java
|
|
+++ b/protocol/src/main/java/net/md_5/bungee/protocol/ProtocolConstants.java
|
|
@@ -7,6 +7,10 @@ public class ProtocolConstants
|
|
{
|
|
|
|
private static final boolean SNAPSHOT_SUPPORT = Boolean.getBoolean( "net.md_5.bungee.protocol.snapshot" );
|
|
+ // FlameCord start - 1.7.x support
|
|
+ public static final int MINECRAFT_1_7_2 = 4;
|
|
+ public static final int MINECRAFT_1_7_6 = 5;
|
|
+ // FlameCord end - 1.7.x support
|
|
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;
|
|
@@ -44,6 +48,7 @@ public class ProtocolConstants
|
|
static
|
|
{
|
|
ImmutableList.Builder<String> supportedVersions = ImmutableList.<String>builder().add(
|
|
+ "1.7.x", // FlameCord - 1.7.x support
|
|
"1.8.x",
|
|
"1.9.x",
|
|
"1.10.x",
|
|
@@ -57,6 +62,10 @@ public class ProtocolConstants
|
|
"1.18.x"
|
|
);
|
|
ImmutableList.Builder<Integer> supportedVersionIds = ImmutableList.<Integer>builder().add(
|
|
+ // FlameCord start - 1.7.x support
|
|
+ ProtocolConstants.MINECRAFT_1_7_2,
|
|
+ ProtocolConstants.MINECRAFT_1_7_6,
|
|
+ // FlameCord end - 1.7.x support
|
|
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/packet/Chat.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/Chat.java
|
|
index 6034fc18..6100687c 100644
|
|
--- 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
|
|
@@ -41,6 +41,7 @@ public class Chat extends DefinedPacket
|
|
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
{
|
|
message = readString( buf, ( direction == ProtocolConstants.Direction.TO_CLIENT ) ? 262144 : ( protocolVersion >= ProtocolConstants.MINECRAFT_1_11 ? 256 : 100 ) );
|
|
+ if ( ProtocolConstants.isAfterOrEq( protocolVersion, ProtocolConstants.MINECRAFT_1_8 ) ) // FlameCord - 1.7.x support
|
|
if ( direction == ProtocolConstants.Direction.TO_CLIENT )
|
|
{
|
|
position = buf.readByte();
|
|
@@ -60,6 +61,7 @@ public class Chat extends DefinedPacket
|
|
} else
|
|
// Waterfall end
|
|
writeString( message, buf );
|
|
+ if ( ProtocolConstants.isAfterOrEq( protocolVersion, ProtocolConstants.MINECRAFT_1_8 ) ) // FlameCord - 1.7.x support
|
|
if ( direction == ProtocolConstants.Direction.TO_CLIENT )
|
|
{
|
|
buf.writeByte( position );
|
|
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
|
|
index d7d4e6ab..570a89f0 100644
|
|
--- 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
|
|
@@ -34,6 +34,12 @@ public class ClientSettings extends DefinedPacket
|
|
chatFlags = protocolVersion >= ProtocolConstants.MINECRAFT_1_9 ? DefinedPacket.readVarInt( buf ) : buf.readUnsignedByte();
|
|
chatColours = buf.readBoolean();
|
|
skinParts = buf.readByte();
|
|
+ // FlameCord start - 1.7.x support
|
|
+ if ( ProtocolConstants.isBeforeOrEq( protocolVersion, ProtocolConstants.MINECRAFT_1_7_6 ) )
|
|
+ {
|
|
+ difficulty = buf.readByte();
|
|
+ }
|
|
+ // FlameCord end - 1.7.x support
|
|
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_9 )
|
|
{
|
|
mainHand = DefinedPacket.readVarInt( buf );
|
|
@@ -51,6 +57,19 @@ public class ClientSettings extends DefinedPacket
|
|
@Override
|
|
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
{
|
|
+ // FlameCord start - 1.7.x support
|
|
+ if ( ProtocolConstants.isBeforeOrEq( protocolVersion, ProtocolConstants.MINECRAFT_1_7_6 ) )
|
|
+ {
|
|
+ writeString( locale, buf );
|
|
+ buf.writeByte( viewDistance );
|
|
+ buf.writeByte( chatFlags );
|
|
+ buf.writeBoolean( chatColours );
|
|
+ buf.writeByte( skinParts );
|
|
+ buf.writeByte( difficulty );
|
|
+ return;
|
|
+ }
|
|
+ // FlameCord end - 1.7.x support
|
|
+
|
|
writeString( locale, buf );
|
|
buf.writeByte( viewDistance );
|
|
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_9 )
|
|
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
|
|
index a29524ca..86182cdd 100644
|
|
--- 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
|
|
@@ -23,6 +23,16 @@ public class EncryptionRequest extends DefinedPacket
|
|
@Override
|
|
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
{
|
|
+ // FlameCord start - 1.7.x support
|
|
+ if ( ProtocolConstants.isBeforeOrEq( protocolVersion, ProtocolConstants.MINECRAFT_1_7_6 ) )
|
|
+ {
|
|
+ serverId = readString( buf );
|
|
+ publicKey = v17readArray( buf );
|
|
+ verifyToken = v17readArray( buf );
|
|
+ return;
|
|
+ }
|
|
+ // FlameCord end - 1.7.x support
|
|
+
|
|
serverId = readString( buf );
|
|
publicKey = readArray( buf );
|
|
verifyToken = readArray( buf );
|
|
@@ -31,6 +41,16 @@ public class EncryptionRequest extends DefinedPacket
|
|
@Override
|
|
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
{
|
|
+ // FlameCord start - 1.7.x support
|
|
+ if ( ProtocolConstants.isBeforeOrEq( protocolVersion, ProtocolConstants.MINECRAFT_1_7_6 ) )
|
|
+ {
|
|
+ writeString( serverId, buf );
|
|
+ v17writeArray( publicKey, buf, false );
|
|
+ v17writeArray( verifyToken, buf, false );
|
|
+ return;
|
|
+ }
|
|
+ // FlameCord end - 1.7.x support
|
|
+
|
|
writeString( serverId, buf );
|
|
writeArray( publicKey, buf );
|
|
writeArray( verifyToken, buf );
|
|
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
|
|
index 53575ce0..52d7a5cc 100644
|
|
--- 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
|
|
@@ -22,6 +22,15 @@ public class EncryptionResponse extends DefinedPacket
|
|
@Override
|
|
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
{
|
|
+ // FlameCord start - 1.7.x support
|
|
+ if ( ProtocolConstants.isBeforeOrEq( protocolVersion, ProtocolConstants.MINECRAFT_1_7_6 ) )
|
|
+ {
|
|
+ sharedSecret = v17readArray( buf );
|
|
+ verifyToken = v17readArray( buf );
|
|
+ return;
|
|
+ }
|
|
+ // FlameCord end - 1.7.x support
|
|
+
|
|
sharedSecret = readArray( buf, 128 );
|
|
verifyToken = readArray( buf, 128 );
|
|
}
|
|
@@ -29,6 +38,15 @@ public class EncryptionResponse extends DefinedPacket
|
|
@Override
|
|
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
{
|
|
+ // FlameCord start - 1.7.x support
|
|
+ if ( ProtocolConstants.isBeforeOrEq( protocolVersion, ProtocolConstants.MINECRAFT_1_7_6 ) )
|
|
+ {
|
|
+ v17writeArray( sharedSecret, buf, false );
|
|
+ v17writeArray( verifyToken, buf, false );
|
|
+ return;
|
|
+ }
|
|
+ // FlameCord end - 1.7.x support
|
|
+
|
|
writeArray( sharedSecret, buf );
|
|
writeArray( verifyToken, buf );
|
|
}
|
|
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
|
|
index d11a9ea9..0ed78a8c 100644
|
|
--- 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
|
|
@@ -7,6 +7,7 @@ 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
|
|
@@ -21,20 +22,41 @@ public class EntityEffect extends DefinedPacket {
|
|
private boolean hideParticles;
|
|
|
|
@Override
|
|
- public void read(ByteBuf buf) {
|
|
- this.entityId = readVarInt(buf);
|
|
+ public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) {
|
|
+ this.entityId = protocolVersion >= ProtocolConstants.MINECRAFT_1_8 ? readVarInt(buf) : buf.readInt(); // FlameCord - 1.7.x support
|
|
this.effectId = buf.readUnsignedByte();
|
|
this.amplifier = buf.readUnsignedByte();
|
|
- this.duration = readVarInt(buf);
|
|
- this.hideParticles = buf.readBoolean();
|
|
+ this.duration = protocolVersion >= ProtocolConstants.MINECRAFT_1_8 ? readVarInt(buf) : buf.readShort(); // FlameCord - 1.7.x support
|
|
+ // FlameCord start - 1.7.x support
|
|
+ if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_8 )
|
|
+ {
|
|
+ this.hideParticles = buf.readBoolean();
|
|
+ }
|
|
+ // FlameCord end - 1.7.x support
|
|
}
|
|
|
|
@Override
|
|
- public void write(ByteBuf buf) {
|
|
- writeVarInt(this.entityId, buf);
|
|
+ public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) {
|
|
+ // FlameCord start - 1.7.x support
|
|
+ if (protocolVersion >= ProtocolConstants.MINECRAFT_1_8)
|
|
+ {
|
|
+ writeVarInt(this.entityId, buf);
|
|
+ } else
|
|
+ {
|
|
+ buf.writeInt(effectId);
|
|
+ }
|
|
+ // FlameCord end - 1.7.x support
|
|
buf.writeByte(this.effectId);
|
|
buf.writeByte(this.amplifier);
|
|
- writeVarInt(this.duration, buf);
|
|
+ // FlameCord start - 1.7.x support
|
|
+ if (protocolVersion >= ProtocolConstants.MINECRAFT_1_8)
|
|
+ {
|
|
+ writeVarInt(this.duration, buf);
|
|
+ } else
|
|
+ {
|
|
+ buf.writeShort(duration);
|
|
+ }
|
|
+ // FlameCord end - 1.7.x support
|
|
buf.writeBoolean(this.hideParticles);
|
|
}
|
|
|
|
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
|
|
index 7ed2dc3a..435b8578 100644
|
|
--- 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
|
|
@@ -7,6 +7,7 @@ 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
|
|
@@ -18,14 +19,22 @@ public class EntityRemoveEffect extends DefinedPacket {
|
|
private int effectId;
|
|
|
|
@Override
|
|
- public void read(ByteBuf buf) {
|
|
- this.entityId = readVarInt(buf);
|
|
+ public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) {
|
|
+ this.entityId = protocolVersion >= ProtocolConstants.MINECRAFT_1_8 ? readVarInt(buf) : buf.readInt(); // FlameCord - 1.7.x support
|
|
this.effectId = buf.readUnsignedByte();
|
|
}
|
|
|
|
@Override
|
|
- public void write(ByteBuf buf) {
|
|
- writeVarInt(this.entityId, buf);
|
|
+ public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) {
|
|
+ // FlameCord start - 1.7.x support
|
|
+ if (protocolVersion >= ProtocolConstants.MINECRAFT_1_8)
|
|
+ {
|
|
+ writeVarInt(this.entityId, buf);
|
|
+ } else
|
|
+ {
|
|
+ buf.writeInt(entityId);
|
|
+ }
|
|
+ // FlameCord end - 1.7.x support
|
|
buf.writeByte(effectId);
|
|
}
|
|
|
|
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
|
|
index b004bc41..a8c3e773 100644
|
|
--- 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
|
|
@@ -21,12 +21,28 @@ public class KeepAlive extends DefinedPacket
|
|
@Override
|
|
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
{
|
|
+ // FlameCord start - 1.7.x support
|
|
+ if ( ProtocolConstants.isBeforeOrEq( protocolVersion, ProtocolConstants.MINECRAFT_1_7_6 ) )
|
|
+ {
|
|
+ randomId = buf.readInt();
|
|
+ return;
|
|
+ }
|
|
+ // FlameCord end - 1.7.x support
|
|
+
|
|
randomId = ( protocolVersion >= ProtocolConstants.MINECRAFT_1_12_2 ) ? buf.readLong() : readVarInt( buf );
|
|
}
|
|
|
|
@Override
|
|
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
{
|
|
+ // FlameCord start - 1.7.x support
|
|
+ if ( ProtocolConstants.isBeforeOrEq( protocolVersion, ProtocolConstants.MINECRAFT_1_7_6 ) )
|
|
+ {
|
|
+ buf.writeInt((int) randomId);
|
|
+ return;
|
|
+ }
|
|
+ // FlameCord end - 1.7.x support
|
|
+
|
|
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_12_2 )
|
|
{
|
|
buf.writeLong( randomId );
|
|
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
|
|
index 551bd104..5aeae06c 100644
|
|
--- 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)
|
|
{
|
|
+ // FlameCord start - 1.7.x support
|
|
+ if ( protocolVersion <= ProtocolConstants.MINECRAFT_1_7_2 ) {
|
|
+ uuid = readUndashedUUID( buf );
|
|
+ } else
|
|
+ // FlameCord end - 1.7.x support
|
|
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)
|
|
{
|
|
+ // FlameCord start - 1.7.x support
|
|
+ if ( protocolVersion <= ProtocolConstants.MINECRAFT_1_7_2 ) {
|
|
+ writeUndashedUUID( uuid.toString(), buf );
|
|
+ } else
|
|
+ // FlameCord end - 1.7.x support
|
|
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_16 )
|
|
{
|
|
writeUUID( uuid, buf );
|
|
@@ -51,4 +61,14 @@ public class LoginSuccess extends DefinedPacket
|
|
{
|
|
handler.handle( this );
|
|
}
|
|
+
|
|
+ // FlameCord start - 1.7.x support
|
|
+ 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 );
|
|
+ }
|
|
+ // FlameCord end - 1.7.x support
|
|
}
|
|
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
|
|
index 92bacc7c..cae5bda5 100644
|
|
--- 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
|
|
@@ -21,6 +21,18 @@ public class PlayerListItem extends DefinedPacket
|
|
@Override
|
|
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
{
|
|
+ // FlameCord start - 1.7.x support
|
|
+ if ( ProtocolConstants.isBeforeOrEq( protocolVersion, ProtocolConstants.MINECRAFT_1_7_6 ) )
|
|
+ {
|
|
+ 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();
|
|
+ return;
|
|
+ }
|
|
+ // FlameCord end - 1.7.x support
|
|
+
|
|
action = Action.values()[DefinedPacket.readVarInt( buf )];
|
|
items = new Item[ DefinedPacket.readVarInt( buf ) ];
|
|
for ( int i = 0; i < items.length; i++ )
|
|
@@ -75,6 +87,17 @@ public class PlayerListItem extends DefinedPacket
|
|
@Override
|
|
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
{
|
|
+ // FlameCord start - 1.7.x support
|
|
+ if ( ProtocolConstants.isBeforeOrEq( protocolVersion, ProtocolConstants.MINECRAFT_1_7_6 ) )
|
|
+ {
|
|
+ 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 );
|
|
+ return;
|
|
+ }
|
|
+ // FlameCord end - 1.7.x support
|
|
+
|
|
DefinedPacket.writeVarInt( action.ordinal(), buf );
|
|
DefinedPacket.writeVarInt( items.length, buf );
|
|
for ( Item item : items )
|
|
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
|
|
index 91f71c09..57a82d29 100644
|
|
--- 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
|
|
@@ -73,6 +73,15 @@ public class PluginMessage extends DefinedPacket
|
|
@Override
|
|
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
{
|
|
+ // FlameCord start - 1.7.x support
|
|
+ if ( ProtocolConstants.isBeforeOrEq( protocolVersion, ProtocolConstants.MINECRAFT_1_7_6 ) )
|
|
+ {
|
|
+ tag = readString( buf );
|
|
+ data = v17readArray( buf );
|
|
+ return;
|
|
+ }
|
|
+ // FlameCord end - 1.7.x support
|
|
+
|
|
tag = ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 ) ? MODERNISE.apply( readString( buf ) ) : readString( buf, 20 );
|
|
int maxSize = ( direction == ProtocolConstants.Direction.TO_SERVER ) ? Short.MAX_VALUE : 0x100000;
|
|
Preconditions.checkArgument( buf.readableBytes() <= maxSize, "Payload too large" );
|
|
@@ -83,6 +92,15 @@ public class PluginMessage extends DefinedPacket
|
|
@Override
|
|
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
{
|
|
+ // FlameCord start - 1.7.x support
|
|
+ if ( ProtocolConstants.isBeforeOrEq( protocolVersion, ProtocolConstants.MINECRAFT_1_7_6 ) )
|
|
+ {
|
|
+ writeString( tag, buf );
|
|
+ v17writeArray( data, buf, allowExtendedPacket );
|
|
+ return;
|
|
+ }
|
|
+ // FlameCord end - 1.7.x support
|
|
+
|
|
writeString( ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 ) ? MODERNISE.apply( tag ) : tag, buf );
|
|
buf.writeBytes( data );
|
|
}
|
|
diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/PluginMessage.java.orig b/protocol/src/main/java/net/md_5/bungee/protocol/packet/PluginMessage.java.orig
|
|
new file mode 100644
|
|
index 00000000..91f71c09
|
|
--- /dev/null
|
|
+++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/PluginMessage.java.orig
|
|
@@ -0,0 +1,100 @@
|
|
+package net.md_5.bungee.protocol.packet;
|
|
+
|
|
+import com.google.common.base.Function;
|
|
+import com.google.common.base.Preconditions;
|
|
+import io.netty.buffer.ByteBuf;
|
|
+import io.netty.buffer.ByteBufUtil; // Waterfall
|
|
+import java.io.ByteArrayInputStream;
|
|
+import java.io.DataInput;
|
|
+import java.io.DataInputStream;
|
|
+import java.util.Locale;
|
|
+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 PluginMessage extends DefinedPacket
|
|
+{
|
|
+
|
|
+ public static final Function<String, String> MODERNISE = new Function<String, String>()
|
|
+ {
|
|
+ @Override
|
|
+ public String apply(String tag)
|
|
+ {
|
|
+ // Transform as per Bukkit
|
|
+ if ( tag.equals( "BungeeCord" ) )
|
|
+ {
|
|
+ return "bungeecord:main";
|
|
+ }
|
|
+ if ( tag.equals( "bungeecord:main" ) )
|
|
+ {
|
|
+ return "BungeeCord";
|
|
+ }
|
|
+
|
|
+ // Code that gets to here is UNLIKELY to be viable on the Bukkit side of side things,
|
|
+ // but we keep it anyway. It will eventually be enforced API side.
|
|
+ if ( tag.indexOf( ':' ) != -1 )
|
|
+ {
|
|
+ return tag;
|
|
+ }
|
|
+
|
|
+ return "legacy:" + tag.toLowerCase( Locale.ROOT );
|
|
+ }
|
|
+ };
|
|
+
|
|
+ public PluginMessage(String tag, ByteBuf data, boolean allowExtendedPacket) {
|
|
+ this(tag, ByteBufUtil.getBytes(data), allowExtendedPacket);
|
|
+ }
|
|
+
|
|
+ private String tag;
|
|
+ private byte[] data;
|
|
+
|
|
+ public void setData(byte[] data) {
|
|
+ this.data = Preconditions.checkNotNull(data, "Null data");
|
|
+ }
|
|
+
|
|
+ public void setData(ByteBuf buf) {
|
|
+ Preconditions.checkNotNull(buf, "Null buffer");
|
|
+ setData(ByteBufUtil.getBytes(buf));
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Allow this packet to be sent as an "extended" packet.
|
|
+ */
|
|
+ private boolean allowExtendedPacket = false;
|
|
+
|
|
+ @Override
|
|
+ public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
+ {
|
|
+ tag = ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 ) ? MODERNISE.apply( readString( buf ) ) : readString( buf, 20 );
|
|
+ int maxSize = ( direction == ProtocolConstants.Direction.TO_SERVER ) ? Short.MAX_VALUE : 0x100000;
|
|
+ Preconditions.checkArgument( buf.readableBytes() <= maxSize, "Payload too large" );
|
|
+ data = new byte[ buf.readableBytes() ];
|
|
+ buf.readBytes( data );
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
+ {
|
|
+ writeString( ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 ) ? MODERNISE.apply( tag ) : tag, buf );
|
|
+ buf.writeBytes( data );
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void handle(AbstractPacketHandler handler) throws Exception
|
|
+ {
|
|
+ handler.handle( this );
|
|
+ }
|
|
+
|
|
+ public DataInput getStream()
|
|
+ {
|
|
+ return new DataInputStream( new ByteArrayInputStream( data ) );
|
|
+ }
|
|
+}
|
|
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
|
|
index 3c7905d5..75b371e9 100644
|
|
--- 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
|
|
@@ -28,6 +28,16 @@ public class ScoreboardObjective extends DefinedPacket
|
|
@Override
|
|
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
{
|
|
+ // FlameCord start - 1.7.x support
|
|
+ if ( ProtocolConstants.isBeforeOrEq( protocolVersion, ProtocolConstants.MINECRAFT_1_7_6 ) )
|
|
+ {
|
|
+ name = readString( buf );
|
|
+ value = readString( buf );
|
|
+ action = buf.readByte();
|
|
+ return;
|
|
+ }
|
|
+ // FlameCord end - 1.7.x support
|
|
+
|
|
name = readString( buf );
|
|
action = buf.readByte();
|
|
if ( action == 0 || action == 2 )
|
|
@@ -46,6 +56,16 @@ public class ScoreboardObjective extends DefinedPacket
|
|
@Override
|
|
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
{
|
|
+ // FlameCord start - 1.7.x support
|
|
+ if ( ProtocolConstants.isBeforeOrEq( protocolVersion, ProtocolConstants.MINECRAFT_1_7_6 ) )
|
|
+ {
|
|
+ writeString( name, buf );
|
|
+ writeString( value, buf );
|
|
+ buf.writeByte( action );
|
|
+ return;
|
|
+ }
|
|
+ // FlameCord end - 1.7.x support
|
|
+
|
|
writeString( name, buf );
|
|
buf.writeByte( action );
|
|
if ( action == 0 || action == 2 )
|
|
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
|
|
index 0b27fc86..a812441d 100644
|
|
--- 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
|
|
@@ -27,6 +27,20 @@ public class ScoreboardScore extends DefinedPacket
|
|
@Override
|
|
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
{
|
|
+ // FlameCord start - 1.7.x support
|
|
+ if ( ProtocolConstants.isBeforeOrEq( protocolVersion, ProtocolConstants.MINECRAFT_1_7_6 ) )
|
|
+ {
|
|
+ itemName = readString( buf );
|
|
+ action = buf.readByte();
|
|
+ if ( action != 1 )
|
|
+ {
|
|
+ scoreName = readString( buf );
|
|
+ value = buf.readInt();
|
|
+ }
|
|
+ return;
|
|
+ }
|
|
+ // FlameCord end - 1.7.x support
|
|
+
|
|
itemName = readString( buf );
|
|
action = buf.readByte();
|
|
scoreName = readString( buf );
|
|
@@ -39,6 +53,20 @@ public class ScoreboardScore extends DefinedPacket
|
|
@Override
|
|
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
{
|
|
+ // FlameCord start - 1.7.x support
|
|
+ if ( ProtocolConstants.isBeforeOrEq( protocolVersion, ProtocolConstants.MINECRAFT_1_7_6 ) )
|
|
+ {
|
|
+ writeString( itemName, buf );
|
|
+ buf.writeByte( action );
|
|
+ if ( action != 1 )
|
|
+ {
|
|
+ writeString( scoreName, buf );
|
|
+ buf.writeInt( value );
|
|
+ }
|
|
+ return;
|
|
+ }
|
|
+ // FlameCord end - 1.7.x support
|
|
+
|
|
writeString( itemName, buf );
|
|
buf.writeByte( action );
|
|
writeString( scoreName, buf );
|
|
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
|
|
index 80e4f85a..cab28b99 100644
|
|
--- 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
|
|
@@ -43,6 +43,7 @@ public class TabCompleteRequest extends DefinedPacket
|
|
}
|
|
cursor = readString( buf, ( protocolVersion > ProtocolConstants.MINECRAFT_1_13 ? 32500 : ( protocolVersion == ProtocolConstants.MINECRAFT_1_13 ? 256 : 32767 ) ) );
|
|
|
|
+ if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_8 ) // FlameCord - 1.7.x support
|
|
if ( protocolVersion < ProtocolConstants.MINECRAFT_1_13 )
|
|
{
|
|
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_9 )
|
|
@@ -66,6 +67,7 @@ public class TabCompleteRequest extends DefinedPacket
|
|
}
|
|
writeString( cursor, buf );
|
|
|
|
+ if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_8 ) // FlameCord - 1.7.x support
|
|
if ( protocolVersion < ProtocolConstants.MINECRAFT_1_13 )
|
|
{
|
|
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_9 )
|
|
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
|
|
index a5555f6a..09dc67f9 100644
|
|
--- 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
|
|
@@ -55,12 +55,22 @@ public class Team extends DefinedPacket
|
|
suffix = readString( buf );
|
|
}
|
|
friendlyFire = buf.readByte();
|
|
- nameTagVisibility = readString( buf );
|
|
+ // FlameCord start - 1.7.x support
|
|
+ if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_8 )
|
|
+ {
|
|
+ nameTagVisibility = readString( buf );
|
|
+ }
|
|
+ // FlameCord end - 1.7.x support
|
|
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_9 )
|
|
{
|
|
collisionRule = readString( buf );
|
|
}
|
|
- color = ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 ) ? readVarInt( buf ) : buf.readByte();
|
|
+ // FlameCord start - 1.7.x support
|
|
+ if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_8 )
|
|
+ {
|
|
+ color = ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 ) ? readVarInt( buf ) : buf.readByte();
|
|
+ }
|
|
+ // FlameCord end - 1.7.x support
|
|
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 )
|
|
{
|
|
prefix = readString( buf );
|
|
@@ -69,7 +79,7 @@ public class Team extends DefinedPacket
|
|
}
|
|
if ( mode == 0 || mode == 3 || mode == 4 )
|
|
{
|
|
- int len = readVarInt( buf );
|
|
+ int len = protocolVersion >= ProtocolConstants.MINECRAFT_1_8 ? readVarInt( buf ) : buf.readShort(); // FlameCord - 1.7.x support
|
|
players = new String[ len ];
|
|
for ( int i = 0; i < len; i++ )
|
|
{
|
|
@@ -81,6 +91,30 @@ public class Team extends DefinedPacket
|
|
@Override
|
|
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
{
|
|
+ // FlameCord start - 1.7.x support
|
|
+ if ( ProtocolConstants.isBeforeOrEq( protocolVersion, ProtocolConstants.MINECRAFT_1_7_6 ) )
|
|
+ {
|
|
+ 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 );
|
|
+ }
|
|
+ }
|
|
+ return;
|
|
+ }
|
|
+ // FlameCord end - 1.7.x support
|
|
+
|
|
writeString( name, buf );
|
|
buf.writeByte( mode );
|
|
if ( mode == 0 || mode == 2 )
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
|
|
index 11b62d81..5ef34fcb 100644
|
|
--- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
|
|
@@ -170,6 +170,14 @@ public class BungeeCord extends ProxyServer
|
|
.registerTypeAdapter( SelectorComponent.class, new SelectorComponentSerializer() )
|
|
.registerTypeAdapter( ServerPing.PlayerInfo.class, new PlayerInfoSerializer() )
|
|
.registerTypeAdapter( Favicon.class, Favicon.getFaviconTypeAdapter() ).create();
|
|
+ // FlameCord start - 1.7.x support
|
|
+ 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();
|
|
+ // FlameCord end - 1.7.x support
|
|
@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
|
|
index 1d377a65..0ea5f90b 100644
|
|
--- a/proxy/src/main/java/net/md_5/bungee/BungeeTitle.java
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/BungeeTitle.java
|
|
@@ -183,6 +183,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; // FlameCord - 1.7.x support
|
|
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
|
|
index 491cf1a1..6cd8ec3b 100644
|
|
--- a/proxy/src/main/java/net/md_5/bungee/PlayerInfoSerializer.java
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/PlayerInfoSerializer.java
|
|
@@ -10,9 +10,23 @@ 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>
|
|
{
|
|
+ // FlameCord start - 1.7.x support
|
|
+ private final int protocol;
|
|
+
|
|
+ public PlayerInfoSerializer()
|
|
+ {
|
|
+ this.protocol = ProtocolConstants.MINECRAFT_1_7_6;
|
|
+ }
|
|
+
|
|
+ public PlayerInfoSerializer(int protocol)
|
|
+ {
|
|
+ this.protocol = protocol;
|
|
+ }
|
|
+ // FlameCord end - 1.7.x support
|
|
|
|
@Override
|
|
public ServerPing.PlayerInfo deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
|
|
@@ -20,7 +34,7 @@ public class PlayerInfoSerializer implements JsonSerializer<ServerPing.PlayerInf
|
|
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( "-" ) ) // FlameCord - 1.7.x support
|
|
{
|
|
info.setId( id );
|
|
} else
|
|
@@ -35,7 +49,15 @@ public class PlayerInfoSerializer implements JsonSerializer<ServerPing.PlayerInf
|
|
{
|
|
JsonObject out = new JsonObject();
|
|
out.addProperty( "name", src.getName() );
|
|
- out.addProperty( "id", src.getUniqueId().toString() );
|
|
+ // FlameCord start - 1.7.x support
|
|
+ if ( ProtocolConstants.isBeforeOrEq( protocol, ProtocolConstants.MINECRAFT_1_7_2 ) )
|
|
+ {
|
|
+ out.addProperty( "id", src.getId() );
|
|
+ } else
|
|
+ {
|
|
+ out.addProperty( "id", src.getUniqueId().toString() );
|
|
+ }
|
|
+ // FlameCord end - 1.7.x support
|
|
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
|
|
index 9e74d158..75028024 100644
|
|
--- a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java
|
|
@@ -280,10 +280,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();
|
|
+ // FlameCord start - 1.7.x support
|
|
+ String brandString = bungee.getName() + " (" + bungee.getVersion() + ")";
|
|
+
|
|
+ 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( 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();
|
|
+ }
|
|
+ // FlameCord end - 1.7.x support
|
|
}
|
|
|
|
user.setDimension( login.getDimension() );
|
|
@@ -296,7 +306,7 @@ public class ServerConnector extends PacketHandler
|
|
if ( !user.isDisableEntityMetadataRewrite() ) { // Waterfall
|
|
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 ) ); // FlameCord - 1.7 support
|
|
}
|
|
for ( Score score : serverScoreboard.getScores() )
|
|
{
|
|
@@ -465,7 +475,13 @@ public class ServerConnector extends PacketHandler
|
|
if ( pluginMessage.getTag().equals( ForgeConstants.FML_HANDSHAKE_TAG ) || pluginMessage.getTag().equals( ForgeConstants.FORGE_REGISTER ) )
|
|
{
|
|
this.handshakeHandler.handle( pluginMessage );
|
|
-
|
|
+ // FlameCord start - 1.7.x support
|
|
+ if ( user.getForgeClientHandler().checkUserOutdated() )
|
|
+ {
|
|
+ ch.close();
|
|
+ user.getPendingConnects().remove(target);
|
|
+ }
|
|
+ // FlameCord end - 1.7.x support
|
|
// We send the message as part of the handler, so don't send it here.
|
|
throw CancelSendSignal.INSTANCE;
|
|
}
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/UserConnection.java b/proxy/src/main/java/net/md_5/bungee/UserConnection.java
|
|
index 7c52ee9a..fe73e6e8 100644
|
|
--- a/proxy/src/main/java/net/md_5/bungee/UserConnection.java
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/UserConnection.java
|
|
@@ -193,6 +193,7 @@ public final class UserConnection implements ProxiedPlayer
|
|
public void setDisplayName(String name)
|
|
{
|
|
Preconditions.checkNotNull( name, "displayName" );
|
|
+ Preconditions.checkArgument( name.length() <= 16, "Display name cannot be longer than 16 characters" ); // FlameCord - 1.7.x support
|
|
displayName = name;
|
|
}
|
|
|
|
@@ -507,7 +508,7 @@ public final class UserConnection implements ProxiedPlayer
|
|
// transform score components
|
|
message = ChatComponentTransformer.getInstance().transform( this, true, message );
|
|
|
|
- if ( position == ChatMessageType.ACTION_BAR && getPendingConnection().getVersion() < ProtocolConstants.MINECRAFT_1_17 )
|
|
+ if ( position == ChatMessageType.ACTION_BAR && getPendingConnection().getVersion() < ProtocolConstants.MINECRAFT_1_17 && getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_8 ) // FlameCord - 1.7.x support
|
|
{
|
|
// 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
|
|
@@ -703,6 +704,7 @@ public final class UserConnection implements ProxiedPlayer
|
|
@Override
|
|
public void setTabHeader(BaseComponent header, BaseComponent footer)
|
|
{
|
|
+ if ( ProtocolConstants.isBeforeOrEq( pendingConnection.getVersion(), ProtocolConstants.MINECRAFT_1_7_6 ) ) return; // FlameCord
|
|
header = ChatComponentTransformer.getInstance().transform( this, true, header )[0];
|
|
footer = ChatComponentTransformer.getInstance().transform( this, true, footer )[0];
|
|
|
|
@@ -715,6 +717,7 @@ public final class UserConnection implements ProxiedPlayer
|
|
@Override
|
|
public void setTabHeader(BaseComponent[] header, BaseComponent[] footer)
|
|
{
|
|
+ if ( ProtocolConstants.isBeforeOrEq( pendingConnection.getVersion(), ProtocolConstants.MINECRAFT_1_7_6 ) ) return; // FlameCord
|
|
header = ChatComponentTransformer.getInstance().transform( this, true, header );
|
|
footer = ChatComponentTransformer.getInstance().transform( this, true, footer );
|
|
|
|
@@ -744,6 +747,7 @@ public final class UserConnection implements ProxiedPlayer
|
|
|
|
public void setCompressionThreshold(int compressionThreshold)
|
|
{
|
|
+ if ( ProtocolConstants.isBeforeOrEq( pendingConnection.getVersion(), ProtocolConstants.MINECRAFT_1_7_6 ) ) return; // FlameCord
|
|
if ( !ch.isClosing() && this.compressionThreshold == -1 && compressionThreshold >= 0 )
|
|
{
|
|
this.compressionThreshold = compressionThreshold;
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/UserConnection.java.orig b/proxy/src/main/java/net/md_5/bungee/UserConnection.java.orig
|
|
new file mode 100644
|
|
index 00000000..7c52ee9a
|
|
--- /dev/null
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/UserConnection.java.orig
|
|
@@ -0,0 +1,772 @@
|
|
+package net.md_5.bungee;
|
|
+
|
|
+import com.google.common.base.Preconditions;
|
|
+import com.google.common.collect.HashMultimap;
|
|
+import com.google.common.collect.ImmutableMap;
|
|
+import com.google.common.collect.Multimap;
|
|
+import io.netty.bootstrap.Bootstrap;
|
|
+import io.netty.channel.Channel;
|
|
+import io.netty.channel.ChannelFuture;
|
|
+import io.netty.channel.ChannelFutureListener;
|
|
+import io.netty.channel.ChannelInitializer;
|
|
+import io.netty.channel.ChannelOption;
|
|
+import io.netty.util.internal.PlatformDependent;
|
|
+import java.net.InetSocketAddress;
|
|
+import java.net.SocketAddress;
|
|
+import java.util.Collection;
|
|
+import java.util.Collections;
|
|
+import java.util.HashSet;
|
|
+import java.util.LinkedList;
|
|
+import java.util.Locale;
|
|
+import java.util.Map;
|
|
+import java.util.Objects;
|
|
+import java.util.Queue;
|
|
+import java.util.UUID;
|
|
+import java.util.logging.Level;
|
|
+import lombok.Getter;
|
|
+import lombok.NonNull;
|
|
+import lombok.RequiredArgsConstructor;
|
|
+import lombok.Setter;
|
|
+import net.md_5.bungee.api.Callback;
|
|
+import net.md_5.bungee.api.ChatMessageType;
|
|
+import net.md_5.bungee.api.ProxyServer;
|
|
+import net.md_5.bungee.api.ServerConnectRequest;
|
|
+import net.md_5.bungee.api.SkinConfiguration;
|
|
+import net.md_5.bungee.api.Title;
|
|
+import net.md_5.bungee.api.chat.BaseComponent;
|
|
+import net.md_5.bungee.api.chat.TextComponent;
|
|
+import net.md_5.bungee.api.config.ServerInfo;
|
|
+import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|
+import net.md_5.bungee.api.event.PermissionCheckEvent;
|
|
+import net.md_5.bungee.api.event.ServerConnectEvent;
|
|
+import net.md_5.bungee.api.score.Scoreboard;
|
|
+import net.md_5.bungee.chat.ComponentSerializer;
|
|
+import net.md_5.bungee.connection.InitialHandler;
|
|
+import net.md_5.bungee.entitymap.EntityMap;
|
|
+import net.md_5.bungee.forge.ForgeClientHandler;
|
|
+import net.md_5.bungee.forge.ForgeConstants;
|
|
+import net.md_5.bungee.forge.ForgeServerHandler;
|
|
+import net.md_5.bungee.netty.ChannelWrapper;
|
|
+import net.md_5.bungee.netty.HandlerBoss;
|
|
+import net.md_5.bungee.netty.PipelineUtils;
|
|
+import net.md_5.bungee.protocol.DefinedPacket;
|
|
+import net.md_5.bungee.protocol.MinecraftDecoder;
|
|
+import net.md_5.bungee.protocol.MinecraftEncoder;
|
|
+import net.md_5.bungee.protocol.PacketWrapper;
|
|
+import net.md_5.bungee.protocol.Protocol;
|
|
+import net.md_5.bungee.protocol.ProtocolConstants;
|
|
+import net.md_5.bungee.protocol.packet.Chat;
|
|
+import net.md_5.bungee.protocol.packet.ClientSettings;
|
|
+import net.md_5.bungee.protocol.packet.Kick;
|
|
+import net.md_5.bungee.protocol.packet.PlayerListHeaderFooter;
|
|
+import net.md_5.bungee.protocol.packet.PluginMessage;
|
|
+import net.md_5.bungee.protocol.packet.SetCompression;
|
|
+import net.md_5.bungee.tab.ServerUnique;
|
|
+import net.md_5.bungee.tab.TabList;
|
|
+import net.md_5.bungee.util.CaseInsensitiveSet;
|
|
+import net.md_5.bungee.util.ChatComponentTransformer;
|
|
+
|
|
+@RequiredArgsConstructor
|
|
+public final class UserConnection implements ProxiedPlayer
|
|
+{
|
|
+
|
|
+ /*========================================================================*/
|
|
+ @NonNull
|
|
+ private final ProxyServer bungee;
|
|
+ @NonNull
|
|
+ @Getter
|
|
+ private final ChannelWrapper ch;
|
|
+ @Getter
|
|
+ @NonNull
|
|
+ private final String name;
|
|
+ @Getter
|
|
+ private final InitialHandler pendingConnection;
|
|
+ /*========================================================================*/
|
|
+ @Getter
|
|
+ @Setter
|
|
+ private ServerConnection server;
|
|
+ @Getter
|
|
+ @Setter
|
|
+ private Object dimension;
|
|
+ @Getter
|
|
+ @Setter
|
|
+ private boolean dimensionChange = true;
|
|
+ @Getter
|
|
+ private final Collection<ServerInfo> pendingConnects = new HashSet<>();
|
|
+ /*========================================================================*/
|
|
+ @Getter
|
|
+ @Setter
|
|
+ private int ping = 100;
|
|
+ @Getter
|
|
+ @Setter
|
|
+ private ServerInfo reconnectServer;
|
|
+ @Getter
|
|
+ private TabList tabListHandler;
|
|
+ @Getter
|
|
+ @Setter
|
|
+ private int gamemode;
|
|
+ @Getter
|
|
+ private int compressionThreshold = -1;
|
|
+ // Used for trying multiple servers in order
|
|
+ @Setter
|
|
+ private Queue<String> serverJoinQueue;
|
|
+ /*========================================================================*/
|
|
+ private final Collection<String> groups = new CaseInsensitiveSet();
|
|
+ private final Collection<String> permissions = new CaseInsensitiveSet();
|
|
+ /*========================================================================*/
|
|
+ @Getter
|
|
+ @Setter
|
|
+ private int clientEntityId;
|
|
+ @Getter
|
|
+ @Setter
|
|
+ private int serverEntityId;
|
|
+ @Getter
|
|
+ private ClientSettings settings;
|
|
+ @Getter
|
|
+ private final Scoreboard serverSentScoreboard = new Scoreboard();
|
|
+ @Getter
|
|
+ private final Collection<UUID> sentBossBars = new HashSet<>();
|
|
+ // Waterfall start
|
|
+ @Getter
|
|
+ private final Multimap<Integer, Integer> potions = HashMultimap.create();
|
|
+ // Waterfall end
|
|
+ /*========================================================================*/
|
|
+ @Getter
|
|
+ private String displayName;
|
|
+ @Getter
|
|
+ private EntityMap entityRewrite;
|
|
+ private Locale locale;
|
|
+ /*========================================================================*/
|
|
+ @Getter
|
|
+ @Setter
|
|
+ private ForgeClientHandler forgeClientHandler;
|
|
+ @Getter
|
|
+ @Setter
|
|
+ private ForgeServerHandler forgeServerHandler;
|
|
+ /*========================================================================*/
|
|
+ private final Unsafe unsafe = new Unsafe()
|
|
+ {
|
|
+ @Override
|
|
+ public void sendPacket(DefinedPacket packet)
|
|
+ {
|
|
+ ch.write( packet );
|
|
+ }
|
|
+ };
|
|
+
|
|
+ public void init()
|
|
+ {
|
|
+ this.entityRewrite = EntityMap.getEntityMap( getPendingConnection().getVersion() );
|
|
+
|
|
+ this.displayName = name;
|
|
+
|
|
+ tabListHandler = new ServerUnique( this );
|
|
+
|
|
+ Collection<String> g = bungee.getConfigurationAdapter().getGroups( name );
|
|
+ g.addAll( bungee.getConfigurationAdapter().getGroups( getUniqueId().toString() ) );
|
|
+ for ( String s : g )
|
|
+ {
|
|
+ addGroups( s );
|
|
+ }
|
|
+
|
|
+ forgeClientHandler = new ForgeClientHandler( this );
|
|
+
|
|
+ // No-config FML handshake marker.
|
|
+ // Set whether the connection has a 1.8 FML marker in the handshake.
|
|
+ if (this.getPendingConnection().getExtraDataInHandshake().contains( ForgeConstants.FML_HANDSHAKE_TOKEN ))
|
|
+ {
|
|
+ forgeClientHandler.setFmlTokenInHandshake( true );
|
|
+ }
|
|
+ }
|
|
+
|
|
+ public void sendPacket(PacketWrapper packet)
|
|
+ {
|
|
+ ch.write( packet );
|
|
+ }
|
|
+
|
|
+ @Deprecated
|
|
+ public boolean isActive()
|
|
+ {
|
|
+ return !ch.isClosed();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void setDisplayName(String name)
|
|
+ {
|
|
+ Preconditions.checkNotNull( name, "displayName" );
|
|
+ displayName = name;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void connect(ServerInfo target)
|
|
+ {
|
|
+ connect( target, null, ServerConnectEvent.Reason.PLUGIN );
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void connect(ServerInfo target, ServerConnectEvent.Reason reason)
|
|
+ {
|
|
+ connect( target, null, false, reason );
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void connect(ServerInfo target, Callback<Boolean> callback)
|
|
+ {
|
|
+ connect( target, callback, false, ServerConnectEvent.Reason.PLUGIN );
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void connect(ServerInfo target, Callback<Boolean> callback, ServerConnectEvent.Reason reason)
|
|
+ {
|
|
+ connect( target, callback, false, reason );
|
|
+ }
|
|
+
|
|
+ @Deprecated
|
|
+ public void connectNow(ServerInfo target)
|
|
+ {
|
|
+ connectNow( target, ServerConnectEvent.Reason.UNKNOWN );
|
|
+ }
|
|
+
|
|
+ public void connectNow(ServerInfo target, ServerConnectEvent.Reason reason)
|
|
+ {
|
|
+ dimensionChange = true;
|
|
+ connect( target, reason );
|
|
+ }
|
|
+
|
|
+ public ServerInfo updateAndGetNextServer(ServerInfo currentTarget)
|
|
+ {
|
|
+ if ( serverJoinQueue == null )
|
|
+ {
|
|
+ serverJoinQueue = new LinkedList<>( getPendingConnection().getListener().getServerPriority() );
|
|
+ }
|
|
+
|
|
+ ServerInfo next = null;
|
|
+ while ( !serverJoinQueue.isEmpty() )
|
|
+ {
|
|
+ ServerInfo candidate = ProxyServer.getInstance().getServerInfo( serverJoinQueue.remove() );
|
|
+ if ( !Objects.equals( currentTarget, candidate ) )
|
|
+ {
|
|
+ next = candidate;
|
|
+ break;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ return next;
|
|
+ }
|
|
+
|
|
+ public void connect(ServerInfo info, final Callback<Boolean> callback, final boolean retry)
|
|
+ {
|
|
+ connect( info, callback, retry, ServerConnectEvent.Reason.PLUGIN );
|
|
+ }
|
|
+
|
|
+ public void connect(ServerInfo info, final Callback<Boolean> callback, final boolean retry, ServerConnectEvent.Reason reason)
|
|
+ {
|
|
+ // Waterfall start
|
|
+ connect(info, callback, retry, reason, bungee.getConfig().getServerConnectTimeout());
|
|
+ }
|
|
+ public void connect(ServerInfo info, final Callback<Boolean> callback, final boolean retry, int timeout) {
|
|
+ connect(info, callback, retry, ServerConnectEvent.Reason.PLUGIN, timeout);
|
|
+ }
|
|
+
|
|
+ public void connect(ServerInfo info, final Callback<Boolean> callback, final boolean retry, ServerConnectEvent.Reason reason, final int timeout) {
|
|
+ this.connect(info, callback, retry, reason, timeout, true);
|
|
+ }
|
|
+
|
|
+ public void connect(ServerInfo info, final Callback<Boolean> callback, final boolean retry, ServerConnectEvent.Reason reason, final int timeout, boolean sendFeedback)
|
|
+ {
|
|
+ // Waterfall end
|
|
+ Preconditions.checkNotNull( info, "info" );
|
|
+
|
|
+ ServerConnectRequest.Builder builder = ServerConnectRequest.builder().retry( retry ).reason( reason ).target( info ).sendFeedback(sendFeedback); // Waterfall - feedback param
|
|
+ builder.connectTimeout(timeout); // Waterfall
|
|
+ if ( callback != null )
|
|
+ {
|
|
+ // Convert the Callback<Boolean> to be compatible with Callback<Result> from ServerConnectRequest.
|
|
+ builder.callback( new Callback<ServerConnectRequest.Result>()
|
|
+ {
|
|
+ @Override
|
|
+ public void done(ServerConnectRequest.Result result, Throwable error)
|
|
+ {
|
|
+ callback.done( ( result == ServerConnectRequest.Result.SUCCESS ) ? Boolean.TRUE : Boolean.FALSE, error );
|
|
+ }
|
|
+ } );
|
|
+ }
|
|
+
|
|
+ connect( builder.build() );
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void connect(final ServerConnectRequest request)
|
|
+ {
|
|
+ Preconditions.checkNotNull( request, "request" );
|
|
+
|
|
+ final Callback<ServerConnectRequest.Result> callback = request.getCallback();
|
|
+ ServerConnectEvent event = new ServerConnectEvent( this, request.getTarget(), request.getReason(), request );
|
|
+ if ( bungee.getPluginManager().callEvent( event ).isCancelled() )
|
|
+ {
|
|
+ if ( callback != null )
|
|
+ {
|
|
+ callback.done( ServerConnectRequest.Result.EVENT_CANCEL, null );
|
|
+ }
|
|
+
|
|
+ if ( getServer() == null && !ch.isClosing() )
|
|
+ {
|
|
+ throw new IllegalStateException( "Cancelled ServerConnectEvent with no server or disconnect." );
|
|
+ }
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ final BungeeServerInfo target = (BungeeServerInfo) event.getTarget(); // Update in case the event changed target
|
|
+
|
|
+ if ( getServer() != null && Objects.equals( getServer().getInfo(), target ) )
|
|
+ {
|
|
+ if ( callback != null )
|
|
+ {
|
|
+ callback.done( ServerConnectRequest.Result.ALREADY_CONNECTED, null );
|
|
+ }
|
|
+
|
|
+ if (request.isSendFeedback()) sendMessage( bungee.getTranslation( "already_connected" ) ); // Waterfall
|
|
+ return;
|
|
+ }
|
|
+ if ( pendingConnects.contains( target ) )
|
|
+ {
|
|
+ if ( callback != null )
|
|
+ {
|
|
+ callback.done( ServerConnectRequest.Result.ALREADY_CONNECTING, null );
|
|
+ }
|
|
+
|
|
+ if (request.isSendFeedback()) sendMessage( bungee.getTranslation( "already_connecting" ) ); // Waterfall
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ pendingConnects.add( target );
|
|
+
|
|
+ ChannelInitializer initializer = new ChannelInitializer()
|
|
+ {
|
|
+ @Override
|
|
+ protected void initChannel(Channel ch) throws Exception
|
|
+ {
|
|
+ PipelineUtils.BASE.initChannel( ch );
|
|
+ ch.pipeline().addAfter( PipelineUtils.FRAME_DECODER, PipelineUtils.PACKET_DECODER, new MinecraftDecoder( Protocol.HANDSHAKE, false, getPendingConnection().getVersion() ) );
|
|
+ ch.pipeline().addAfter( PipelineUtils.FRAME_PREPENDER, PipelineUtils.PACKET_ENCODER, new MinecraftEncoder( Protocol.HANDSHAKE, false, getPendingConnection().getVersion() ) );
|
|
+ ch.pipeline().get( HandlerBoss.class ).setHandler( new ServerConnector( bungee, UserConnection.this, target ) );
|
|
+ }
|
|
+ };
|
|
+ ChannelFutureListener listener = new ChannelFutureListener()
|
|
+ {
|
|
+ @Override
|
|
+ @SuppressWarnings("ThrowableResultIgnored")
|
|
+ public void operationComplete(ChannelFuture future) throws Exception
|
|
+ {
|
|
+ if ( callback != null )
|
|
+ {
|
|
+ callback.done( ( future.isSuccess() ) ? ServerConnectRequest.Result.SUCCESS : ServerConnectRequest.Result.FAIL, future.cause() );
|
|
+ }
|
|
+
|
|
+ if ( !future.isSuccess() )
|
|
+ {
|
|
+ future.channel().close();
|
|
+ pendingConnects.remove( target );
|
|
+
|
|
+ ServerInfo def = updateAndGetNextServer( target );
|
|
+ if ( request.isRetry() && def != null && ( getServer() == null || def != getServer().getInfo() ) )
|
|
+ {
|
|
+ if (request.isSendFeedback()) sendMessage( bungee.getTranslation( "fallback_lobby" ) ); // Waterfall
|
|
+ connect( def, null, true, ServerConnectEvent.Reason.LOBBY_FALLBACK, request.getConnectTimeout(), request.isSendFeedback() ); // Waterfall
|
|
+ } else if ( dimensionChange )
|
|
+ {
|
|
+ disconnect( bungee.getTranslation( "fallback_kick", connectionFailMessage( future.cause() ) ) );
|
|
+ } else
|
|
+ {
|
|
+ if (request.isSendFeedback()) sendMessage( bungee.getTranslation( "fallback_kick", connectionFailMessage( future.cause() ) ) );
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ };
|
|
+ Bootstrap b = new Bootstrap()
|
|
+ .channel( PipelineUtils.getChannel( target.getAddress() ) )
|
|
+ .group( ch.getHandle().eventLoop() )
|
|
+ .handler( initializer )
|
|
+ .option( ChannelOption.CONNECT_TIMEOUT_MILLIS, request.getConnectTimeout() )
|
|
+ .remoteAddress( target.getAddress() );
|
|
+ // Windows is bugged, multi homed users will just have to live with random connecting IPs
|
|
+ if ( getPendingConnection().getListener().isSetLocalAddress() && !PlatformDependent.isWindows() && getPendingConnection().getListener().getSocketAddress() instanceof InetSocketAddress )
|
|
+ {
|
|
+ b.localAddress( getPendingConnection().getListener().getHost().getHostString(), 0 );
|
|
+ }
|
|
+ b.connect().addListener( listener );
|
|
+ }
|
|
+
|
|
+ private String connectionFailMessage(Throwable cause)
|
|
+ {
|
|
+ bungee.getLogger().log(Level.WARNING, "Error occurred processing connection for " + this.name + " " + Util.exception( cause, false )); // Waterfall
|
|
+ return ""; // Waterfall
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void disconnect(String reason)
|
|
+ {
|
|
+ disconnect0( TextComponent.fromLegacyText( reason ) );
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void disconnect(BaseComponent... reason)
|
|
+ {
|
|
+ disconnect0( reason );
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void disconnect(BaseComponent reason)
|
|
+ {
|
|
+ disconnect0( reason );
|
|
+ }
|
|
+
|
|
+ public void disconnect0(final BaseComponent... reason)
|
|
+ {
|
|
+ if ( !ch.isClosing() )
|
|
+ {
|
|
+ bungee.getLogger().log( Level.INFO, "[{0}] disconnected with: {1}", new Object[]
|
|
+ {
|
|
+ getName(), BaseComponent.toLegacyText( reason )
|
|
+ } );
|
|
+
|
|
+ ch.close( new Kick( ComponentSerializer.toString( reason ) ) );
|
|
+
|
|
+ if ( server != null )
|
|
+ {
|
|
+ server.setObsolete( true );
|
|
+ server.disconnect( "Quitting" );
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void chat(String message)
|
|
+ {
|
|
+ Preconditions.checkState( server != null, "Not connected to server" );
|
|
+ server.getCh().write( new Chat( message ) );
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void sendMessage(String message)
|
|
+ {
|
|
+ sendMessage( TextComponent.fromLegacyText( message ) );
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void sendMessages(String... messages)
|
|
+ {
|
|
+ for ( String message : messages )
|
|
+ {
|
|
+ sendMessage( message );
|
|
+ }
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void sendMessage(BaseComponent... message)
|
|
+ {
|
|
+ sendMessage( ChatMessageType.SYSTEM, message );
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void sendMessage(BaseComponent message)
|
|
+ {
|
|
+ sendMessage( ChatMessageType.SYSTEM, message );
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void sendMessage(ChatMessageType position, BaseComponent... message)
|
|
+ {
|
|
+ sendMessage( position, null, message );
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void sendMessage(ChatMessageType position, BaseComponent message)
|
|
+ {
|
|
+ sendMessage( position, (UUID) null, message );
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void sendMessage(UUID sender, BaseComponent... message)
|
|
+ {
|
|
+ sendMessage( ChatMessageType.CHAT, sender, message );
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void sendMessage(UUID sender, BaseComponent message)
|
|
+ {
|
|
+ sendMessage( ChatMessageType.CHAT, sender, message );
|
|
+ }
|
|
+
|
|
+ private void sendMessage(ChatMessageType position, UUID sender, String message)
|
|
+ {
|
|
+ unsafe().sendPacket( new Chat( message, (byte) position.ordinal(), sender ) );
|
|
+ }
|
|
+
|
|
+ private void sendMessage(ChatMessageType position, UUID sender, BaseComponent... message)
|
|
+ {
|
|
+ // transform score components
|
|
+ message = ChatComponentTransformer.getInstance().transform( this, true, message );
|
|
+
|
|
+ if ( position == ChatMessageType.ACTION_BAR && getPendingConnection().getVersion() < ProtocolConstants.MINECRAFT_1_17 )
|
|
+ {
|
|
+ // 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
|
|
+ if ( getPendingConnection().getVersion() <= ProtocolConstants.MINECRAFT_1_10 )
|
|
+ {
|
|
+ sendMessage( position, sender, ComponentSerializer.toString( new TextComponent( BaseComponent.toLegacyText( message ) ) ) );
|
|
+ } else
|
|
+ {
|
|
+ net.md_5.bungee.protocol.packet.Title title = new net.md_5.bungee.protocol.packet.Title();
|
|
+ title.setAction( net.md_5.bungee.protocol.packet.Title.Action.ACTIONBAR );
|
|
+ title.setText( ComponentSerializer.toString( message ) );
|
|
+ unsafe.sendPacket( title );
|
|
+ }
|
|
+ } else
|
|
+ {
|
|
+ sendMessage( position, sender, ComponentSerializer.toString( message ) );
|
|
+ }
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void sendData(String channel, byte[] data)
|
|
+ {
|
|
+ unsafe().sendPacket( new PluginMessage( channel, data, forgeClientHandler.isForgeUser() ) );
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public InetSocketAddress getAddress()
|
|
+ {
|
|
+ return (InetSocketAddress) getSocketAddress();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public SocketAddress getSocketAddress()
|
|
+ {
|
|
+ return ch.getRemoteAddress();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public Collection<String> getGroups()
|
|
+ {
|
|
+ return Collections.unmodifiableCollection( groups );
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void addGroups(String... groups)
|
|
+ {
|
|
+ for ( String group : groups )
|
|
+ {
|
|
+ this.groups.add( group );
|
|
+ for ( String permission : bungee.getConfigurationAdapter().getPermissions( group ) )
|
|
+ {
|
|
+ setPermission( permission, true );
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void removeGroups(String... groups)
|
|
+ {
|
|
+ for ( String group : groups )
|
|
+ {
|
|
+ this.groups.remove( group );
|
|
+ for ( String permission : bungee.getConfigurationAdapter().getPermissions( group ) )
|
|
+ {
|
|
+ setPermission( permission, false );
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean hasPermission(String permission)
|
|
+ {
|
|
+ return bungee.getPluginManager().callEvent( new PermissionCheckEvent( this, permission, permissions.contains( permission ) ) ).hasPermission();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void setPermission(String permission, boolean value)
|
|
+ {
|
|
+ if ( value )
|
|
+ {
|
|
+ permissions.add( permission );
|
|
+ } else
|
|
+ {
|
|
+ permissions.remove( permission );
|
|
+ }
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public Collection<String> getPermissions()
|
|
+ {
|
|
+ return Collections.unmodifiableCollection( permissions );
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public String toString()
|
|
+ {
|
|
+ return name;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public Unsafe unsafe()
|
|
+ {
|
|
+ return unsafe;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public String getUUID()
|
|
+ {
|
|
+ return getPendingConnection().getUUID();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public UUID getUniqueId()
|
|
+ {
|
|
+ return getPendingConnection().getUniqueId();
|
|
+ }
|
|
+
|
|
+ public void setSettings(ClientSettings settings)
|
|
+ {
|
|
+ this.settings = settings;
|
|
+ this.locale = null;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public Locale getLocale()
|
|
+ {
|
|
+ return ( locale == null && settings != null ) ? locale = Locale.forLanguageTag( settings.getLocale().replace( '_', '-' ) ) : locale;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public byte getViewDistance()
|
|
+ {
|
|
+ return ( settings != null ) ? settings.getViewDistance() : 10;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public ProxiedPlayer.ChatMode getChatMode()
|
|
+ {
|
|
+ if ( settings == null )
|
|
+ {
|
|
+ return ProxiedPlayer.ChatMode.SHOWN;
|
|
+ }
|
|
+
|
|
+ switch ( settings.getChatFlags() )
|
|
+ {
|
|
+ default:
|
|
+ case 0:
|
|
+ return ProxiedPlayer.ChatMode.SHOWN;
|
|
+ case 1:
|
|
+ return ProxiedPlayer.ChatMode.COMMANDS_ONLY;
|
|
+ case 2:
|
|
+ return ProxiedPlayer.ChatMode.HIDDEN;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean hasChatColors()
|
|
+ {
|
|
+ return settings == null || settings.isChatColours();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public SkinConfiguration getSkinParts()
|
|
+ {
|
|
+ return ( settings != null ) ? new PlayerSkinConfiguration( settings.getSkinParts() ) : PlayerSkinConfiguration.SKIN_SHOW_ALL;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public ProxiedPlayer.MainHand getMainHand()
|
|
+ {
|
|
+ return ( settings == null || settings.getMainHand() == 1 ) ? ProxiedPlayer.MainHand.RIGHT : ProxiedPlayer.MainHand.LEFT;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean isForgeUser()
|
|
+ {
|
|
+ return forgeClientHandler.isForgeUser();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public Map<String, String> getModList()
|
|
+ {
|
|
+ if ( forgeClientHandler.getClientModList() == null )
|
|
+ {
|
|
+ // Return an empty map, rather than a null, if the client hasn't got any mods,
|
|
+ // or is yet to complete a handshake.
|
|
+ return ImmutableMap.of();
|
|
+ }
|
|
+
|
|
+ return ImmutableMap.copyOf( forgeClientHandler.getClientModList() );
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void setTabHeader(BaseComponent header, BaseComponent footer)
|
|
+ {
|
|
+ header = ChatComponentTransformer.getInstance().transform( this, true, header )[0];
|
|
+ footer = ChatComponentTransformer.getInstance().transform( this, true, footer )[0];
|
|
+
|
|
+ unsafe().sendPacket( new PlayerListHeaderFooter(
|
|
+ ComponentSerializer.toString( header ),
|
|
+ ComponentSerializer.toString( footer )
|
|
+ ) );
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void setTabHeader(BaseComponent[] header, BaseComponent[] footer)
|
|
+ {
|
|
+ header = ChatComponentTransformer.getInstance().transform( this, true, header );
|
|
+ footer = ChatComponentTransformer.getInstance().transform( this, true, footer );
|
|
+
|
|
+ unsafe().sendPacket( new PlayerListHeaderFooter(
|
|
+ ComponentSerializer.toString( header ),
|
|
+ ComponentSerializer.toString( footer )
|
|
+ ) );
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void resetTabHeader()
|
|
+ {
|
|
+ // Mojang did not add a way to remove the header / footer completely, we can only set it to empty
|
|
+ setTabHeader( (BaseComponent) null, null );
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void sendTitle(Title title)
|
|
+ {
|
|
+ title.send( this );
|
|
+ }
|
|
+
|
|
+ public String getExtraDataInHandshake()
|
|
+ {
|
|
+ return this.getPendingConnection().getExtraDataInHandshake();
|
|
+ }
|
|
+
|
|
+ public void setCompressionThreshold(int compressionThreshold)
|
|
+ {
|
|
+ if ( !ch.isClosing() && this.compressionThreshold == -1 && compressionThreshold >= 0 )
|
|
+ {
|
|
+ this.compressionThreshold = compressionThreshold;
|
|
+ unsafe.sendPacket( new SetCompression( compressionThreshold ) );
|
|
+ ch.setCompressionThreshold( compressionThreshold );
|
|
+ }
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean isConnected()
|
|
+ {
|
|
+ return !ch.isClosed();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public Scoreboard getScoreboard()
|
|
+ {
|
|
+ return serverSentScoreboard;
|
|
+ }
|
|
+
|
|
+ // Waterfall start
|
|
+ public boolean isDisableEntityMetadataRewrite() {
|
|
+ return entityRewrite == net.md_5.bungee.entitymap.EntityMap_Dummy.INSTANCE;
|
|
+ }
|
|
+ // Waterfall end
|
|
+}
|
|
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
|
|
index 97c4b210..6082d40c 100644
|
|
--- a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java
|
|
@@ -18,6 +18,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;
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap; // Waterfall
|
|
import java.util.List;
|
|
@@ -184,7 +185,7 @@ public class DownstreamBridge extends PacketHandler
|
|
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) ); // FlameCord - 1.7.x support
|
|
break;
|
|
case 1:
|
|
serverScoreboard.removeObjective( objective.getName() );
|
|
@@ -194,7 +195,7 @@ public class DownstreamBridge extends PacketHandler
|
|
if ( oldObjective != null )
|
|
{
|
|
oldObjective.setValue( objective.getValue() );
|
|
- oldObjective.setType( objective.getType().toString() );
|
|
+ oldObjective.setType( objective.getType() != null ? objective.getType().toString() : null ); // FlameCord - 1.7.x support
|
|
}
|
|
break;
|
|
default:
|
|
@@ -292,16 +293,28 @@ public class DownstreamBridge extends PacketHandler
|
|
|
|
if ( pluginMessage.getTag().equals( con.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_13 ? "minecraft:brand" : "MC|Brand" ) )
|
|
{
|
|
- 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();
|
|
- DefinedPacket.writeString( bungee.getName() + " <- " + serverBrand, brand ); // Waterfall
|
|
- pluginMessage.setData( brand );
|
|
- brand.release();
|
|
+ // FlameCord start - 1.7.x support
|
|
+ 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();
|
|
+ DefinedPacket.writeString(bungee.getName() + " <- " + serverBrand, brand ); // Waterfall
|
|
+ pluginMessage.setData(brand);
|
|
+ brand.release();
|
|
+ } catch (Exception ProtocolHacksSuck)
|
|
+ {
|
|
+ return;
|
|
+ }
|
|
+ } else
|
|
+ {
|
|
+ String serverBrand = new String( pluginMessage.getData(), StandardCharsets.UTF_8);
|
|
+ pluginMessage.setData( ( bungee.getName() + " <- " + serverBrand ).getBytes(StandardCharsets.UTF_8) ); // FlameCord - 1.7.x support
|
|
+ }
|
|
+ // FlameCord end - 1.7.x support
|
|
// 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
|
|
index 4afab05d..f6378e03 100644
|
|
--- a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
|
|
@@ -3,6 +3,9 @@ package net.md_5.bungee.connection;
|
|
import com.google.common.base.Charsets;
|
|
import com.google.common.base.Preconditions;
|
|
import com.google.gson.Gson;
|
|
+import com.google.gson.JsonElement;
|
|
+import com.google.gson.JsonObject;
|
|
+
|
|
import java.math.BigInteger;
|
|
import java.net.InetSocketAddress;
|
|
import java.net.SocketAddress;
|
|
@@ -257,8 +260,23 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
|
@Override
|
|
public void done(ProxyPingEvent pingResult, Throwable error)
|
|
{
|
|
- Gson gson = BungeeCord.getInstance().gson;
|
|
- unsafe.sendPacket( new StatusResponse( gson.toJson( pingResult.getResponse() ) ) );
|
|
+ // FlameCord start - 1.7.x support
|
|
+ Gson gson = handshake.getProtocolVersion() == ProtocolConstants.MINECRAFT_1_7_2 ? BungeeCord.getInstance().gsonLegacy : BungeeCord.getInstance().gson;
|
|
+ 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() ) ) );
|
|
+ }
|
|
+ // FlameCord end - 1.7.x support
|
|
if ( bungee.getConnectionThrottle() != null )
|
|
{
|
|
bungee.getConnectionThrottle().unthrottle( getSocketAddress() );
|
|
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
|
|
index 6df3f3dd..a409d440 100644
|
|
--- a/proxy/src/main/java/net/md_5/bungee/connection/PingHandler.java
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/connection/PingHandler.java
|
|
@@ -16,6 +16,7 @@ import net.md_5.bungee.protocol.MinecraftDecoder;
|
|
import net.md_5.bungee.protocol.MinecraftEncoder;
|
|
import net.md_5.bungee.protocol.PacketWrapper;
|
|
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;
|
|
@@ -65,7 +66,7 @@ public class PingHandler extends PacketHandler
|
|
@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; // FlameCord - 1.7.x support
|
|
ServerPing serverPing = gson.fromJson( statusResponse.getResponse(), ServerPing.class );
|
|
( (BungeeServerInfo) target ).cachePing( serverPing );
|
|
callback.done( serverPing, null );
|
|
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
|
|
index 9537208e..e354032a 100644
|
|
--- a/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java
|
|
@@ -85,7 +85,12 @@ public class UpstreamBridge extends PacketHandler
|
|
} );
|
|
for ( ProxiedPlayer player : con.getServer().getInfo().getPlayers() )
|
|
{
|
|
- player.unsafe().sendPacket( packet );
|
|
+ // FlameCord start - 1.7.x support
|
|
+ if ( ProtocolConstants.isAfterOrEq( player.getPendingConnection().getVersion(), ProtocolConstants.MINECRAFT_1_8 ) )
|
|
+ {
|
|
+ player.unsafe().sendPacket( packet );
|
|
+ }
|
|
+ // FlameCord end - 1.7.x support
|
|
}
|
|
con.getServer().disconnect( "Quitting" );
|
|
}
|
|
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
|
|
index cda6451d..1509071f 100644
|
|
--- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java
|
|
@@ -35,6 +35,12 @@ public abstract class EntityMap
|
|
// Waterfall end
|
|
switch ( version )
|
|
{
|
|
+ // FlameCord start - 1.7.x support
|
|
+ case ProtocolConstants.MINECRAFT_1_7_2:
|
|
+ return EntityMap_1_7_2.INSTANCE;
|
|
+ case ProtocolConstants.MINECRAFT_1_7_6:
|
|
+ return EntityMap_1_7_6.INSTANCE;
|
|
+ // FlameCord end - 1.7.x support
|
|
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
|
|
index 00000000..cdc07dc4
|
|
--- /dev/null
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_7_2.java
|
|
@@ -0,0 +1,102 @@
|
|
+// FlameCord start - 1.7.x support
|
|
+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 );
|
|
+ }
|
|
+}
|
|
+// FlameCord end - 1.7.x support
|
|
\ No newline at end of file
|
|
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
|
|
index 00000000..5ce42f62
|
|
--- /dev/null
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_7_6.java
|
|
@@ -0,0 +1,62 @@
|
|
+// FlameCord start - 1.7.x support
|
|
+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 );
|
|
+ }
|
|
+}
|
|
+// FlameCord end - 1.7.x support
|
|
\ No newline at end of file
|
|
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
|
|
index bea2bbff..caed4384 100644
|
|
--- a/proxy/src/main/java/net/md_5/bungee/forge/ForgeClientHandler.java
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/forge/ForgeClientHandler.java
|
|
@@ -8,6 +8,7 @@ import lombok.Getter;
|
|
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;
|
|
@@ -23,6 +24,12 @@ public class ForgeClientHandler
|
|
@NonNull
|
|
private final UserConnection con;
|
|
|
|
+ // FlameCord start - 1.7.x support
|
|
+ @Getter
|
|
+ @Setter(AccessLevel.PACKAGE)
|
|
+ private boolean forgeOutdated = false;
|
|
+ // FlameCord end - 1.7.x support
|
|
+
|
|
/**
|
|
* The users' mod list.
|
|
*/
|
|
@@ -175,4 +182,21 @@ public class ForgeClientHandler
|
|
{
|
|
return fmlTokenInHandshake || clientModList != null;
|
|
}
|
|
+
|
|
+ // FlameCord start - 1.7.x support
|
|
+ /**
|
|
+ * 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;
|
|
+ }
|
|
+ // FlameCord end - 1.7.x support
|
|
}
|
|
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
|
|
index 5e02f8c8..85bc21b9 100644
|
|
--- 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 );
|
|
+ // FlameCord start - 1.7.x support
|
|
+ // 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 );
|
|
+ }
|
|
+ }
|
|
+ // FlameCord end - 1.7.x support
|
|
}
|
|
|
|
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
|
|
index daf12f74..7d053485 100644
|
|
--- 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<>(); // FlameCord - 1.7.x support
|
|
|
|
public ServerUnique(ProxiedPlayer player)
|
|
{
|
|
@@ -23,10 +25,26 @@ public class ServerUnique extends TabList
|
|
{
|
|
if ( playerListItem.getAction() == PlayerListItem.Action.ADD_PLAYER )
|
|
{
|
|
- uuids.add( item.getUuid() );
|
|
+ // FlameCord start - 1.7.x support
|
|
+ if ( item.getUuid() != null )
|
|
+ {
|
|
+ uuids.add( item.getUuid() );
|
|
+ } else
|
|
+ {
|
|
+ usernames.add( item.getUsername() );
|
|
+ }
|
|
+ // FlameCord end - 1.7.x support
|
|
} else if ( playerListItem.getAction() == PlayerListItem.Action.REMOVE_PLAYER )
|
|
{
|
|
- uuids.remove( item.getUuid() );
|
|
+ // FlameCord start - 1.7.x support
|
|
+ if ( item.getUuid() != null )
|
|
+ {
|
|
+ uuids.remove( item.getUuid() );
|
|
+ } else
|
|
+ {
|
|
+ usernames.remove( item.getUsername() );
|
|
+ }
|
|
+ // FlameCord end - 1.7.x support
|
|
}
|
|
}
|
|
player.unsafe().sendPacket( playerListItem );
|
|
@@ -43,16 +61,46 @@ 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() ]; // FlameCord - 1.7.x support
|
|
int i = 0;
|
|
+
|
|
+ // FlameCord start - 1.7.x support
|
|
+ for ( String username : usernames )
|
|
+ {
|
|
+ PlayerListItem.Item item = items[i++] = new PlayerListItem.Item();
|
|
+ item.setUsername( username );
|
|
+ item.setDisplayName( username );
|
|
+ }
|
|
+ // FlameCord end - 1.7.x support
|
|
+
|
|
for ( UUID uuid : uuids )
|
|
{
|
|
PlayerListItem.Item item = items[i++] = new PlayerListItem.Item();
|
|
item.setUuid( uuid );
|
|
}
|
|
packet.setItems( items );
|
|
- player.unsafe().sendPacket( packet );
|
|
+ // FlameCord start - 1.7.x support
|
|
+ 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 );
|
|
+ }
|
|
+ }
|
|
+ // FlameCord end - 1.7.x support
|
|
uuids.clear();
|
|
+ usernames.clear(); // FlameCord - 1.7.x support
|
|
}
|
|
|
|
@Override
|
|
--
|
|
2.36.0.windows.1
|
|
|