Skip to content

Commit 7277905

Browse files
committed
Velocity b501+ support
1 parent 41118f4 commit 7277905

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/main/java/net/elytrium/fastmotd/injection/HandshakeSessionHandlerHook.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import com.velocitypowered.proxy.protocol.MinecraftPacket;
2525
import com.velocitypowered.proxy.protocol.StateRegistry;
2626
import com.velocitypowered.proxy.protocol.netty.MinecraftDecoder;
27+
import com.velocitypowered.proxy.protocol.netty.MinecraftVarintFrameDecoder;
2728
import com.velocitypowered.proxy.protocol.packet.HandshakePacket;
2829
import com.velocitypowered.proxy.protocol.packet.LegacyHandshakePacket;
2930
import com.velocitypowered.proxy.protocol.packet.LegacyPingPacket;
@@ -34,6 +35,7 @@
3435
import io.netty.buffer.Unpooled;
3536
import io.netty.channel.Channel;
3637
import io.netty.channel.ChannelOutboundBuffer;
38+
import io.netty.channel.ChannelPipeline;
3739
import java.net.InetSocketAddress;
3840
import net.elytrium.fastmotd.FastMOTD;
3941
import net.elytrium.fastmotd.Settings;
@@ -143,8 +145,14 @@ public boolean handle(HandshakePacket handshake) {
143145

144146
this.protocolVersion = handshake.getProtocolVersion();
145147
this.serverAddress = cleanHost(handshake.getServerAddress()) + ":" + handshake.getPort();
146-
this.channel.pipeline().remove(Connections.FRAME_ENCODER);
147-
this.channel.pipeline().get(MinecraftDecoder.class).setState(StateRegistry.STATUS);
148+
149+
ChannelPipeline pipeline = this.channel.pipeline();
150+
pipeline.remove(Connections.FRAME_ENCODER);
151+
pipeline.get(MinecraftDecoder.class).setState(StateRegistry.STATUS);
152+
MinecraftVarintFrameDecoder frameDecoder = pipeline.get(MinecraftVarintFrameDecoder.class);
153+
if (frameDecoder != null) {
154+
frameDecoder.setState(StateRegistry.STATUS);
155+
}
148156

149157
if (Settings.IMP.MAIN.LOG_PINGS) {
150158
this.plugin.getLogger().info("{} is pinging the server with version {}", this.connection.getRemoteAddress(), this.protocolVersion);

0 commit comments

Comments
 (0)