diff --git a/patches/server/Add-API-for-quit-reason.patch b/patches/server/Add-API-for-quit-reason.patch index 45e505229f..1256f23a08 100644 --- a/patches/server/Add-API-for-quit-reason.patch +++ b/patches/server/Add-API-for-quit-reason.patch @@ -29,9 +29,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java @@ -0,0 +0,0 @@ public class ServerPlayer extends Player { - public boolean isRealPlayer; // Paper public final com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<ServerPlayer> cachedSingleHashSet; // Paper public PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // Paper + public @Nullable String clientBrandName = null; // Paper - Brand name + public org.bukkit.event.player.PlayerQuitEvent.QuitReason quitReason = null; // Paper - there are a lot of changes to do if we change all methods leading to the event // Paper start - replace player chunk loader diff --git a/patches/server/Brand-support.patch b/patches/server/Brand-support.patch index 81d7d9e74c..f85d0e447a 100644 --- a/patches/server/Brand-support.patch +++ b/patches/server/Brand-support.patch @@ -4,6 +4,18 @@ 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java ++++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java +@@ -0,0 +0,0 @@ public class ServerPlayer extends Player { + public boolean isRealPlayer; // Paper + public final com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<ServerPlayer> cachedSingleHashSet; // Paper + public 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 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java @@ -12,7 +24,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 private int latency; private volatile boolean suspendFlushingOnServerThread = false; private static final long KEEPALIVE_LIMIT = Long.getLong("paper.playerconnection.keepalive", 30) * 1000; // Paper - provide property to set keepalive limit -+ private @Nullable String clientBrandName = null; // Paper - Brand name + protected static final ResourceLocation MINECRAFT_BRAND = new ResourceLocation("brand"); // Paper - Brand support public ServerCommonPacketListenerImpl(MinecraftServer minecraftserver, Connection networkmanager, CommonListenerCookie commonlistenercookie, ServerPlayer player) { // CraftBukkit @@ -23,7 +34,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public void handleCustomPayload(ServerboundCustomPayloadPacket packet) { + // Paper start - handle brand payload packet + if (packet.payload() instanceof net.minecraft.network.protocol.common.custom.BrandPayload brandPayload) { -+ this.clientBrandName = brandPayload.brand(); ++ this.player.clientBrandName = brandPayload.brand(); + } + // Paper end - handle brand payload if (!(packet.payload() instanceof ServerboundCustomPayloadPacket.UnknownPayload)) { @@ -36,29 +47,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // 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.clientBrandName = new net.minecraft.network.FriendlyByteBuf(io.netty.buffer.Unpooled.copiedBuffer(data)).readUtf(256); ++ this.player.clientBrandName = new net.minecraft.network.FriendlyByteBuf(io.netty.buffer.Unpooled.copiedBuffer(data)).readUtf(256); + } catch (StringIndexOutOfBoundsException ex) { -+ this.clientBrandName = "illegal"; ++ 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); -@@ -0,0 +0,0 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack - - } - -+ // Paper start - brand support -+ @Nullable -+ public String getClientBrandName() { -+ return this.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 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -70,7 +67,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start - brand support + @Override + public String getClientBrandName() { -+ return getHandle().connection != null ? getHandle().connection.getClientBrandName() : null; ++ return getHandle().clientBrandName; + } + // Paper end +