Avoid negative server ping player sample counts. Fixes #1067 (#1068)

This commit is contained in:
Minecrell 2018-03-30 18:53:15 +02:00 committed by Daniel Ennis
parent aa6c4f29fd
commit 604192da0c
1 changed files with 21 additions and 8 deletions

View File

@ -1,4 +1,4 @@
From 26a88cddba5d4b477a501c983fead50ad3c9e5df Mon Sep 17 00:00:00 2001
From f61ac2e8621e11b322ff53f1d819279ba62d9824 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
@ -6,7 +6,7 @@ Subject: [PATCH] Implement extended PaperServerListPingEvent
diff --git a/src/main/java/com/destroystokyo/paper/network/PaperServerListPingEventImpl.java b/src/main/java/com/destroystokyo/paper/network/PaperServerListPingEventImpl.java
new file mode 100644
index 000000000..c1a8e295b
index 00000000..c1a8e295
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/network/PaperServerListPingEventImpl.java
@@ -0,0 +1,31 @@
@ -43,7 +43,7 @@ index 000000000..c1a8e295b
+}
diff --git a/src/main/java/com/destroystokyo/paper/network/PaperStatusClient.java b/src/main/java/com/destroystokyo/paper/network/PaperStatusClient.java
new file mode 100644
index 000000000..a2a409e63
index 00000000..a2a409e6
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/network/PaperStatusClient.java
@@ -0,0 +1,11 @@
@ -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..350410527
index 00000000..35041052
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/network/StandardPaperServerListPingEventImpl.java
@@ -0,0 +1,112 @@
@ -177,7 +177,7 @@ index 000000000..350410527
+
+}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 579f0ba0d..99cfe1ae5 100644
index 579f0ba0..99cfe1ae 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -768,7 +768,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IAs
@ -203,7 +203,7 @@ index 579f0ba0d..99cfe1ae5 100644
return this.v.getMaxPlayers();
}
diff --git a/src/main/java/net/minecraft/server/PacketStatusListener.java b/src/main/java/net/minecraft/server/PacketStatusListener.java
index 313bb0007..f3c25367d 100644
index 313bb000..f3c25367 100644
--- a/src/main/java/net/minecraft/server/PacketStatusListener.java
+++ b/src/main/java/net/minecraft/server/PacketStatusListener.java
@@ -30,6 +30,8 @@ public class PacketStatusListener implements PacketStatusInListener {
@ -226,7 +226,7 @@ index 313bb0007..f3c25367d 100644
// CraftBukkit end
}
diff --git a/src/main/java/net/minecraft/server/ServerPing.java b/src/main/java/net/minecraft/server/ServerPing.java
index 981582212..ac161f505 100644
index 98158221..ac161f50 100644
--- a/src/main/java/net/minecraft/server/ServerPing.java
+++ b/src/main/java/net/minecraft/server/ServerPing.java
@@ -29,6 +29,7 @@ public class ServerPing {
@ -250,6 +250,19 @@ index 981582212..ac161f505 100644
public void a(GameProfile[] agameprofile) {
this.c = agameprofile;
}
--
2.16.2
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
index cc1f3ac9..4f9fd4bc 100644
--- a/src/main/java/org/spigotmc/SpigotConfig.java
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
@@ -281,7 +281,7 @@ public class SpigotConfig
public static int playerSample;
private static void playerSample()
{
- playerSample = getInt( "settings.sample-count", 12 );
+ playerSample = Math.max(getInt( "settings.sample-count", 12 ), 0); // Paper - Avoid negative counts
Bukkit.getLogger().log( Level.INFO, "Server Ping Player Sample Count: {0}", playerSample ); // Paper - Use logger
}
--
2.16.3