mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-04 07:17:46 +01:00
Move clientBrandName over to ServerPlayer (#9809)
This commit is contained in:
parent
a9860b1ccd
commit
e331557dfc
@ -29,9 +29,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||||
+++ b/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 {
|
@@ -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 final com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<ServerPlayer> cachedSingleHashSet; // Paper
|
||||||
public PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // 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
|
+ 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
|
// Paper start - replace player chunk loader
|
||||||
|
@ -4,6 +4,18 @@ Date: Sat, 11 Apr 2020 13:10:58 +0200
|
|||||||
Subject: [PATCH] Brand support
|
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
|
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
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
--- a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
||||||
@ -12,7 +24,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
private int latency;
|
private int latency;
|
||||||
private volatile boolean suspendFlushingOnServerThread = false;
|
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 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
|
+ protected static final ResourceLocation MINECRAFT_BRAND = new ResourceLocation("brand"); // Paper - Brand support
|
||||||
|
|
||||||
public ServerCommonPacketListenerImpl(MinecraftServer minecraftserver, Connection networkmanager, CommonListenerCookie commonlistenercookie, ServerPlayer player) { // CraftBukkit
|
public ServerCommonPacketListenerImpl(MinecraftServer minecraftserver, Connection networkmanager, CommonListenerCookie commonlistenercookie, ServerPlayer player) { // CraftBukkit
|
||||||
@ -23,7 +34,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
public void handleCustomPayload(ServerboundCustomPayloadPacket packet) {
|
public void handleCustomPayload(ServerboundCustomPayloadPacket packet) {
|
||||||
+ // Paper start - handle brand payload packet
|
+ // Paper start - handle brand payload packet
|
||||||
+ if (packet.payload() instanceof net.minecraft.network.protocol.common.custom.BrandPayload brandPayload) {
|
+ 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
|
+ // Paper end - handle brand payload
|
||||||
if (!(packet.payload() instanceof ServerboundCustomPayloadPacket.UnknownPayload)) {
|
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...
|
+ // Paper start - Brand support - Retain this incase upstream decides to 'break' the new mechanism in favour of backwards compat...
|
||||||
+ if (identifier.equals(MINECRAFT_BRAND)) {
|
+ if (identifier.equals(MINECRAFT_BRAND)) {
|
||||||
+ try {
|
+ 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) {
|
+ } catch (StringIndexOutOfBoundsException ex) {
|
||||||
+ this.clientBrandName = "illegal";
|
+ this.player.clientBrandName = "illegal";
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
this.cserver.getMessenger().dispatchIncomingMessage(this.player.getBukkitEntity(), identifier.toString(), data);
|
this.cserver.getMessenger().dispatchIncomingMessage(this.player.getBukkitEntity(), identifier.toString(), data);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ServerGamePacketListenerImpl.LOGGER.error("Couldn\'t dispatch custom payload", 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
|
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
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||||
@ -70,7 +67,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+ // Paper start - brand support
|
+ // Paper start - brand support
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public String getClientBrandName() {
|
+ public String getClientBrandName() {
|
||||||
+ return getHandle().connection != null ? getHandle().connection.getClientBrandName() : null;
|
+ return getHandle().clientBrandName;
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
+
|
+
|
||||||
|
Loading…
Reference in New Issue
Block a user