diff options
Diffstat (limited to 'patches/server/0059-Player-Tab-List-and-Title-APIs.patch')
-rw-r--r-- | patches/server/0059-Player-Tab-List-and-Title-APIs.patch | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/patches/server/0059-Player-Tab-List-and-Title-APIs.patch b/patches/server/0059-Player-Tab-List-and-Title-APIs.patch new file mode 100644 index 0000000000..db2fa88567 --- /dev/null +++ b/patches/server/0059-Player-Tab-List-and-Title-APIs.patch @@ -0,0 +1,109 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Techcable <[email protected]> +Date: Thu, 3 Mar 2016 02:32:10 -0600 +Subject: [PATCH] Player Tab List and Title APIs + + +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +index 68df6270f7d08cde78235749950e05bf60c1641c..ef3f1d00a595fd1fb7297d7ab96e791acbcbbed6 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +@@ -386,6 +386,98 @@ public class CraftPlayer extends CraftHumanEntity implements Player { + } + } + ++ // 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) { ++ getHandle().connection.send(new ClientboundSetTitlesAnimationPacket(fadeInTicks, stayTicks, fadeOutTicks)); ++ } ++ ++ @Override ++ public void setSubtitle(BaseComponent[] subtitle) { ++ final ClientboundSetSubtitleTextPacket packet = new ClientboundSetSubtitleTextPacket(org.bukkit.craftbukkit.util.CraftChatMessage.fromJSON(net.md_5.bungee.chat.ComponentSerializer.toString(subtitle))); ++ getHandle().connection.send(packet); ++ } ++ ++ @Override ++ public void setSubtitle(BaseComponent subtitle) { ++ setSubtitle(new BaseComponent[]{subtitle}); ++ } ++ ++ @Override ++ public void showTitle(BaseComponent[] title) { ++ final ClientboundSetTitleTextPacket packet = new ClientboundSetTitleTextPacket(org.bukkit.craftbukkit.util.CraftChatMessage.fromJSON(net.md_5.bungee.chat.ComponentSerializer.toString(title))); ++ getHandle().connection.send(packet); ++ } ++ ++ @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(com.destroystokyo.paper.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(com.destroystokyo.paper.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().connection.send(new ClientboundClearTitlesPacket(false)); ++ } ++ // Paper end ++ + @Override + public String getDisplayName() { + if(true) return io.papermc.paper.adventure.DisplayNames.getLegacy(this); // Paper |