mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 12:27:59 +01:00
added remaining hunks from chat/title packets (#5844)
This commit is contained in:
parent
e3fac1cbe3
commit
ca8a47f9e8
@ -1110,6 +1110,78 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
// Spigot start
|
// Spigot start
|
||||||
if (this.components != null) {
|
if (this.components != null) {
|
||||||
buf.writeUtf(net.md_5.bungee.chat.ComponentSerializer.toString(components));
|
buf.writeUtf(net.md_5.bungee.chat.ComponentSerializer.toString(components));
|
||||||
|
diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundSetActionBarTextPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundSetActionBarTextPacket.java
|
||||||
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundSetActionBarTextPacket.java
|
||||||
|
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundSetActionBarTextPacket.java
|
||||||
|
@@ -0,0 +0,0 @@ import net.minecraft.network.protocol.Packet;
|
||||||
|
|
||||||
|
public class ClientboundSetActionBarTextPacket implements Packet<ClientGamePacketListener> {
|
||||||
|
private final Component text;
|
||||||
|
+ public net.kyori.adventure.text.Component adventure$text; // Paper
|
||||||
|
|
||||||
|
public ClientboundSetActionBarTextPacket(Component message) {
|
||||||
|
this.text = message;
|
||||||
|
@@ -0,0 +0,0 @@ public class ClientboundSetActionBarTextPacket implements Packet<ClientGamePacke
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(FriendlyByteBuf buf) {
|
||||||
|
+ // Paper start
|
||||||
|
+ if (this.adventure$text != null) {
|
||||||
|
+ buf.writeComponent(this.adventure$text);
|
||||||
|
+ } else
|
||||||
|
+ // Paper end
|
||||||
|
buf.writeComponent(this.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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundSetSubtitleTextPacket.java
|
||||||
|
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundSetSubtitleTextPacket.java
|
||||||
|
@@ -0,0 +0,0 @@ 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 ClientboundSetSubtitleTextPacket(Component subtitle) {
|
||||||
|
this.text = subtitle;
|
||||||
|
@@ -0,0 +0,0 @@ public class ClientboundSetSubtitleTextPacket implements Packet<ClientGamePacket
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(FriendlyByteBuf buf) {
|
||||||
|
+ // Paper start
|
||||||
|
+ if (this.adventure$text != null) {
|
||||||
|
+ buf.writeComponent(this.adventure$text);
|
||||||
|
+ } 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundSetTitleTextPacket.java
|
||||||
|
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundSetTitleTextPacket.java
|
||||||
|
@@ -0,0 +0,0 @@ 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 ClientboundSetTitleTextPacket(Component title) {
|
||||||
|
this.text = title;
|
||||||
|
@@ -0,0 +0,0 @@ public class ClientboundSetTitleTextPacket implements Packet<ClientGamePacketLis
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(FriendlyByteBuf buf) {
|
||||||
|
+ // Paper start
|
||||||
|
+ if (this.adventure$text != null) {
|
||||||
|
+ buf.writeComponent(this.adventure$text);
|
||||||
|
+ } else
|
||||||
|
+ // Paper end
|
||||||
|
buf.writeComponent(this.text);
|
||||||
|
}
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundTabListPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundTabListPacket.java
|
diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundTabListPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundTabListPacket.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundTabListPacket.java
|
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundTabListPacket.java
|
||||||
@ -2221,8 +2293,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public void sendActionBar(final net.kyori.adventure.text.Component message) {
|
+ public void sendActionBar(final net.kyori.adventure.text.Component message) {
|
||||||
+ final net.minecraft.network.protocol.game.ClientboundSetActionBarTextPacket packet = new net.minecraft.network.protocol.game.ClientboundSetActionBarTextPacket(io.papermc.paper.adventure.PaperAdventure.asVanilla(message));
|
+ final net.minecraft.network.protocol.game.ClientboundSetActionBarTextPacket packet = new net.minecraft.network.protocol.game.ClientboundSetActionBarTextPacket((net.minecraft.network.chat.Component) null);
|
||||||
+ // packet.adventure$text = message; // TODO: kashike add fields to packet
|
+ packet.adventure$text = message;
|
||||||
+ this.getHandle().connection.send(packet);
|
+ this.getHandle().connection.send(packet);
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
@ -2248,9 +2320,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+ private void adventure$sendPlayerListHeaderAndFooter() {
|
+ private void adventure$sendPlayerListHeaderAndFooter() {
|
||||||
+ final ServerGamePacketListenerImpl connection = this.getHandle().connection;
|
+ final ServerGamePacketListenerImpl connection = this.getHandle().connection;
|
||||||
+ if (connection == null) return;
|
+ if (connection == null) return;
|
||||||
+ final ClientboundTabListPacket packet = new net.minecraft.network.protocol.game.ClientboundTabListPacket(io.papermc.paper.adventure.PaperAdventure.asVanilla((this.playerListHeader == null) ? net.kyori.adventure.text.Component.empty() : this.playerListHeader), io.papermc.paper.adventure.PaperAdventure.asVanilla((this.playerListFooter == null) ? net.kyori.adventure.text.Component.empty() : this.playerListFooter));
|
+ final ClientboundTabListPacket packet = new ClientboundTabListPacket(null, null);
|
||||||
+ // packet.adventure$header = (this.playerListHeader == null) ? net.kyori.adventure.text.Component.empty() : this.playerListHeader; // TODO: kashike add fields to packet
|
+ packet.adventure$header = (this.playerListHeader == null) ? net.kyori.adventure.text.Component.empty() : this.playerListHeader;
|
||||||
+ // packet.adventure$footer = (this.playerListFooter == null) ? net.kyori.adventure.text.Component.empty() : this.playerListFooter;
|
+ packet.adventure$footer = (this.playerListFooter == null) ? net.kyori.adventure.text.Component.empty() : this.playerListFooter;
|
||||||
+ connection.send(packet);
|
+ connection.send(packet);
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
@ -2261,11 +2333,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+ if (times != null) {
|
+ if (times != null) {
|
||||||
+ connection.send(new ClientboundSetTitlesAnimationPacket(ticks(times.fadeIn()), ticks(times.stay()), ticks(times.fadeOut())));
|
+ connection.send(new ClientboundSetTitlesAnimationPacket(ticks(times.fadeIn()), ticks(times.stay()), ticks(times.fadeOut())));
|
||||||
+ }
|
+ }
|
||||||
+ final ClientboundSetSubtitleTextPacket sp = new ClientboundSetSubtitleTextPacket(io.papermc.paper.adventure.PaperAdventure.asVanilla(title.subtitle()));
|
+ final ClientboundSetSubtitleTextPacket sp = new ClientboundSetSubtitleTextPacket((net.minecraft.network.chat.Component) null);
|
||||||
+ // sp.adventure$text = title.subtitle(); // TODO: kashike add fields to packet
|
+ sp.adventure$text = title.subtitle();
|
||||||
+ connection.send(sp);
|
+ connection.send(sp);
|
||||||
+ final ClientboundSetTitleTextPacket tp = new ClientboundSetTitleTextPacket(io.papermc.paper.adventure.PaperAdventure.asVanilla(title.title()));
|
+ final ClientboundSetTitleTextPacket tp = new ClientboundSetTitleTextPacket((net.minecraft.network.chat.Component) null);
|
||||||
+ // tp.adventure$text = title.title();
|
+ tp.adventure$text = title.title();
|
||||||
+ connection.send(tp);
|
+ connection.send(tp);
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
|
@ -32,6 +32,48 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
@Nullable
|
@Nullable
|
||||||
public static MutableComponent fromJson(String json) {
|
public static MutableComponent fromJson(String json) {
|
||||||
return (MutableComponent) GsonHelper.fromJson(Component.Serializer.GSON, json, MutableComponent.class, false);
|
return (MutableComponent) GsonHelper.fromJson(Component.Serializer.GSON, json, MutableComponent.class, false);
|
||||||
|
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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundSetSubtitleTextPacket.java
|
||||||
|
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundSetSubtitleTextPacket.java
|
||||||
|
@@ -0,0 +0,0 @@ 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;
|
||||||
|
@@ -0,0 +0,0 @@ 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundSetTitleTextPacket.java
|
||||||
|
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundSetTitleTextPacket.java
|
||||||
|
@@ -0,0 +0,0 @@ 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;
|
||||||
|
@@ -0,0 +0,0 @@ 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
|
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
|
||||||
@ -81,8 +123,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public void setSubtitle(BaseComponent[] subtitle) {
|
+ public void setSubtitle(BaseComponent[] subtitle) {
|
||||||
+ final String json = net.md_5.bungee.chat.ComponentSerializer.toString(subtitle);
|
+ final ClientboundSetSubtitleTextPacket packet = new ClientboundSetSubtitleTextPacket((net.minecraft.network.chat.Component) null);
|
||||||
+ getHandle().connection.send(new ClientboundSetSubtitleTextPacket(Component.Serializer.fromJson(json)));
|
+ packet.components = subtitle;
|
||||||
|
+ getHandle().connection.send(packet);
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
@ -92,8 +135,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public void showTitle(BaseComponent[] title) {
|
+ public void showTitle(BaseComponent[] title) {
|
||||||
+ final String json = net.md_5.bungee.chat.ComponentSerializer.toString(title);
|
+ final ClientboundSetTitleTextPacket packet = new ClientboundSetTitleTextPacket((net.minecraft.network.chat.Component) null);
|
||||||
+ getHandle().connection.send(new ClientboundSetTitleTextPacket(Component.Serializer.fromJson(json)));
|
+ packet.components = title;
|
||||||
|
+ getHandle().connection.send(packet);
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
|
@ -4,6 +4,27 @@ Date: Tue, 27 Dec 2016 15:02:42 -0500
|
|||||||
Subject: [PATCH] String based Action Bar API
|
Subject: [PATCH] String based Action Bar API
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundSetActionBarTextPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundSetActionBarTextPacket.java
|
||||||
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundSetActionBarTextPacket.java
|
||||||
|
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundSetActionBarTextPacket.java
|
||||||
|
@@ -0,0 +0,0 @@ import net.minecraft.network.protocol.Packet;
|
||||||
|
public class ClientboundSetActionBarTextPacket 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 ClientboundSetActionBarTextPacket(Component message) {
|
||||||
|
this.text = message;
|
||||||
|
@@ -0,0 +0,0 @@ public class ClientboundSetActionBarTextPacket implements Packet<ClientGamePacke
|
||||||
|
// 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
|
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
|
||||||
@ -15,7 +36,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+ @Override
|
+ @Override
|
||||||
+ public void sendActionBar(BaseComponent[] message) {
|
+ public void sendActionBar(BaseComponent[] message) {
|
||||||
+ if (getHandle().connection == null) return;
|
+ if (getHandle().connection == null) return;
|
||||||
+ getHandle().connection.send(new net.minecraft.network.protocol.game.ClientboundSetActionBarTextPacket(Component.Serializer.fromJson(net.md_5.bungee.chat.ComponentSerializer.toString(message))));
|
+ net.minecraft.network.protocol.game.ClientboundSetActionBarTextPacket packet = new net.minecraft.network.protocol.game.ClientboundSetActionBarTextPacket((net.minecraft.network.chat.Component) null);
|
||||||
|
+ packet.components = message;
|
||||||
|
+ getHandle().connection.send(packet);
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
|
Loading…
Reference in New Issue
Block a user