aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-vineflower/net/minecraft/server/network/LegacyQueryHandler.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/server/network/LegacyQueryHandler.java.patch')
-rw-r--r--patch-remap/mache-vineflower/net/minecraft/server/network/LegacyQueryHandler.java.patch180
1 files changed, 180 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/server/network/LegacyQueryHandler.java.patch b/patch-remap/mache-vineflower/net/minecraft/server/network/LegacyQueryHandler.java.patch
new file mode 100644
index 0000000000..360dfca374
--- /dev/null
+++ b/patch-remap/mache-vineflower/net/minecraft/server/network/LegacyQueryHandler.java.patch
@@ -0,0 +1,180 @@
+--- a/net/minecraft/server/network/LegacyQueryHandler.java
++++ b/net/minecraft/server/network/LegacyQueryHandler.java
+@@ -12,113 +12,122 @@
+ import org.slf4j.Logger;
+
+ public class LegacyQueryHandler extends ChannelInboundHandlerAdapter {
++
+ private static final Logger LOGGER = LogUtils.getLogger();
+ private final ServerInfo server;
+
+- public LegacyQueryHandler(ServerInfo serverInfo) {
+- this.server = serverInfo;
++ public LegacyQueryHandler(ServerInfo serverinfo) {
++ this.server = serverinfo;
+ }
+
+- @Override
+- public void channelRead(ChannelHandlerContext context, Object message) {
+- ByteBuf byteBuf = (ByteBuf)message;
+- byteBuf.markReaderIndex();
++ public void channelRead(ChannelHandlerContext channelhandlercontext, Object object) {
++ ByteBuf bytebuf = (ByteBuf) object;
++
++ bytebuf.markReaderIndex();
+ boolean flag = true;
+
+ try {
+ try {
+- if (byteBuf.readUnsignedByte() != 254) {
++ if (bytebuf.readUnsignedByte() != 254) {
+ return;
+ }
+
+- SocketAddress socketAddress = context.channel().remoteAddress();
+- int i = byteBuf.readableBytes();
++ 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) {
+- LOGGER.debug("Ping: (<1.3.x) from {}", socketAddress);
+- String string = createVersion0Response(this.server);
+- sendFlushAndClose(context, createLegacyDisconnectPacket(context.alloc(), string));
++ LegacyQueryHandler.LOGGER.debug("Ping: (<1.3.x) from {}", socketaddress);
++ s = createVersion0Response(this.server, event); // CraftBukkit
++ sendFlushAndClose(channelhandlercontext, createLegacyDisconnectPacket(channelhandlercontext.alloc(), s));
+ } else {
+- if (byteBuf.readUnsignedByte() != 1) {
++ if (bytebuf.readUnsignedByte() != 1) {
+ return;
+ }
+
+- if (byteBuf.isReadable()) {
+- if (!readCustomPayloadPacket(byteBuf)) {
++ if (bytebuf.isReadable()) {
++ if (!readCustomPayloadPacket(bytebuf)) {
+ return;
+ }
+
+- LOGGER.debug("Ping: (1.6) from {}", socketAddress);
++ LegacyQueryHandler.LOGGER.debug("Ping: (1.6) from {}", socketaddress);
+ } else {
+- LOGGER.debug("Ping: (1.4-1.5.x) from {}", socketAddress);
++ LegacyQueryHandler.LOGGER.debug("Ping: (1.4-1.5.x) from {}", socketaddress);
+ }
+
+- String string = createVersion1Response(this.server);
+- sendFlushAndClose(context, createLegacyDisconnectPacket(context.alloc(), string));
++ s = createVersion1Response(this.server, event); // CraftBukkit
++ sendFlushAndClose(channelhandlercontext, createLegacyDisconnectPacket(channelhandlercontext.alloc(), s));
+ }
+
+- byteBuf.release();
++ bytebuf.release();
+ flag = false;
+- } catch (RuntimeException var11) {
++ } catch (RuntimeException runtimeexception) {
++ ;
+ }
++
+ } finally {
+ if (flag) {
+- byteBuf.resetReaderIndex();
+- context.channel().pipeline().remove(this);
+- context.fireChannelRead(message);
++ bytebuf.resetReaderIndex();
++ channelhandlercontext.channel().pipeline().remove(this);
++ channelhandlercontext.fireChannelRead(object);
+ }
++
+ }
+ }
+
+- private static boolean readCustomPayloadPacket(ByteBuf byteBuf) {
+- short unsignedByte = byteBuf.readUnsignedByte();
+- if (unsignedByte != 250) {
++ private static boolean readCustomPayloadPacket(ByteBuf bytebuf) {
++ short short0 = bytebuf.readUnsignedByte();
++
++ if (short0 != 250) {
+ return false;
+ } else {
+- String legacyString = LegacyProtocolUtils.readLegacyString(byteBuf);
+- if (!"MC|PingHost".equals(legacyString)) {
++ String s = LegacyProtocolUtils.readLegacyString(bytebuf);
++
++ if (!"MC|PingHost".equals(s)) {
+ return false;
+ } else {
+- int unsignedShort = byteBuf.readUnsignedShort();
+- if (byteBuf.readableBytes() != unsignedShort) {
++ int i = bytebuf.readUnsignedShort();
++
++ if (bytebuf.readableBytes() != i) {
+ return false;
+ } else {
+- short unsignedByte1 = byteBuf.readUnsignedByte();
+- if (unsignedByte1 < 73) {
++ short short1 = bytebuf.readUnsignedByte();
++
++ if (short1 < 73) {
+ return false;
+ } else {
+- String legacyString1 = LegacyProtocolUtils.readLegacyString(byteBuf);
+- int _int = byteBuf.readInt();
+- return _int <= 65535;
++ String s1 = LegacyProtocolUtils.readLegacyString(bytebuf);
++ int j = bytebuf.readInt();
++
++ return j <= 65535;
+ }
+ }
+ }
+ }
+ }
+
+- private static String createVersion0Response(ServerInfo serverInfo) {
+- return String.format(Locale.ROOT, "%s§%d§%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,
+- "§1\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 context) {
+- channelHandlerContext.pipeline().firstContext().writeAndFlush(context).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 string) {
+- ByteBuf byteBuf = byteBufAllocator.buffer();
+- byteBuf.writeByte(255);
+- LegacyProtocolUtils.writeLegacyString(byteBuf, string);
+- return byteBuf;
++ private static ByteBuf createLegacyDisconnectPacket(ByteBufAllocator bytebufallocator, String s) {
++ ByteBuf bytebuf = bytebufallocator.buffer();
++
++ bytebuf.writeByte(255);
++ LegacyProtocolUtils.writeLegacyString(bytebuf, s);
++ return bytebuf;
+ }
+ }