Mindustry icon indicating copy to clipboard operation
Mindustry copied to clipboard

[Refactor] Server cleanup and more

Open Darkness6030 opened this issue 2 years ago • 4 comments

I did a small refactoring, but didn't break the formatting. Also i added the ability for mods to change the default GameOverEvent listener so you can add a custom map loader or custom GameOver message Also i made two fields public. Why? Because using getters and setters in this class is pointless

  • [x] I have read the contribution guidelines.
  • [x] I have ensured that my code compiles, if applicable. It compiles
  • [x] I have ensured that any new features in this PR function correctly in-game, if applicable. It works

Darkness6030 avatar Sep 26 '22 13:09 Darkness6030

Also i made two fields public. Why? Because using getters and setters in this class is pointless

No, it isn't. It's not clear that setting these undocumented fields happens to do anything in the moment and you are essentially exposing implementation details that could change at any time. The setters should be things like "setNextMap", not nextMapOverride. Additionally, even I don't remember what lastMode is for (can it be null? what does it actually refer to?)

Anuken avatar Sep 26 '22 13:09 Anuken

I'll try to replace "lastServerMode" with "Vars.state.rules.mode()" and test how will it work

Darkness6030 avatar Sep 26 '22 13:09 Darkness6030

And yes, it works correctly for any gamemode. Also, it will choose the next map based on the gamemode of the current one, which is better.

Darkness6030 avatar Sep 26 '22 13:09 Darkness6030

@Anuken now nextMapOverride is documented, lastServerMode is replaced and removed. What about all the other changes?

Darkness6030 avatar Sep 26 '22 14:09 Darkness6030