13
0
geforkt von Mirrors/Paper

SPIGOT-1219: Allow ping without status query.

Also minor refactor to use more of the Vanilla logic.
Dieser Commit ist enthalten in:
md_5 2015-10-03 11:25:43 +10:00
Ursprung d4e32cef0c
Commit 4a7472d0bf

Datei anzeigen

@ -17,29 +17,18 @@
public class PacketStatusListener implements PacketStatusInListener { public class PacketStatusListener implements PacketStatusInListener {
private static final IChatBaseComponent a = new ChatComponentText("Status request has been handled."); private static final IChatBaseComponent a = new ChatComponentText("Status request has been handled.");
@@ -14,17 +25,116 @@ @@ -17,10 +28,96 @@
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) { public void a(PacketStatusInStart packetstatusinstart) {
- if (this.d) { if (this.d) {
+ // this.networkManager.handle(new PacketStatusOutServerInfo(this.minecraftServer.aG()));
+ // CraftBukkit start - fire ping event
+ if (this.state != WAITING) {
this.networkManager.close(PacketStatusListener.a); this.networkManager.close(PacketStatusListener.a);
- } else { - } else {
- this.d = true; - this.d = true;
- this.networkManager.handle(new PacketStatusOutServerInfo(this.minecraftServer.aG())); - this.networkManager.handle(new PacketStatusOutServerInfo(this.minecraftServer.aG()));
+ // CraftBukkit start - fire ping event
+ return; + return;
} + }
+ state = PING; + this.d = true;
+ // this.networkManager.handle(new PacketStatusOutServerInfo(this.minecraftServer.aG()));
+ final Object[] players = minecraftServer.getPlayerList().players.toArray(); + final Object[] players = minecraftServer.getPlayerList().players.toArray();
+ class ServerListPingEvent extends org.bukkit.event.server.ServerListPingEvent { + class ServerListPingEvent extends org.bukkit.event.server.ServerListPingEvent {
+ CraftIconCache icon = minecraftServer.server.getServerIcon(); + CraftIconCache icon = minecraftServer.server.getServerIcon();
@ -112,7 +101,7 @@
+ if (player != null) { + if (player != null) {
+ profiles.add(((EntityPlayer) player).getProfile()); + profiles.add(((EntityPlayer) player).getProfile());
+ } + }
+ } }
+ +
+ ServerPing.ServerPingPlayerSample playerSample = new ServerPing.ServerPingPlayerSample(event.getMaxPlayers(), profiles.size()); + ServerPing.ServerPingPlayerSample playerSample = new ServerPing.ServerPingPlayerSample(event.getMaxPlayers(), profiles.size());
+ playerSample.a(profiles.toArray(new GameProfile[profiles.size()])); + playerSample.a(profiles.toArray(new GameProfile[profiles.size()]));
@ -128,15 +117,3 @@
} }
public void a(PacketStatusInPing packetstatusinping) { public void a(PacketStatusInPing packetstatusinping) {
- this.networkManager.handle(new PacketStatusOutPong(packetstatusinping.a()));
- this.networkManager.close(PacketStatusListener.a);
+ // CraftBukkit start
+ if (state != PING) {
+ this.networkManager.close(PacketStatusListener.a);
+ return;
+ }
+ state = DONE;
+ this.networkManager.a(new PacketStatusOutPong(packetstatusinping.a()), ChannelFutureListener.CLOSE); // Close on completion
+ // CraftBukkit end
}
}