Fix non-fatal NPE in networking code

This commit is contained in:
ceikry 2021-10-22 13:54:28 -05:00
parent bf497bae36
commit b8ae0254c2

View file

@ -62,7 +62,7 @@ public class IoEventHandler {
ByteBuffer buffer = ByteBuffer.allocate(100_000); ByteBuffer buffer = ByteBuffer.allocate(100_000);
IoSession session = (IoSession) key.attachment(); IoSession session = (IoSession) key.attachment();
if (channel.read(buffer) == -1) { if (channel.read(buffer) == -1) {
if(session.getPlayer() != null){ if(session != null && session.getPlayer() != null){
Repository.getDisconnectionQueue().add(session.getPlayer()); Repository.getDisconnectionQueue().add(session.getPlayer());
} }
key.cancel(); key.cancel();