mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 15:49:00 +01:00
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.
This commit is contained in:
parent
31c3ae2bb4
commit
f556e7652a
1 changed files with 3 additions and 4 deletions
|
@ -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
|
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
|
--- a/src/main/java/com/destroystokyo/paper/event/server/PaperServerListPingEvent.java
|
||||||
+++ b/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;
|
@@ -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.network.StatusClient;
|
||||||
import com.destroystokyo.paper.profile.PlayerProfile;
|
import com.destroystokyo.paper.profile.PlayerProfile;
|
||||||
+import com.google.common.base.Strings;
|
+import com.google.common.base.Strings;
|
||||||
+import com.google.common.collect.ImmutableList;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
|
@ -26,11 +25,11 @@ index dd1deafd..32cf9f01 100644
|
||||||
+ @Override
|
+ @Override
|
||||||
+ @Deprecated
|
+ @Deprecated
|
||||||
+ public List<String> getSampleText() {
|
+ public List<String> getSampleText() {
|
||||||
+ ImmutableList.Builder<String> sampleText = ImmutableList.builder();
|
+ List<String> sampleText = new ArrayList<>();
|
||||||
+ for (PlayerProfile profile : getPlayerSample()) {
|
+ for (PlayerProfile profile : getPlayerSample()) {
|
||||||
+ sampleText.add(Strings.nullToEmpty(profile.getName()));
|
+ sampleText.add(Strings.nullToEmpty(profile.getName()));
|
||||||
+ }
|
+ }
|
||||||
+ return sampleText.build();
|
+ return sampleText;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
|
|
Loading…
Reference in a new issue