From f556e7652a81773ac69ffeedf2389dff0680d175 Mon Sep 17 00:00:00 2001 From: Minecrell Date: Mon, 26 Mar 2018 23:45:18 +0200 Subject: [PATCH] Improve backward compatibility of deprecated player sample API (#1065) Some plugins (e.g. older builds of EssentialsX) assume that ServerListPingEvent.getSampleText() returns a mutable copy of the player sample list. This was the case until it was refactored on top of the new API introduced in #980. As a result, they may run into an error when trying to modify the returned list directly. Modify getSampleText() to return a mutable copy (a plain ArrayList) to mimic the old behavior. --- .../Implement-deprecated-player-sample-API.patch | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Spigot-API-Patches/Implement-deprecated-player-sample-API.patch b/Spigot-API-Patches/Implement-deprecated-player-sample-API.patch index fd2ce11d0a..dc0d259bc0 100644 --- a/Spigot-API-Patches/Implement-deprecated-player-sample-API.patch +++ b/Spigot-API-Patches/Implement-deprecated-player-sample-API.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Implement deprecated player sample API diff --git a/src/main/java/com/destroystokyo/paper/event/server/PaperServerListPingEvent.java b/src/main/java/com/destroystokyo/paper/event/server/PaperServerListPingEvent.java -index dd1deafd..32cf9f01 100644 +index dd1deafd..db992df2 100644 --- a/src/main/java/com/destroystokyo/paper/event/server/PaperServerListPingEvent.java +++ b/src/main/java/com/destroystokyo/paper/event/server/PaperServerListPingEvent.java @@ -0,0 +0,0 @@ import static java.util.Objects.requireNonNull; @@ -13,7 +13,6 @@ index dd1deafd..32cf9f01 100644 import com.destroystokyo.paper.network.StatusClient; import com.destroystokyo.paper.profile.PlayerProfile; +import com.google.common.base.Strings; -+import com.google.common.collect.ImmutableList; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; @@ -26,11 +25,11 @@ index dd1deafd..32cf9f01 100644 + @Override + @Deprecated + public List getSampleText() { -+ ImmutableList.Builder sampleText = ImmutableList.builder(); ++ List sampleText = new ArrayList<>(); + for (PlayerProfile profile : getPlayerSample()) { + sampleText.add(Strings.nullToEmpty(profile.getName())); + } -+ return sampleText.build(); ++ return sampleText; + } + + @Override