Minecraft 24w21b support

This commit is contained in:
md_5 2024-05-27 06:48:08 +10:00
parent 18eae8a1a6
commit 8e8a635361
No known key found for this signature in database
GPG Key ID: E8E901AC7C617C11
6 changed files with 173 additions and 2 deletions

View File

@ -10,6 +10,7 @@ import net.md_5.bungee.protocol.packet.ClientStatus;
import net.md_5.bungee.protocol.packet.Commands; import net.md_5.bungee.protocol.packet.Commands;
import net.md_5.bungee.protocol.packet.CookieRequest; import net.md_5.bungee.protocol.packet.CookieRequest;
import net.md_5.bungee.protocol.packet.CookieResponse; import net.md_5.bungee.protocol.packet.CookieResponse;
import net.md_5.bungee.protocol.packet.DisconnectReportDetails;
import net.md_5.bungee.protocol.packet.EncryptionRequest; import net.md_5.bungee.protocol.packet.EncryptionRequest;
import net.md_5.bungee.protocol.packet.EncryptionResponse; import net.md_5.bungee.protocol.packet.EncryptionResponse;
import net.md_5.bungee.protocol.packet.EntityStatus; import net.md_5.bungee.protocol.packet.EntityStatus;
@ -38,6 +39,7 @@ import net.md_5.bungee.protocol.packet.ScoreboardObjective;
import net.md_5.bungee.protocol.packet.ScoreboardScore; import net.md_5.bungee.protocol.packet.ScoreboardScore;
import net.md_5.bungee.protocol.packet.ScoreboardScoreReset; import net.md_5.bungee.protocol.packet.ScoreboardScoreReset;
import net.md_5.bungee.protocol.packet.ServerData; import net.md_5.bungee.protocol.packet.ServerData;
import net.md_5.bungee.protocol.packet.ServerLinks;
import net.md_5.bungee.protocol.packet.SetCompression; import net.md_5.bungee.protocol.packet.SetCompression;
import net.md_5.bungee.protocol.packet.StartConfiguration; import net.md_5.bungee.protocol.packet.StartConfiguration;
import net.md_5.bungee.protocol.packet.StatusRequest; import net.md_5.bungee.protocol.packet.StatusRequest;
@ -268,4 +270,12 @@ public abstract class AbstractPacketHandler
public void handle(CookieResponse cookieResponse) throws Exception public void handle(CookieResponse cookieResponse) throws Exception
{ {
} }
public void handle(DisconnectReportDetails disconnectReportDetails) throws Exception
{
}
public void handle(ServerLinks serverLinks) throws Exception
{
}
} }

View File

