Paper/patches/server/0438-Brand-support.patch

77 lines
5.0 KiB
Diff
Raw Normal View History

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/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
Updated Upstream (Bukkit/CraftBukkit/Spigot) Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: cc9aa21a SPIGOT-6399, SPIGOT-7344: Clarify collidable behavior for player entities f23325b6 Add API for per-world simulation distances 26e1774e Add API for per-world view distances 0b541e60 Add PlayerLoginEvent#getRealAddress 5f027d2d PR-949: Add Vector#fromJOML() overloads for read-only vector types CraftBukkit Changes: bcf56171a PR-1321: Clean up some stuff which got missed during previous PRs 7f833a2d1 SPIGOT-7462: Players no longer drop XP after dying near a Sculk Catalyst 752aac669 Implement APIs for per world view and simulation distances 57d7ef433 Preserve empty enchantment tags for glow effect 465ec3fb4 Remove connected check on setScoreboard f90ce621e Use one PermissibleBase for all command blocks 5876cca44 SPIGOT-7550: Fix creation of Arrow instances f03fc3aa3 SPIGOT-7549: ServerTickManager#setTickRate incorrect Precondition 9d7f49b01 SPIGOT-7548: Fix wrong spawn location for experience orb and dropped item Spigot Changes: ed9ba9a4 Drop no longer required patch ignoring -o option 86b5dd6a SPIGOT-7546: Fix hardcoded check for outdated client message aa7cde7a Remove obsolete APIs for per world view and simulation distances 6dff577e Remove obsolete patch preserving empty `ench` tags a3bf95b8 Remove obsolete PlayerLoginEvent#getRealAddress 1b02f5d6 Remove obsolete connected check on setScoreboard patch acf717eb Remove obsolete command block PermissibleBase patch 053fa2a9 Remove redundant patch dealing with null tile entities
2023-12-25 23:51:56 +01:00
index 14126f4f2f0c8d5ae06275fd735178a2c4d3efc0..f73988baef278bf603fc53a8a371514a094d9c37 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
2023-12-06 04:00:14 +01:00
@@ -278,6 +278,7 @@ public class ServerPlayer extends Player {
public boolean isRealPlayer; // Paper
public final com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<ServerPlayer> cachedSingleHashSet; // Paper
2023-12-06 04:00:14 +01:00
public com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // Paper
+ public @Nullable String clientBrandName = null; // Paper - Brand name
// 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
2023-12-25 11:51:44 +01:00
index 44aa178968c87fa72023a2c0f33c1a8123f3db72..f489b207cd3b62a33723f2e9ed0f46020d7f4fd1 100644
--- a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
2023-12-25 11:51:44 +01:00
@@ -55,6 +55,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
private volatile boolean suspendFlushingOnServerThread = false;
2023-12-25 11:51:44 +01:00
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;
2023-12-25 11:51:44 +01:00
@@ -110,6 +111,11 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
2023-09-24 20:48:29 +02:00
@Override
public void handleCustomPayload(ServerboundCustomPayloadPacket packet) {
+ // Paper start - handle brand payload packet
+ if (packet.payload() instanceof net.minecraft.network.protocol.common.custom.BrandPayload brandPayload) {
+ this.player.clientBrandName = brandPayload.brand();
2023-09-24 20:48:29 +02:00
+ }
+ // Paper end - handle brand payload
if (!(packet.payload() instanceof ServerboundCustomPayloadPacket.UnknownPayload)) {
return;
}
2023-12-25 11:51:44 +01:00
@@ -141,6 +147,15 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
try {
byte[] data = new byte[payload.readableBytes()];
payload.readBytes(data);
2023-09-24 20:48:29 +02:00
+ // 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
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 196ece23104bc67a2df4e528851c0a2df8baaf5b..ff8bef2a88f04e4a333f90de05faddd66c69be20 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;