2016-02-18 03:03:21 +01:00
|
|
|
From 88944a9edb0263524b98a1f1731831a360de0bd9 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Techcable <Techcable@outlook.com>
|
2016-02-17 02:55:21 +01:00
|
|
|
Date: Tue, 16 Feb 2016 19:45:55 -0600
|
|
|
|
Subject: [PATCH] Player Tab List and Title APIs
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutPlayerListHeaderFooter.java b/src/main/java/net/minecraft/server/PacketPlayOutPlayerListHeaderFooter.java
|
2016-02-18 03:03:21 +01:00
|
|
|
index 1606d6d..795e70a 100644
|
2016-02-17 02:55:21 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/PacketPlayOutPlayerListHeaderFooter.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/PacketPlayOutPlayerListHeaderFooter.java
|
|
|
|
@@ -4,6 +4,8 @@ import java.io.IOException;
|
|
|
|
|
|
|
|
public class PacketPlayOutPlayerListHeaderFooter implements Packet<PacketListenerPlayOut> {
|
|
|
|
|
|
|
|
+ public net.md_5.bungee.api.chat.BaseComponent[] header, footer; // Paper
|
|
|
|
+
|
|
|
|
private IChatBaseComponent a;
|
|
|
|
private IChatBaseComponent b;
|
|
|
|
|
2016-02-18 03:03:21 +01:00
|
|
|
@@ -19,15 +21,30 @@ public class PacketPlayOutPlayerListHeaderFooter implements Packet<PacketListene
|
2016-02-17 02:55:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void b(PacketDataSerializer packetdataserializer) throws IOException {
|
|
|
|
- packetdataserializer.a(this.a);
|
|
|
|
- packetdataserializer.a(this.b);
|
|
|
|
+ // Paper start
|
|
|
|
+ if (this.header != null) {
|
|
|
|
+ packetdataserializer.a(net.md_5.bungee.chat.ComponentSerializer.toString(this.header));
|
|
|
|
+ } else {
|
|
|
|
+ packetdataserializer.a(this.a);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (this.footer != null) {
|
|
|
|
+ packetdataserializer.a(net.md_5.bungee.chat.ComponentSerializer.toString(this.footer));
|
|
|
|
+ } else {
|
|
|
|
+ packetdataserializer.a(this.b);
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(PacketListenerPlayOut packetlistenerplayout) {
|
|
|
|
packetlistenerplayout.a(this);
|
|
|
|
}
|
2016-02-18 03:03:21 +01:00
|
|
|
|
|
|
|
+ // PaperSpigot start - fix compile error
|
|
|
|
+ /*
|
|
|
|
public void a(PacketListener packetlistener) {
|
|
|
|
this.a((PacketListenerPlayOut) packetlistener);
|
|
|
|
}
|
|
|
|
+ */
|
|
|
|
+ // PaperSpigot end
|
2016-02-17 02:55:21 +01:00
|
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutTitle.java b/src/main/java/net/minecraft/server/PacketPlayOutTitle.java
|
2016-02-18 03:03:21 +01:00
|
|
|
index 2711298..20016b5 100644
|
2016-02-17 02:55:21 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/PacketPlayOutTitle.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/PacketPlayOutTitle.java
|
|
|
|
@@ -10,6 +10,18 @@ public class PacketPlayOutTitle implements Packet<PacketListenerPlayOut> {
|
|
|
|
private int d;
|
|
|
|
private int e;
|
|
|
|
|
|
|
|
+ // 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
|
|
|
|
+
|
|
|
|
public PacketPlayOutTitle() {}
|
|
|
|
|
|
|
|
public PacketPlayOutTitle(EnumTitleAction packetplayouttitle_enumtitleaction, IChatBaseComponent ichatbasecomponent) {
|
|
|
|
@@ -45,7 +57,13 @@ public class PacketPlayOutTitle implements Packet<PacketListenerPlayOut> {
|
|
|
|
public void b(PacketDataSerializer packetdataserializer) throws IOException {
|
|
|
|
packetdataserializer.a((Enum) this.a);
|
|
|
|
if (this.a == EnumTitleAction.TITLE || this.a == EnumTitleAction.SUBTITLE) {
|
|
|
|
- packetdataserializer.a(this.b);
|
|
|
|
+ // Paper start
|
|
|
|
+ if (this.components != null) {
|
|
|
|
+ packetdataserializer.a(net.md_5.bungee.chat.ComponentSerializer.toString(components));
|
|
|
|
+ } else {
|
|
|
|
+ packetdataserializer.a(this.b);
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.a == EnumTitleAction.TIMES) {
|
2016-02-18 03:03:21 +01:00
|
|
|
@@ -60,9 +78,13 @@ public class PacketPlayOutTitle implements Packet<PacketListenerPlayOut> {
|
2016-02-17 02:55:21 +01:00
|
|
|
packetlistenerplayout.a(this);
|
|
|
|
}
|
|
|
|
|
2016-02-18 03:03:21 +01:00
|
|
|
+ // PaperSpigot start - fix compile error
|
|
|
|
+ /*
|
|
|
|
public void a(PacketListener packetlistener) {
|
|
|
|
this.a((PacketListenerPlayOut) packetlistener);
|
|
|
|
}
|
|
|
|
+ */
|
|
|
|
+ // PaperSpigot end
|
|
|
|
|
2016-02-17 02:55:21 +01:00
|
|
|
public static enum EnumTitleAction {
|
|
|
|
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
2016-02-18 03:03:21 +01:00
|
|
|
index dba0520..3075076 100644
|
2016-02-17 02:55:21 +01:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
2016-02-18 03:03:21 +01:00
|
|
|
@@ -64,6 +64,9 @@ import org.bukkit.metadata.MetadataValue;
|
|
|
|
import org.bukkit.plugin.Plugin;
|
|
|
|
import org.bukkit.plugin.messaging.StandardMessenger;
|
|
|
|
import org.bukkit.scoreboard.Scoreboard;
|
|
|
|
+// PaperSpigot start
|
|
|
|
+import org.github.paperspigot.Title;
|
|
|
|
+// PaperSpigot end
|
|
|
|
|
|
|
|
@DelegateDeserialization(CraftOfflinePlayer.class)
|
|
|
|
public class CraftPlayer extends CraftHumanEntity implements Player {
|
|
|
|
@@ -176,6 +179,83 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
2016-02-17 02:55:21 +01:00
|
|
|
packet.components = components;
|
|
|
|
getHandle().playerConnection.sendPacket(packet);
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void setPlayerListHeaderFooter(BaseComponent[] header, BaseComponent[] footer) {
|
|
|
|
+ PacketPlayOutPlayerListHeaderFooter packet = new PacketPlayOutPlayerListHeaderFooter();
|
|
|
|
+ packet.header = header;
|
|
|
|
+ packet.footer = footer;
|
|
|
|
+ getHandle().playerConnection.sendPacket(packet);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @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
|
2016-02-18 03:03:21 +01:00
|
|
|
+ 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
|
2016-02-17 02:55:21 +01:00
|
|
|
+ public void hideTitle() {
|
|
|
|
+ getHandle().playerConnection.sendPacket(new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.CLEAR, (BaseComponent[]) null, 0, 0, 0));
|
|
|
|
+ }
|
|
|
|
// Paper end
|
|
|
|
|
|
|
|
@Override
|
|
|
|
--
|
|
|
|
2.7.1
|
|
|
|
|