Why is the code only working in debug mode?

I am making a game with a save/load mechanism but the save only works when I'm in debug mode. the ID for my code is Upload id: 2024_01_28_KJAq65QVMGwChUWe4p45N4 (files: BattleMach.java and 7 more)

and I think that the problem is in classes.Game.java at line 48. It's not printing the save code s but in debug mode it's printing it. Why? 

And the console output in debug mode is:

C:\Users\sulai\.jdks\openjdk-21.0.1\bin\java.exe -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:54201,suspend=y,server=n -javaagent:C:\Users\sulai\AppData\Local\JetBrains\IdeaIC2023.3\captureAgent\debugger-agent.jar -Dfile.encoding=UTF-8 -Dsun.stdout.encoding=UTF-8 -Dsun.stderr.encoding=UTF-8 -classpath "C:\Users\sulai\IdeaProjects\An RPG Game\out\production\An RPG Game;C:\Users\sulai\.m2\repository\com\google\code\gson\gson\2.10.1\gson-2.10.1.jar;C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2023.3.1\lib\idea_rt.jar" classes.Main
Connected to the target VM, address: '127.0.0.1:54201', transport: 'socket'
BattleMachs!
1. New game
2. Load game
Enter your choice:
1
Press 'O' for options
Enter your name:
1
Are you sure that you want 1 to be your name? (Enter yes or no):
0
Are you sure that you want 1 to be your name? (Enter yes or no):
o
You are in the options screen.
1 - Save game
2 - Save and quit
3 - Set text speed
Enter E to exit:
1
You exited the options screen.

Are you sure that you want 1 to be your name? (Enter yes or no):
Copy line below (it is a save code):
{"name":"1","delay":0.028571429}

 

and without:

C:\Users\sulai\.jdks\openjdk-21.0.1\bin\java.exe "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2023.3.1\lib\idea_rt.jar=52716:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2023.3.1\bin" -Dfile.encoding=UTF-8 -Dsun.stdout.encoding=UTF-8 -Dsun.stderr.encoding=UTF-8 -classpath "C:\Users\sulai\IdeaProjects\An RPG Game\out\production\An RPG Game;C:\Users\sulai\.m2\repository\com\google\code\gson\gson\2.10.1\gson-2.10.1.jar" classes.Main
BattleMachs!

1. New game
2. Load game
Enter your choice:
1
Press 'O' for options

Enter your name:
s
Are you sure that you want s to be your name? (Enter yes or no):
o
You are in the options screen.
1 - Save game
2 - Save and quit
3 - Set text speed
Enter E to exit:
1
You exited the options screen.


Are you sure that you want s to be your name? (Enter yes or no):

Process finished with exit code 130
0

I got it. It's working now

0

请先登录再写评论。