Player Tab List and Title APIs

This commit is contained in:
Jedediah Smith 2016-02-16 19:55:21 -06:00
parent e42db95777
commit d498084c93
3 changed files with 417 additions and 0 deletions

View file

@ -0,0 +1,101 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jedediah Smith <jedediah@silencegreys.com>
Date: Tue, 16 Feb 2016 19:51:11 -0600
Subject: [PATCH] Player Tab List and Title APIs
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/entity/Player.java
+++ b/src/main/java/org/bukkit/entity/Player.java
@@ -0,0 +0,0 @@ public interface Player extends HumanEntity, Conversable, CommandSender, Offline
* @param components the components to send
*/
public void sendMessage(net.md_5.bungee.api.chat.BaseComponent... components);
+
+ /**
+ * Set the text displayed in the player list header and footer for this player
+ *
+ * @param header content for the top of the player list
+ * @param footer content for the bottom of the player list
+ */
+ public void setPlayerListHeaderFooter(net.md_5.bungee.api.chat.BaseComponent[] header, net.md_5.bungee.api.chat.BaseComponent[] footer);
+
+ /**
+ * Set the text displayed in the player list header and footer for this player
+ *
+ * @param header content for the top of the player list
+ * @param footer content for the bottom of the player list
+ */
+ public void setPlayerListHeaderFooter(net.md_5.bungee.api.chat.BaseComponent header, net.md_5.bungee.api.chat.BaseComponent footer);
+
+ /**
+ * Set the times for titles displayed to the player
+ *
+ * @param fadeInTicks ticks to fade-in
+ * @param stayTicks ticks to stay visible
+ * @param fadeOutTicks ticks to fade-out
+ */
+ public void setTitleTimes(int fadeInTicks, int stayTicks, int fadeOutTicks);
+
+ /**
+ * Set the subtitle of titles displayed to the player
+ */
+ public void setSubtitle(net.md_5.bungee.api.chat.BaseComponent[] subtitle);
+
+ /**
+ * Set the subtitle of titles displayed to the player
+ */
+ public void setSubtitle(net.md_5.bungee.api.chat.BaseComponent subtitle);
+
+ /**
+ * Show the given title to the player, along with the last subtitle set, using the last set times
+ */
+ public void showTitle(net.md_5.bungee.api.chat.BaseComponent[] title);
+
+ /**
+ * Show the given title to the player, along with the last subtitle set, using the last set times
+ */
+ public void showTitle(net.md_5.bungee.api.chat.BaseComponent title);
+
+ /**
+ * Show the given title and subtitle to the player using the given times
+ *
+ * @param title big text
+ * @param subtitle little text under it
+ * @param fadeInTicks ticks to fade-in
+ * @param stayTicks ticks to stay visible
+ * @param fadeOutTicks ticks to fade-out
+ */
+ public void showTitle(net.md_5.bungee.api.chat.BaseComponent[] title, net.md_5.bungee.api.chat.BaseComponent[] subtitle, int fadeInTicks, int stayTicks, int fadeOutTicks);
+
+ /**
+ * Show the given title and subtitle to the player using the given times
+ *
+ * @param title big text
+ * @param subtitle little text under it
+ * @param fadeInTicks ticks to fade-in
+ * @param stayTicks ticks to stay visible
+ * @param fadeOutTicks ticks to fade-out
+ */
+ public void showTitle(net.md_5.bungee.api.chat.BaseComponent title, net.md_5.bungee.api.chat.BaseComponent subtitle, int fadeInTicks, int stayTicks, int fadeOutTicks);
+
+ /**
+ * Hide any title that is currently visible to the player
+ */
+ public void hideTitle();
// Paper end
/**
@@ -0,0 +0,0 @@ public interface Player extends HumanEntity, Conversable, CommandSender, Offline
/**
* Resets the title displayed to the player.
- * @deprecated API subject to change.
*/
- @Deprecated
+ // Paper - Undeprecate
public void resetTitle();
// Spigot start
--

View file

