Avoided null pointer exception by adding an if statement

This commit is contained in:
Seraina 2022-04-14 15:05:00 +02:00
parent b37916134a
commit 2f79b41618

View File

@ -461,8 +461,9 @@ public class ClientHandler implements Runnable {
*/ */
public void disconnectClient() { public void disconnectClient() {
Lobby l = getLobby(); Lobby l = getLobby();
Game g = l.getGame(); if (l != null) {
if (l != null && g != null) { Game g = l.getGame();
if(g != null)
l.getGame().getGameState().handleClientDisconnect(this); l.getGame().getGameState().handleClientDisconnect(this);
} }
socket = this.getSocket(); socket = this.getSocket();