Skip to content

Commit

Permalink
Remove unused postinitchannel GeyserServerInitializer
Browse files Browse the repository at this point in the history
  • Loading branch information
Kas-tle authored Apr 12, 2024
1 parent ddd47b6 commit 5e78331
Showing 1 changed file with 0 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,38 +80,6 @@ public void initSession(@NonNull BedrockServerSession bedrockServerSession) {
}
}

@Override
protected void postInitChannel(Channel channel) throws Exception {
super.postInitChannel(channel);

channel.pipeline().addLast(new SimpleChannelInboundHandler<ByteBuf>() {
private static final int allowedExceptions = 5;
private static final long delayUntilExceptionsReset = 60;

private long lastException;
private int exceptionCounts;

@Override
protected void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) throws Exception {
ctx.fireChannelRead(msg);
}

@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
final long currentTime = System.currentTimeMillis();
if (currentTime >= lastException + (delayUntilExceptionsReset * 1000)) {
exceptionCounts = 0;
}
lastException = currentTime;
if (exceptionCounts++ > allowedExceptions) {
ctx.pipeline().get(GeyserBedrockPeer.class).close("Too many exceptions created.");
return;
}
super.exceptionCaught(ctx, cause);
}
});
}

@Override
protected BedrockPeer createPeer(Channel channel) {
return new GeyserBedrockPeer(channel, this::createSession);
Expand Down

0 comments on commit 5e78331

Please sign in to comment.