How should per-world data be handled in SSP?
MatanShahar opened this issue ยท 1 comments
Some information (like the knowladge map [#839]) in EE3 should be kept in memory on a per-world basis, in SMP this is handled by clearing the player information one he logs out (using onPlayerLoggedOut
). The problem with SMP is that this event is never being called, the internal server shuts down (causing an invocation of onServerStopping
) and that's it.
Attempting to clear player information by means of onServerStopping
wont work as it is executed on the server instance alone.
I think there are two (better) ways to go about solving said issue:
- Messaging - Sending a packet to each player currently logged in, asking to preform a clear operation. I don't really like approach as I don't believe it is the server's responsibility to keep players' state current in future play sessions (as they log into SSP or other servers).
- Introducing Sessions - when considering the issue more closely I think we can realize that the information isn't dependent on the player identity (UUID) alone but is also dependent on the current play session, once this session ends the information is not longer valid. Hence I propose rewriting some of the code. Whenever a player logs into an instance (be it SSP or SMP) his last player session is being invalidated and he is granted a new one. Session can be easily represented with incrementing integers since memory is wiped anyway when the current instance (minecraft executable) is being closed.
The knowledge system is designed to be stored server side only, and the issue today is that the singleton for the registry is not cleared when the server shuts down. The player logout is only meant to save that players data to disk (an attempt at lazy saving but its not working well in practice).
This is being improved as part of #989