PaperMC/nms-patches/LegacyPingHandler.patch

35 lines
2.5 KiB
Diff
Raw Normal View History

--- a/net/minecraft/server/LegacyPingHandler.java
+++ b/net/minecraft/server/LegacyPingHandler.java
@@ -34,11 +34,12 @@
MinecraftServer minecraftserver = this.b.d();
int i = bytebuf.readableBytes();
String s;
2018-12-13 01:00:00 +01:00
+ org.bukkit.event.server.ServerListPingEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callServerListPingEvent(minecraftserver.server, inetsocketaddress.getAddress(), minecraftserver.getMotd(), minecraftserver.getPlayerCount(), minecraftserver.getMaxPlayers()); // CraftBukkit
switch (i) {
case 0:
2019-04-25 04:00:00 +02:00
LegacyPingHandler.LOGGER.debug("Ping: (<1.3.x) from {}:{}", inetsocketaddress.getAddress(), inetsocketaddress.getPort());
2018-12-25 22:00:00 +01:00
- s = String.format("%s\u00a7%d\u00a7%d", minecraftserver.getMotd(), minecraftserver.getPlayerCount(), minecraftserver.getMaxPlayers());
+ s = String.format("%s\u00a7%d\u00a7%d", event.getMotd(), event.getNumPlayers(), event.getMaxPlayers()); // CraftBukkit
this.a(channelhandlercontext, this.a(s));
break;
case 1:
@@ -47,7 +48,7 @@
}
2019-04-25 04:00:00 +02:00
LegacyPingHandler.LOGGER.debug("Ping: (1.4-1.5.x) from {}:{}", inetsocketaddress.getAddress(), inetsocketaddress.getPort());
2018-12-25 22:00:00 +01:00
- s = String.format("\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", 127, minecraftserver.getVersion(), minecraftserver.getMotd(), minecraftserver.getPlayerCount(), minecraftserver.getMaxPlayers());
+ s = String.format("\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", 127, minecraftserver.getVersion(), event.getMotd(), event.getNumPlayers(), event.getMaxPlayers()); // CraftBukkit
this.a(channelhandlercontext, this.a(s));
break;
default:
@@ -66,7 +67,7 @@
}
2019-04-25 04:00:00 +02:00
LegacyPingHandler.LOGGER.debug("Ping: (1.6) from {}:{}", inetsocketaddress.getAddress(), inetsocketaddress.getPort());
2018-12-25 22:00:00 +01:00
- String s1 = String.format("\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", 127, minecraftserver.getVersion(), minecraftserver.getMotd(), minecraftserver.getPlayerCount(), minecraftserver.getMaxPlayers());
+ String s1 = String.format("\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", 127, minecraftserver.getVersion(), event.getMotd(), event.getNumPlayers(), event.getMaxPlayers()); // CraftBukkit
ByteBuf bytebuf1 = this.a(s1);
try {