mirror of
https://github.com/SpigotMC/BungeeCord.git
synced 2024-12-19 07:07:58 +01:00
Minecraft 24w21b support
This commit is contained in:
parent
18eae8a1a6
commit
8e8a635361
@ -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.CookieRequest;
|
||||
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.EncryptionResponse;
|
||||
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.ScoreboardScoreReset;
|
||||
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.StartConfiguration;
|
||||
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(DisconnectReportDetails disconnectReportDetails) throws Exception
|
||||
{
|
||||
}
|
||||
|
||||
public void handle(ServerLinks serverLinks) throws Exception
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -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.CookieRequest;
|
||||
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.EncryptionResponse;
|
||||
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.ScoreboardScoreReset;
|
||||
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.StartConfiguration;
|
||||
import net.md_5.bungee.protocol.packet.StatusRequest;
|
||||
@ -496,6 +498,16 @@ public enum Protocol
|
||||
Transfer::new,
|
||||
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(
|
||||
KeepAlive.class,
|
||||
@ -742,6 +754,16 @@ public enum Protocol
|
||||
Transfer::new,
|
||||
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(
|
||||
ClientSettings.class,
|
||||
|
@ -46,6 +46,7 @@ public class ProtocolConstants
|
||||
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_5 = 766;
|
||||
public static final int MINECRAFT_1_21 = 1073742022;
|
||||
public static final List<String> SUPPORTED_VERSIONS;
|
||||
public static final List<Integer> SUPPORTED_VERSION_IDS;
|
||||
|
||||
@ -110,8 +111,8 @@ public class ProtocolConstants
|
||||
|
||||
if ( SNAPSHOT_SUPPORT )
|
||||
{
|
||||
// supportedVersions.add( "1.20.x" );
|
||||
// supportedVersionIds.add( ProtocolConstants.MINECRAFT_1_20_5 );
|
||||
supportedVersions.add( "1.21.x" );
|
||||
supportedVersionIds.add( ProtocolConstants.MINECRAFT_1_21 );
|
||||
}
|
||||
|
||||
SUPPORTED_VERSIONS = supportedVersions.build();
|
||||
|
@ -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 );
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -87,6 +87,7 @@ public abstract class EntityMap
|
||||
case ProtocolConstants.MINECRAFT_1_20_3:
|
||||
return EntityMap_1_16_2.INSTANCE_1_20_3;
|
||||
case ProtocolConstants.MINECRAFT_1_20_5:
|
||||
case ProtocolConstants.MINECRAFT_1_21:
|
||||
return EntityMap_1_16_2.INSTANCE_1_20_5;
|
||||
}
|
||||
throw new RuntimeException( "Version " + version + " has no entity map" );
|
||||
|
Loading…
Reference in New Issue
Block a user