3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-11-17 05:20:14 +01:00

Merge remote-tracking branch 'origin/dev/3.0.0' into dev/3.0.0

# Conflicts:
#	api/src/main/java/com/velocitypowered/api/proxy/Player.java
#	proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java
Dieser Commit ist enthalten in:
Andrew Steinborn 2021-06-12 20:13:52 -04:00
Commit c33f9e0466
4 geänderte Dateien mit 28 neuen und 5 gelöschten Zeilen

Datei anzeigen

@ -237,4 +237,12 @@ public interface Player extends CommandSource, Identified, InboundConnection,
return HoverEvent.showEntity(op.apply(HoverEvent.ShowEntity.of(this, getUniqueId(), return HoverEvent.showEntity(op.apply(HoverEvent.ShowEntity.of(this, getUniqueId(),
Component.text(getUsername())))); Component.text(getUsername()))));
} }
/**
* Gets the player's client brand.
*
* @return the player's client brand
*/
@Nullable String getClientBrand();
} }

Datei anzeigen

@ -230,6 +230,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
player.getKnownChannels().removeAll(PluginMessageUtil.getChannels(packet)); player.getKnownChannels().removeAll(PluginMessageUtil.getChannels(packet));
backendConn.write(packet.retain()); backendConn.write(packet.retain());
} else if (PluginMessageUtil.isMcBrand(packet)) { } else if (PluginMessageUtil.isMcBrand(packet)) {
player.setClientBrand(PluginMessageUtil.readBrandMessage(packet.content()));
backendConn.write(PluginMessageUtil backendConn.write(PluginMessageUtil
.rewriteMinecraftBrand(packet, server.getVersion(), player.getProtocolVersion())); .rewriteMinecraftBrand(packet, server.getVersion(), player.getProtocolVersion()));
} else if (BungeeCordMessageResponder.isBungeeCordMessage(packet)) { } else if (BungeeCordMessageResponder.isBungeeCordMessage(packet)) {

Datei anzeigen

@ -144,6 +144,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
.withDynamic(Identity.NAME, this::getUsername) .withDynamic(Identity.NAME, this::getUsername)
.withStatic(PermissionChecker.POINTER, getPermissionChecker()) .withStatic(PermissionChecker.POINTER, getPermissionChecker())
.build(); .build();
private @Nullable String clientBrand;
ConnectedPlayer(VelocityServer server, GameProfile profile, MinecraftConnection connection, ConnectedPlayer(VelocityServer server, GameProfile profile, MinecraftConnection connection,
@Nullable InetSocketAddress virtualHost, boolean onlineMode) { @Nullable InetSocketAddress virtualHost, boolean onlineMode) {
@ -761,6 +762,15 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
return true; return true;
} }
@Override
public String getClientBrand() {
return clientBrand;
}
void setClientBrand(String clientBrand) {
this.clientBrand = clientBrand;
}
@Override @Override
public void spoofChatInput(String input) { public void spoofChatInput(String input) {
Preconditions.checkArgument(input.length() <= Chat.MAX_SERVERBOUND_MESSAGE_LENGTH, Preconditions.checkArgument(input.length() <= Chat.MAX_SERVERBOUND_MESSAGE_LENGTH,

Datei anzeigen

@ -139,11 +139,15 @@ public final class PluginMessageUtil {
return new PluginMessage(message.getChannel(), rewrittenBuf); return new PluginMessage(message.getChannel(), rewrittenBuf);
} }
private static String readBrandMessage(ByteBuf content) { /**
// Some clients (mostly poorly-implemented bots) do not send validly-formed brand messages. * Some clients (mostly poorly-implemented bots) do not send validly-formed brand messages.
// In order to accommodate their broken behavior, we'll first try to read in the 1.8 format, and * In order to accommodate their broken behavior, we'll first try to read in the 1.8 format, and
// if that fails, treat it as a 1.7-format message (which has no prefixed length). (The message * if that fails, treat it as a 1.7-format message (which has no prefixed length). (The message
// Velocity sends will be in the correct format depending on the protocol.) * Velocity sends will be in the correct format depending on the protocol.)
* @param content the brand packet
* @return the client brand
*/
public static String readBrandMessage(ByteBuf content) {
try { try {
return ProtocolUtils.readString(content.slice()); return ProtocolUtils.readString(content.slice());
} catch (Exception e) { } catch (Exception e) {