Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 04:20:04 +01:00
77 Zeilen
4.9 KiB
Diff
77 Zeilen
4.9 KiB
Diff
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
|
|
index e6a24484ef11a1d815a85126aec221547479f7d3..ffd9ff7db5180cb351839a3ce331353d16b662d2 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
@@ -290,6 +290,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
|
|
|
|
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 289a74e35836717bd20c777e9fc8c17722e90411..a5dce1e83e63292054b21ec693ec3006e08d3ff2 100644
|
|
--- a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
|
@@ -77,6 +77,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;
|
|
@@ -142,6 +143,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;
|
|
}
|
|
@@ -173,6 +179,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 776532b4818d15a5f4cfd35d0c076d4774615681..9a9c6e43c96689171a2767f93aea8856db1b7287 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
@@ -3112,6 +3112,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;
|