Compare commits

..

No commits in common. "e71767688d81ebff2b913920a04c5a958b57e4d9" and "511017ab35e621f4173e7425c0735aa3c19b3964" have entirely different histories.

23 changed files with 90 additions and 712 deletions

View File

@ -22,7 +22,7 @@
<dependency> <dependency>
<groupId>com.google.code.gson</groupId> <groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId> <artifactId>gson</artifactId>
<version>2.10</version> <version>2.8.9</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -22,7 +22,7 @@
<dependency> <dependency>
<groupId>com.google.code.gson</groupId> <groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId> <artifactId>gson</artifactId>
<version>2.10</version> <version>2.8.9</version>
<scope>compile</scope> <scope>compile</scope>
<optional>true</optional> <optional>true</optional>
</dependency> </dependency>

View File

@ -89,7 +89,7 @@
<dependency> <dependency>
<groupId>com.google.guava</groupId> <groupId>com.google.guava</groupId>
<artifactId>guava</artifactId> <artifactId>guava</artifactId>
<version>31.1-jre</version> <version>31.0.1-jre</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -25,8 +25,6 @@ import net.md_5.bungee.protocol.packet.LoginSuccess;
import net.md_5.bungee.protocol.packet.PingPacket; import net.md_5.bungee.protocol.packet.PingPacket;
import net.md_5.bungee.protocol.packet.PlayerListHeaderFooter; import net.md_5.bungee.protocol.packet.PlayerListHeaderFooter;
import net.md_5.bungee.protocol.packet.PlayerListItem; import net.md_5.bungee.protocol.packet.PlayerListItem;
import net.md_5.bungee.protocol.packet.PlayerListItemRemove;
import net.md_5.bungee.protocol.packet.PlayerListItemUpdate;
import net.md_5.bungee.protocol.packet.PluginMessage; import net.md_5.bungee.protocol.packet.PluginMessage;
import net.md_5.bungee.protocol.packet.Respawn; import net.md_5.bungee.protocol.packet.Respawn;
import net.md_5.bungee.protocol.packet.ScoreboardDisplay; import net.md_5.bungee.protocol.packet.ScoreboardDisplay;
@ -116,14 +114,6 @@ public abstract class AbstractPacketHandler
{ {
} }
public void handle(PlayerListItemRemove playerListItem) throws Exception
{
}
public void handle(PlayerListItemUpdate playerListItem) throws Exception
{
}
public void handle(PlayerListHeaderFooter playerListHeaderFooter) throws Exception public void handle(PlayerListHeaderFooter playerListHeaderFooter) throws Exception
{ {
} }

View File