@ -18,6 +18,7 @@ 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.CookieRequest; import net.md_5.bungee.protocol.packet.CookieRequest;
import net.md_5.bungee.protocol.packet.CookieResponse; import net.md_5.bungee.protocol.packet.CookieResponse;
import net.md_5.bungee.protocol.packet.DisconnectReportDetails;
import net.md_5.bungee.protocol.packet.EncryptionRequest; import net.md_5.bungee.protocol.packet.EncryptionRequest;
import net.md_5.bungee.protocol.packet.EncryptionResponse; import net.md_5.bungee.protocol.packet.EncryptionResponse;
import net.md_5.bungee.protocol.packet.EntityStatus; import net.md_5.bungee.protocol.packet.EntityStatus;
@ -44,6 +45,7 @@ import net.md_5.bungee.protocol.packet.ScoreboardObjective;
import net.md_5.bungee.protocol.packet.ScoreboardScore; import net.md_5.bungee.protocol.packet.ScoreboardScore;
import net.md_5.bungee.protocol.packet.ScoreboardScoreReset; import net.md_5.bungee.protocol.packet.ScoreboardScoreReset;
import net.md_5.bungee.protocol.packet.ServerData; import net.md_5.bungee.protocol.packet.ServerData;
import net.md_5.bungee.protocol.packet.ServerLinks;
import net.md_5.bungee.protocol.packet.SetCompression; import net.md_5.bungee.protocol.packet.SetCompression;
import net.md_5.bungee.protocol.packet.StartConfiguration; import net.md_5.bungee.protocol.packet.StartConfiguration;
import net.md_5.bungee.protocol.packet.StatusRequest; import net.md_5.bungee.protocol.packet.StatusRequest;
@ -496,6 +498,16 @@ public enum Protocol
Transfer::new, Transfer::new,
map( ProtocolConstants.MINECRAFT_1_20_5, 0x73 ) map( ProtocolConstants.MINECRAFT_1_20_5, 0x73 )
); );
TO_CLIENT.registerPacket(
DisconnectReportDetails.class,
DisconnectReportDetails::new,
map( ProtocolConstants.MINECRAFT_1_21, 0x7A )
);
TO_CLIENT.registerPacket(
ServerLinks.class,
ServerLinks::new,
map( ProtocolConstants.MINECRAFT_1_21, 0x7B )
);
TO_SERVER.registerPacket( TO_SERVER.registerPacket(
KeepAlive.class, KeepAlive.class,
@ -742,6 +754,16 @@ public enum Protocol
Transfer::new, Transfer::new,
map( ProtocolConstants.MINECRAFT_1_20_5, 0x0B ) map( ProtocolConstants.MINECRAFT_1_20_5, 0x0B )
); );
TO_CLIENT.registerPacket(
DisconnectReportDetails.class,
DisconnectReportDetails::new,
map( ProtocolConstants.MINECRAFT_1_21, 0x0F )
);
TO_CLIENT.registerPacket(
ServerLinks.class,
ServerLinks::new,
map( ProtocolConstants.MINECRAFT_1_21, 0x10 )
);
TO_SERVER.registerPacket( TO_SERVER.registerPacket(
ClientSettings.class, ClientSettings.class,

View File

@ -46,6 +46,7 @@ public class ProtocolConstants
public static final int MINECRAFT_1_20_2 = 764; public static final int MINECRAFT_1_20_2 = 764;
public static final int MINECRAFT_1_20_3 = 765; public static final int MINECRAFT_1_20_3 = 765;
public static final int MINECRAFT_1_20_5 = 766; public static final int MINECRAFT_1_20_5 = 766;
public static final int MINECRAFT_1_21 = 1073742022;
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;
@ -110,8 +111,8 @@ public class ProtocolConstants
if ( SNAPSHOT_SUPPORT ) if ( SNAPSHOT_SUPPORT )
{ {
// supportedVersions.add( "1.20.x" ); supportedVersions.add( "1.21.x" );
// supportedVersionIds.add( ProtocolConstants.MINECRAFT_1_20_5 ); supportedVersionIds.add( ProtocolConstants.MINECRAFT_1_21 );
} }
SUPPORTED_VERSIONS = supportedVersions.build(); SUPPORTED_VERSIONS = supportedVersions.build();

View File

@ -0,0 +1,55 @@
package net.md_5.bungee.protocol.packet;
import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
import java.util.HashMap;
import java.util.Map;
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 DisconnectReportDetails extends DefinedPacket
{
private Map<String, String> details;
@Override
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
{
int len = readVarInt( buf );
Preconditions.checkArgument( len <= 32, "Too many details" );
details = new HashMap<>();
for ( int i = 0; i < len; i++ )
{
details.put( readString( buf, 128 ), readString( buf, 4096 ) );
}
}
@Override
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
{
Preconditions.checkArgument( details.size() <= 32, "Too many details" );
writeVarInt( details.size(), buf );
for ( Map.Entry<String, String> detail : details.entrySet() )
{
writeString( detail.getKey(), buf, 128 );
writeString( detail.getValue(), buf, 4096 );
}
}
@Override
public void handle(AbstractPacketHandler handler) throws Exception
{
handler.handle( this );
}
}

View File

@ -0,0 +1,82 @@
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.api.chat.BaseComponent;
import net.md_5.bungee.protocol.AbstractPacketHandler;
import net.md_5.bungee.protocol.DefinedPacket;
import net.md_5.bungee.protocol.Either;
import net.md_5.bungee.protocol.ProtocolConstants;
@Data
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class ServerLinks extends DefinedPacket
{
private Link[] links;
@Override
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
{
int len = readVarInt( buf );
links = new Link[ len ];
for ( int i = 0; i < len; i++ )
{
Either<LinkType, BaseComponent> type;
if ( buf.readBoolean() )
{
type = Either.left( LinkType.values()[readVarInt( buf )] );
} else
{
type = Either.right( readBaseComponent( buf, protocolVersion ) );
}
String url = readString( buf );
links[i] = new Link( type, url );
}
}
@Override
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
{
writeVarInt( links.length, buf );
for ( Link link : links )
{
Either<LinkType, BaseComponent> type = link.getType();
if ( type.isLeft() )
{
buf.writeBoolean( true );
writeVarInt( type.getLeft().ordinal(), buf );
} else
{
buf.writeBoolean( false );
writeBaseComponent( type.getRight(), buf, protocolVersion );
}
writeString( link.getUrl(), buf );
}
}
@Override
public void handle(AbstractPacketHandler handler) throws Exception
{
handler.handle( this );
}
public enum LinkType
{
REPORT_BUG;
}
@Data
public static class Link
{
private final Either<LinkType, BaseComponent> type;
private final String url;
}
}

View File

@ -87,6 +87,7 @@ public abstract class EntityMap
case ProtocolConstants.MINECRAFT_1_20_3: case ProtocolConstants.MINECRAFT_1_20_3:
return EntityMap_1_16_2.INSTANCE_1_20_3; return EntityMap_1_16_2.INSTANCE_1_20_3;
case ProtocolConstants.MINECRAFT_1_20_5: case ProtocolConstants.MINECRAFT_1_20_5:
case ProtocolConstants.MINECRAFT_1_21:
return EntityMap_1_16_2.INSTANCE_1_20_5; return EntityMap_1_16_2.INSTANCE_1_20_5;
} }
throw new RuntimeException( "Version " + version + " has no entity map" ); throw new RuntimeException( "Version " + version + " has no entity map" );