Chunk packet. Counting players and kicking if too many

This commit is contained in:
Nanit
2020-11-26 12:29:54 +02:00
parent 011a48724d
commit 7eb6f75908
10 changed files with 234 additions and 26 deletions

View File

@@ -7,11 +7,29 @@ import ru.nanit.limbo.LimboConfig;
import ru.nanit.limbo.connection.ClientChannelInitializer;
import ru.nanit.limbo.util.Logger;
import java.util.concurrent.atomic.AtomicInteger;
public final class LimboServer {
private AtomicInteger playersCount;
public int getPlayersCount(){
return playersCount.get();
}
public void incrementPlayers(){
playersCount.incrementAndGet();
}
public void decrementPlayers(){
playersCount.decrementAndGet();
}
public void start() throws Exception {
Logger.info("Starting server...");
playersCount = new AtomicInteger();
ServerBootstrap bootstrap = new ServerBootstrap()
.group(new NioEventLoopGroup(), new NioEventLoopGroup())
.channel(NioServerSocketChannel.class)