Pecacheu / Elevators-v2

Adds fully-featured Elevators to Minecraft!
GNU General Public License v3.0
10 stars 10 forks source link

Fixed saveConfig() returning too early skipping the loading code #7

Closed Salzian closed 6 years ago

Salzian commented 6 years ago

When the server tries to save the config file, it skips the whole saving logic right after checking if the config.yml file exists.

Pecacheu commented 6 years ago

Are you sure that fixes it? It's supposed to return the first time, since it's just extracting the file, it shouldn't be modifying it. If that's causing it not to save elevators, that could indicate a problem with when the function is called.

Pecacheu commented 6 years ago

I'll test your modified line...

Salzian commented 6 years ago

I tested it for over 4 hours reworking all the code, thinking about saving the elevator data in an own file. In the end, I realized, that the only mistake was this line. When the try/catch gets executed, it either returned false in case of an IOException or true when it was able to read the file. However, in both scenarios it returns, not saving the elevator data to the file.

My config.yml never got modifier prior to this change, now I didn't come across any problems.

Salzian commented 6 years ago

As soon as I restarted my server, the server read the empty config.yml elevator array, since the code never saved before properly. The only time the code completely runs was when there was no config.yml file.

Pecacheu commented 6 years ago

Yeah, I tested it. You are correct with the issue. It's a classic case of having the signs backwards. That return true; belongs in the if, not the else. Of course, I don't really need it anyway, it was only to keep it from messing with the formatting of the comments, which is an issue I fixed a while ago.

So I can definitely take the pull request.