Buggy code:
ArrayList < Move > moves = new ArrayList < Move > ( ) ; int row = cord . getRow ( ) ; int col = cord . getCol ( ) ; if ( ( ChessBoard . validPosition ( ( row - 1 ) , col ) ) && ( board [ ( row - 1 ) ] [ col ] . isEmptyOrEnemy ( player ) ) ) moves . add ( new Move ( cord , new Coord ( ( row - 1 ) , col ) , null ) ) ; if ( ( ChessBoard . validPosition ( ( row - 1 ) , ( col - 1 ) ) ) && ( board [ ( row - 1 ) ] [ ( col - 1 ) ] . isEmptyOrEnemy ( player ) ) ) moves . add ( new Move ( cord , new Coord ( ( row - 1 ) , ( col - 1 ) ) , null ) ) ; if ( ( ChessBoard . validPosition ( ( row - 1 ) , ( col + 1 ) ) ) && ( board [ ( row - 1 ) ] [ ( col + 1 ) ] . isEmptyOrEnemy ( player ) ) ) moves . add ( new Move ( cord , new Coord ( ( row - 1 ) , ( col + 1 ) ) , null ) ) ; if ( ( ChessBoard . validPosition ( row , ( col - 1 ) ) ) && ( board [ row ] [ ( col - 1 ) ] . isEmptyOrEnemy ( player ) ) ) moves . add ( new Move ( cord , new Coord ( row , ( col - 1 ) ) , null ) ) ; if ( ( ChessBoard . validPosition ( row , ( col + 1 ) ) ) && ( board [ row ] [ ( col + 1 ) ] . isEmptyOrEnemy ( player ) ) ) moves . add ( new Move ( cord , new Coord ( row , ( col + 1 ) ) , null ) ) ; if ( ( ChessBoard . validPosition ( ( row + 1 ) , col ) ) && ( board [ ( row + 1 ) ] [ col ] . isEmptyOrEnemy ( player ) ) ) moves . add ( new Move ( cord , new Coord ( ( row + 1 ) , col ) , null ) ) ; if ( ( ChessBoard . validPosition ( ( row + 1 ) , ( col - 1 ) ) ) && ( board [ ( row + 1 ) ] [ ( col - 1 ) ] . isEmptyOrEnemy ( player ) ) ) moves . add ( new Move ( cord , new Coord ( ( row + 1 ) , ( col - 1 ) ) , null ) ) ; if ( ( ChessBoard . validPosition ( ( row + 1 ) , ( col + 1 ) ) ) && ( board [ ( row + 1 ) ] [ ( col + 1 ) ] . isEmptyOrEnemy ( player ) ) ) moves . add ( new Move ( cord , new Coord ( ( row + 1 ) , ( col + 1 ) ) , null ) ) ; if ( ( ( ( player ) == ( Player . PLAYER1 ) ) && ( ! ( hasMoved ) ) ) && ( ! ( cb . kingInCheck ( ) ) ) ) { if ( board [ 7 ] [ 0 ] . isOwnType ( ROOK ) ) { boolean leftSideEmpty = true ; for ( int i = col - 1 ; i > 0 ; i -- ) leftSideEmpty = leftSideEmpty && ( board [ 7 ] [ i ] . isEmpty ( ) ) ; Rook left = ( ( Rook ) ( board [ 7 ] [ 0 ] . getPiece ( ) ) ) ; boolean rookMoved = left . hasMoved ( ) ; ChessBoard boardClone = new ChessBoard ( cb ) ; Coord kingFrom = new Coord ( row , col ) ; Coord kingThrough = new Coord ( row , ( col - 1 ) ) ; boardClone . applyMove ( new Move ( kingFrom , kingThrough , null ) ) ; boolean inCheckThrough = boardClone . kingInCheck ( ) ; if ( ( leftSideEmpty && ( ! rookMoved ) ) && ( ! inCheckThrough ) ) moves . add ( new Move ( cord , new Coord ( row , ( col - 2 ) ) , null ) ) ; } <START_BUG> if ( board [ 7 ] [ 0 ] . isOwnType ( ROOK ) ) { <END_BUG> boolean rightSideEmpty = true ; for ( int i = col + 1 ; i < 7 ; i ++ ) rightSideEmpty = rightSideEmpty && ( board [ 7 ] [ i ] . isEmpty ( ) ) ; Rook right = ( ( Rook ) ( board [ 7 ] [ 7 ] . getPiece ( ) ) ) ; boolean rookMoved = right . hasMoved ( ) ; ChessBoard boardClone = new ChessBoard ( cb ) ; Coord kingFrom = new Coord ( 7 , col ) ; Coord kingThrough = new Coord ( 7 , ( col + 1 ) ) ; boardClone . applyMove ( new Move ( kingFrom , kingThrough , null ) ) ; boolean inCheckThrough = boardClone . kingInCheck ( ) ; if ( ( rightSideEmpty && ( ! rookMoved ) ) && ( ! inCheckThrough ) ) moves . add ( new Move ( cord , new Coord ( row , ( col + 2 ) ) , null ) ) ;

Fix:
if ( board [ 7 ] [ 7 ] . isOwnType ( ROOK ) ) {