Add optional 1.17 (21w19a) snapshot protocol support

Accessible via the net.md_5.bungee.protocol.snapshot JVM property.
This commit is contained in:
md_5 2021-05-15 09:17:24 +10:00
parent 5fa596fee9
commit f0908b663f
No known key found for this signature in database
GPG Key ID: E8E901AC7C617C11
11 changed files with 334 additions and 91 deletions

View File

@ -2,6 +2,7 @@ package net.md_5.bungee.protocol;
import net.md_5.bungee.protocol.packet.BossBar; import net.md_5.bungee.protocol.packet.BossBar;
import net.md_5.bungee.protocol.packet.Chat; import net.md_5.bungee.protocol.packet.Chat;
import net.md_5.bungee.protocol.packet.ClearTitles;
import net.md_5.bungee.protocol.packet.ClientSettings; import net.md_5.bungee.protocol.packet.ClientSettings;
import net.md_5.bungee.protocol.packet.ClientStatus; import net.md_5.bungee.protocol.packet.ClientStatus;
import net.md_5.bungee.protocol.packet.Commands; import net.md_5.bungee.protocol.packet.Commands;
@ -30,10 +31,12 @@ import net.md_5.bungee.protocol.packet.ScoreboardScore;
import net.md_5.bungee.protocol.packet.SetCompression; import net.md_5.bungee.protocol.packet.SetCompression;
import net.md_5.bungee.protocol.packet.StatusRequest; import net.md_5.bungee.protocol.packet.StatusRequest;
import net.md_5.bungee.protocol.packet.StatusResponse; import net.md_5.bungee.protocol.packet.StatusResponse;
import net.md_5.bungee.protocol.packet.Subtitle;
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;
import net.md_5.bungee.protocol.packet.Team; import net.md_5.bungee.protocol.packet.Team;
import net.md_5.bungee.protocol.packet.Title; import net.md_5.bungee.protocol.packet.Title;
import net.md_5.bungee.protocol.packet.TitleTimes;
import net.md_5.bungee.protocol.packet.ViewDistance; import net.md_5.bungee.protocol.packet.ViewDistance;
public abstract class AbstractPacketHandler public abstract class AbstractPacketHandler
@ -127,6 +130,18 @@ public abstract class AbstractPacketHandler
{ {
} }
public void handle(Subtitle title) throws Exception
{
}
public void handle(TitleTimes title) throws Exception
{
}
public void handle(ClearTitles title) throws Exception
{
}
public void handle(PluginMessage pluginMessage) throws Exception public void handle(PluginMessage pluginMessage) throws Exception
{ {
} }

View File