@ -9,9 +9,6 @@ import java.io.DataInputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.EnumSet;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@ -311,53 +308,6 @@ public abstract class DefinedPacket
} }
} }
public static <E extends Enum<E>> void writeEnumSet(EnumSet<E> enumset, Class<E> oclass, ByteBuf buf)
{
E[] enums = oclass.getEnumConstants();
BitSet bits = new BitSet( enums.length );
for ( int i = 0; i < enums.length; ++i )
{
bits.set( i, enumset.contains( enums[i] ) );
}
writeFixedBitSet( bits, enums.length, buf );
}
public static <E extends Enum<E>> EnumSet<E> readEnumSet(Class<E> oclass, ByteBuf buf)
{
E[] enums = oclass.getEnumConstants();
BitSet bits = readFixedBitSet( enums.length, buf );
EnumSet<E> set = EnumSet.noneOf( oclass );
for ( int i = 0; i < enums.length; ++i )
{
if ( bits.get( i ) )
{
set.add( enums[i] );
}
}
return set;
}
public static BitSet readFixedBitSet(int i, ByteBuf buf)
{
byte[] bits = new byte[ ( i + 8 ) >> 3 ];
buf.readBytes( bits );
return BitSet.valueOf( bits );
}
public static void writeFixedBitSet(BitSet bits, int size, ByteBuf buf)
{
if ( bits.length() > size )
{
throw new OverflowPacketException( "BitSet too large (expected " + size + " got " + bits.size() + ")" );
}
buf.writeBytes( Arrays.copyOf( bits.toByteArray(), ( size + 8 ) >> 3 ) );
}
public void read(ByteBuf buf) public void read(ByteBuf buf)
{ {
throw new UnsupportedOperationException( "Packet must implement read method" ); throw new UnsupportedOperationException( "Packet must implement read method" );

View File

@ -31,8 +31,6 @@ import net.md_5.bungee.protocol.packet.LoginSuccess;
import net.md_5.bungee.protocol.packet.PingPacket; import net.md_5.bungee.protocol.packet.PingPacket;
import net.md_5.bungee.protocol.packet.PlayerListHeaderFooter; import net.md_5.bungee.protocol.packet.PlayerListHeaderFooter;
import net.md_5.bungee.protocol.packet.PlayerListItem; import net.md_5.bungee.protocol.packet.PlayerListItem;
import net.md_5.bungee.protocol.packet.PlayerListItemRemove;
import net.md_5.bungee.protocol.packet.PlayerListItemUpdate;
import net.md_5.bungee.protocol.packet.PluginMessage; import net.md_5.bungee.protocol.packet.PluginMessage;
import net.md_5.bungee.protocol.packet.Respawn; import net.md_5.bungee.protocol.packet.Respawn;
import net.md_5.bungee.protocol.packet.ScoreboardDisplay; import net.md_5.bungee.protocol.packet.ScoreboardDisplay;
@ -83,8 +81,7 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_16_2, 0x1F ), map( ProtocolConstants.MINECRAFT_1_16_2, 0x1F ),
map( ProtocolConstants.MINECRAFT_1_17, 0x21 ), map( ProtocolConstants.MINECRAFT_1_17, 0x21 ),
map( ProtocolConstants.MINECRAFT_1_19, 0x1E ), map( ProtocolConstants.MINECRAFT_1_19, 0x1E ),
map( ProtocolConstants.MINECRAFT_1_19_1, 0x20 ), map( ProtocolConstants.MINECRAFT_1_19_1, 0x20 )
map( ProtocolConstants.MINECRAFT_1_19_3, 0x1F )
); );
TO_CLIENT.registerPacket( TO_CLIENT.registerPacket(
Login.class, Login.class,
@ -97,8 +94,7 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_16_2, 0x24 ), map( ProtocolConstants.MINECRAFT_1_16_2, 0x24 ),
map( ProtocolConstants.MINECRAFT_1_17, 0x26 ), map( ProtocolConstants.MINECRAFT_1_17, 0x26 ),
map( ProtocolConstants.MINECRAFT_1_19, 0x23 ), map( ProtocolConstants.MINECRAFT_1_19, 0x23 ),
map( ProtocolConstants.MINECRAFT_1_19_1, 0x25 ), map( ProtocolConstants.MINECRAFT_1_19_1, 0x25 )
map( ProtocolConstants.MINECRAFT_1_19_3, 0x24 )
); );
TO_CLIENT.registerPacket( Chat.class, TO_CLIENT.registerPacket( Chat.class,
Chat::new, Chat::new,
@ -124,8 +120,7 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_16_2, 0x39 ), map( ProtocolConstants.MINECRAFT_1_16_2, 0x39 ),
map( ProtocolConstants.MINECRAFT_1_17, 0x3D ), map( ProtocolConstants.MINECRAFT_1_17, 0x3D ),
map( ProtocolConstants.MINECRAFT_1_19, 0x3B ), map( ProtocolConstants.MINECRAFT_1_19, 0x3B ),
map( ProtocolConstants.MINECRAFT_1_19_1, 0x3E ), map( ProtocolConstants.MINECRAFT_1_19_1, 0x3E )
map( ProtocolConstants.MINECRAFT_1_19_3, 0x3D )
); );
TO_CLIENT.registerPacket( TO_CLIENT.registerPacket(
BossBar.class, BossBar.class,
@ -149,8 +144,7 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_16_2, 0x32 ), map( ProtocolConstants.MINECRAFT_1_16_2, 0x32 ),
map( ProtocolConstants.MINECRAFT_1_17, 0x36 ), map( ProtocolConstants.MINECRAFT_1_17, 0x36 ),
map( ProtocolConstants.MINECRAFT_1_19, 0x34 ), map( ProtocolConstants.MINECRAFT_1_19, 0x34 ),
map( ProtocolConstants.MINECRAFT_1_19_1, 0x37 ), map( ProtocolConstants.MINECRAFT_1_19_1, 0x37 )
map( ProtocolConstants.MINECRAFT_1_19_3, -1 )
); );
TO_CLIENT.registerPacket( TO_CLIENT.registerPacket(
TabCompleteResponse.class, TabCompleteResponse.class,
@ -162,8 +156,7 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_16, 0x10 ), map( ProtocolConstants.MINECRAFT_1_16, 0x10 ),
map( ProtocolConstants.MINECRAFT_1_16_2, 0x0F ), map( ProtocolConstants.MINECRAFT_1_16_2, 0x0F ),
map( ProtocolConstants.MINECRAFT_1_17, 0x11 ), map( ProtocolConstants.MINECRAFT_1_17, 0x11 ),
map( ProtocolConstants.MINECRAFT_1_19, 0x0E ), map( ProtocolConstants.MINECRAFT_1_19, 0x0E )
map( ProtocolConstants.MINECRAFT_1_19_3, 0x0D )
); );
TO_CLIENT.registerPacket( TO_CLIENT.registerPacket(
ScoreboardObjective.class, ScoreboardObjective.class,
@ -176,8 +169,7 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_14, 0x49 ), map( ProtocolConstants.MINECRAFT_1_14, 0x49 ),
map( ProtocolConstants.MINECRAFT_1_15, 0x4A ), map( ProtocolConstants.MINECRAFT_1_15, 0x4A ),
map( ProtocolConstants.MINECRAFT_1_17, 0x53 ), map( ProtocolConstants.MINECRAFT_1_17, 0x53 ),
map( ProtocolConstants.MINECRAFT_1_19_1, 0x56 ), map( ProtocolConstants.MINECRAFT_1_19_1, 0x56 )
map( ProtocolConstants.MINECRAFT_1_19_3, 0x54 )
); );
TO_CLIENT.registerPacket( TO_CLIENT.registerPacket(
ScoreboardScore.class, ScoreboardScore.class,
@ -190,8 +182,7 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_14, 0x4C ), map( ProtocolConstants.MINECRAFT_1_14, 0x4C ),
map( ProtocolConstants.MINECRAFT_1_15, 0x4D ), map( ProtocolConstants.MINECRAFT_1_15, 0x4D ),
map( ProtocolConstants.MINECRAFT_1_17, 0x56 ), map( ProtocolConstants.MINECRAFT_1_17, 0x56 ),
map( ProtocolConstants.MINECRAFT_1_19_1, 0x59 ), map( ProtocolConstants.MINECRAFT_1_19_1, 0x59 )
map( ProtocolConstants.MINECRAFT_1_19_3, 0x57 )
); );
TO_CLIENT.registerPacket( TO_CLIENT.registerPacket(
ScoreboardDisplay.class, ScoreboardDisplay.class,
@ -204,8 +195,7 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_14, 0x42 ), map( ProtocolConstants.MINECRAFT_1_14, 0x42 ),
map( ProtocolConstants.MINECRAFT_1_15, 0x43 ), map( ProtocolConstants.MINECRAFT_1_15, 0x43 ),
map( ProtocolConstants.MINECRAFT_1_17, 0x4C ), map( ProtocolConstants.MINECRAFT_1_17, 0x4C ),
map( ProtocolConstants.MINECRAFT_1_19_1, 0x4F ), map( ProtocolConstants.MINECRAFT_1_19_1, 0x4F )
map( ProtocolConstants.MINECRAFT_1_19_3, 0x4D )
); );
TO_CLIENT.registerPacket( TO_CLIENT.registerPacket(
Team.class, Team.class,
@ -218,8 +208,7 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_14, 0x4B ), map( ProtocolConstants.MINECRAFT_1_14, 0x4B ),
map( ProtocolConstants.MINECRAFT_1_15, 0x4C ), map( ProtocolConstants.MINECRAFT_1_15, 0x4C ),
map( ProtocolConstants.MINECRAFT_1_17, 0x55 ), map( ProtocolConstants.MINECRAFT_1_17, 0x55 ),
map( ProtocolConstants.MINECRAFT_1_19_1, 0x58 ), map( ProtocolConstants.MINECRAFT_1_19_1, 0x58 )
map( ProtocolConstants.MINECRAFT_1_19_3, 0x56 )
); );
TO_CLIENT.registerPacket( TO_CLIENT.registerPacket(
PluginMessage.class, PluginMessage.class,
@ -233,8 +222,7 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_16_2, 0x17 ), map( ProtocolConstants.MINECRAFT_1_16_2, 0x17 ),
map( ProtocolConstants.MINECRAFT_1_17, 0x18 ), map( ProtocolConstants.MINECRAFT_1_17, 0x18 ),
map( ProtocolConstants.MINECRAFT_1_19, 0x15 ), map( ProtocolConstants.MINECRAFT_1_19, 0x15 ),
map( ProtocolConstants.MINECRAFT_1_19_1, 0x16 ), map( ProtocolConstants.MINECRAFT_1_19_1, 0x16 )
map( ProtocolConstants.MINECRAFT_1_19_3, 0x15 )
); );
TO_CLIENT.registerPacket( TO_CLIENT.registerPacket(
Kick.class, Kick.class,
@ -248,8 +236,7 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_16_2, 0x19 ), map( ProtocolConstants.MINECRAFT_1_16_2, 0x19 ),
map( ProtocolConstants.MINECRAFT_1_17, 0x1A ), map( ProtocolConstants.MINECRAFT_1_17, 0x1A ),
map( ProtocolConstants.MINECRAFT_1_19, 0x17 ), map( ProtocolConstants.MINECRAFT_1_19, 0x17 ),
map( ProtocolConstants.MINECRAFT_1_19_1, 0x19 ), map( ProtocolConstants.MINECRAFT_1_19_1, 0x19 )
map( ProtocolConstants.MINECRAFT_1_19_3, 0x17 )
); );
TO_CLIENT.registerPacket( TO_CLIENT.registerPacket(
Title.class, Title.class,
@ -263,38 +250,33 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_16, 0x4F ), map( ProtocolConstants.MINECRAFT_1_16, 0x4F ),
map( ProtocolConstants.MINECRAFT_1_17, 0x59 ), map( ProtocolConstants.MINECRAFT_1_17, 0x59 ),
map( ProtocolConstants.MINECRAFT_1_18, 0x5A ), map( ProtocolConstants.MINECRAFT_1_18, 0x5A ),
map( ProtocolConstants.MINECRAFT_1_19_1, 0x5D ), map( ProtocolConstants.MINECRAFT_1_19_1, 0x5D )
map( ProtocolConstants.MINECRAFT_1_19_3, 0x5B )
); );
TO_CLIENT.registerPacket( TO_CLIENT.registerPacket(
ClearTitles.class, ClearTitles.class,
ClearTitles::new, ClearTitles::new,
map( ProtocolConstants.MINECRAFT_1_17, 0x10 ), map( ProtocolConstants.MINECRAFT_1_17, 0x10 ),
map( ProtocolConstants.MINECRAFT_1_19, 0x0D ), map( ProtocolConstants.MINECRAFT_1_19, 0x0D )
map( ProtocolConstants.MINECRAFT_1_19_3, 0x0C )
); );
TO_CLIENT.registerPacket( TO_CLIENT.registerPacket(
Subtitle.class, Subtitle.class,
Subtitle::new, Subtitle::new,
map( ProtocolConstants.MINECRAFT_1_17, 0x57 ), map( ProtocolConstants.MINECRAFT_1_17, 0x57 ),
map( ProtocolConstants.MINECRAFT_1_18, 0x58 ), map( ProtocolConstants.MINECRAFT_1_18, 0x58 ),
map( ProtocolConstants.MINECRAFT_1_19_1, 0x5B ), map( ProtocolConstants.MINECRAFT_1_19_1, 0x5B )
map( ProtocolConstants.MINECRAFT_1_19_3, 0x59 )
); );
TO_CLIENT.registerPacket( TO_CLIENT.registerPacket(
TitleTimes.class, TitleTimes.class,
TitleTimes::new, TitleTimes::new,
map( ProtocolConstants.MINECRAFT_1_17, 0x5A ), map( ProtocolConstants.MINECRAFT_1_17, 0x5A ),
map( ProtocolConstants.MINECRAFT_1_18, 0x5B ), map( ProtocolConstants.MINECRAFT_1_18, 0x5B ),
map( ProtocolConstants.MINECRAFT_1_19_1, 0x5E ), map( ProtocolConstants.MINECRAFT_1_19_1, 0x5E )
map( ProtocolConstants.MINECRAFT_1_19_3, 0x5C )
); );
TO_CLIENT.registerPacket( TO_CLIENT.registerPacket(
SystemChat.class, SystemChat.class,
SystemChat::new, SystemChat::new,
map( ProtocolConstants.MINECRAFT_1_19, 0x5F ), map( ProtocolConstants.MINECRAFT_1_19, 0x5F ),
map( ProtocolConstants.MINECRAFT_1_19_1, 0x62 ), map( ProtocolConstants.MINECRAFT_1_19_1, 0x62 )
map( ProtocolConstants.MINECRAFT_1_19_3, 0x60 )
); );
TO_CLIENT.registerPacket( TO_CLIENT.registerPacket(
PlayerListHeaderFooter.class, PlayerListHeaderFooter.class,
@ -311,8 +293,7 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_17, 0x5E ), map( ProtocolConstants.MINECRAFT_1_17, 0x5E ),
map( ProtocolConstants.MINECRAFT_1_18, 0x5F ), map( ProtocolConstants.MINECRAFT_1_18, 0x5F ),
map( ProtocolConstants.MINECRAFT_1_19, 0x60 ), map( ProtocolConstants.MINECRAFT_1_19, 0x60 ),
map( ProtocolConstants.MINECRAFT_1_19_1, 0x63 ), map( ProtocolConstants.MINECRAFT_1_19_1, 0x63 )
map( ProtocolConstants.MINECRAFT_1_19_3, 0x61 )
); );
TO_CLIENT.registerPacket( TO_CLIENT.registerPacket(
EntityStatus.class, EntityStatus.class,
@ -326,8 +307,7 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_16_2, 0x1A ), map( ProtocolConstants.MINECRAFT_1_16_2, 0x1A ),
map( ProtocolConstants.MINECRAFT_1_17, 0x1B ), map( ProtocolConstants.MINECRAFT_1_17, 0x1B ),
map( ProtocolConstants.MINECRAFT_1_19, 0x18 ), map( ProtocolConstants.MINECRAFT_1_19, 0x18 ),
map( ProtocolConstants.MINECRAFT_1_19_1, 0x1A ), map( ProtocolConstants.MINECRAFT_1_19_1, 0x1A )
map( ProtocolConstants.MINECRAFT_1_19_3, 0x19 )
); );
TO_CLIENT.registerPacket( TO_CLIENT.registerPacket(
Commands.class, Commands.class,
@ -337,8 +317,7 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_16, 0x11 ), map( ProtocolConstants.MINECRAFT_1_16, 0x11 ),
map( ProtocolConstants.MINECRAFT_1_16_2, 0x10 ), map( ProtocolConstants.MINECRAFT_1_16_2, 0x10 ),
map( ProtocolConstants.MINECRAFT_1_17, 0x12 ), map( ProtocolConstants.MINECRAFT_1_17, 0x12 ),
map( ProtocolConstants.MINECRAFT_1_19, 0x0F ), map( ProtocolConstants.MINECRAFT_1_19, 0x0F )
map( ProtocolConstants.MINECRAFT_1_19_3, 0x0E )
); );
TO_CLIENT.registerPacket( TO_CLIENT.registerPacket(
GameState.class, GameState.class,
@ -348,8 +327,7 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_16_2, 0x1D ), map( ProtocolConstants.MINECRAFT_1_16_2, 0x1D ),
map( ProtocolConstants.MINECRAFT_1_17, 0x1E ), map( ProtocolConstants.MINECRAFT_1_17, 0x1E ),
map( ProtocolConstants.MINECRAFT_1_19, 0x1B ), map( ProtocolConstants.MINECRAFT_1_19, 0x1B ),
map( ProtocolConstants.MINECRAFT_1_19_1, 0x1D ), map( ProtocolConstants.MINECRAFT_1_19_1, 0x1D )
map( ProtocolConstants.MINECRAFT_1_19_3, 0x1C )
); );
TO_CLIENT.registerPacket( TO_CLIENT.registerPacket(
ViewDistance.class, ViewDistance.class,
@ -359,25 +337,13 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_16, 0x41 ), map( ProtocolConstants.MINECRAFT_1_16, 0x41 ),
map( ProtocolConstants.MINECRAFT_1_17, 0x4A ), map( ProtocolConstants.MINECRAFT_1_17, 0x4A ),
map( ProtocolConstants.MINECRAFT_1_19, 0x49 ), map( ProtocolConstants.MINECRAFT_1_19, 0x49 ),
map( ProtocolConstants.MINECRAFT_1_19_1, 0x4C ), map( ProtocolConstants.MINECRAFT_1_19_1, 0x4C )
map( ProtocolConstants.MINECRAFT_1_19_3, 0x4B )
); );
TO_CLIENT.registerPacket( TO_CLIENT.registerPacket(
ServerData.class, ServerData.class,
ServerData::new, ServerData::new,
map( ProtocolConstants.MINECRAFT_1_19, 0x3F ), map( ProtocolConstants.MINECRAFT_1_19, 0x3F ),
map( ProtocolConstants.MINECRAFT_1_19_1, 0x42 ), map( ProtocolConstants.MINECRAFT_1_19_1, 0x42 )
map( ProtocolConstants.MINECRAFT_1_19_3, 0x41 )
);
TO_CLIENT.registerPacket(
PlayerListItemRemove.class,
PlayerListItemRemove::new,
map( ProtocolConstants.MINECRAFT_1_19_3, 0x35 )
);
TO_CLIENT.registerPacket(
PlayerListItemUpdate.class,
PlayerListItemUpdate::new,
map( ProtocolConstants.MINECRAFT_1_19_3, 0x36 )
); );
TO_SERVER.registerPacket( TO_SERVER.registerPacket(
@ -392,8 +358,7 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_16, 0x10 ), map( ProtocolConstants.MINECRAFT_1_16, 0x10 ),
map( ProtocolConstants.MINECRAFT_1_17, 0x0F ), map( ProtocolConstants.MINECRAFT_1_17, 0x0F ),
map( ProtocolConstants.MINECRAFT_1_19, 0x11 ), map( ProtocolConstants.MINECRAFT_1_19, 0x11 ),
map( ProtocolConstants.MINECRAFT_1_19_1, 0x12 ), map( ProtocolConstants.MINECRAFT_1_19_1, 0x12 )
map( ProtocolConstants.MINECRAFT_1_19_3, 0x11 )
); );
TO_SERVER.registerPacket( Chat.class, TO_SERVER.registerPacket( Chat.class,
Chat::new, Chat::new,
@ -426,8 +391,7 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_13, 0x05 ), map( ProtocolConstants.MINECRAFT_1_13, 0x05 ),
map( ProtocolConstants.MINECRAFT_1_14, 0x06 ), map( ProtocolConstants.MINECRAFT_1_14, 0x06 ),
map( ProtocolConstants.MINECRAFT_1_19, 0x08 ), map( ProtocolConstants.MINECRAFT_1_19, 0x08 ),
map( ProtocolConstants.MINECRAFT_1_19_1, 0x09 ), map( ProtocolConstants.MINECRAFT_1_19_1, 0x09 )
map( ProtocolConstants.MINECRAFT_1_19_3, 0x08 )
); );
TO_SERVER.registerPacket( TO_SERVER.registerPacket(
ClientSettings.class, ClientSettings.class,
@ -438,8 +402,7 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_12_1, 0x04 ), map( ProtocolConstants.MINECRAFT_1_12_1, 0x04 ),
map( ProtocolConstants.MINECRAFT_1_14, 0x05 ), map( ProtocolConstants.MINECRAFT_1_14, 0x05 ),
map( ProtocolConstants.MINECRAFT_1_19, 0x07 ), map( ProtocolConstants.MINECRAFT_1_19, 0x07 ),
map( ProtocolConstants.MINECRAFT_1_19_1, 0x08 ), map( ProtocolConstants.MINECRAFT_1_19_1, 0x08 )
map( ProtocolConstants.MINECRAFT_1_19_3, 0x07 )
); );
TO_SERVER.registerPacket( TO_SERVER.registerPacket(
PluginMessage.class, PluginMessage.class,
@ -452,8 +415,7 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_14, 0x0B ), map( ProtocolConstants.MINECRAFT_1_14, 0x0B ),
map( ProtocolConstants.MINECRAFT_1_17, 0x0A ), map( ProtocolConstants.MINECRAFT_1_17, 0x0A ),
map( ProtocolConstants.MINECRAFT_1_19, 0x0C ), map( ProtocolConstants.MINECRAFT_1_19, 0x0C ),
map( ProtocolConstants.MINECRAFT_1_19_1, 0x0D ), map( ProtocolConstants.MINECRAFT_1_19_1, 0x0D )
map( ProtocolConstants.MINECRAFT_1_19_3, 0x0C )
); );
} }
}, },

View File

@ -40,7 +40,6 @@ public class ProtocolConstants
public static final int MINECRAFT_1_18_2 = 758; public static final int MINECRAFT_1_18_2 = 758;
public static final int MINECRAFT_1_19 = 759; public static final int MINECRAFT_1_19 = 759;
public static final int MINECRAFT_1_19_1 = 760; public static final int MINECRAFT_1_19_1 = 760;
public static final int MINECRAFT_1_19_3 = 761;
public static final List<String> SUPPORTED_VERSIONS; public static final List<String> SUPPORTED_VERSIONS;
public static final List<Integer> SUPPORTED_VERSION_IDS; public static final List<Integer> SUPPORTED_VERSION_IDS;
@ -93,8 +92,7 @@ public class ProtocolConstants
ProtocolConstants.MINECRAFT_1_18, ProtocolConstants.MINECRAFT_1_18,
ProtocolConstants.MINECRAFT_1_18_2, ProtocolConstants.MINECRAFT_1_18_2,
ProtocolConstants.MINECRAFT_1_19, ProtocolConstants.MINECRAFT_1_19,
ProtocolConstants.MINECRAFT_1_19_1, ProtocolConstants.MINECRAFT_1_19_1
ProtocolConstants.MINECRAFT_1_19_3
); );
if ( SNAPSHOT_SUPPORT ) if ( SNAPSHOT_SUPPORT )

View File

@ -1,39 +0,0 @@
package net.md_5.bungee.protocol;
import io.netty.buffer.ByteBuf;
import java.util.BitSet;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class SeenMessages extends DefinedPacket
{
private int offset;
private BitSet acknowledged;
@Override
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
{
offset = DefinedPacket.readVarInt( buf );
acknowledged = DefinedPacket.readFixedBitSet( 20, buf );
}
@Override
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
{
DefinedPacket.writeVarInt( offset, buf );
DefinedPacket.writeFixedBitSet( acknowledged, 20, buf );
}
@Override
public void handle(AbstractPacketHandler handler) throws Exception
{
throw new UnsupportedOperationException( "Not supported." );
}
}

View File

@ -9,7 +9,6 @@ import net.md_5.bungee.protocol.AbstractPacketHandler;
import net.md_5.bungee.protocol.ChatChain; import net.md_5.bungee.protocol.ChatChain;
import net.md_5.bungee.protocol.DefinedPacket; import net.md_5.bungee.protocol.DefinedPacket;
import net.md_5.bungee.protocol.ProtocolConstants; import net.md_5.bungee.protocol.ProtocolConstants;
import net.md_5.bungee.protocol.SeenMessages;
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@ -24,7 +23,6 @@ public class ClientChat extends DefinedPacket
private byte[] signature; private byte[] signature;
private boolean signedPreview; private boolean signedPreview;
private ChatChain chain; private ChatChain chain;
private SeenMessages seenMessages;
@Override @Override
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
@ -32,27 +30,9 @@ public class ClientChat extends DefinedPacket
message = readString( buf, 256 ); message = readString( buf, 256 );
timestamp = buf.readLong(); timestamp = buf.readLong();
salt = buf.readLong(); salt = buf.readLong();
signature = readArray( buf );
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_3 ) signedPreview = buf.readBoolean();
{ if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_1 )
if ( buf.readBoolean() )
{
signature = new byte[ 256 ];
buf.readBytes( signature );
}
} else
{
signature = readArray( buf );
}
if ( protocolVersion < ProtocolConstants.MINECRAFT_1_19_3 )
{
signedPreview = buf.readBoolean();
}
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_3 )
{
seenMessages = new SeenMessages();
seenMessages.read( buf, direction, protocolVersion );
} else if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_1 )
{ {
chain = new ChatChain(); chain = new ChatChain();
chain.read( buf, direction, protocolVersion ); chain.read( buf, direction, protocolVersion );
@ -65,25 +45,9 @@ public class ClientChat extends DefinedPacket
writeString( message, buf ); writeString( message, buf );
buf.writeLong( timestamp ); buf.writeLong( timestamp );
buf.writeLong( salt ); buf.writeLong( salt );
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_3 ) writeArray( signature, buf );
{ buf.writeBoolean( signedPreview );
buf.writeBoolean( signature != null ); if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_1 )
if ( signature != null )
{
buf.writeBytes( signature );
}
} else
{
writeArray( signature, buf );
}
if ( protocolVersion < ProtocolConstants.MINECRAFT_1_19_3 )
{
buf.writeBoolean( signedPreview );
}
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_3 )
{
seenMessages.write( buf, direction, protocolVersion );
} else if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_1 )
{ {
chain.write( buf, direction, protocolVersion ); chain.write( buf, direction, protocolVersion );
} }

View File

@ -12,7 +12,6 @@ import net.md_5.bungee.protocol.AbstractPacketHandler;
import net.md_5.bungee.protocol.ChatChain; import net.md_5.bungee.protocol.ChatChain;
import net.md_5.bungee.protocol.DefinedPacket; import net.md_5.bungee.protocol.DefinedPacket;
import net.md_5.bungee.protocol.ProtocolConstants; import net.md_5.bungee.protocol.ProtocolConstants;
import net.md_5.bungee.protocol.SeenMessages;
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@ -27,7 +26,6 @@ public class ClientCommand extends DefinedPacket
private Map<String, byte[]> signatures; private Map<String, byte[]> signatures;
private boolean signedPreview; private boolean signedPreview;
private ChatChain chain; private ChatChain chain;
private SeenMessages seenMessages;
@Override @Override
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
@ -41,29 +39,11 @@ public class ClientCommand extends DefinedPacket
signatures = new HashMap<>( cnt ); signatures = new HashMap<>( cnt );
for ( int i = 0; i < cnt; i++ ) for ( int i = 0; i < cnt; i++ )
{ {
String name = readString( buf, 16 ); signatures.put( readString( buf, 16 ), readArray( buf ) );
byte[] signature;
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_3 )
{
signature = new byte[ 256 ];
buf.readBytes( signature );
} else
{
signature = readArray( buf );
}
signatures.put( name, signature );
} }
if ( protocolVersion < ProtocolConstants.MINECRAFT_1_19_3 ) signedPreview = buf.readBoolean();
{ if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_1 )
signedPreview = buf.readBoolean();
}
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_3 )
{
seenMessages = new SeenMessages();
seenMessages.read( buf, direction, protocolVersion );
} else if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_1 )
{ {
chain = new ChatChain(); chain = new ChatChain();
chain.read( buf, direction, protocolVersion ); chain.read( buf, direction, protocolVersion );
@ -81,23 +61,11 @@ public class ClientCommand extends DefinedPacket
for ( Map.Entry<String, byte[]> entry : signatures.entrySet() ) for ( Map.Entry<String, byte[]> entry : signatures.entrySet() )
{ {
writeString( entry.getKey(), buf ); writeString( entry.getKey(), buf );
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_3 ) writeArray( entry.getValue(), buf );
{
buf.writeBytes( entry.getValue() );
} else
{
writeArray( entry.getValue(), buf );
}
} }
if ( protocolVersion < ProtocolConstants.MINECRAFT_1_19_3 ) buf.writeBoolean( signedPreview );
{ if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_1 )
buf.writeBoolean( signedPreview );
}
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_3 )
{
seenMessages.write( buf, direction, protocolVersion );
} else if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_1 )
{ {
chain.write( buf, direction, protocolVersion ); chain.write( buf, direction, protocolVersion );
} }

View File

