Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-17 05:20:14 +01:00
Simplify the discard logic.
Dieser Commit ist enthalten in:
Ursprung
dd2e1ad241
Commit
11fb5f2be3
@ -16,7 +16,6 @@ import com.velocitypowered.natives.encryption.VelocityCipher;
|
||||
import com.velocitypowered.natives.encryption.VelocityCipherFactory;
|
||||
import com.velocitypowered.natives.util.Natives;
|
||||
import com.velocitypowered.proxy.VelocityServer;
|
||||
import com.velocitypowered.proxy.network.netty.DiscardHandler;
|
||||
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
||||
import com.velocitypowered.proxy.protocol.StateRegistry;
|
||||
import com.velocitypowered.proxy.protocol.netty.MinecraftCipherDecoder;
|
||||
@ -152,7 +151,6 @@ public class MinecraftConnection extends ChannelInboundHandlerAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
installDiscardHandler(ctx);
|
||||
ctx.close();
|
||||
}
|
||||
}
|
||||
@ -168,18 +166,6 @@ public class MinecraftConnection extends ChannelInboundHandlerAdapter {
|
||||
Preconditions.checkState(this.channel.eventLoop().inEventLoop(), "Not in event loop");
|
||||
}
|
||||
|
||||
private void installDiscardHandler(ChannelHandlerContext ctx) {
|
||||
if (ctx.pipeline().get("discard") == null) {
|
||||
ctx.pipeline().addBefore(MINECRAFT_DECODER, "discard", DiscardHandler.HANDLER);
|
||||
}
|
||||
}
|
||||
|
||||
private void installDiscardHandler() {
|
||||
if (channel.pipeline().get("discard") == null) {
|
||||
channel.pipeline().addBefore(MINECRAFT_DECODER, "discard", DiscardHandler.HANDLER);
|
||||
}
|
||||
}
|
||||
|
||||
public EventLoop eventLoop() {
|
||||
return channel.eventLoop();
|
||||
}
|
||||
@ -220,7 +206,6 @@ public class MinecraftConnection extends ChannelInboundHandlerAdapter {
|
||||
public void closeWith(Object msg) {
|
||||
if (channel.isActive()) {
|
||||
knownDisconnect = true;
|
||||
installDiscardHandler();
|
||||
channel.writeAndFlush(msg).addListener(ChannelFutureListener.CLOSE);
|
||||
}
|
||||
}
|
||||
@ -230,7 +215,6 @@ public class MinecraftConnection extends ChannelInboundHandlerAdapter {
|
||||
*/
|
||||
public void close() {
|
||||
if (channel.isActive()) {
|
||||
installDiscardHandler();
|
||||
channel.close();
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +0,0 @@
|
||||
package com.velocitypowered.proxy.network.netty;
|
||||
|
||||
import io.netty.channel.ChannelHandler.Sharable;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandlerAdapter;
|
||||
import io.netty.util.ReferenceCountUtil;
|
||||
|
||||
@Sharable
|
||||
public class DiscardHandler extends ChannelInboundHandlerAdapter {
|
||||
|
||||
public static final DiscardHandler HANDLER = new DiscardHandler();
|
||||
|
||||
@Override
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
ReferenceCountUtil.release(msg);
|
||||
}
|
||||
}
|
@ -14,6 +14,11 @@ public class MinecraftVarintFrameDecoder extends ByteToMessageDecoder {
|
||||
|
||||
@Override
|
||||
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) {
|
||||
if (!ctx.channel().isActive()) {
|
||||
in.skipBytes(in.readableBytes());
|
||||
return;
|
||||
}
|
||||
|
||||
while (in.isReadable()) {
|
||||
int varintEnd = in.forEachByte(reader);
|
||||
if (varintEnd == -1) {
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren