2021-03-15 23:00:00 +01:00
|
|
|
--- a/net/minecraft/server/network/LegacyPingHandler.java
|
|
|
|
+++ b/net/minecraft/server/network/LegacyPingHandler.java
|
2023-09-21 18:40:00 +02:00
|
|
|
@@ -35,10 +35,11 @@
|
|
|
|
SocketAddress socketaddress = channelhandlercontext.channel().remoteAddress();
|
|
|
|
int i = bytebuf.readableBytes();
|
|
|
|
String s;
|
|
|
|
+ org.bukkit.event.server.ServerListPingEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callServerListPingEvent(socketaddress, server.getMotd(), server.getPlayerCount(), server.getMaxPlayers()); // CraftBukkit
|
2018-12-12 01:19:31 +01:00
|
|
|
|
2023-09-21 18:40:00 +02:00
|
|
|
if (i == 0) {
|
|
|
|
LegacyPingHandler.LOGGER.debug("Ping: (<1.3.x) from {}", socketaddress);
|
|
|
|
- s = createVersion0Response(this.server);
|
|
|
|
+ s = createVersion0Response(this.server, event); // CraftBukkit
|
|
|
|
sendFlushAndClose(channelhandlercontext, createLegacyDisconnectPacket(channelhandlercontext.alloc(), s));
|
|
|
|
} else {
|
|
|
|
if (bytebuf.readUnsignedByte() != 1) {
|
|
|
|
@@ -55,7 +56,7 @@
|
|
|
|
LegacyPingHandler.LOGGER.debug("Ping: (1.4-1.5.x) from {}", socketaddress);
|
2019-05-27 22:30:00 +02:00
|
|
|
}
|
2018-12-12 01:19:31 +01:00
|
|
|
|
2023-09-21 18:40:00 +02:00
|
|
|
- s = createVersion1Response(this.server);
|
|
|
|
+ s = createVersion1Response(this.server, event); // CraftBukkit
|
|
|
|
sendFlushAndClose(channelhandlercontext, createLegacyDisconnectPacket(channelhandlercontext.alloc(), s));
|
|
|
|
}
|
|
|
|
|
|
|
|
@@ -106,12 +107,16 @@
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- private static String createVersion0Response(ServerInfo serverinfo) {
|
|
|
|
- return String.format(Locale.ROOT, "%s\u00a7%d\u00a7%d", serverinfo.getMotd(), serverinfo.getPlayerCount(), serverinfo.getMaxPlayers());
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ private static String createVersion0Response(ServerInfo serverinfo, org.bukkit.event.server.ServerListPingEvent event) {
|
|
|
|
+ return String.format(Locale.ROOT, "%s\u00a7%d\u00a7%d", event.getMotd(), event.getNumPlayers(), event.getMaxPlayers());
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
2018-12-12 01:19:31 +01:00
|
|
|
|
2023-09-21 18:40:00 +02:00
|
|
|
- private static String createVersion1Response(ServerInfo serverinfo) {
|
|
|
|
- return String.format(Locale.ROOT, "\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", 127, serverinfo.getServerVersion(), serverinfo.getMotd(), serverinfo.getPlayerCount(), serverinfo.getMaxPlayers());
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ private static String createVersion1Response(ServerInfo serverinfo, org.bukkit.event.server.ServerListPingEvent event) {
|
|
|
|
+ return String.format(Locale.ROOT, "\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", 127, serverinfo.getServerVersion(), event.getMotd(), event.getNumPlayers(), event.getMaxPlayers());
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
2018-12-12 01:19:31 +01:00
|
|
|
|
2023-09-21 18:40:00 +02:00
|
|
|
private static void sendFlushAndClose(ChannelHandlerContext channelhandlercontext, ByteBuf bytebuf) {
|