@ -23,11 +23,13 @@ import com.mojang.brigadier.tree.LiteralCommandNode;
import com.mojang.brigadier.tree.RootCommandNode; import com.mojang.brigadier.tree.RootCommandNode;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import java.util.ArrayDeque; import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Deque; import java.util.Deque;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
@ -307,8 +309,7 @@ public class Commands extends DefinedPacket
{ {
private static final Map<String, ArgumentSerializer> PROVIDERS = new HashMap<>(); private static final Map<String, ArgumentSerializer> PROVIDERS = new HashMap<>();
private static final ArgumentSerializer[] IDS_1_19; private static final List<ArgumentSerializer> PROVIDER_LIST = new ArrayList<>();
private static final ArgumentSerializer[] IDS_1_19_3;
private static final Map<Class<?>, ProperArgumentSerializer<?>> PROPER_PROVIDERS = new HashMap<>(); private static final Map<Class<?>, ProperArgumentSerializer<?>> PROPER_PROVIDERS = new HashMap<>();
// //
private static final ArgumentSerializer<Void> VOID = new ArgumentSerializer<Void>() private static final ArgumentSerializer<Void> VOID = new ArgumentSerializer<Void>()
@ -574,124 +575,13 @@ public class Commands extends DefinedPacket
register( "minecraft:template_rotation", VOID ); // 1.19 register( "minecraft:template_rotation", VOID ); // 1.19
register( "minecraft:uuid", VOID ); // 1.16 register( "minecraft:uuid", VOID ); // 1.16
register( "minecraft:gamemode", VOID ); // 1.19.3
register( "minecraft:resource_or_tag_key", RAW_STRING ); // 1.19.3
register( "minecraft:resource_key", RAW_STRING ); // 1.19.3
register( "minecraft:nbt", VOID ); // 1.13 // removed register( "minecraft:nbt", VOID ); // 1.13 // removed
IDS_1_19 = new ArgumentSerializer[]
{
get( "brigadier:bool" ),
get( "brigadier:float" ),
get( "brigadier:double" ),
get( "brigadier:integer" ),
get( "brigadier:long" ),
get( "brigadier:string" ),
get( "minecraft:entity" ),
get( "minecraft:game_profile" ),
get( "minecraft:block_pos" ),
get( "minecraft:column_pos" ),
get( "minecraft:vec3" ),
get( "minecraft:vec2" ),
get( "minecraft:block_state" ),
get( "minecraft:block_predicate" ),
get( "minecraft:item_stack" ),
get( "minecraft:item_predicate" ),
get( "minecraft:color" ),
get( "minecraft:component" ),
get( "minecraft:message" ),
get( "minecraft:nbt_compound_tag" ),
get( "minecraft:nbt_tag" ),
get( "minecraft:nbt_path" ),
get( "minecraft:objective" ),
get( "minecraft:objective_criteria" ),
get( "minecraft:operation" ),
get( "minecraft:particle" ),
get( "minecraft:angle" ),
get( "minecraft:rotation" ),
get( "minecraft:scoreboard_slot" ),
get( "minecraft:score_holder" ),
get( "minecraft:swizzle" ),
get( "minecraft:team" ),
get( "minecraft:item_slot" ),
get( "minecraft:resource_location" ),
get( "minecraft:mob_effect" ),
get( "minecraft:function" ),
get( "minecraft:entity_anchor" ),
get( "minecraft:int_range" ),
get( "minecraft:float_range" ),
get( "minecraft:item_enchantment" ),
get( "minecraft:entity_summon" ),
get( "minecraft:dimension" ),
get( "minecraft:time" ),
get( "minecraft:resource_or_tag" ),
get( "minecraft:resource" ),
get( "minecraft:template_mirror" ),
get( "minecraft:template_rotation" ),
get( "minecraft:uuid" )
};
IDS_1_19_3 = new ArgumentSerializer[]
{
get( "brigadier:bool" ),
get( "brigadier:float" ),
get( "brigadier:double" ),
get( "brigadier:integer" ),
get( "brigadier:long" ),
get( "brigadier:string" ),
get( "minecraft:entity" ),
get( "minecraft:game_profile" ),
get( "minecraft:block_pos" ),
get( "minecraft:column_pos" ),
get( "minecraft:vec3" ),
get( "minecraft:vec2" ),
get( "minecraft:block_state" ),
get( "minecraft:block_predicate" ),
get( "minecraft:item_stack" ),
get( "minecraft:item_predicate" ),
get( "minecraft:color" ),
get( "minecraft:component" ),
get( "minecraft:message" ),
get( "minecraft:nbt_compound_tag" ),
get( "minecraft:nbt_tag" ),
get( "minecraft:nbt_path" ),
get( "minecraft:objective" ),
get( "minecraft:objective_criteria" ),
get( "minecraft:operation" ),
get( "minecraft:particle" ),
get( "minecraft:angle" ),
get( "minecraft:rotation" ),
get( "minecraft:scoreboard_slot" ),
get( "minecraft:score_holder" ),
get( "minecraft:swizzle" ),
get( "minecraft:team" ),
get( "minecraft:item_slot" ),
get( "minecraft:resource_location" ),
get( "minecraft:function" ),
get( "minecraft:entity_anchor" ),
get( "minecraft:int_range" ),
get( "minecraft:float_range" ),
get( "minecraft:dimension" ),
get( "minecraft:gamemode" ),
get( "minecraft:time" ),
get( "minecraft:resource_or_tag" ),
get( "minecraft:resource_or_tag_key" ),
get( "minecraft:resource" ),
get( "minecraft:resource_key" ),
get( "minecraft:template_mirror" ),
get( "minecraft:template_rotation" ),
get( "minecraft:uuid" )
};
} }
private static void register(String name, ArgumentSerializer serializer) private static void register(String name, ArgumentSerializer serializer)
{ {
PROVIDERS.put( name, serializer ); PROVIDERS.put( name, serializer );
} PROVIDER_LIST.add( serializer );
private static ArgumentSerializer get(String name)
{
return PROVIDERS.get( name );
} }
private static ArgumentType<?> read(ByteBuf buf, int protocolVersion) private static ArgumentType<?> read(ByteBuf buf, int protocolVersion)
@ -702,14 +592,7 @@ public class Commands extends DefinedPacket
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19 ) if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19 )
{ {
key = readVarInt( buf ); key = readVarInt( buf );
reader = PROVIDER_LIST.get( (Integer) key );
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_3 )
{
reader = IDS_1_19_3[(Integer) key];
} else
{
reader = IDS_1_19[(Integer) key];
}
} else } else
{ {
key = readString( buf ); key = readString( buf );

View File

@ -23,7 +23,7 @@ public class EncryptionResponse extends DefinedPacket
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
{ {
sharedSecret = readArray( buf, 128 ); sharedSecret = readArray( buf, 128 );
if ( protocolVersion < ProtocolConstants.MINECRAFT_1_19 || protocolVersion >= ProtocolConstants.MINECRAFT_1_19_3 || buf.readBoolean() ) if ( protocolVersion < ProtocolConstants.MINECRAFT_1_19 || buf.readBoolean() )
{ {
verifyToken = readArray( buf, 128 ); verifyToken = readArray( buf, 128 );
} else } else
@ -38,7 +38,7 @@ public class EncryptionResponse extends DefinedPacket
writeArray( sharedSecret, buf ); writeArray( sharedSecret, buf );
if ( verifyToken != null ) if ( verifyToken != null )
{ {
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19 && protocolVersion <= ProtocolConstants.MINECRAFT_1_19_3 ) if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19 )
{ {
buf.writeBoolean( true ); buf.writeBoolean( true );
} }

View File

@ -26,7 +26,7 @@ public class LoginRequest extends DefinedPacket
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
{ {
data = readString( buf, 16 ); data = readString( buf, 16 );
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19 && protocolVersion < ProtocolConstants.MINECRAFT_1_19_3 ) if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19 )
{ {
publicKey = readPublicKey( buf ); publicKey = readPublicKey( buf );
} }
@ -43,7 +43,7 @@ public class LoginRequest extends DefinedPacket
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
{ {
writeString( data, buf ); writeString( data, buf );
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19 && protocolVersion < ProtocolConstants.MINECRAFT_1_19_3 ) if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19 )
{ {
writePublicKey( publicKey, buf ); writePublicKey( publicKey, buf );
} }

View File

@ -123,26 +123,21 @@ public class PlayerListItem extends DefinedPacket
{ {
// ALL // ALL
UUID uuid; private UUID uuid;
// ADD_PLAYER // ADD_PLAYER
String username; private String username;
Property[] properties; private Property[] properties;
private PlayerPublicKey publicKey;
UUID chatSessionId;
PlayerPublicKey publicKey;
// UPDATE_LISTED
Boolean listed;
// ADD_PLAYER & UPDATE_GAMEMODE // ADD_PLAYER & UPDATE_GAMEMODE
Integer gamemode; private int gamemode;
// ADD_PLAYER & UPDATE_LATENCY // ADD_PLAYER & UPDATE_LATENCY
Integer ping; private int ping;
// ADD_PLAYER & UPDATE_DISPLAY_NAME // ADD_PLAYER & UPDATE_DISPLAY_NAME
String displayName; private String displayName;
} }
} }

View File

@ -1,45 +0,0 @@
package net.md_5.bungee.protocol.packet;
import io.netty.buffer.ByteBuf;
import java.util.UUID;
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
@EqualsAndHashCode(callSuper = false)
public class PlayerListItemRemove extends DefinedPacket
{
private UUID[] uuids;
@Override
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
{
uuids = new UUID[ DefinedPacket.readVarInt( buf ) ];
for ( int i = 0; i < uuids.length; i++ )
{
uuids[i] = DefinedPacket.readUUID( buf );
}
}
@Override
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
{
DefinedPacket.writeVarInt( uuids.length, buf );
for ( UUID uuid : uuids )
{
DefinedPacket.writeUUID( uuid, buf );
}
}
@Override
public void handle(AbstractPacketHandler handler) throws Exception
{
handler.handle( this );
}
}

View File

@ -1,133 +0,0 @@
package net.md_5.bungee.protocol.packet;
import io.netty.buffer.ByteBuf;
import java.util.EnumSet;
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.PlayerPublicKey;
import net.md_5.bungee.protocol.ProtocolConstants;
import net.md_5.bungee.protocol.packet.PlayerListItem.Item;
@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class PlayerListItemUpdate extends DefinedPacket
{
private EnumSet<Action> actions;
private Item[] items;
@Override
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
{
actions = readEnumSet( PlayerListItemUpdate.Action.class, buf );
items = new Item[ DefinedPacket.readVarInt( buf ) ];
for ( int i = 0; i < items.length; i++ )
{
Item item = items[i] = new Item();
item.setUuid( DefinedPacket.readUUID( buf ) );
for ( Action action : actions )
{
switch ( action )
{
case ADD_PLAYER:
item.username = DefinedPacket.readString( buf );
item.properties = DefinedPacket.readProperties( buf );
break;
case INITIALIZE_CHAT:
if ( buf.readBoolean() )
{
item.chatSessionId = readUUID( buf );
item.publicKey = new PlayerPublicKey( buf.readLong(), readArray( buf, 512 ), readArray( buf, 4096 ) );
}
break;
case UPDATE_GAMEMODE:
item.gamemode = DefinedPacket.readVarInt( buf );
break;
case UPDATE_LISTED:
item.listed = buf.readBoolean();
break;
case UPDATE_LATENCY:
item.ping = DefinedPacket.readVarInt( buf );
break;
case UPDATE_DISPLAY_NAME:
if ( buf.readBoolean() )
{
item.displayName = DefinedPacket.readString( buf );
}
break;
}
}
}
}
@Override
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
{
DefinedPacket.writeEnumSet( actions, PlayerListItemUpdate.Action.class, buf );
DefinedPacket.writeVarInt( items.length, buf );
for ( Item item : items )
{
DefinedPacket.writeUUID( item.uuid, buf );
for ( Action action : actions )
{
switch ( action )
{
case ADD_PLAYER:
DefinedPacket.writeString( item.username, buf );
DefinedPacket.writeProperties( item.properties, buf );
break;
case INITIALIZE_CHAT:
buf.writeBoolean( item.chatSessionId != null );
if ( item.chatSessionId != null )
{
writeUUID( item.chatSessionId, buf );
buf.writeLong( item.publicKey.getExpiry() );
writeArray( item.publicKey.getKey(), buf );
writeArray( item.publicKey.getSignature(), buf );
}
break;
case UPDATE_GAMEMODE:
DefinedPacket.writeVarInt( item.gamemode, buf );
break;
case UPDATE_LISTED:
buf.writeBoolean( item.listed );
break;
case UPDATE_LATENCY:
DefinedPacket.writeVarInt( item.ping, buf );
break;
case UPDATE_DISPLAY_NAME:
buf.writeBoolean( item.displayName != null );
if ( item.displayName != null )
{
DefinedPacket.writeString( item.displayName, buf );
}
break;
}
}
}
}
@Override
public void handle(AbstractPacketHandler handler) throws Exception
{
handler.handle( this );
}
public static enum Action
{
ADD_PLAYER,
INITIALIZE_CHAT,
UPDATE_GAMEMODE,
UPDATE_LISTED,
UPDATE_LATENCY,
UPDATE_DISPLAY_NAME;
}
}

View File

@ -33,10 +33,7 @@ public class ServerData extends DefinedPacket
icon = readString( buf ); icon = readString( buf );
} }
if ( protocolVersion < ProtocolConstants.MINECRAFT_1_19_3 ) preview = buf.readBoolean();
{
preview = buf.readBoolean();
}
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_1 ) if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_1 )
{ {
@ -65,10 +62,7 @@ public class ServerData extends DefinedPacket
buf.writeBoolean( false ); buf.writeBoolean( false );
} }
if ( protocolVersion < ProtocolConstants.MINECRAFT_1_19_3 ) buf.writeBoolean( preview );
{
buf.writeBoolean( preview );
}
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_1 ) if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_1 )
{ {

View File

@ -54,8 +54,6 @@ import net.md_5.bungee.protocol.packet.Commands;
import net.md_5.bungee.protocol.packet.KeepAlive; import net.md_5.bungee.protocol.packet.KeepAlive;
import net.md_5.bungee.protocol.packet.Kick; import net.md_5.bungee.protocol.packet.Kick;
import net.md_5.bungee.protocol.packet.PlayerListItem; import net.md_5.bungee.protocol.packet.PlayerListItem;
import net.md_5.bungee.protocol.packet.PlayerListItemRemove;
import net.md_5.bungee.protocol.packet.PlayerListItemUpdate;
import net.md_5.bungee.protocol.packet.PluginMessage; import net.md_5.bungee.protocol.packet.PluginMessage;
import net.md_5.bungee.protocol.packet.Respawn; import net.md_5.bungee.protocol.packet.Respawn;
import net.md_5.bungee.protocol.packet.ScoreboardDisplay; import net.md_5.bungee.protocol.packet.ScoreboardDisplay;
@ -155,20 +153,6 @@ public class DownstreamBridge extends PacketHandler
throw CancelSendSignal.INSTANCE; // Always throw because of profile rewriting throw CancelSendSignal.INSTANCE; // Always throw because of profile rewriting
} }
@Override
public void handle(PlayerListItemRemove playerList) throws Exception
{
con.getTabListHandler().onUpdate( TabList.rewrite( playerList ) );
throw CancelSendSignal.INSTANCE; // Always throw because of profile rewriting
}
@Override
public void handle(PlayerListItemUpdate playerList) throws Exception
{
con.getTabListHandler().onUpdate( TabList.rewrite( playerList ) );
throw CancelSendSignal.INSTANCE; // Always throw because of profile rewriting
}
@Override @Override
public void handle(ScoreboardObjective objective) throws Exception public void handle(ScoreboardObjective objective) throws Exception
{ {

View File

@ -383,7 +383,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
return; return;
} }
if ( BungeeCord.getInstance().config.isEnforceSecureProfile() && getVersion() < ProtocolConstants.MINECRAFT_1_19_3 ) if ( BungeeCord.getInstance().config.isEnforceSecureProfile() )
{ {
PlayerPublicKey publicKey = loginRequest.getPublicKey(); PlayerPublicKey publicKey = loginRequest.getPublicKey();
if ( publicKey == null ) if ( publicKey == null )
@ -522,7 +522,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
if ( BungeeCord.getInstance().config.isEnforceSecureProfile() ) if ( BungeeCord.getInstance().config.isEnforceSecureProfile() )
{ {
if ( getVersion() >= ProtocolConstants.MINECRAFT_1_19_1 && getVersion() < ProtocolConstants.MINECRAFT_1_19_3 ) if ( getVersion() >= ProtocolConstants.MINECRAFT_1_19_1 )
{ {
boolean secure = false; boolean secure = false;
try try

View File

@ -8,7 +8,6 @@ import io.netty.channel.Channel;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.UUID;
import net.md_5.bungee.BungeeCord; import net.md_5.bungee.BungeeCord;
import net.md_5.bungee.ServerConnection.KeepAliveData; import net.md_5.bungee.ServerConnection.KeepAliveData;
import net.md_5.bungee.UserConnection; import net.md_5.bungee.UserConnection;
@ -32,7 +31,6 @@ import net.md_5.bungee.protocol.packet.ClientCommand;
import net.md_5.bungee.protocol.packet.ClientSettings; import net.md_5.bungee.protocol.packet.ClientSettings;
import net.md_5.bungee.protocol.packet.KeepAlive; import net.md_5.bungee.protocol.packet.KeepAlive;
import net.md_5.bungee.protocol.packet.PlayerListItem; import net.md_5.bungee.protocol.packet.PlayerListItem;
import net.md_5.bungee.protocol.packet.PlayerListItemRemove;
import net.md_5.bungee.protocol.packet.PluginMessage; import net.md_5.bungee.protocol.packet.PluginMessage;
import net.md_5.bungee.protocol.packet.TabCompleteRequest; import net.md_5.bungee.protocol.packet.TabCompleteRequest;
import net.md_5.bungee.protocol.packet.TabCompleteResponse; import net.md_5.bungee.protocol.packet.TabCompleteResponse;
@ -77,30 +75,17 @@ public class UpstreamBridge extends PacketHandler
// TODO: This should only done with server_unique // TODO: This should only done with server_unique
// tab list (which is the only one supported // tab list (which is the only one supported
// currently) // currently)
PlayerListItem oldPacket = new PlayerListItem(); PlayerListItem packet = new PlayerListItem();
oldPacket.setAction( PlayerListItem.Action.REMOVE_PLAYER ); packet.setAction( PlayerListItem.Action.REMOVE_PLAYER );
PlayerListItem.Item item = new PlayerListItem.Item(); PlayerListItem.Item item = new PlayerListItem.Item();
item.setUuid( con.getUniqueId() ); item.setUuid( con.getUniqueId() );
oldPacket.setItems( new PlayerListItem.Item[] packet.setItems( new PlayerListItem.Item[]
{ {
item item
} ); } );
PlayerListItemRemove newPacket = new PlayerListItemRemove();
newPacket.setUuids( new UUID[]
{
con.getUniqueId()
} );
for ( ProxiedPlayer player : con.getServer().getInfo().getPlayers() ) for ( ProxiedPlayer player : con.getServer().getInfo().getPlayers() )
{ {
if ( player.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_19_3 ) player.unsafe().sendPacket( packet );
{
player.unsafe().sendPacket( newPacket );
} else
{
player.unsafe().sendPacket( oldPacket );
}
} }
con.getServer().disconnect( "Quitting" ); con.getServer().disconnect( "Quitting" );
} }

View File

@ -77,7 +77,6 @@ public abstract class EntityMap
case ProtocolConstants.MINECRAFT_1_19: case ProtocolConstants.MINECRAFT_1_19:
return EntityMap_1_16_2.INSTANCE_1_19; return EntityMap_1_16_2.INSTANCE_1_19;
case ProtocolConstants.MINECRAFT_1_19_1: case ProtocolConstants.MINECRAFT_1_19_1:
case ProtocolConstants.MINECRAFT_1_19_3:
return EntityMap_1_16_2.INSTANCE_1_19_1; return EntityMap_1_16_2.INSTANCE_1_19_1;
} }
throw new RuntimeException( "Version " + version + " has no entity map" ); throw new RuntimeException( "Version " + version + " has no entity map" );

View File

@ -4,10 +4,7 @@ import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
import java.util.UUID; import java.util.UUID;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.protocol.ProtocolConstants;
import net.md_5.bungee.protocol.packet.PlayerListItem; import net.md_5.bungee.protocol.packet.PlayerListItem;
import net.md_5.bungee.protocol.packet.PlayerListItemRemove;
import net.md_5.bungee.protocol.packet.PlayerListItemUpdate;
public class ServerUnique extends TabList public class ServerUnique extends TabList
{ {
@ -35,32 +32,6 @@ public class ServerUnique extends TabList
player.unsafe().sendPacket( playerListItem ); player.unsafe().sendPacket( playerListItem );
} }
@Override
public void onUpdate(PlayerListItemRemove playerListItem)
{
for ( UUID uuid : playerListItem.getUuids() )
{
uuids.remove( uuid );
}
player.unsafe().sendPacket( playerListItem );
}
@Override
public void onUpdate(PlayerListItemUpdate playerListItem)
{
for ( PlayerListItem.Item item : playerListItem.getItems() )
{
for ( PlayerListItemUpdate.Action action : playerListItem.getActions() )
{
if ( action == PlayerListItemUpdate.Action.ADD_PLAYER )
{
uuids.add( item.getUuid() );
}
}
}
player.unsafe().sendPacket( playerListItem );
}
@Override @Override
public void onPingChange(int ping) public void onPingChange(int ping)
{ {
@ -70,25 +41,17 @@ public class ServerUnique extends TabList
@Override @Override
public void onServerChange() public void onServerChange()
{ {
if ( player.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_19_3 ) PlayerListItem packet = new PlayerListItem();
packet.setAction( PlayerListItem.Action.REMOVE_PLAYER );
PlayerListItem.Item[] items = new PlayerListItem.Item[ uuids.size() ];
int i = 0;
for ( UUID uuid : uuids )
{ {
PlayerListItemRemove packet = new PlayerListItemRemove(); PlayerListItem.Item item = items[i++] = new PlayerListItem.Item();
packet.setUuids( uuids.stream().toArray( UUID[]::new ) ); item.setUuid( uuid );
player.unsafe().sendPacket( packet );
} else
{
PlayerListItem packet = new PlayerListItem();
packet.setAction( PlayerListItem.Action.REMOVE_PLAYER );
PlayerListItem.Item[] items = new PlayerListItem.Item[ uuids.size() ];
int i = 0;
for ( UUID uuid : uuids )
{
PlayerListItem.Item item = items[i++] = new PlayerListItem.Item();
item.setUuid( uuid );
}
packet.setItems( items );
player.unsafe().sendPacket( packet );
} }
packet.setItems( items );
player.unsafe().sendPacket( packet );
uuids.clear(); uuids.clear();
} }
@ -103,5 +66,4 @@ public class ServerUnique extends TabList
{ {
} }
} }

View File

@ -7,8 +7,6 @@ import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.connection.LoginResult; import net.md_5.bungee.connection.LoginResult;
import net.md_5.bungee.protocol.Property; import net.md_5.bungee.protocol.Property;
import net.md_5.bungee.protocol.packet.PlayerListItem; import net.md_5.bungee.protocol.packet.PlayerListItem;
import net.md_5.bungee.protocol.packet.PlayerListItemRemove;
import net.md_5.bungee.protocol.packet.PlayerListItemUpdate;
@RequiredArgsConstructor @RequiredArgsConstructor
public abstract class TabList public abstract class TabList
@ -18,10 +16,6 @@ public abstract class TabList
public abstract void onUpdate(PlayerListItem playerListItem); public abstract void onUpdate(PlayerListItem playerListItem);
public abstract void onUpdate(PlayerListItemRemove playerListItem);
public abstract void onUpdate(PlayerListItemUpdate playerListItem);
public abstract void onPingChange(int ping); public abstract void onPingChange(int ping);
public abstract void onServerChange(); public abstract void onServerChange();
@ -34,48 +28,14 @@ public abstract class TabList
{ {
for ( PlayerListItem.Item item : playerListItem.getItems() ) for ( PlayerListItem.Item item : playerListItem.getItems() )
{ {
rewrite( item ); if ( item.getUuid() == null ) // Old style ping
} {
return playerListItem; continue;
} }
UserConnection player = BungeeCord.getInstance().getPlayerByOfflineUUID( item.getUuid() );
public static PlayerListItemRemove rewrite(PlayerListItemRemove playerListItem)
{
for ( int i = 0; i < playerListItem.getUuids().length; i++ )
{
UserConnection player = BungeeCord.getInstance().getPlayerByOfflineUUID( playerListItem.getUuids()[i] );
if ( player != null ) if ( player != null )
{ {
playerListItem.getUuids()[i] = player.getUniqueId(); item.setUuid( player.getUniqueId() );
}
}
return playerListItem;
}
public static PlayerListItemUpdate rewrite(PlayerListItemUpdate playerListItem)
{
for ( PlayerListItem.Item item : playerListItem.getItems() )
{
rewrite( item );
}
return playerListItem;
}
private static void rewrite(PlayerListItem.Item item)
{
if ( item.getUuid() == null ) // Old style ping
{
return;
}
UserConnection player = BungeeCord.getInstance().getPlayerByOfflineUUID( item.getUuid() );
if ( player != null )
{
item.setUuid( player.getUniqueId() );
if ( item.getProperties() != null )
{
LoginResult loginResult = player.getPendingConnection().getLoginProfile(); LoginResult loginResult = player.getPendingConnection().getLoginProfile();
if ( loginResult != null && loginResult.getProperties() != null ) if ( loginResult != null && loginResult.getProperties() != null )
{ {
@ -89,15 +49,16 @@ public abstract class TabList
{ {
item.setProperties( new Property[ 0 ] ); item.setProperties( new Property[ 0 ] );
} }
} if ( playerListItem.getAction() == PlayerListItem.Action.ADD_PLAYER || playerListItem.getAction() == PlayerListItem.Action.UPDATE_GAMEMODE )
if ( item.getGamemode() != null ) {
{ player.setGamemode( item.getGamemode() );
player.setGamemode( item.getGamemode() ); }
} if ( playerListItem.getAction() == PlayerListItem.Action.ADD_PLAYER || playerListItem.getAction() == PlayerListItem.Action.UPDATE_LATENCY )
if ( item.getPing() != null ) {
{ player.setPing( item.getPing() );
player.setPing( item.getPing() ); }
} }
} }
return playerListItem;
} }
} }