mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-27 04:55:47 +01:00
2fa8efce9b
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: 82af5dc6 SPIGOT-7396: Add PlayerSignOpenEvent 3f0281ca SPIGOT-7063, PR-763: Add DragonBattle#initiateRespawn with custom EnderCrystals f83c8df4 PR-873: Add PlayerRecipeBookClickEvent 14560d39 SPIGOT-7435: Add TeleportCause#EXIT_BED 2cc6db92 SPIGOT-7422, PR-887: Add API to set sherds on decorated pots 36022f02 PR-883: Add ItemFactory#getSpawnEgg 12eb5c46 PR-881: Update Scoreboard Javadocs, remove explicit exception throwing f6d8d44a PR-882: Add modern time API methods to ban API 21a7b710 Upgrade some Maven plugins to reduce warnings 11fd1225 PR-886: Deprecate the SmithingRecipe constructor as it now does nothing dbd1761d SPIGOT-7406: Improve documentation for getDragonBattle CraftBukkit Changes: d548daac2 SPIGOT-7446: BlockState#update not updating a spawner's type to null 70e0bc050 SPIGOT-7447: Fix --forceUpgrade 6752f1d63 SPIGOT-7396: Add PlayerSignOpenEvent 847b4cad5 SPIGOT-7063, PR-1071: Add DragonBattle#initiateRespawn with custom EnderCrystals c335a555f PR-1212: Add PlayerRecipeBookClickEvent 4be756ecb SPIGOT-7445: Fix opening smithing inventory db70bd6ed SPIGOT-7441: Fix issue placing certain items in creative/op f7fa6d993 SPIGOT-7435: Add TeleportCause#EXIT_BED b435e8e8d SPIGOT-7349: Player#setDisplayName not working when message/format unmodified a2fafdd1d PR-1232: Re-add fix for player rotation 7cf863de1 PR-1233: Remove some old MC bug fixes now fixed in vanilla 08ec344ad Fix ChunkGenerator#generateCaves never being called 5daeb502a SPIGOT-7422, PR-1228: Add API to set sherds on decorated pots 52faa6b32 PR-1224: Add ItemFactory#getSpawnEgg 01cae71b7 SPIGOT-7429: Fix LEFT_CLICK_AIR not working for passable entities and spectators a94277a18 PR-1223: Remove non-existent scoreboard display name/prefix/suffix limits 36b107660 PR-1225: Add modern time API methods to ban API 59ead25bc Upgrade some Maven plugins to reduce warnings 202fc5c4e Increase outdated build delay ce545de57 SPIGOT-7398: TextDisplay#setInterpolationDuration incorrectly updates the line width Spigot Changes: b41c46db Rebuild patches 3374045a SPIGOT-7431: Fix EntityMountEvent returning opposite entities 0ca4eb66 Rebuild patches
177 lines
8.0 KiB
Diff
177 lines
8.0 KiB
Diff
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
|
|
index 9020bc6d9ff6bc0c9b3f00470813f3258554cf45..c2f56f4628e42c130e4c55030432cb43aa0d8458 100644
|
|
--- a/src/main/java/net/minecraft/network/FriendlyByteBuf.java
|
|
+++ b/src/main/java/net/minecraft/network/FriendlyByteBuf.java
|
|
@@ -548,6 +548,11 @@ public class FriendlyByteBuf extends ByteBuf {
|
|
public FriendlyByteBuf writeComponent(final net.kyori.adventure.text.Component component) {
|
|
return this.writeUtf(PaperAdventure.asJsonString(component, this.adventure$locale), 262144);
|
|
}
|
|
+
|
|
+ @Deprecated
|
|
+ public FriendlyByteBuf 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 FriendlyByteBuf writeComponent(Component text) {
|
|
diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundSetSubtitleTextPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundSetSubtitleTextPacket.java
|
|
index c44a276d201fdfa5144d45d319d7761583c60639..f68a1a6dc6add9496e25cb52c318e086e356e2bb 100644
|
|
--- 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
|
|
index bd808eb312ade7122973a47f4b96505829511da5..bf0f9cab7c66c089f35b851e799ba4a43420b437 100644
|
|
--- 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);
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
index d9031a89cc087fef8c39bcb93c68d07b8b2ab474..b6f8885196f806174f7d611c778fc1f74129d6d4 100644
|
|
--- 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;
|
|
@@ -334,6 +335,100 @@ 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((net.minecraft.network.chat.Component) null);
|
|
+ packet.components = 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((net.minecraft.network.chat.Component) null);
|
|
+ packet.components = 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(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().connection.send(new ClientboundClearTitlesPacket(false));
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
@Override
|
|
public String getDisplayName() {
|
|
if(true) return io.papermc.paper.adventure.DisplayNames.getLegacy(this); // Paper
|