diff --git a/.idea/artifacts/PGNator_jar.xml b/.idea/artifacts/PGNator_jar.xml new file mode 100644 index 0000000..43cfe47 --- /dev/null +++ b/.idea/artifacts/PGNator_jar.xml @@ -0,0 +1,63 @@ + + + $PROJECT_DIR$/out/artifacts/PGNator_jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/moe/wah/pgnator/commands/Pgn2Gif.java b/src/main/java/moe/wah/pgnator/commands/Pgn2Gif.java index 6634639..fa21c2d 100644 --- a/src/main/java/moe/wah/pgnator/commands/Pgn2Gif.java +++ b/src/main/java/moe/wah/pgnator/commands/Pgn2Gif.java @@ -59,8 +59,19 @@ public class Pgn2Gif extends ApplicationCommand { } // Load PGN from file PgnHolder pgn = new PgnHolder("./temp/pgn/" + attachment.getFileName()); + Game game = null; try { - outputFile = pgnToGif(pgn); + game = pgnToGame(pgn); + } catch (Exception e) { + throw new RuntimeException(e); + } + + if (pgn.getGames().getFirst().getHalfMoves().isEmpty()) { + log.debug("Invalid PGN!"); + event.getHook().sendMessage("Invalid PGN!").queue(); + } + try { + outputFile = gameToGif(game); } catch (Exception e) { throw new RuntimeException(e); } @@ -80,11 +91,9 @@ public class Pgn2Gif extends ApplicationCommand { }); } - private static File pgnToGif(PgnHolder pgn) throws Exception { + private static File gameToGif(Game game) throws Exception { ChessRenderer renderer = new ChessRenderer(ChessThemeLibrary.GREEN_THEME, 60); - Game game = pgnToGame(pgn); String boardID = String.valueOf(Instant.now().toEpochMilli()); - game.loadMoveText(); MoveList moves = game.getHalfMoves(); Board board = new Board(); diff --git a/src/main/resources/META-INF/MANIFEST.MF b/src/main/resources/META-INF/MANIFEST.MF new file mode 100644 index 0000000..8353d93 --- /dev/null +++ b/src/main/resources/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Main-Class: moe.wah.pgnator.PGNator +