mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-31 12:56:29 +00:00
87 lines
4.9 KiB
Diff
87 lines
4.9 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Taiyou06 <kaandindar21@gmail.com>
|
|
Date: Thu, 8 May 2025 11:14:06 +0200
|
|
Subject: [PATCH] Alternative join logic
|
|
|
|
|
|
diff --git a/net/minecraft/network/Connection.java b/net/minecraft/network/Connection.java
|
|
index f998cf8d70302a21289de4d84b46d322d0b8a8fe..7423729fc9a6501c3a6408442ce28066067ce865 100644
|
|
--- a/net/minecraft/network/Connection.java
|
|
+++ b/net/minecraft/network/Connection.java
|
|
@@ -341,35 +341,54 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
|
|
this.validateListener(protocolInfo, packetInfo);
|
|
if (protocolInfo.flow() != this.getReceiving()) {
|
|
throw new IllegalStateException("Invalid inbound protocol: " + protocolInfo.id());
|
|
+ }
|
|
+ this.packetListener = packetInfo;
|
|
+ this.disconnectListener = null;
|
|
+ UnconfiguredPipelineHandler.InboundConfigurationTask inboundConfigurationTask = UnconfiguredPipelineHandler.setupInboundProtocol(protocolInfo);
|
|
+ BundlerInfo bundlerInfo = protocolInfo.bundlerInfo();
|
|
+ if (bundlerInfo != null) {
|
|
+ PacketBundlePacker packetBundlePacker = new PacketBundlePacker(bundlerInfo);
|
|
+ inboundConfigurationTask = inboundConfigurationTask.andThen(context -> context.pipeline().addAfter("decoder", "bundler", (ChannelHandler)packetBundlePacker));
|
|
+ }
|
|
+ ChannelFuture future = this.channel.writeAndFlush(inboundConfigurationTask);
|
|
+ if (!org.dreeam.leaf.config.modules.network.AlternativeJoin.AlternativeJoin) {
|
|
+ Connection.syncAfterConfigurationChange(future);
|
|
} else {
|
|
- this.packetListener = packetInfo;
|
|
- this.disconnectListener = null;
|
|
- UnconfiguredPipelineHandler.InboundConfigurationTask inboundConfigurationTask = UnconfiguredPipelineHandler.setupInboundProtocol(protocolInfo);
|
|
- BundlerInfo bundlerInfo = protocolInfo.bundlerInfo();
|
|
- if (bundlerInfo != null) {
|
|
- PacketBundlePacker packetBundlePacker = new PacketBundlePacker(bundlerInfo);
|
|
- inboundConfigurationTask = inboundConfigurationTask.andThen(context -> context.pipeline().addAfter("decoder", "bundler", packetBundlePacker));
|
|
- }
|
|
-
|
|
- syncAfterConfigurationChange(this.channel.writeAndFlush(inboundConfigurationTask));
|
|
+ java.util.concurrent.CompletableFuture.runAsync(() -> {
|
|
+ try {
|
|
+ future.await();
|
|
+ } catch (InterruptedException e) {
|
|
+ Thread.currentThread().interrupt();
|
|
+ }
|
|
+ });
|
|
}
|
|
}
|
|
|
|
public void setupOutboundProtocol(ProtocolInfo<?> protocolInfo) {
|
|
+ boolean flag;
|
|
if (protocolInfo.flow() != this.getSending()) {
|
|
throw new IllegalStateException("Invalid outbound protocol: " + protocolInfo.id());
|
|
+ }
|
|
+ UnconfiguredPipelineHandler.OutboundConfigurationTask outboundConfigurationTask = UnconfiguredPipelineHandler.setupOutboundProtocol(protocolInfo);
|
|
+ BundlerInfo bundlerInfo = protocolInfo.bundlerInfo();
|
|
+ if (bundlerInfo != null) {
|
|
+ PacketBundleUnpacker packetBundleUnpacker = new PacketBundleUnpacker(bundlerInfo);
|
|
+ outboundConfigurationTask = outboundConfigurationTask.andThen(context -> context.pipeline().addAfter("encoder", "unbundler", (ChannelHandler)packetBundleUnpacker));
|
|
+ }
|
|
+ boolean bl = flag = protocolInfo.id() == ConnectionProtocol.LOGIN;
|
|
+ ChannelFuture future = this.channel.writeAndFlush(outboundConfigurationTask.andThen(context -> {
|
|
+ this.sendLoginDisconnect = flag;
|
|
+ }));
|
|
+ if (!org.dreeam.leaf.config.modules.network.AlternativeJoin.AlternativeJoin) {
|
|
+ Connection.syncAfterConfigurationChange(future);
|
|
} else {
|
|
- UnconfiguredPipelineHandler.OutboundConfigurationTask outboundConfigurationTask = UnconfiguredPipelineHandler.setupOutboundProtocol(protocolInfo);
|
|
- BundlerInfo bundlerInfo = protocolInfo.bundlerInfo();
|
|
- if (bundlerInfo != null) {
|
|
- PacketBundleUnpacker packetBundleUnpacker = new PacketBundleUnpacker(bundlerInfo);
|
|
- outboundConfigurationTask = outboundConfigurationTask.andThen(
|
|
- context -> context.pipeline().addAfter("encoder", "unbundler", packetBundleUnpacker)
|
|
- );
|
|
- }
|
|
-
|
|
- boolean flag = protocolInfo.id() == ConnectionProtocol.LOGIN;
|
|
- syncAfterConfigurationChange(this.channel.writeAndFlush(outboundConfigurationTask.andThen(context -> this.sendLoginDisconnect = flag)));
|
|
+ java.util.concurrent.CompletableFuture.runAsync(() -> {
|
|
+ try {
|
|
+ future.await();
|
|
+ } catch (InterruptedException e) {
|
|
+ Thread.currentThread().interrupt();
|
|
+ }
|
|
+ });
|
|
}
|
|
}
|
|
|