Add world save mode for ServerWorld#save() to support flush
Now explain exactly what the two enum values do :). Rather what the implementation is contractually obligated to do.
Some concerns were raised about whatever the new method is ambiguous with the old one and that it would be a bit better to be more explicit here. The first option would be to introduce a new method saveAndFlush and keep the old one. The second option would be to use more explicit enum names.
I'm not really sure what would be the best approach for the enums here and would vision it more like:
public enum WorldSaveMode {
SAVE_CHUNKS,
SAVE_METADATA,
FLUSH
}
boolean save(EnumSet<WorldSaveMode> saveModes) throws IOException;
This would give more flexibility but it could hurt more the typical use case as you usually would want to have (SAVE_CHUNKS, SAVE_METADATA) combo and optionally add the FLUSH option there. Also does passing just FLUSH mean its a no-op or does it flush the pending writes if there are any? On top of that it does require more stuff on the implementation side. In my opinion using enums here would look cumbersome without the use of EnumSet.
Sorry for going back and forth with this.
Some concerns were raised about whatever the new method is ambiguous with the old one and that it would be a bit better to be more explicit here. The first option would be to introduce a new method
saveAndFlushand keep the old one. The second option would be to use more explicit enum names.
I like the option with the saveAndFlush() method. It's simple and obvious. Better than the boolean flag. Initially, I did so, but Zidane expressed an opinion about the Enum option. Other potential "modes" of saving in the future, as it seems to me, cannot be for the sake of which we need to do Enum. And the SerializationBehavior is responsible for managing what needs to be stored (manually or automatic), it is actually a world parameter, not a passed argument. I suggest just making the saveAndFlush() method. If in the future you need to redo this, the method can be easily deprecated and redirect the call to the right place.
Other potential "modes" of saving in the future, as it seems to me, cannot be for the sake of which we need to do Enum.
I would imagine you could want to do something like world.save(EnumSet.of(WorldSaveMode.SAVE_METADATA)) to save the metadata immediately but without the chunks. But it is more complicated.
I suggest just making the saveAndFlush() method.
That should be enough for now to get this merged.