diff options
author | Thinkofdeath <thinkofdeath@spigotmc.org> | 2015-02-05 19:04:03 +0000 |
---|---|---|
committer | Thinkofdeath <thinkofdeath@spigotmc.org> | 2015-02-05 19:04:03 +0000 |
commit | 0cf233dd6d9457b43201a03155242e43ff401461 (patch) | |
tree | 19cb4e6c4f10a75c4c51abd78948bcf225294ddf | |
parent | 43207df1df3d1f150e075ec35b592e4602099c73 (diff) | |
download | craftbukkit-0cf233dd6d9457b43201a03155242e43ff401461.tar craftbukkit-0cf233dd6d9457b43201a03155242e43ff401461.tar.gz craftbukkit-0cf233dd6d9457b43201a03155242e43ff401461.tar.lz craftbukkit-0cf233dd6d9457b43201a03155242e43ff401461.tar.xz craftbukkit-0cf233dd6d9457b43201a03155242e43ff401461.zip |
SPIGOT-527: Improve vanilla's ping handling
-rw-r--r-- | nms-patches/PacketStatusListener.patch | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/nms-patches/PacketStatusListener.patch b/nms-patches/PacketStatusListener.patch index f354e7b0..9de1eba1 100644 --- a/nms-patches/PacketStatusListener.patch +++ b/nms-patches/PacketStatusListener.patch @@ -1,10 +1,11 @@ ---- ../work/decompile-8eb82bde//net/minecraft/server/PacketStatusListener.java 2014-11-28 17:43:43.277707431 +0000 -+++ src/main/java/net/minecraft/server/PacketStatusListener.java 2014-11-28 17:38:17.000000000 +0000 -@@ -1,5 +1,15 @@ +--- ../work/decompile-8eb82bde//net/minecraft/server/PacketStatusListener.java 2015-02-05 19:03:06.828858157 +0000 ++++ src/main/java/net/minecraft/server/PacketStatusListener.java 2015-02-05 19:03:06.828858157 +0000 +@@ -1,5 +1,16 @@ package net.minecraft.server; +// CraftBukkit start +import com.mojang.authlib.GameProfile; ++import io.netty.channel.ChannelFutureListener; +import java.net.InetSocketAddress; +import java.util.Iterator; + @@ -16,13 +17,26 @@ public class PacketStatusListener implements PacketStatusInListener { private final MinecraftServer minecraftServer; -@@ -13,7 +23,93 @@ +@@ -12,11 +23,116 @@ + public void a(IChatBaseComponent ichatbasecomponent) {} ++ // CraftBukkit start ++ private static final int WAITING = 0; ++ private static final int PING = 1; ++ private static final int DONE = 2; ++ private int state = WAITING; ++ // CraftBukkit end ++ public void a(PacketStatusInStart packetstatusinstart) { - this.networkManager.handle(new PacketStatusOutServerInfo(this.minecraftServer.aE())); + // this.networkManager.handle(new PacketStatusOutServerInfo(this.minecraftServer.aE())); + // CraftBukkit start - fire ping event ++ if (state != WAITING) { ++ networkManager.close(null); ++ return; ++ } ++ state = PING; + final Object[] players = minecraftServer.getPlayerList().players.toArray(); + class ServerListPingEvent extends org.bukkit.event.server.ServerListPingEvent { + CraftIconCache icon = minecraftServer.server.getServerIcon(); @@ -111,3 +125,14 @@ } public void a(PacketStatusInPing packetstatusinping) { +- this.networkManager.handle(new PacketStatusOutPong(packetstatusinping.a())); ++ // CraftBukkit start ++ if (state != PING) { ++ networkManager.close(null); ++ return; ++ } ++ state = DONE; ++ this.networkManager.a(new PacketStatusOutPong(packetstatusinping.a()), ChannelFutureListener.CLOSE); // Close on completion ++ // CraftBukkit end + } + } |