2021-06-11 14:02:28 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: DigitalRegent <misterwener@gmail.com>
Date: Sat, 11 Apr 2020 13:10:58 +0200
Subject: [PATCH] Brand support
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
2023-02-09 18:15:21 +01:00
index d5f879303080dadf0fbd5d15840c2536942c6d0b..473944ad4f317dcb8d0a0ec9dcc736dfc04ae382 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
2022-08-29 15:21:45 +02:00
@@ -298,6 +298,8 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
2021-06-11 14:02:28 +02:00
private static final long KEEPALIVE_LIMIT = Long.getLong("paper.playerconnection.keepalive", 30) * 1000; // Paper - provide property to set keepalive limit
2022-06-08 08:06:17 +02:00
private static final int MAX_SIGN_LINE_LENGTH = Integer.getInteger("Paper.maxSignLength", 80); // Paper
2021-06-11 14:02:28 +02:00
+ private String clientBrandName = null; // Paper - Brand name
+
public ServerGamePacketListenerImpl(MinecraftServer server, Connection connection, ServerPlayer player) {
2022-06-08 08:06:17 +02:00
this.lastChatTimeStamp = new AtomicReference(Instant.EPOCH);
2022-12-07 21:16:54 +01:00
this.lastSeenMessages = new LastSeenMessagesValidator(20);
2023-02-09 18:15:21 +01:00
@@ -3328,6 +3330,8 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
2021-06-11 14:02:28 +02:00
private static final ResourceLocation CUSTOM_REGISTER = new ResourceLocation("register");
private static final ResourceLocation CUSTOM_UNREGISTER = new ResourceLocation("unregister");
+ private static final ResourceLocation MINECRAFT_BRAND = new ResourceLocation("brand"); // Paper - Brand support
+
@Override
public void handleCustomPayload(ServerboundCustomPayloadPacket packet) {
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel());
2023-02-09 18:15:21 +01:00
@@ -3355,6 +3359,15 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
2021-06-11 14:02:28 +02:00
try {
byte[] data = new byte[packet.data.readableBytes()];
packet.data.readBytes(data);
+ // Paper start - Brand support
+ if (packet.identifier.equals(MINECRAFT_BRAND)) {
+ try {
2022-06-08 08:06:17 +02:00
+ this.clientBrandName = new net.minecraft.network.FriendlyByteBuf(io.netty.buffer.Unpooled.copiedBuffer(data)).readUtf(256);
2021-06-11 14:02:28 +02:00
+ } catch (StringIndexOutOfBoundsException ex) {
+ this.clientBrandName = "illegal";
+ }
+ }
+ // Paper end
2021-06-14 12:42:08 +02:00
this.cserver.getMessenger().dispatchIncomingMessage(this.player.getBukkitEntity(), packet.identifier.toString(), data);
2021-06-11 14:02:28 +02:00
} catch (Exception ex) {
ServerGamePacketListenerImpl.LOGGER.error("Couldn\'t dispatch custom payload", ex);
2023-02-09 18:15:21 +01:00
@@ -3364,6 +3377,12 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
2021-06-11 14:02:28 +02:00
}
+ // Paper start - brand support
+ public String getClientBrandName() {
+ return clientBrandName;
+ }
+ // Paper end
+
public final boolean isDisconnected() {
return (!this.player.joining && !this.connection.isConnected()) || this.processedDisconnect; // Paper
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
2023-02-09 18:15:21 +01:00
index 4592cac06c8e96d4677ba315f70d5336fcdd0558..b098fcdcadcbf3dac5942a451a16e24b137fa08d 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
2023-02-09 18:15:21 +01:00
@@ -2847,6 +2847,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
2021-06-11 14:02:28 +02:00
// Paper end
};
+ // Paper start - brand support
+ @Override
+ public String getClientBrandName() {
+ return getHandle().connection != null ? getHandle().connection.getClientBrandName() : null;
+ }
+ // Paper end
+
public Player.Spigot spigot()
{
2021-06-14 12:42:08 +02:00
return this.spigot;