diff options
author | Jake Potrebic <[email protected]> | 2024-06-13 13:57:13 -0700 |
---|---|---|
committer | Jake Potrebic <[email protected]> | 2024-06-13 13:57:13 -0700 |
commit | 27e29ccaf24065325acf1b70b18f99157a924893 (patch) | |
tree | d3220349fc0244b0e8aac2b1063dbef028107e07 /patches/server/0396-Brand-support.patch | |
parent | 0bc9aeef268b9522e3c97dd5a09b8d3d759a6fb8 (diff) | |
download | Paper-27e29ccaf24065325acf1b70b18f99157a924893.tar.gz Paper-27e29ccaf24065325acf1b70b18f99157a924893.zip |
487/1053
Diffstat (limited to 'patches/server/0396-Brand-support.patch')
-rw-r--r-- | patches/server/0396-Brand-support.patch | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/patches/server/0396-Brand-support.patch b/patches/server/0396-Brand-support.patch new file mode 100644 index 0000000000..eb4a88b700 --- /dev/null +++ b/patches/server/0396-Brand-support.patch @@ -0,0 +1,76 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: DigitalRegent <[email protected]> +Date: Sat, 11 Apr 2020 13:10:58 +0200 +Subject: [PATCH] Brand support + + +diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java +index b808d9c710d6cd59ac34ea537f603fd4002073d0..45d36070735cd7a8baee585165a95a169d7059b4 100644 +--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java ++++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java +@@ -294,6 +294,7 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player { + public boolean isRealPlayer; // Paper + public final com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<ServerPlayer> cachedSingleHashSet; // Paper + public com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // Paper - PlayerNaturallySpawnCreaturesEvent ++ public @Nullable String clientBrandName = null; // Paper - Brand support + + public ServerPlayer(MinecraftServer server, ServerLevel world, GameProfile profile, ClientInformation clientOptions) { + super(world, world.getSharedSpawnPos(), world.getSharedSpawnAngle(), profile); +diff --git a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java +index adf953994d2c7e8f1e15075722ee2b9213e4bf94..4761a8d8f342c649bc2e5f530819fa88f43542ec 100644 +--- a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java ++++ b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java +@@ -78,6 +78,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack + private volatile boolean suspendFlushingOnServerThread = false; + public final java.util.Map<java.util.UUID, net.kyori.adventure.resource.ResourcePackCallback> packCallbacks = new java.util.concurrent.ConcurrentHashMap<>(); // Paper - adventure resource pack callbacks + private static final long KEEPALIVE_LIMIT = Long.getLong("paper.playerconnection.keepalive", 30) * 1000; // Paper - provide property to set keepalive limit ++ protected static final ResourceLocation MINECRAFT_BRAND = new ResourceLocation("brand"); // Paper - Brand support + + public ServerCommonPacketListenerImpl(MinecraftServer minecraftserver, Connection networkmanager, CommonListenerCookie commonlistenercookie, ServerPlayer player) { // CraftBukkit + this.server = minecraftserver; +@@ -143,6 +144,11 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack + + @Override + public void handleCustomPayload(ServerboundCustomPayloadPacket packet) { ++ // Paper start - Brand support ++ if (packet.payload() instanceof net.minecraft.network.protocol.common.custom.BrandPayload brandPayload) { ++ this.player.clientBrandName = brandPayload.brand(); ++ } ++ // Paper end - Brand support + if (!(packet.payload() instanceof DiscardedPayload)) { + return; + } +@@ -174,6 +180,15 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack + try { + byte[] data = new byte[payload.readableBytes()]; + payload.readBytes(data); ++ // Paper start - Brand support; Retain this incase upstream decides to 'break' the new mechanism in favour of backwards compat... ++ if (identifier.equals(MINECRAFT_BRAND)) { ++ try { ++ this.player.clientBrandName = new net.minecraft.network.FriendlyByteBuf(io.netty.buffer.Unpooled.copiedBuffer(data)).readUtf(256); ++ } catch (StringIndexOutOfBoundsException ex) { ++ this.player.clientBrandName = "illegal"; ++ } ++ } ++ // Paper end - Brand support + this.cserver.getMessenger().dispatchIncomingMessage(this.player.getBukkitEntity(), identifier.toString(), data); + } catch (Exception ex) { + ServerGamePacketListenerImpl.LOGGER.error("Couldn\'t dispatch custom payload", ex); +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +index e837939d35ee168f5640b28fae07675817492cb9..8b89959fa688f17ea9f16597cc0cc49f1d94a0ff 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +@@ -3134,6 +3134,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player { + // Paper end + }; + ++ // Paper start - brand support ++ @Override ++ public String getClientBrandName() { ++ return getHandle().clientBrandName; ++ } ++ // Paper end ++ + public Player.Spigot spigot() + { + return this.spigot; |