@ -11,6 +11,7 @@ import lombok.Data;
import lombok.Getter; import lombok.Getter;
import net.md_5.bungee.protocol.packet.BossBar; import net.md_5.bungee.protocol.packet.BossBar;
import net.md_5.bungee.protocol.packet.Chat; import net.md_5.bungee.protocol.packet.Chat;
import net.md_5.bungee.protocol.packet.ClearTitles;
import net.md_5.bungee.protocol.packet.ClientSettings; import net.md_5.bungee.protocol.packet.ClientSettings;
import net.md_5.bungee.protocol.packet.Commands; import net.md_5.bungee.protocol.packet.Commands;
import net.md_5.bungee.protocol.packet.EncryptionRequest; import net.md_5.bungee.protocol.packet.EncryptionRequest;
@ -36,10 +37,12 @@ import net.md_5.bungee.protocol.packet.ScoreboardScore;
import net.md_5.bungee.protocol.packet.SetCompression; import net.md_5.bungee.protocol.packet.SetCompression;
import net.md_5.bungee.protocol.packet.StatusRequest; import net.md_5.bungee.protocol.packet.StatusRequest;
import net.md_5.bungee.protocol.packet.StatusResponse; import net.md_5.bungee.protocol.packet.StatusResponse;
import net.md_5.bungee.protocol.packet.Subtitle;
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;
import net.md_5.bungee.protocol.packet.Team; import net.md_5.bungee.protocol.packet.Team;
import net.md_5.bungee.protocol.packet.Title; import net.md_5.bungee.protocol.packet.Title;
import net.md_5.bungee.protocol.packet.TitleTimes;
import net.md_5.bungee.protocol.packet.ViewDistance; import net.md_5.bungee.protocol.packet.ViewDistance;
public enum Protocol public enum Protocol
@ -69,7 +72,8 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_14, 0x20 ), map( ProtocolConstants.MINECRAFT_1_14, 0x20 ),
map( ProtocolConstants.MINECRAFT_1_15, 0x21 ), map( ProtocolConstants.MINECRAFT_1_15, 0x21 ),
map( ProtocolConstants.MINECRAFT_1_16, 0x20 ), map( ProtocolConstants.MINECRAFT_1_16, 0x20 ),
map( ProtocolConstants.MINECRAFT_1_16_2, 0x1F ) map( ProtocolConstants.MINECRAFT_1_16_2, 0x1F ),
map( ProtocolConstants.MINECRAFT_1_17, 0x21 )
); );
TO_CLIENT.registerPacket( TO_CLIENT.registerPacket(
Login.class, Login.class,
@ -78,7 +82,8 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_13, 0x25 ), map( ProtocolConstants.MINECRAFT_1_13, 0x25 ),
map( ProtocolConstants.MINECRAFT_1_15, 0x26 ), map( ProtocolConstants.MINECRAFT_1_15, 0x26 ),
map( ProtocolConstants.MINECRAFT_1_16, 0x25 ), map( ProtocolConstants.MINECRAFT_1_16, 0x25 ),
map( ProtocolConstants.MINECRAFT_1_16_2, 0x24 ) map( ProtocolConstants.MINECRAFT_1_16_2, 0x24 ),
map( ProtocolConstants.MINECRAFT_1_17, 0x26 )
); );
TO_CLIENT.registerPacket( TO_CLIENT.registerPacket(
Chat.class, Chat.class,
@ -86,7 +91,8 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_9, 0x0F ), map( ProtocolConstants.MINECRAFT_1_9, 0x0F ),
map( ProtocolConstants.MINECRAFT_1_13, 0x0E ), map( ProtocolConstants.MINECRAFT_1_13, 0x0E ),
map( ProtocolConstants.MINECRAFT_1_15, 0x0F ), map( ProtocolConstants.MINECRAFT_1_15, 0x0F ),
map( ProtocolConstants.MINECRAFT_1_16, 0x0E ) map( ProtocolConstants.MINECRAFT_1_16, 0x0E ),
map( ProtocolConstants.MINECRAFT_1_17, 0x0F )
); );
TO_CLIENT.registerPacket( TO_CLIENT.registerPacket(
Respawn.class, Respawn.class,
@ -98,13 +104,15 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_14, 0x3A ), map( ProtocolConstants.MINECRAFT_1_14, 0x3A ),
map( ProtocolConstants.MINECRAFT_1_15, 0x3B ), map( ProtocolConstants.MINECRAFT_1_15, 0x3B ),
map( ProtocolConstants.MINECRAFT_1_16, 0x3A ), map( ProtocolConstants.MINECRAFT_1_16, 0x3A ),
map( ProtocolConstants.MINECRAFT_1_16_2, 0x39 ) map( ProtocolConstants.MINECRAFT_1_16_2, 0x39 ),
map( ProtocolConstants.MINECRAFT_1_17, 0x3D )
); );
TO_CLIENT.registerPacket( TO_CLIENT.registerPacket(
BossBar.class, BossBar.class,
map( ProtocolConstants.MINECRAFT_1_9, 0x0C ), map( ProtocolConstants.MINECRAFT_1_9, 0x0C ),
map( ProtocolConstants.MINECRAFT_1_15, 0x0D ), map( ProtocolConstants.MINECRAFT_1_15, 0x0D ),
map( ProtocolConstants.MINECRAFT_1_16, 0x0C ) map( ProtocolConstants.MINECRAFT_1_16, 0x0C ),
map( ProtocolConstants.MINECRAFT_1_17, 0x0D )
); );
TO_CLIENT.registerPacket( TO_CLIENT.registerPacket(
PlayerListItem.class, // PlayerInfo PlayerListItem.class, // PlayerInfo
@ -115,7 +123,8 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_14, 0x33 ), map( ProtocolConstants.MINECRAFT_1_14, 0x33 ),
map( ProtocolConstants.MINECRAFT_1_15, 0x34 ), map( ProtocolConstants.MINECRAFT_1_15, 0x34 ),
map( ProtocolConstants.MINECRAFT_1_16, 0x33 ), map( ProtocolConstants.MINECRAFT_1_16, 0x33 ),
map( ProtocolConstants.MINECRAFT_1_16_2, 0x32 ) map( ProtocolConstants.MINECRAFT_1_16_2, 0x32 ),
map( ProtocolConstants.MINECRAFT_1_17, 0x36 )
); );
TO_CLIENT.registerPacket( TO_CLIENT.registerPacket(
TabCompleteResponse.class, TabCompleteResponse.class,
@ -124,7 +133,8 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_13, 0x10 ), map( ProtocolConstants.MINECRAFT_1_13, 0x10 ),
map( ProtocolConstants.MINECRAFT_1_15, 0x11 ), map( ProtocolConstants.MINECRAFT_1_15, 0x11 ),
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 )
); );
TO_CLIENT.registerPacket( TO_CLIENT.registerPacket(
ScoreboardObjective.class, ScoreboardObjective.class,
@ -134,7 +144,8 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_12_1, 0x42 ), map( ProtocolConstants.MINECRAFT_1_12_1, 0x42 ),
map( ProtocolConstants.MINECRAFT_1_13, 0x45 ), map( ProtocolConstants.MINECRAFT_1_13, 0x45 ),
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 )
); );
TO_CLIENT.registerPacket( TO_CLIENT.registerPacket(
ScoreboardScore.class, ScoreboardScore.class,
@ -144,7 +155,8 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_12_1, 0x45 ), map( ProtocolConstants.MINECRAFT_1_12_1, 0x45 ),
map( ProtocolConstants.MINECRAFT_1_13, 0x48 ), map( ProtocolConstants.MINECRAFT_1_13, 0x48 ),
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 )
); );
TO_CLIENT.registerPacket( TO_CLIENT.registerPacket(
ScoreboardDisplay.class, ScoreboardDisplay.class,
@ -154,7 +166,8 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_12_1, 0x3B ), map( ProtocolConstants.MINECRAFT_1_12_1, 0x3B ),
map( ProtocolConstants.MINECRAFT_1_13, 0x3E ), map( ProtocolConstants.MINECRAFT_1_13, 0x3E ),
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 )
); );
TO_CLIENT.registerPacket( TO_CLIENT.registerPacket(
Team.class, Team.class,
@ -164,7 +177,8 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_12_1, 0x44 ), map( ProtocolConstants.MINECRAFT_1_12_1, 0x44 ),
map( ProtocolConstants.MINECRAFT_1_13, 0x47 ), map( ProtocolConstants.MINECRAFT_1_13, 0x47 ),
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 )
); );
TO_CLIENT.registerPacket( TO_CLIENT.registerPacket(
PluginMessage.class, PluginMessage.class,
@ -174,7 +188,8 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_14, 0x18 ), map( ProtocolConstants.MINECRAFT_1_14, 0x18 ),
map( ProtocolConstants.MINECRAFT_1_15, 0x19 ), map( ProtocolConstants.MINECRAFT_1_15, 0x19 ),
map( ProtocolConstants.MINECRAFT_1_16, 0x18 ), map( ProtocolConstants.MINECRAFT_1_16, 0x18 ),
map( ProtocolConstants.MINECRAFT_1_16_2, 0x17 ) map( ProtocolConstants.MINECRAFT_1_16_2, 0x17 ),
map( ProtocolConstants.MINECRAFT_1_17, 0x18 )
); );
TO_CLIENT.registerPacket( TO_CLIENT.registerPacket(
Kick.class, Kick.class,
@ -184,7 +199,8 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_14, 0x1A ), map( ProtocolConstants.MINECRAFT_1_14, 0x1A ),
map( ProtocolConstants.MINECRAFT_1_15, 0x1B ), map( ProtocolConstants.MINECRAFT_1_15, 0x1B ),
map( ProtocolConstants.MINECRAFT_1_16, 0x1A ), map( ProtocolConstants.MINECRAFT_1_16, 0x1A ),
map( ProtocolConstants.MINECRAFT_1_16_2, 0x19 ) map( ProtocolConstants.MINECRAFT_1_16_2, 0x19 ),
map( ProtocolConstants.MINECRAFT_1_17, 0x1A )
); );
TO_CLIENT.registerPacket( TO_CLIENT.registerPacket(
Title.class, Title.class,
@ -194,7 +210,18 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_13, 0x4B ), map( ProtocolConstants.MINECRAFT_1_13, 0x4B ),
map( ProtocolConstants.MINECRAFT_1_14, 0x4F ), map( ProtocolConstants.MINECRAFT_1_14, 0x4F ),
map( ProtocolConstants.MINECRAFT_1_15, 0x50 ), map( ProtocolConstants.MINECRAFT_1_15, 0x50 ),
map( ProtocolConstants.MINECRAFT_1_16, 0x4F ) map( ProtocolConstants.MINECRAFT_1_16, 0x4F ),
map( ProtocolConstants.MINECRAFT_1_17, 0x59 )
);
TO_CLIENT.registerPacket( ClearTitles.class,
map( ProtocolConstants.MINECRAFT_1_17, 0x10 )
);
TO_CLIENT.registerPacket(
Subtitle.class,
map( ProtocolConstants.MINECRAFT_1_17, 0x57 )
);
TO_CLIENT.registerPacket( TitleTimes.class,
map( ProtocolConstants.MINECRAFT_1_17, 0x5A )
); );
TO_CLIENT.registerPacket( TO_CLIENT.registerPacket(
PlayerListHeaderFooter.class, PlayerListHeaderFooter.class,
@ -206,7 +233,8 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_13, 0x4E ), map( ProtocolConstants.MINECRAFT_1_13, 0x4E ),
map( ProtocolConstants.MINECRAFT_1_14, 0x53 ), map( ProtocolConstants.MINECRAFT_1_14, 0x53 ),
map( ProtocolConstants.MINECRAFT_1_15, 0x54 ), map( ProtocolConstants.MINECRAFT_1_15, 0x54 ),
map( ProtocolConstants.MINECRAFT_1_16, 0x53 ) map( ProtocolConstants.MINECRAFT_1_16, 0x53 ),
map( ProtocolConstants.MINECRAFT_1_17, 0x5E )
); );
TO_CLIENT.registerPacket( TO_CLIENT.registerPacket(
EntityStatus.class, EntityStatus.class,
@ -216,26 +244,30 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_14, 0x1B ), map( ProtocolConstants.MINECRAFT_1_14, 0x1B ),
map( ProtocolConstants.MINECRAFT_1_15, 0x1C ), map( ProtocolConstants.MINECRAFT_1_15, 0x1C ),
map( ProtocolConstants.MINECRAFT_1_16, 0x1B ), map( ProtocolConstants.MINECRAFT_1_16, 0x1B ),
map( ProtocolConstants.MINECRAFT_1_16_2, 0x1A ) map( ProtocolConstants.MINECRAFT_1_16_2, 0x1A ),
map( ProtocolConstants.MINECRAFT_1_17, 0x1B )
); );
TO_CLIENT.registerPacket( TO_CLIENT.registerPacket(
Commands.class, Commands.class,
map( ProtocolConstants.MINECRAFT_1_13, 0x11 ), map( ProtocolConstants.MINECRAFT_1_13, 0x11 ),
map( ProtocolConstants.MINECRAFT_1_15, 0x12 ), map( ProtocolConstants.MINECRAFT_1_15, 0x12 ),
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 )
); );
TO_CLIENT.registerPacket( TO_CLIENT.registerPacket(
GameState.class, GameState.class,
map( ProtocolConstants.MINECRAFT_1_15, 0x1F ), map( ProtocolConstants.MINECRAFT_1_15, 0x1F ),
map( ProtocolConstants.MINECRAFT_1_16, 0x1E ), map( ProtocolConstants.MINECRAFT_1_16, 0x1E ),
map( ProtocolConstants.MINECRAFT_1_16_2, 0x1D ) map( ProtocolConstants.MINECRAFT_1_16_2, 0x1D ),
map( ProtocolConstants.MINECRAFT_1_17, 0x1E )
); );
TO_CLIENT.registerPacket( TO_CLIENT.registerPacket(
ViewDistance.class, ViewDistance.class,
map( ProtocolConstants.MINECRAFT_1_14, 0x41 ), map( ProtocolConstants.MINECRAFT_1_14, 0x41 ),
map( ProtocolConstants.MINECRAFT_1_15, 0x42 ), map( ProtocolConstants.MINECRAFT_1_15, 0x42 ),
map( ProtocolConstants.MINECRAFT_1_16, 0x41 ) map( ProtocolConstants.MINECRAFT_1_16, 0x41 ),
map( ProtocolConstants.MINECRAFT_1_17, 0x4A )
); );
TO_SERVER.registerPacket( TO_SERVER.registerPacket(
@ -246,7 +278,8 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_12_1, 0x0B ), map( ProtocolConstants.MINECRAFT_1_12_1, 0x0B ),
map( ProtocolConstants.MINECRAFT_1_13, 0x0E ), map( ProtocolConstants.MINECRAFT_1_13, 0x0E ),
map( ProtocolConstants.MINECRAFT_1_14, 0x0F ), map( ProtocolConstants.MINECRAFT_1_14, 0x0F ),
map( ProtocolConstants.MINECRAFT_1_16, 0x10 ) map( ProtocolConstants.MINECRAFT_1_16, 0x10 ),
map( ProtocolConstants.MINECRAFT_1_17, 0x0F )
); );
TO_SERVER.registerPacket( TO_SERVER.registerPacket(
Chat.class, Chat.class,
@ -280,7 +313,8 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_12, 0x0A ), map( ProtocolConstants.MINECRAFT_1_12, 0x0A ),
map( ProtocolConstants.MINECRAFT_1_12_1, 0x09 ), map( ProtocolConstants.MINECRAFT_1_12_1, 0x09 ),
map( ProtocolConstants.MINECRAFT_1_13, 0x0A ), map( ProtocolConstants.MINECRAFT_1_13, 0x0A ),
map( ProtocolConstants.MINECRAFT_1_14, 0x0B ) map( ProtocolConstants.MINECRAFT_1_14, 0x0B ),
map( ProtocolConstants.MINECRAFT_1_17, 0x0A )
); );
} }
}, },

