Skip to main content

Packet filtering

BaseIONetworkManager contains two fields: sendFilters and receiveFilters. You can filter packets just by adding your own filter to these filter sets. A filter is defined as BiPredicate<Packet, NetworkManager>. If the BiPredicate returns true the packet will be filtered and consequently no further processed. For performance purposes you should always check for the correct packet type first.

The NetworkManager instance is provided on purpose:
You can get Player connection information with
    ((InetSocketAddress) (here: player's IP).
You can get the player object with
Keep in mind that depending on your packet you have other INetHandlers than NetHandlerPlayServer.


BaseIONetworkManager.receiveFilters.add((packet, networkManager) -> {
if (packet instanceof CPacketLoginStart) {
CPacketLoginStart packet = (CPacketLoginStart) p;
GameProfile player = packet.getProfile();"GameProfile " + player.toString() + " tries to connect");
return true;