2020-05-06 09:48:49 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2016-02-29 23:09:49 +00:00
|
|
|
From: Techcable <Techcable@outlook.com>
|
|
|
|
Date: Thu, 3 Mar 2016 02:32:10 -0600
|
|
|
|
Subject: [PATCH] Player Tab List and Title APIs
|
|
|
|
|
|
|
|
|
2018-09-01 10:09:13 +00:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/IChatBaseComponent.java b/src/main/java/net/minecraft/server/IChatBaseComponent.java
|
2021-02-21 19:45:33 +00:00
|
|
|
index de6bfc27cd38fd6293853d55cf62699aade94212..65aec1dc2fd9ef9c9a9f022f13008505383a0af4 100644
|
2018-09-01 10:09:13 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/IChatBaseComponent.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/IChatBaseComponent.java
|
2021-02-21 19:45:33 +00:00
|
|
|
@@ -356,6 +356,7 @@ public interface IChatBaseComponent extends Message, IChatFormatted, Iterable<IC
|
2019-01-01 03:15:55 +00:00
|
|
|
return IChatBaseComponent.ChatSerializer.a.toJsonTree(ichatbasecomponent);
|
2018-09-01 10:09:13 +00:00
|
|
|
}
|
|
|
|
|
2018-09-01 10:33:50 +00:00
|
|
|
+ @Nullable public static IChatBaseComponent jsonToComponent(String json) { return a(json);} // Paper - OBFHELPER
|
2018-09-01 10:09:13 +00:00
|
|
|
@Nullable
|
2020-06-25 09:27:25 +00:00
|
|
|
public static IChatMutableComponent a(String s) {
|
|
|
|
return (IChatMutableComponent) ChatDeserializer.a(IChatBaseComponent.ChatSerializer.a, s, IChatMutableComponent.class, false);
|
2021-02-27 11:02:06 +00:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/PacketDataSerializer.java b/src/main/java/net/minecraft/server/PacketDataSerializer.java
|
|
|
|
index 6c9aed49d5e63d6df608719ed17e813f86e93fcc..391f96e585d80f7921fd96f207b0b60d88961ae7 100644
|
|
|
|
--- a/src/main/java/net/minecraft/server/PacketDataSerializer.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/PacketDataSerializer.java
|
|
|
|
@@ -158,6 +158,11 @@ public class PacketDataSerializer extends ByteBuf {
|
|
|
|
public PacketDataSerializer writeComponent(final net.kyori.adventure.text.Component component) {
|
|
|
|
return this.writeUtf(PaperAdventure.asJsonString(component, this.adventure$locale), 262144);
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ @Deprecated
|
|
|
|
+ public PacketDataSerializer writeComponent(final net.md_5.bungee.api.chat.BaseComponent[] component) {
|
|
|
|
+ return this.writeUtf(net.md_5.bungee.chat.ComponentSerializer.toString(component), 262144);
|
|
|
|
+ }
|
|
|
|
// Paper end
|
|
|
|
|
|
|
|
public PacketDataSerializer a(IChatBaseComponent ichatbasecomponent) {
|
2016-03-23 06:05:09 +00:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutTitle.java b/src/main/java/net/minecraft/server/PacketPlayOutTitle.java
|
2021-02-27 11:02:06 +00:00
|
|
|
index 772ca6256964692a2b9c12e2edc532d2a8f51f7b..71168d9d0252e93253fa3b3f0bface3ae58757b7 100644
|
2016-03-23 06:05:09 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/PacketPlayOutTitle.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/PacketPlayOutTitle.java
|
2021-02-21 19:45:33 +00:00
|
|
|
@@ -44,6 +44,17 @@ public class PacketPlayOutTitle implements Packet<PacketListenerPlayOut> {
|
2019-01-01 03:15:55 +00:00
|
|
|
}
|
2016-03-23 06:05:09 +00:00
|
|
|
|
2018-08-31 22:56:57 +00:00
|
|
|
}
|
2016-03-23 06:05:09 +00:00
|
|
|
+ // Paper start
|
|
|
|
+ public net.md_5.bungee.api.chat.BaseComponent[] components;
|
|
|
|
+
|
|
|
|
+ public PacketPlayOutTitle(EnumTitleAction action, net.md_5.bungee.api.chat.BaseComponent[] components, int fadeIn, int stay, int fadeOut) {
|
|
|
|
+ this.a = action;
|
|
|
|
+ this.components = components;
|
|
|
|
+ this.c = fadeIn;
|
|
|
|
+ this.d = stay;
|
|
|
|
+ this.e = fadeOut;
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
|
2019-04-26 01:24:00 +00:00
|
|
|
@Override
|
2016-03-23 06:05:09 +00:00
|
|
|
public void b(PacketDataSerializer packetdataserializer) throws IOException {
|
2021-02-27 11:02:06 +00:00
|
|
|
@@ -52,6 +63,8 @@ public class PacketPlayOutTitle implements Packet<PacketListenerPlayOut> {
|
|
|
|
// Paper start
|
|
|
|
if (this.adventure$text != null) {
|
|
|
|
packetdataserializer.writeComponent(this.adventure$text);
|
|
|
|
+ } else if (this.components != null) {
|
|
|
|
+ packetdataserializer.writeComponent(this.components);
|
|
|
|
} else
|
|
|
|
// Paper end
|
|
|
|
packetdataserializer.a(this.b);
|
2016-02-29 23:09:49 +00:00
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
2021-02-24 09:32:17 +00:00
|
|
|
index 4c0a6d00b17b5e11c0f2b5d7170701bedd20b87c..2542b3a135dd3f728a5a44c9f9c81ae524734abf 100644
|
2016-02-29 23:09:49 +00: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;
|
2017-02-18 02:03:38 +00:00
|
|
|
import com.google.common.io.BaseEncoding;
|
2021-02-24 09:32:17 +00:00
|
|
|
@@ -238,6 +239,96 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
2016-12-20 22:34:27 +00:00
|
|
|
}
|
2016-02-29 23:09:49 +00:00
|
|
|
}
|
2016-12-20 22:34:27 +00:00
|
|
|
|
|
|
|
+ // Paper start
|
2016-02-29 23:09:49 +00:00
|
|
|
+ @Override
|
|
|
|
+ public void setPlayerListHeaderFooter(BaseComponent[] header, BaseComponent[] footer) {
|
2018-09-01 10:09:13 +00:00
|
|
|
+ if (header != null) {
|
2018-10-15 05:05:02 +00:00
|
|
|
+ String headerJson = net.md_5.bungee.chat.ComponentSerializer.toString(header);
|
2021-02-21 19:45:33 +00:00
|
|
|
+ playerListHeader = net.kyori.adventure.text.serializer.gson.GsonComponentSerializer.gson().deserialize(headerJson);
|
2018-09-01 10:09:13 +00:00
|
|
|
+ } else {
|
|
|
|
+ playerListHeader = null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (footer != null) {
|
2018-10-15 05:05:02 +00:00
|
|
|
+ String footerJson = net.md_5.bungee.chat.ComponentSerializer.toString(footer);
|
2021-02-21 19:45:33 +00:00
|
|
|
+ playerListFooter = net.kyori.adventure.text.serializer.gson.GsonComponentSerializer.gson().deserialize(footerJson);
|
|
|
|
+ } else {
|
2018-09-01 10:09:13 +00:00
|
|
|
+ playerListFooter = null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ updatePlayerListHeaderFooter();
|
2016-02-29 23:09:49 +00:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @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) {
|
|
|
|
+ getHandle().playerConnection.sendPacket(new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.TIMES, (BaseComponent[]) null, fadeInTicks, stayTicks, fadeOutTicks));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void setSubtitle(BaseComponent[] subtitle) {
|
|
|
|
+ getHandle().playerConnection.sendPacket(new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.SUBTITLE, subtitle, 0, 0, 0));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void setSubtitle(BaseComponent subtitle) {
|
|
|
|
+ setSubtitle(new BaseComponent[]{subtitle});
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void showTitle(BaseComponent[] title) {
|
|
|
|
+ getHandle().playerConnection.sendPacket(new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.TITLE, title, 0, 0, 0));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @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() {
|
|
|
|
+ getHandle().playerConnection.sendPacket(new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.CLEAR, (BaseComponent[]) null, 0, 0, 0));
|
|
|
|
+ }
|
2016-12-20 22:34:27 +00:00
|
|
|
+ // Paper end
|
|
|
|
+
|
2016-02-29 23:09:49 +00:00
|
|
|
@Override
|
2016-12-20 22:34:27 +00:00
|
|
|
public String getDisplayName() {
|
2021-02-23 13:45:09 +00:00
|
|
|
if(true) return io.papermc.paper.adventure.PaperAdventure.LEGACY_SECTION_UXRC.serialize(this.getHandle().adventure$displayName); // Paper
|