PerWorldInventory
PerWorldInventory copied to clipboard
Tech: Using bukkits internal Metadata system for storing PWIPlayers?
Using two different systems to store information about the player, as we discussed in the PR, is not that great.
But it got me thinking about storing the PWIPlayerObjects themselves using the Metadata system.
It would delete the need for a cache, as the Metadatavalues themselves are caches for each player. They have an invalidate method and can lazy-load the relevant information when needed. It would remove the need for a "clear cache" timer, and overall, reduce complexity of the code I think.
Decided to make this a separate issue as I didn't want the discussion in the PR to go off track to much.
Either way the player-location information obviously (in retrospect) should go into the PWIPlayer-class. This is just asking what you think about placing the PWIPlayer objects into bukkits internal place for plugins to place information about the player, instead of using your own cache for that.
Might work as an alternative datasource implementation?
This is an interesting idea that I hadn't ever before considered. It might be worth it to create a new branch and poke around with it.
Well, probably not datasource, as it's not persistent. We still need to persist our own data ourselves. But it'll remove the need to keep flushing our cache manually. I'm not entirely sure if/when invalidate() on metadata is called, but it means we can be requested to dump our data from RAM in a standardized way by, say, a memory management plugin for huge servers etc.
Eitherway, I feel using standard libs for this might be of interest rather than implementing our own player cache.