View File

@ -1,11 +1,12 @@
package net.md_5.bungee.protocol; package net.md_5.bungee.protocol;
import java.util.Arrays; import com.google.common.collect.ImmutableList;
import java.util.List; import java.util.List;
public class ProtocolConstants public class ProtocolConstants
{ {
private static final boolean SNAPSHOT_SUPPORT = Boolean.getBoolean( "net.md_5.bungee.protocol.snapshot" );
public static final int MINECRAFT_1_8 = 47; public static final int MINECRAFT_1_8 = 47;
public static final int MINECRAFT_1_9 = 107; public static final int MINECRAFT_1_9 = 107;
public static final int MINECRAFT_1_9_1 = 108; public static final int MINECRAFT_1_9_1 = 108;
@ -33,7 +34,13 @@ public class ProtocolConstants
public static final int MINECRAFT_1_16_2 = 751; public static final int MINECRAFT_1_16_2 = 751;
public static final int MINECRAFT_1_16_3 = 753; public static final int MINECRAFT_1_16_3 = 753;
public static final int MINECRAFT_1_16_4 = 754; public static final int MINECRAFT_1_16_4 = 754;
public static final List<String> SUPPORTED_VERSIONS = Arrays.asList( public static final int MINECRAFT_1_17 = 1073741851;
public static final List<String> SUPPORTED_VERSIONS;
public static final List<Integer> SUPPORTED_VERSION_IDS;
static
{
ImmutableList.Builder<String> supportedVersions = ImmutableList.<String>builder().add(
"1.8.x", "1.8.x",
"1.9.x", "1.9.x",
"1.10.x", "1.10.x",
@ -44,7 +51,7 @@ public class ProtocolConstants
"1.15.x", "1.15.x",
"1.16.x" "1.16.x"
); );
public static final List<Integer> SUPPORTED_VERSION_IDS = Arrays.asList( ImmutableList.Builder<Integer> supportedVersionIds = ImmutableList.<Integer>builder().add(
ProtocolConstants.MINECRAFT_1_8, ProtocolConstants.MINECRAFT_1_8,
ProtocolConstants.MINECRAFT_1_9, ProtocolConstants.MINECRAFT_1_9,
ProtocolConstants.MINECRAFT_1_9_1, ProtocolConstants.MINECRAFT_1_9_1,
@ -74,6 +81,16 @@ public class ProtocolConstants
ProtocolConstants.MINECRAFT_1_16_4 ProtocolConstants.MINECRAFT_1_16_4
); );
if ( SNAPSHOT_SUPPORT )
{
supportedVersions.add( "1.17.x" );
supportedVersionIds.add( ProtocolConstants.MINECRAFT_1_17 );
}
SUPPORTED_VERSIONS = supportedVersions.build();
SUPPORTED_VERSION_IDS = supportedVersionIds.build();
}
public enum Direction public enum Direction
{ {

View File

@ -0,0 +1,38 @@
package net.md_5.bungee.protocol.packet;
import io.netty.buffer.ByteBuf;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import net.md_5.bungee.protocol.AbstractPacketHandler;
import net.md_5.bungee.protocol.DefinedPacket;
import net.md_5.bungee.protocol.ProtocolConstants;
@Data
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class ClearTitles extends DefinedPacket
{
private boolean reset;
@Override
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
{
reset = buf.readBoolean();
}
@Override
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
{
buf.writeBoolean( reset );
}
@Override
public void handle(AbstractPacketHandler handler) throws Exception
{
handler.handle( this );
}
}

View File

@ -23,6 +23,7 @@ public class ClientSettings extends DefinedPacket
private byte difficulty; private byte difficulty;
private byte skinParts; private byte skinParts;
private int mainHand; private int mainHand;
private boolean disableTextFiltering;
@Override @Override
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
@ -36,6 +37,10 @@ public class ClientSettings extends DefinedPacket
{ {
mainHand = DefinedPacket.readVarInt( buf ); mainHand = DefinedPacket.readVarInt( buf );
} }
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_17 )
{
disableTextFiltering = buf.readBoolean();
}
} }
@Override @Override
@ -56,6 +61,10 @@ public class ClientSettings extends DefinedPacket
{ {
DefinedPacket.writeVarInt( mainHand, buf ); DefinedPacket.writeVarInt( mainHand, buf );
} }
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_17 )
{
buf.writeBoolean( disableTextFiltering );
}
} }
@Override @Override

