generated from Lenni0451/GradleTemplate
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change handshake intent from transfer when connecting first
- Loading branch information
Showing
4 changed files
with
44 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/main/java/net/lenni0451/miniconnect/proxy/event/HandshakeIntentListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package net.lenni0451.miniconnect.proxy.event; | ||
|
||
import io.netty.channel.ChannelHandlerContext; | ||
import io.netty.channel.SimpleChannelInboundHandler; | ||
import net.lenni0451.lambdaevents.EventHandler; | ||
import net.lenni0451.miniconnect.Main; | ||
import net.lenni0451.miniconnect.utils.ChannelUtils; | ||
import net.raphimc.netminecraft.constants.IntendedState; | ||
import net.raphimc.netminecraft.constants.MCPipeline; | ||
import net.raphimc.netminecraft.packet.Packet; | ||
import net.raphimc.netminecraft.packet.impl.handshaking.C2SHandshakingClientIntentionPacket; | ||
import net.raphimc.viaproxy.plugins.events.Client2ProxyChannelInitializeEvent; | ||
import net.raphimc.viaproxy.plugins.events.types.ITyped; | ||
|
||
public class HandshakeIntentListener { | ||
|
||
@EventHandler | ||
public void onClient2ProxyChannelInitialize(final Client2ProxyChannelInitializeEvent event) { | ||
if (!event.getType().equals(ITyped.Type.POST)) return; | ||
event.getChannel().pipeline().addBefore(MCPipeline.HANDLER_HANDLER_NAME, "miniconnect-intent-changer", new SimpleChannelInboundHandler<Packet>() { | ||
@Override | ||
protected void channelRead0(ChannelHandlerContext channelHandlerContext, Packet packet) { | ||
if (packet instanceof C2SHandshakingClientIntentionPacket clientIntention) { | ||
if (clientIntention.intendedState.equals(IntendedState.TRANSFER)) { | ||
if (Main.getInstance().getStateRegistry().getChangeHandshakeIntent().remove(ChannelUtils.getChannelAddress(event.getChannel()))) { | ||
clientIntention.intendedState = IntendedState.LOGIN; | ||
} | ||
} | ||
} | ||
channelHandlerContext.fireChannelRead(packet); | ||
} | ||
}); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters