Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 12:30:06 +01:00
0faaa7da92
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: 19b7b7bd #561: Add clear weather World API 5929c808 #552: Add the ability to retrieve hit, step, fall, and other sounds from blocks. CraftBukkit Changes: e1ebdd92 #771: Add clear weather World API 424598d2 #752: Add the ability to retrieve hit, step, fall, and other sounds from blocks.
162 Zeilen
6.9 KiB
Diff
162 Zeilen
6.9 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/server/IChatBaseComponent.java b/src/main/java/net/minecraft/server/IChatBaseComponent.java
|
|
index 7441beeaa4ee83467dac4d68176132efc6247337..b8770066a86df25d6ba9ecf74d846c730d228c01 100644
|
|
--- a/src/main/java/net/minecraft/server/IChatBaseComponent.java
|
|
+++ b/src/main/java/net/minecraft/server/IChatBaseComponent.java
|
|
@@ -352,6 +352,7 @@ public interface IChatBaseComponent extends Message, IChatFormatted, Iterable<IC
|
|
return IChatBaseComponent.ChatSerializer.a.toJsonTree(ichatbasecomponent);
|
|
}
|
|
|
|
+ @Nullable public static IChatBaseComponent jsonToComponent(String json) { return a(json);} // Paper - OBFHELPER
|
|
@Nullable
|
|
public static IChatMutableComponent a(String s) {
|
|
return (IChatMutableComponent) ChatDeserializer.a(IChatBaseComponent.ChatSerializer.a, s, IChatMutableComponent.class, false);
|
|
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutTitle.java b/src/main/java/net/minecraft/server/PacketPlayOutTitle.java
|
|
index 3a6e780007bc1b1fa799166daa01d3a9e15c7ab0..535056c64ef866e645b1bfbd149b50c53cb64485 100644
|
|
--- a/src/main/java/net/minecraft/server/PacketPlayOutTitle.java
|
|
+++ b/src/main/java/net/minecraft/server/PacketPlayOutTitle.java
|
|
@@ -43,12 +43,29 @@ public class PacketPlayOutTitle implements Packet<PacketListenerPlayOut> {
|
|
}
|
|
|
|
}
|
|
+ // 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
|
|
|
|
@Override
|
|
public void b(PacketDataSerializer packetdataserializer) throws IOException {
|
|
packetdataserializer.a((Enum) this.a);
|
|
if (this.a == PacketPlayOutTitle.EnumTitleAction.TITLE || this.a == PacketPlayOutTitle.EnumTitleAction.SUBTITLE || this.a == PacketPlayOutTitle.EnumTitleAction.ACTIONBAR) {
|
|
- 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 == PacketPlayOutTitle.EnumTitleAction.TIMES) {
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
index aeae422524e8e135549e0d6e4ccf4a553c1061b2..4a7ac9ddbfa221645f68be34db4b5704661ef5a6 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;
|
|
@@ -238,6 +239,96 @@ 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.minecraft.server.ChatBaseComponent.ChatSerializer.jsonToComponent(headerJson);
|
|
+ } else {
|
|
+ playerListHeader = null;
|
|
+ }
|
|
+
|
|
+ if (footer != null) {
|
|
+ String footerJson = net.md_5.bungee.chat.ComponentSerializer.toString(footer);
|
|
+ playerListFooter = net.minecraft.server.ChatBaseComponent.ChatSerializer.jsonToComponent(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().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 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().playerConnection.sendPacket(new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.CLEAR, (BaseComponent[]) null, 0, 0, 0));
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
@Override
|
|
public String getDisplayName() {
|
|
return getHandle().displayName;
|