mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-09 12:19:56 +01:00
f79c0daece
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: 5c21a63f PR-717: Add PlayerHideEntityEvent and PlayerShowEntityEvent CraftBukkit Changes: c26a7b54d PR-1000: Add PlayerHideEntityEvent and PlayerShowEntityEvent
92 lines
4.6 KiB
Diff
92 lines
4.6 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/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
index 67f0a953751707f982df958e88c825ea98f4f984..bbfcadfd3316f2617288b1dd48d145b266b29cfe 100644
|
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
@@ -4,6 +4,7 @@ import com.google.common.collect.Lists;
|
|
import com.google.common.primitives.Floats;
|
|
import com.mojang.brigadier.ParseResults;
|
|
import com.mojang.brigadier.StringReader;
|
|
+import io.netty.buffer.Unpooled;
|
|
import io.netty.util.concurrent.Future;
|
|
import io.netty.util.concurrent.GenericFutureListener;
|
|
import it.unimi.dsi.fastutil.ints.Int2ObjectMap.Entry;
|
|
@@ -37,6 +38,7 @@ import net.minecraft.nbt.CompoundTag;
|
|
import net.minecraft.nbt.ListTag;
|
|
import net.minecraft.nbt.StringTag;
|
|
import net.minecraft.network.Connection;
|
|
+import net.minecraft.network.FriendlyByteBuf;
|
|
import net.minecraft.network.chat.ChatType;
|
|
import net.minecraft.network.chat.Component;
|
|
import net.minecraft.network.chat.MutableComponent;
|
|
@@ -258,6 +260,8 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
|
private static final int MAX_SIGN_LINE_LENGTH = Integer.getInteger("Paper.maxSignLength", 80);
|
|
private static final long KEEPALIVE_LIMIT = Long.getLong("paper.playerconnection.keepalive", 30) * 1000; // Paper - provide property to set keepalive limit
|
|
|
|
+ private String clientBrandName = null; // Paper - Brand name
|
|
+
|
|
public ServerGamePacketListenerImpl(MinecraftServer server, Connection connection, ServerPlayer player) {
|
|
this.server = server;
|
|
this.connection = connection;
|
|
@@ -3007,6 +3011,8 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
|
private static final ResourceLocation CUSTOM_REGISTER = new ResourceLocation("register");
|
|
private static final ResourceLocation CUSTOM_UNREGISTER = new ResourceLocation("unregister");
|
|
|
|
+ private static final ResourceLocation MINECRAFT_BRAND = new ResourceLocation("brand"); // Paper - Brand support
|
|
+
|
|
@Override
|
|
public void handleCustomPayload(ServerboundCustomPayloadPacket packet) {
|
|
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel());
|
|
@@ -3034,6 +3040,15 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
|
try {
|
|
byte[] data = new byte[packet.data.readableBytes()];
|
|
packet.data.readBytes(data);
|
|
+ // Paper start - Brand support
|
|
+ if (packet.identifier.equals(MINECRAFT_BRAND)) {
|
|
+ try {
|
|
+ this.clientBrandName = new FriendlyByteBuf(Unpooled.copiedBuffer(data)).readUtf(256);
|
|
+ } catch (StringIndexOutOfBoundsException ex) {
|
|
+ this.clientBrandName = "illegal";
|
|
+ }
|
|
+ }
|
|
+ // Paper end
|
|
this.cserver.getMessenger().dispatchIncomingMessage(this.player.getBukkitEntity(), packet.identifier.toString(), data);
|
|
} catch (Exception ex) {
|
|
ServerGamePacketListenerImpl.LOGGER.error("Couldn\'t dispatch custom payload", ex);
|
|
@@ -3043,6 +3058,12 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
|
|
|
}
|
|
|
|
+ // Paper start - brand support
|
|
+ public String getClientBrandName() {
|
|
+ return 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 26d784b974ee25b4d26e52822162d7998f45c640..8dc8b4984b745355491760196ca4e25a944a6cae 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
@@ -2591,6 +2591,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|
// Paper end
|
|
};
|
|
|
|
+ // Paper start - brand support
|
|
+ @Override
|
|
+ public String getClientBrandName() {
|
|
+ return getHandle().connection != null ? getHandle().connection.getClientBrandName() : null;
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
public Player.Spigot spigot()
|
|
{
|
|
return this.spigot;
|