geforkt von Mirrors/Paper
e15167251b
* Drop original implementation for old player sample API * Add extended PaperServerListPingEvent Add a new event that extends the original ServerListPingEvent and allows full control of the response sent to the client. * Implement deprecated player sample API
79 Zeilen
3.0 KiB
Diff
79 Zeilen
3.0 KiB
Diff
From 9ed51547f8f2474fdda8cfd6178dcaa7b301dc0a Mon Sep 17 00:00:00 2001
|
|
From: Minecrell <minecrell@minecrell.net>
|
|
Date: Mon, 27 Nov 2017 16:21:19 +0100
|
|
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 a6576f99..41899698 100644
|
|
--- a/src/main/java/com/destroystokyo/paper/event/server/PaperServerListPingEvent.java
|
|
+++ b/src/main/java/com/destroystokyo/paper/event/server/PaperServerListPingEvent.java
|
|
@@ -4,6 +4,8 @@ import static java.util.Objects.requireNonNull;
|
|
|
|
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;
|
|
@@ -316,4 +318,25 @@ public class PaperServerListPingEvent extends ServerListPingEvent implements Can
|
|
}
|
|
}
|
|
|
|
+ // TODO: Remove in 1.13
|
|
+
|
|
+ @Override
|
|
+ @Deprecated
|
|
+ public List<String> getSampleText() {
|
|
+ ImmutableList.Builder<String> sampleText = ImmutableList.builder();
|
|
+ for (PlayerProfile profile : getPlayerSample()) {
|
|
+ sampleText.add(Strings.nullToEmpty(profile.getName()));
|
|
+ }
|
|
+ return sampleText.build();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ @Deprecated
|
|
+ public void setSampleText(List<String> sample) {
|
|
+ getPlayerSample().clear();
|
|
+ for (String name : sample) {
|
|
+ getPlayerSample().add(Bukkit.createProfile(name));
|
|
+ }
|
|
+ }
|
|
+
|
|
}
|
|
diff --git a/src/main/java/org/bukkit/event/server/ServerListPingEvent.java b/src/main/java/org/bukkit/event/server/ServerListPingEvent.java
|
|
index cb8d0fcd..116d7c7a 100644
|
|
--- a/src/main/java/org/bukkit/event/server/ServerListPingEvent.java
|
|
+++ b/src/main/java/org/bukkit/event/server/ServerListPingEvent.java
|
|
@@ -4,6 +4,7 @@ import java.net.InetAddress;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
|
|
+import com.destroystokyo.paper.event.server.PaperServerListPingEvent;
|
|
import org.apache.commons.lang.Validate;
|
|
import org.bukkit.entity.Player;
|
|
import org.bukkit.event.HandlerList;
|
|
@@ -151,7 +152,7 @@ public class ServerListPingEvent extends ServerEvent implements Iterable<Player>
|
|
private java.util.List<String> sample;
|
|
|
|
/**
|
|
- * @deprecated Will be replaced in 1.13
|
|
+ * @deprecated Will be removed in 1.13, use {@link PaperServerListPingEvent#getPlayerSample()}
|
|
*/
|
|
@Deprecated
|
|
public void setSampleText(java.util.List<String> sample) {
|
|
@@ -159,7 +160,7 @@ public class ServerListPingEvent extends ServerEvent implements Iterable<Player>
|
|
}
|
|
|
|
/**
|
|
- * @deprecated Will be replaced in 1.13
|
|
+ * @deprecated Will be removed in 1.13, use {@link PaperServerListPingEvent#getPlayerSample()}
|
|
*/
|
|
@Deprecated
|
|
public java.util.List<String> getSampleText() {
|
|
--
|
|
2.16.1
|
|
|