2021-06-11 14:02:28 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Techcable <Techcable@outlook.com>
|
|
|
|
Date: Thu, 3 Mar 2016 02:32:10 -0600
|
|
|
|
Subject: [PATCH] Player Tab List and Title APIs
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/network/FriendlyByteBuf.java b/src/main/java/net/minecraft/network/FriendlyByteBuf.java
|
2023-12-29 20:51:52 +01:00
|
|
|
index 39940edf4aef21842c8abd77bec0d0f1e7e9c762..7dcd8d4e4886e1d35adbc604eafabccb5550f1b4 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/net/minecraft/network/FriendlyByteBuf.java
|
|
|
|
+++ b/src/main/java/net/minecraft/network/FriendlyByteBuf.java
|
2023-12-29 20:51:52 +01:00
|
|
|
@@ -545,6 +545,12 @@ public class FriendlyByteBuf extends ByteBuf {
|
2023-12-12 22:40:33 +01:00
|
|
|
return this.writeWithCodec(NbtOps.INSTANCE, ComponentSerialization.localizedCodec(this.adventure$locale), text);
|
2023-12-12 07:02:06 +01:00
|
|
|
// Paper end - adventure
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
2023-12-12 05:24:48 +01:00
|
|
|
+ // Paper start - deprecated Tab List & Title APIs
|
2021-06-11 14:02:28 +02:00
|
|
|
+ @Deprecated
|
|
|
|
+ public FriendlyByteBuf writeComponent(final net.md_5.bungee.api.chat.BaseComponent[] component) {
|
2023-12-12 05:24:48 +01:00
|
|
|
+ return this.writeComponent(java.util.Objects.requireNonNull(Component.Serializer.fromJson(net.md_5.bungee.chat.ComponentSerializer.toString(component))));
|
2021-06-11 14:02:28 +02:00
|
|
|
+ }
|
2023-12-12 05:24:48 +01:00
|
|
|
+ // Paper end - deprecated Tab List & Title APIs
|
2021-06-11 14:02:28 +02:00
|
|
|
|
2023-12-12 05:24:48 +01:00
|
|
|
public <T extends Enum<T>> T readEnum(Class<T> enumClass) {
|
|
|
|
return ((T[]) enumClass.getEnumConstants())[this.readVarInt()]; // CraftBukkit - fix decompile error
|
2021-06-16 01:41:38 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundSetSubtitleTextPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundSetSubtitleTextPacket.java
|
2023-12-05 20:54:55 +01:00
|
|
|
index e77bd5bb66279f579fad4fdcc8b0606410922e9e..4c05fee93eb20044a4198c43d5ae1eebebaabaf7 100644
|
2021-06-16 01:41:38 +02:00
|
|
|
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundSetSubtitleTextPacket.java
|
|
|
|
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundSetSubtitleTextPacket.java
|
|
|
|
@@ -7,6 +7,7 @@ import net.minecraft.network.protocol.Packet;
|
|
|
|
public class ClientboundSetSubtitleTextPacket implements Packet<ClientGamePacketListener> {
|
|
|
|
private final Component text;
|
|
|
|
public net.kyori.adventure.text.Component adventure$text; // Paper
|
|
|
|
+ public net.md_5.bungee.api.chat.BaseComponent[] components; // Paper
|
|
|
|
|
|
|
|
public ClientboundSetSubtitleTextPacket(Component subtitle) {
|
|
|
|
this.text = subtitle;
|
|
|
|
@@ -21,6 +22,8 @@ public class ClientboundSetSubtitleTextPacket implements Packet<ClientGamePacket
|
|
|
|
// Paper start
|
|
|
|
if (this.adventure$text != null) {
|
|
|
|
buf.writeComponent(this.adventure$text);
|
|
|
|
+ } else if (this.components != null) {
|
|
|
|
+ buf.writeComponent(this.components);
|
|
|
|
} else
|
|
|
|
// Paper end
|
|
|
|
buf.writeComponent(this.text);
|
|
|
|
diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundSetTitleTextPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundSetTitleTextPacket.java
|
2023-12-05 20:54:55 +01:00
|
|
|
index 7bb08db97c324d13836303cc8a4623c71d6c8a2c..5e9045f7722481e1f83a3d36d7b3d86e9f45d5b1 100644
|
2021-06-16 01:41:38 +02:00
|
|
|
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundSetTitleTextPacket.java
|
|
|
|
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundSetTitleTextPacket.java
|
|
|
|
@@ -7,6 +7,7 @@ import net.minecraft.network.protocol.Packet;
|
|
|
|
public class ClientboundSetTitleTextPacket implements Packet<ClientGamePacketListener> {
|
|
|
|
private final Component text;
|
|
|
|
public net.kyori.adventure.text.Component adventure$text; // Paper
|
|
|
|
+ public net.md_5.bungee.api.chat.BaseComponent[] components; // Paper
|
|
|
|
|
|
|
|
public ClientboundSetTitleTextPacket(Component title) {
|
|
|
|
this.text = title;
|
|
|
|
@@ -21,6 +22,8 @@ public class ClientboundSetTitleTextPacket implements Packet<ClientGamePacketLis
|
|
|
|
// Paper start
|
|
|
|
if (this.adventure$text != null) {
|
|
|
|
buf.writeComponent(this.adventure$text);
|
|
|
|
+ } else if (this.components != null) {
|
|
|
|
+ buf.writeComponent(this.components);
|
|
|
|
} else
|
|
|
|
// Paper end
|
|
|
|
buf.writeComponent(this.text);
|
2021-06-11 14:02:28 +02:00
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
2023-12-29 20:51:52 +01:00
|
|
|
index 054ada5455c6570f86d9a010fcb8eaf57bf7151d..6d8b46743473832b2c7c604b3023541a22e3abc9 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
|
|
@@ -1,5 +1,6 @@
|
|
|
|
package org.bukkit.craftbukkit.entity;
|
|
|
|
|
|
|
|
+import com.destroystokyo.paper.Title;
|
|
|
|
import com.google.common.base.Preconditions;
|
|
|
|
import com.google.common.collect.ImmutableSet;
|
|
|
|
import com.google.common.io.BaseEncoding;
|
Updated Upstream (Bukkit/CraftBukkit) (#10034)
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:
f29cb801 Separate checkstyle-suppressions file is not required
86f99bbe SPIGOT-7540, PR-946: Add ServerTickManager API
d4119585 SPIGOT-6903, PR-945: Add BlockData#getMapColor
b7a2ed41 SPIGOT-7530, PR-947: Add Player#removeResourcePack
9dd56255 SPIGOT-7527, PR-944: Add WindCharge#explode()
994a6163 Attempt upgrade of resolver libraries
CraftBukkit Changes:
b3b43a6ad Add Checkstyle check for unused imports
13fb3358e SPIGOT-7544: Scoreboard#getEntries() doesn't get entries but class names
3dda99c06 SPIGOT-7540, PR-1312: Add ServerTickManager API
2ab4508c0 SPIGOT-6903, PR-1311: Add BlockData#getMapColor
1dbdbbed4 PR-1238: Remove unnecessary sign ticking
659728d2a MC-264285, SPIGOT-7439, PR-1237: Fix unbreakable flint and steel is completely consumed while igniting creeper
e37e29ce0 Increase outdated build delay
c00438b39 SPIGOT-7530, PR-1313: Add Player#removeResourcePack
492dd80ce SPIGOT-7527, PR-1310: Add WindCharge#explode()
e11fbb9d7 Upgrade MySQL driver
9f3a0bd2a Attempt upgrade of resolver libraries
60d16d7ca PR-1306: Centralize Bukkit and Minecraft entity conversion
Spigot Changes:
06d602e7 Rebuild patches
2023-12-17 03:09:28 +01:00
|
|
|
@@ -340,6 +341,100 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Paper start
|
|
|
|
+ @Override
|
|
|
|
+ public void setPlayerListHeaderFooter(BaseComponent[] header, BaseComponent[] footer) {
|
|
|
|
+ if (header != null) {
|
|
|
|
+ String headerJson = net.md_5.bungee.chat.ComponentSerializer.toString(header);
|
|
|
|
+ playerListHeader = net.kyori.adventure.text.serializer.gson.GsonComponentSerializer.gson().deserialize(headerJson);
|
|
|
|
+ } else {
|
|
|
|
+ playerListHeader = null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (footer != null) {
|
|
|
|
+ String footerJson = net.md_5.bungee.chat.ComponentSerializer.toString(footer);
|
|
|
|
+ playerListFooter = net.kyori.adventure.text.serializer.gson.GsonComponentSerializer.gson().deserialize(footerJson);
|
|
|
|
+ } else {
|
|
|
|
+ playerListFooter = null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ updatePlayerListHeaderFooter();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void setPlayerListHeaderFooter(BaseComponent header, BaseComponent footer) {
|
|
|
|
+ this.setPlayerListHeaderFooter(header == null ? null : new BaseComponent[]{header},
|
|
|
|
+ footer == null ? null : new BaseComponent[]{footer});
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void setTitleTimes(int fadeInTicks, int stayTicks, int fadeOutTicks) {
|
2021-06-12 04:23:18 +02:00
|
|
|
+ getHandle().connection.send(new ClientboundSetTitlesAnimationPacket(fadeInTicks, stayTicks, fadeOutTicks));
|
2021-06-11 14:02:28 +02:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void setSubtitle(BaseComponent[] subtitle) {
|
2021-06-16 01:41:38 +02:00
|
|
|
+ final ClientboundSetSubtitleTextPacket packet = new ClientboundSetSubtitleTextPacket((net.minecraft.network.chat.Component) null);
|
|
|
|
+ packet.components = subtitle;
|
|
|
|
+ getHandle().connection.send(packet);
|
2021-06-11 14:02:28 +02:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void setSubtitle(BaseComponent subtitle) {
|
|
|
|
+ setSubtitle(new BaseComponent[]{subtitle});
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void showTitle(BaseComponent[] title) {
|
2021-06-16 01:41:38 +02:00
|
|
|
+ final ClientboundSetTitleTextPacket packet = new ClientboundSetTitleTextPacket((net.minecraft.network.chat.Component) null);
|
|
|
|
+ packet.components = title;
|
|
|
|
+ getHandle().connection.send(packet);
|
2021-06-11 14:02:28 +02:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void showTitle(BaseComponent title) {
|
|
|
|
+ showTitle(new BaseComponent[]{title});
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void showTitle(BaseComponent[] title, BaseComponent[] subtitle, int fadeInTicks, int stayTicks, int fadeOutTicks) {
|
|
|
|
+ setTitleTimes(fadeInTicks, stayTicks, fadeOutTicks);
|
|
|
|
+ setSubtitle(subtitle);
|
|
|
|
+ showTitle(title);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void showTitle(BaseComponent title, BaseComponent subtitle, int fadeInTicks, int stayTicks, int fadeOutTicks) {
|
|
|
|
+ setTitleTimes(fadeInTicks, stayTicks, fadeOutTicks);
|
|
|
|
+ setSubtitle(subtitle);
|
|
|
|
+ showTitle(title);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void sendTitle(Title title) {
|
|
|
|
+ Preconditions.checkNotNull(title, "Title is null");
|
|
|
|
+ setTitleTimes(title.getFadeIn(), title.getStay(), title.getFadeOut());
|
|
|
|
+ setSubtitle(title.getSubtitle() == null ? new BaseComponent[0] : title.getSubtitle());
|
|
|
|
+ showTitle(title.getTitle());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void updateTitle(Title title) {
|
|
|
|
+ Preconditions.checkNotNull(title, "Title is null");
|
|
|
|
+ setTitleTimes(title.getFadeIn(), title.getStay(), title.getFadeOut());
|
|
|
|
+ if (title.getSubtitle() != null) {
|
|
|
|
+ setSubtitle(title.getSubtitle());
|
|
|
|
+ }
|
|
|
|
+ showTitle(title.getTitle());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void hideTitle() {
|
2021-06-12 04:23:18 +02:00
|
|
|
+ getHandle().connection.send(new ClientboundClearTitlesPacket(false));
|
2021-06-11 14:02:28 +02:00
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
+
|
|
|
|
@Override
|
|
|
|
public String getDisplayName() {
|
|
|
|
if(true) return io.papermc.paper.adventure.DisplayNames.getLegacy(this); // Paper
|