fix newlines in spigot tab list API

Spigots implementation around the header/footer strips newlines from the
header/footer, this patch allows the tab list header/footer to retain newlines.
This commit is contained in:
Shane Freeder 2018-09-01 11:33:50 +01:00
parent 1294a18cf9
commit 84993e3fca
2 changed files with 59 additions and 2 deletions

View File

@ -5,14 +5,14 @@ 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 diff --git a/src/main/java/net/minecraft/server/IChatBaseComponent.java b/src/main/java/net/minecraft/server/IChatBaseComponent.java
index 3f5d6c3239..e23c239226 100644 index 286c1b14f6..ff14b3e093 100644
--- a/src/main/java/net/minecraft/server/IChatBaseComponent.java --- a/src/main/java/net/minecraft/server/IChatBaseComponent.java
+++ b/src/main/java/net/minecraft/server/IChatBaseComponent.java +++ b/src/main/java/net/minecraft/server/IChatBaseComponent.java
@@ -0,0 +0,0 @@ public interface IChatBaseComponent extends Message, Iterable<IChatBaseComponent @@ -0,0 +0,0 @@ public interface IChatBaseComponent extends Message, Iterable<IChatBaseComponent
return a.toJsonTree(ichatbasecomponent); return a.toJsonTree(ichatbasecomponent);
} }
+ public static IChatBaseComponent jsonToComponent(String json) { return a(json);} // Paper - OBFHELPER + @Nullable public static IChatBaseComponent jsonToComponent(String json) { return a(json);} // Paper - OBFHELPER
@Nullable @Nullable
public static IChatBaseComponent a(String s) { public static IChatBaseComponent a(String s) {
return (IChatBaseComponent)ChatDeserializer.a(a, s, IChatBaseComponent.class, false); return (IChatBaseComponent)ChatDeserializer.a(a, s, IChatBaseComponent.class, false);

View File

@ -0,0 +1,57 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shane Freeder <theboyetronic@gmail.com>
Date: Sat, 1 Sep 2018 11:29:52 +0100
Subject: [PATCH] fix newlines in spigot tab list API
Spigots implementation around the header/footer strips newlines from the
header/footer, this patch allows the tab list header/footer to retain newlines.
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index f372f19dec..b6cf96e187 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 {
@Override
public void setPlayerListHeader(String header) {
- this.playerListHeader = CraftChatMessage.fromStringOrNull(header);
+ this.playerListHeader = CraftChatMessage.fromStringOrNull(header, true); // Paper - fix up spigot tab API
updatePlayerListHeaderFooter();
}
@Override
public void setPlayerListFooter(String footer) {
- this.playerListFooter = CraftChatMessage.fromStringOrNull(footer);
+ this.playerListFooter = CraftChatMessage.fromStringOrNull(footer, true); // Paper - fix up spigot tab API
updatePlayerListHeaderFooter();
}
@Override
public void setPlayerListHeaderFooter(String header, String footer) {
- this.playerListHeader = CraftChatMessage.fromStringOrNull(header);
- this.playerListFooter = CraftChatMessage.fromStringOrNull(footer);
+ this.playerListHeader = CraftChatMessage.fromStringOrNull(header, true); // Paper - fix up spigot tab API
+ this.playerListFooter = CraftChatMessage.fromStringOrNull(footer, true); // Paper - fix up spigot tab API
updatePlayerListHeaderFooter();
}
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java
index a067e39d54..5e20a9a619 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java
@@ -0,0 +0,0 @@ public final class CraftChatMessage {
}
public static IChatBaseComponent fromStringOrNull(String message) {
- return (message == null || message.isEmpty()) ? null : fromString(message)[0];
+ // Paper start - fix up spigot tab API
+ return fromStringOrNull(message, false);
+ }
+
+ public static IChatBaseComponent fromStringOrNull(String message, boolean keepNewlines) {
+ return (message == null || message.isEmpty()) ? null : fromString(message, keepNewlines)[0];
+ // Paper end - fix up spigot tab API
}
public static IChatBaseComponent[] fromString(String message) {
--