diff options
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/server/network/LegacyQueryHandler.java.patch')
-rw-r--r-- | patch-remap/mache-spigotflower/net/minecraft/server/network/LegacyQueryHandler.java.patch | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/server/network/LegacyQueryHandler.java.patch b/patch-remap/mache-spigotflower/net/minecraft/server/network/LegacyQueryHandler.java.patch new file mode 100644 index 0000000000..a64a289029 --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/server/network/LegacyQueryHandler.java.patch @@ -0,0 +1,59 @@ +--- a/net/minecraft/server/network/LegacyQueryHandler.java ++++ b/net/minecraft/server/network/LegacyQueryHandler.java +@@ -20,7 +20,6 @@ + this.server = serverinfo; + } + +- @Override + public void channelRead(ChannelHandlerContext channelhandlercontext, Object object) { + ByteBuf bytebuf = (ByteBuf) object; + +@@ -36,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 + + if (i == 0) { + LegacyQueryHandler.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) { +@@ -56,7 +56,7 @@ + LegacyQueryHandler.LOGGER.debug("Ping: (1.4-1.5.x) from {}", socketaddress); + } + +- s = createVersion1Response(this.server); ++ s = createVersion1Response(this.server, event); // CraftBukkit + sendFlushAndClose(channelhandlercontext, createLegacyDisconnectPacket(channelhandlercontext.alloc(), s)); + } + +@@ -107,16 +107,20 @@ + } + } + +- 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 + } + +- 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 + } + +- private static void sendFlushAndClose(ChannelHandlerContext channelhandlercontext, ByteBuf bytebuf) { +- channelhandlercontext.pipeline().firstContext().writeAndFlush(bytebuf).addListener(ChannelFutureListener.CLOSE); ++ private static void sendFlushAndClose(ChannelHandlerContext channelhandlercontext, ByteBuf context) { ++ channelhandlercontext.pipeline().firstContext().writeAndFlush(context).addListener(ChannelFutureListener.CLOSE); + } + + private static ByteBuf createLegacyDisconnectPacket(ByteBufAllocator bytebufallocator, String s) { |