Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/SpigotMC/BungeeCord
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed May 27, 2024
2 parents f04278b + 52ab21b commit c48f932
Show file tree
Hide file tree
Showing 7 changed files with 174 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-bom</artifactId>
<version>4.1.109.Final</version>
<version>4.1.110.Final</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
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;
Expand Down Expand Up @@ -38,6 +39,7 @@
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;
Expand Down Expand Up @@ -268,4 +270,12 @@ public void handle(CookieRequest cookieRequest) throws Exception
public void handle(CookieResponse cookieResponse) throws Exception
{
}

public void handle(DisconnectReportDetails disconnectReportDetails) throws Exception
{
}

public void handle(ServerLinks serverLinks) throws Exception
{
}
}
22 changes: 22 additions & 0 deletions protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
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;
Expand All @@ -44,6 +45,7 @@
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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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 );
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public static EntityMap getEntityMap(int version)
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" );
Expand Down

0 comments on commit c48f932

Please sign in to comment.