View File

@ -0,0 +1,36 @@
package net.md_5.bungee.protocol.packet;
import io.netty.buffer.ByteBuf;
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 Subtitle extends DefinedPacket
{
private String text;
@Override
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
{
text = readString( buf );
}
@Override
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
{
writeString( text, buf );
}
@Override
public void handle(AbstractPacketHandler handler) throws Exception
{
handler.handle( this );
}
}

View File

@ -24,9 +24,20 @@ public class Title extends DefinedPacket
private int stay; private int stay;
private int fadeOut; private int fadeOut;
public Title(Action action)
{
this.action = action;
}
@Override @Override
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
{ {
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_17 )
{
text = readString( buf );
return;
}
int index = readVarInt( buf ); int index = readVarInt( buf );
// If we're working on 1.10 or lower, increment the value of the index so we pull out the correct value. // If we're working on 1.10 or lower, increment the value of the index so we pull out the correct value.
@ -54,6 +65,12 @@ public class Title extends DefinedPacket
@Override @Override
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
{ {
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_17 )
{
writeString( text, buf );
return;
}
int index = action.ordinal(); int index = action.ordinal();
// If we're working on 1.10 or lower, increment the value of the index so we pull out the correct value. // If we're working on 1.10 or lower, increment the value of the index so we pull out the correct value.

View File

@ -0,0 +1,42 @@
package net.md_5.bungee.protocol.packet;
import io.netty.buffer.ByteBuf;
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 TitleTimes extends DefinedPacket
{
private int fadeIn;
private int stay;
private int fadeOut;
@Override
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
{
fadeIn = buf.readInt();
stay = buf.readInt();
fadeOut = buf.readInt();
}
@Override
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
{
buf.writeInt( fadeIn );
buf.writeInt( stay );
buf.writeInt( fadeOut );
}
@Override
public void handle(AbstractPacketHandler handler) throws Exception
{
handler.handle( this );
}
}

View File

@ -1,29 +1,46 @@
package net.md_5.bungee; package net.md_5.bungee;
import lombok.Data;
import net.md_5.bungee.api.Title; import net.md_5.bungee.api.Title;
import net.md_5.bungee.api.chat.BaseComponent; import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.chat.ComponentSerializer; import net.md_5.bungee.chat.ComponentSerializer;
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.packet.ClearTitles;
import net.md_5.bungee.protocol.packet.Subtitle;
import net.md_5.bungee.protocol.packet.Title.Action; import net.md_5.bungee.protocol.packet.Title.Action;
import net.md_5.bungee.protocol.packet.TitleTimes;
public class BungeeTitle implements Title public class BungeeTitle implements Title
{ {
private net.md_5.bungee.protocol.packet.Title title, subtitle, times, clear, reset; private TitlePacketHolder<net.md_5.bungee.protocol.packet.Title> title;
private TitlePacketHolder<Subtitle> subtitle;
private TitlePacketHolder<TitleTimes> times;
private TitlePacketHolder<ClearTitles> clear;
private TitlePacketHolder<ClearTitles> reset;
private static net.md_5.bungee.protocol.packet.Title createPacket(Action action) @Data
private static class TitlePacketHolder<T extends DefinedPacket>
{ {
net.md_5.bungee.protocol.packet.Title title = new net.md_5.bungee.protocol.packet.Title();
title.setAction( action );
if ( action == Action.TIMES ) private final net.md_5.bungee.protocol.packet.Title oldPacket;
{ private final T newPacket;
// Set packet to default values first
title.setFadeIn( 20 );
title.setStay( 60 );
title.setFadeOut( 20 );
} }
private static TitlePacketHolder<TitleTimes> createAnimationPacket()
{
TitlePacketHolder<TitleTimes> title = new TitlePacketHolder<>( new net.md_5.bungee.protocol.packet.Title( Action.TIMES ), new TitleTimes() );
title.oldPacket.setFadeIn( 20 );
title.oldPacket.setStay( 60 );
title.oldPacket.setFadeOut( 20 );
title.newPacket.setFadeIn( 20 );
title.newPacket.setStay( 60 );
title.newPacket.setFadeOut( 20 );
return title; return title;
} }
@ -32,10 +49,11 @@ public class BungeeTitle implements Title
{ {
if ( title == null ) if ( title == null )
{ {
title = createPacket( Action.TITLE ); net.md_5.bungee.protocol.packet.Title packet = new net.md_5.bungee.protocol.packet.Title( Action.TITLE );
title = new TitlePacketHolder<>( packet, packet );
} }
title.setText( ComponentSerializer.toString( text ) ); title.oldPacket.setText( ComponentSerializer.toString( text ) ); // = newPacket
return this; return this;
} }
@ -44,10 +62,11 @@ public class BungeeTitle implements Title
{ {
if ( title == null ) if ( title == null )
{ {
title = createPacket( Action.TITLE ); net.md_5.bungee.protocol.packet.Title packet = new net.md_5.bungee.protocol.packet.Title( Action.TITLE );
title = new TitlePacketHolder<>( packet, packet );
} }
title.setText( ComponentSerializer.toString( text ) ); title.oldPacket.setText( ComponentSerializer.toString( text ) ); // = newPacket
return this; return this;
} }
@ -56,10 +75,12 @@ public class BungeeTitle implements Title
{ {
if ( subtitle == null ) if ( subtitle == null )
{ {
subtitle = createPacket( Action.SUBTITLE ); subtitle = new TitlePacketHolder<>( new net.md_5.bungee.protocol.packet.Title( Action.SUBTITLE ), new Subtitle() );
} }
subtitle.setText( ComponentSerializer.toString( text ) ); String serialized = ComponentSerializer.toString( text );
subtitle.oldPacket.setText( serialized );
subtitle.newPacket.setText( serialized );
return this; return this;
} }
@ -68,10 +89,12 @@ public class BungeeTitle implements Title
{ {
if ( subtitle == null ) if ( subtitle == null )
{ {
subtitle = createPacket( Action.SUBTITLE ); subtitle = new TitlePacketHolder<>( new net.md_5.bungee.protocol.packet.Title( Action.SUBTITLE ), new Subtitle() );
} }
subtitle.setText( ComponentSerializer.toString( text ) ); String serialized = ComponentSerializer.toString( text );
subtitle.oldPacket.setText( serialized );
subtitle.newPacket.setText( serialized );
return this; return this;
} }
@ -80,10 +103,11 @@ public class BungeeTitle implements Title
{ {
if ( times == null ) if ( times == null )
{ {
times = createPacket( Action.TIMES ); times = createAnimationPacket();
} }
times.setFadeIn( ticks ); times.oldPacket.setFadeIn( ticks );
times.newPacket.setFadeIn( ticks );
return this; return this;
} }
@ -92,10 +116,11 @@ public class BungeeTitle implements Title
{ {
if ( times == null ) if ( times == null )
{ {
times = createPacket( Action.TIMES ); times = createAnimationPacket();
} }
times.setStay( ticks ); times.oldPacket.setStay( ticks );
times.newPacket.setStay( ticks );
return this; return this;
} }
@ -104,10 +129,11 @@ public class BungeeTitle implements Title
{ {
if ( times == null ) if ( times == null )
{ {
times = createPacket( Action.TIMES ); times = createAnimationPacket();
} }
times.setFadeOut( ticks ); times.oldPacket.setFadeOut( ticks );
times.newPacket.setFadeOut( ticks );
return this; return this;
} }
@ -116,7 +142,7 @@ public class BungeeTitle implements Title
{ {
if ( clear == null ) if ( clear == null )
{ {
clear = createPacket( Action.CLEAR ); clear = new TitlePacketHolder<>( new net.md_5.bungee.protocol.packet.Title( Action.CLEAR ), new ClearTitles() );
} }
title = null; // No need to send title if we clear it after that again title = null; // No need to send title if we clear it after that again
@ -129,7 +155,7 @@ public class BungeeTitle implements Title
{ {
if ( reset == null ) if ( reset == null )
{ {
reset = createPacket( Action.RESET ); reset = new TitlePacketHolder<>( new net.md_5.bungee.protocol.packet.Title( Action.RESET ), new ClearTitles( true ) );
} }
// No need to send these packets if we reset them later // No need to send these packets if we reset them later
@ -140,11 +166,17 @@ public class BungeeTitle implements Title
return this; return this;
} }
private static void sendPacket(ProxiedPlayer player, DefinedPacket packet) private static void sendPacket(ProxiedPlayer player, TitlePacketHolder packet)
{ {
if ( packet != null ) if ( packet != null )
{ {
player.unsafe().sendPacket( packet ); if ( player.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_17 )
{
player.unsafe().sendPacket( packet.newPacket );
} else
{
player.unsafe().sendPacket( packet.oldPacket );
}
} }
} }

View File

@ -68,6 +68,8 @@ public abstract class EntityMap
case ProtocolConstants.MINECRAFT_1_16_3: case ProtocolConstants.MINECRAFT_1_16_3:
case ProtocolConstants.MINECRAFT_1_16_4: case ProtocolConstants.MINECRAFT_1_16_4:
return EntityMap_1_16_2.INSTANCE_1_16_2; return EntityMap_1_16_2.INSTANCE_1_16_2;
case ProtocolConstants.MINECRAFT_1_17:
return EntityMap_1_16_2.INSTANCE_1_17;
} }
throw new RuntimeException( "Version " + version + " has no entity map" ); throw new RuntimeException( "Version " + version + " has no entity map" );
} }

View File

@ -15,6 +15,7 @@ class EntityMap_1_16_2 extends EntityMap
{ {
static final EntityMap_1_16_2 INSTANCE_1_16_2 = new EntityMap_1_16_2( 0x04, 0x2D ); static final EntityMap_1_16_2 INSTANCE_1_16_2 = new EntityMap_1_16_2( 0x04, 0x2D );
static final EntityMap_1_16_2 INSTANCE_1_17 = new EntityMap_1_16_2( 0x04, 0x2D );
// //
private final int spawnPlayerId; private final int spawnPlayerId;
private final int spectateId; private final int spectateId;