mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-01 00:10:32 +01:00
89d51d5f29
Because this exploit has been widely known for years and has not been fixed by Mojang, we decided that it was worth allowing people to toggle it on/off due to how easy it is to make it configurable. It should be noted that this decision does not promise all future exploits will be configurable.
77 lines
4.9 KiB
Diff
77 lines
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 966b86a2b26a32aad2656d1f2beb6daf5b81b3b1..587cce4d3878bc5cba5f4f4e58eacce2f656e242 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
@@ -273,6 +273,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 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 5ba0fa6fda6d496f7540185e6dc58439cc1e04f1..16d1338df730fd66c079b66117cbef91786f2146 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
@@ -3056,6 +3056,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;
|