prevent NPE

it seems repeated momir ai games and you switch to human player and start any game causes the NPE resulting to crashing the UI
This commit is contained in:
Anthony Calosa
2021-03-03 18:43:25 +08:00
parent 55e81e0d92
commit ff4803c506
2 changed files with 1 additions and 3 deletions

View File

@@ -64,8 +64,6 @@ public class PlayerView extends GameEntityView {
}
public String getLobbyPlayerName() {
if (get(TrackableProperty.LobbyPlayerName) == null)
return ""; //todo find the root cause why this would return null after succesful start of game and could freeze the UI?
return get(TrackableProperty.LobbyPlayerName);
}
void updateLobbyPlayerName(Player p) {

View File

@@ -403,7 +403,7 @@ public abstract class AbstractGuiGame implements IGuiGame, IMayViewCards {
@Override
public final void awaitNextInput() {
if (awaitNextInputTimer == null) {
if (awaitNextInputTimer == null && currentPlayer != null) { //Prevent NPE currentPlayer
awaitNextInputTimer = new Timer("awaitNextInputTimer Game:" + this.gameView.getId() + " Player:" + this.currentPlayer.getLobbyPlayerName());
}
//delay updating prompt to await next input briefly so buttons don't flicker disabled then enabled