mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 15:30:19 +01:00
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:
parent
4a3222542d
commit
a5dc62d4b7
2 changed files with 62 additions and 3 deletions
|
@ -1,18 +1,18 @@
|
|||
From 45e81549d601219764a5780bd77a79b852b7b1c8 Mon Sep 17 00:00:00 2001
|
||||
From 445bd2998dd5b384883f8ecc382ce11d980d5c66 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 3f5d6c3239..e23c239226 100644
|
||||
index 286c1b14f6..ff14b3e093 100644
|
||||
--- a/src/main/java/net/minecraft/server/IChatBaseComponent.java
|
||||
+++ b/src/main/java/net/minecraft/server/IChatBaseComponent.java
|
||||
@@ -354,6 +354,7 @@ public interface IChatBaseComponent extends Message, Iterable<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
|
||||
public static IChatBaseComponent a(String s) {
|
||||
return (IChatBaseComponent)ChatDeserializer.a(a, s, IChatBaseComponent.class, false);
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
From 8e85f047aee118800f7ecdf97ac8456800cff021 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
|
||||
@@ -370,20 +370,20 @@ 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
|
||||
@@ -143,7 +143,13 @@ 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) {
|
||||
--
|
||||
2.18.0
|
||||
|
Loading…
Reference in a new issue