aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0414-Brand-support.patch
diff options
context:
space:
mode:
authorNassim Jahnke <[email protected]>2024-01-23 18:01:39 +0100
committerNassim Jahnke <[email protected]>2024-01-23 18:06:51 +0100
commitc57d1aa24560ec71331e685e9fd27aa3d9274f69 (patch)
treeb585b2246be85ecc5047b02b704c0a5f59c96dd9 /patches/server/0414-Brand-support.patch
parente66037960b02c7b22bbed75318904c55a4177977 (diff)
downloadPaper-c57d1aa24560ec71331e685e9fd27aa3d9274f69.tar.gz
Paper-c57d1aa24560ec71331e685e9fd27aa3d9274f69.zip
Move diffs around to compile without later ones applied
Diffstat (limited to 'patches/server/0414-Brand-support.patch')
-rw-r--r--patches/server/0414-Brand-support.patch76
1 files changed, 76 insertions, 0 deletions
diff --git a/patches/server/0414-Brand-support.patch b/patches/server/0414-Brand-support.patch
new file mode 100644
index 0000000000..687d90e2ef
--- /dev/null
+++ b/patches/server/0414-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 897fa2857f070a976cc95695d7009f663a6bc89d..27f1d336b2493bf475a388f63cce8d99408acea3 100644
+--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
++++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
+@@ -274,6 +274,7 @@ public class ServerPlayer extends 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
+
+ // Paper start - replace player chunk loader
+ private final java.util.concurrent.atomic.AtomicReference<io.papermc.paper.chunk.system.RegionizedPlayerChunkLoader.ViewDistances> viewDistances = new java.util.concurrent.atomic.AtomicReference<>(new io.papermc.paper.chunk.system.RegionizedPlayerChunkLoader.ViewDistances(-1, -1, -1));
+diff --git a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
+index e69043316372d98b122ed3788fda79cdd36849e8..6597e6e9987ddb5906909c22704fdfb6557aee8e 100644
+--- a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
++++ b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
+@@ -55,6 +55,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;
+@@ -110,6 +111,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 ServerboundCustomPayloadPacket.UnknownPayload)) {
+ return;
+ }
+@@ -141,6 +147,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 4de49a81238ca3d550f85fdcdf921c17f992f65a..ac908edaad2e58e4813f236e938e9d305f93dbe6 100644
+--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+@@ -3030,6 +3030,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;