@ -0,0 +1,168 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jedediah Smith <jedediah@silencegreys.com>
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
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/PacketPlayOutPlayerListHeaderFooter.java
+++ b/src/main/java/net/minecraft/server/PacketPlayOutPlayerListHeaderFooter.java
@@ -0,0 +0,0 @@ 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;
@@ -0,0 +0,0 @@ public class PacketPlayOutPlayerListHeaderFooter implements Packet<PacketListene
}
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);
}
-
- public void a(PacketListener packetlistener) {
- this.a((PacketListenerPlayOut) packetlistener);
- }
}
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutTitle.java b/src/main/java/net/minecraft/server/PacketPlayOutTitle.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/PacketPlayOutTitle.java
+++ b/src/main/java/net/minecraft/server/PacketPlayOutTitle.java
@@ -0,0 +0,0 @@ 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) {
@@ -0,0 +0,0 @@ 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) {
@@ -0,0 +0,0 @@ public class PacketPlayOutTitle implements Packet<PacketListenerPlayOut> {
packetlistenerplayout.a(this);
}
- public void a(PacketListener packetlistener) {
- this.a((PacketListenerPlayOut) packetlistener);
- }
-
public static enum EnumTitleAction {
TITLE, SUBTITLE, TIMES, CLEAR, RESET;
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
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
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
+ public void hideTitle() {
+ getHandle().playerConnection.sendPacket(new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.CLEAR, (BaseComponent[]) null, 0, 0, 0));
+ }
// Paper end
@Override
--

View file

@ -3557,6 +3557,154 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+
+ protected abstract boolean a(Vec3D vec3d, Vec3D vec3d1, int i, int j, int k);
+}
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutPlayerListHeaderFooter.java b/src/main/java/net/minecraft/server/PacketPlayOutPlayerListHeaderFooter.java
new file mode 100644
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
--- /dev/null
+++ b/src/main/java/net/minecraft/server/PacketPlayOutPlayerListHeaderFooter.java
@@ -0,0 +0,0 @@
+package net.minecraft.server;
+
+import java.io.IOException;
+
+public class PacketPlayOutPlayerListHeaderFooter implements Packet<PacketListenerPlayOut> {
+
+ private IChatBaseComponent a;
+ private IChatBaseComponent b;
+
+ public PacketPlayOutPlayerListHeaderFooter() {}
+
+ public PacketPlayOutPlayerListHeaderFooter(IChatBaseComponent ichatbasecomponent) {
+ this.a = ichatbasecomponent;
+ }
+
+ public void a(PacketDataSerializer packetdataserializer) throws IOException {
+ this.a = packetdataserializer.d();
+ this.b = packetdataserializer.d();
+ }
+
+ public void b(PacketDataSerializer packetdataserializer) throws IOException {
+ packetdataserializer.a(this.a);
+ packetdataserializer.a(this.b);
+ }
+
+ public void a(PacketListenerPlayOut packetlistenerplayout) {
+ packetlistenerplayout.a(this);
+ }
+
+ public void a(PacketListener packetlistener) {
+ this.a((PacketListenerPlayOut) packetlistener);
+ }
+}
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutTitle.java b/src/main/java/net/minecraft/server/PacketPlayOutTitle.java
new file mode 100644
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
--- /dev/null
+++ b/src/main/java/net/minecraft/server/PacketPlayOutTitle.java
@@ -0,0 +0,0 @@
+package net.minecraft.server;
+
+import java.io.IOException;
+
+public class PacketPlayOutTitle implements Packet<PacketListenerPlayOut> {
+
+ private EnumTitleAction a;
+ private IChatBaseComponent b;
+ private int c;
+ private int d;
+ private int e;
+
+ public PacketPlayOutTitle() {}
+
+ public PacketPlayOutTitle(EnumTitleAction packetplayouttitle_enumtitleaction, IChatBaseComponent ichatbasecomponent) {
+ this(packetplayouttitle_enumtitleaction, ichatbasecomponent, -1, -1, -1);
+ }
+
+ public PacketPlayOutTitle(int i, int j, int k) {
+ this(EnumTitleAction.TIMES, (IChatBaseComponent) null, i, j, k);
+ }
+
+ public PacketPlayOutTitle(EnumTitleAction packetplayouttitle_enumtitleaction, IChatBaseComponent ichatbasecomponent, int i, int j, int k) {
+ this.a = packetplayouttitle_enumtitleaction;
+ this.b = ichatbasecomponent;
+ this.c = i;
+ this.d = j;
+ this.e = k;
+ }
+
+ public void a(PacketDataSerializer packetdataserializer) throws IOException {
+ this.a = (EnumTitleAction) packetdataserializer.a(EnumTitleAction.class);
+ if (this.a == EnumTitleAction.TITLE || this.a == EnumTitleAction.SUBTITLE) {
+ this.b = packetdataserializer.d();
+ }
+
+ if (this.a == EnumTitleAction.TIMES) {
+ this.c = packetdataserializer.readInt();
+ this.d = packetdataserializer.readInt();
+ this.e = packetdataserializer.readInt();
+ }
+
+ }
+
+ 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);
+ }
+
+ if (this.a == EnumTitleAction.TIMES) {
+ packetdataserializer.writeInt(this.c);
+ packetdataserializer.writeInt(this.d);
+ packetdataserializer.writeInt(this.e);
+ }
+
+ }
+
+ public void a(PacketListenerPlayOut packetlistenerplayout) {
+ packetlistenerplayout.a(this);
+ }
+
+ public void a(PacketListener packetlistener) {
+ this.a((PacketListenerPlayOut) packetlistener);
+ }
+
+ public static enum EnumTitleAction {
+
+ TITLE, SUBTITLE, TIMES, CLEAR, RESET;
+
+ private EnumTitleAction() {}
+
+ public static EnumTitleAction a(String s) {
+ EnumTitleAction[] apacketplayouttitle_enumtitleaction = values();
+ int i = apacketplayouttitle_enumtitleaction.length;
+
+ for (int j = 0; j < i; ++j) {
+ EnumTitleAction packetplayouttitle_enumtitleaction = apacketplayouttitle_enumtitleaction[j];
+
+ if (packetplayouttitle_enumtitleaction.name().equalsIgnoreCase(s)) {
+ return packetplayouttitle_enumtitleaction;
+ }
+ }
+
+ return EnumTitleAction.TITLE;
+ }
+
+ public static String[] a() {
+ String[] astring = new String[values().length];
+ int i = 0;
+ EnumTitleAction[] apacketplayouttitle_enumtitleaction = values();
+ int j = apacketplayouttitle_enumtitleaction.length;
+
+ for (int k = 0; k < j; ++k) {
+ EnumTitleAction packetplayouttitle_enumtitleaction = apacketplayouttitle_enumtitleaction[k];
+
+ astring[i++] = packetplayouttitle_enumtitleaction.name().toLowerCase();
+ }
+
+ return astring;
+ }
+ }
+}
diff --git a/src/main/java/net/minecraft/server/PathfinderGoalFloat.java b/src/main/java/net/minecraft/server/PathfinderGoalFloat.java
new file mode 100644
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000