#3823: Add client brand API

This commit is contained in:
Outfluencer 2025-04-21 08:28:16 +02:00 committed by GitHub
parent 1279cca971
commit 89069a362d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 17 additions and 0 deletions

View File

@ -382,4 +382,12 @@ public interface ProxiedPlayer extends Connection, CommandSender
*/
@ApiStatus.Experimental
void transfer(String host, int port);
/**
* Gets the client brand of this player.
* If the player has not sent a brand packet yet, it will return null.
*
* @return the brand of the client, or null if not received yet
*/
String getClientBrand();
}

View File

@ -778,6 +778,11 @@ public final class UserConnection implements ProxiedPlayer
return this.getPendingConnection().getExtraDataInHandshake();
}
public String getClientBrand()
{
return getPendingConnection().getClientBrand();
}
public void setCompressionThreshold(int compressionThreshold)
{
if ( !ch.isClosing() && this.compressionThreshold == -1 && compressionThreshold >= 0 )

View File

@ -2,6 +2,7 @@ package net.md_5.bungee.connection;
import com.google.common.base.Preconditions;
import com.google.gson.Gson;
import io.netty.buffer.Unpooled;
import java.math.BigInteger;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
@ -97,6 +98,8 @@ public class InitialHandler extends PacketHandler implements PendingConnection
@Getter
private PluginMessage brandMessage;
@Getter
private String clientBrand;
@Getter
private final Set<String> registeredChannels = new HashSet<>();
private State thisState = State.HANDSHAKE;
private int loginPayloadId;
@ -849,6 +852,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
} else if ( input.getTag().equals( "MC|Brand" ) || input.getTag().equals( "minecraft:brand" ) )
{
brandMessage = input;
clientBrand = DefinedPacket.readString( Unpooled.wrappedBuffer( input.getData() ) );
}
}