Fix NPE during server initialization from server list pings

This commit is contained in:
Shane Freeder 2019-02-06 19:15:46 +00:00
parent e952f6ebe2
commit 182d4f528f
No known key found for this signature in database
GPG Key ID: A3F61EA5A085289C
2 changed files with 9 additions and 8 deletions

View File

@ -1,4 +1,4 @@
From 49a9d5dd768670e0cf6bb85313727ad57bc8428e Mon Sep 17 00:00:00 2001
From 4987254c0fc69b5f08d88f3dec52e37a6e68140d Mon Sep 17 00:00:00 2001
From: Minecrell <minecrell@minecrell.net>
Date: Wed, 11 Oct 2017 15:55:38 +0200
Subject: [PATCH] Add extended PaperServerListPingEvent
@ -8,10 +8,10 @@ and allows full control of the response sent to the client.
diff --git a/src/main/java/com/destroystokyo/paper/event/server/PaperServerListPingEvent.java b/src/main/java/com/destroystokyo/paper/event/server/PaperServerListPingEvent.java
new file mode 100644
index 00000000..dd1deafd
index 00000000..b2a8476c
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/server/PaperServerListPingEvent.java
@@ -0,0 +1,319 @@
@@ -0,0 +1,320 @@
+package com.destroystokyo.paper.event.server;
+
+import static java.util.Objects.requireNonNull;
@ -185,7 +185,8 @@ index 00000000..dd1deafd
+ * Returns the protocol version that will be sent as the protocol version
+ * of the server to the client.
+ *
+ * @return The protocol version of the server
+ * @return The protocol version of the server, or {@code -1} if the server
+ * has not finished initialization yet
+ */
+ public int getProtocolVersion() {
+ return protocolVersion;
@ -366,5 +367,5 @@ index 04804706..44563482 100644
+ // Paper end
}
--
2.18.0
2.20.1

View File

@ -1,4 +1,4 @@
From 929f9ec6f37275914c15fc6ba21f9b3304dba68f Mon Sep 17 00:00:00 2001
From 88af45c086f6c9a71ddcbfe68e612d383a590929 Mon Sep 17 00:00:00 2001
From: Minecrell <minecrell@minecrell.net>
Date: Wed, 11 Oct 2017 15:56:26 +0200
Subject: [PATCH] Implement extended PaperServerListPingEvent
@ -60,7 +60,7 @@ index 000000000..a2a409e63
+}
diff --git a/src/main/java/com/destroystokyo/paper/network/StandardPaperServerListPingEventImpl.java b/src/main/java/com/destroystokyo/paper/network/StandardPaperServerListPingEventImpl.java
new file mode 100644
index 000000000..26e3031d2
index 000000000..a85466bc7
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/network/StandardPaperServerListPingEventImpl.java
@@ -0,0 +1,112 @@
@ -90,7 +90,7 @@ index 000000000..26e3031d2
+ private GameProfile[] originalSample;
+
+ private StandardPaperServerListPingEventImpl(MinecraftServer server, NetworkManager networkManager, ServerPing ping) {
+ super(server, new PaperStatusClient(networkManager), ping.getServerData().getProtocolVersion(), server.server.getServerIcon());
+ super(server, new PaperStatusClient(networkManager), ping.getServerData() != null ? ping.getServerData().getProtocolVersion() : -1, server.server.getServerIcon());
+ this.originalSample = ping.getPlayers() == null ? null : ping.getPlayers().getSample(); // GH-1473 - pre-tick race condition NPE
+ }
+