DataStores and resetting the RS

Words
293
Reading
2 min
Listen
Play
9y

For what project is this:

This a Post which talks about the introduction of the DataStores and the capability of Resets to the RS.

Resetting the RS and its problems

When I initially introduced the RS a couple of months ago, there was one flaw with it: Its data was distributed over several classes and several places inside those classes, all losely coupled using ITokens.
This was a problem when something broke. So I decided to change it.

A central database here we go:

Using our factory systems and a simple Map I was quickly able to create a nice central storage for our SRM:
image.png
This storage is now the central place were the RS stores data that it needs, I gave it an endpoint in its API:
image.png

Getting data:

Now that we have a central place to store the Data. We need a way to get it out. To make this possible we make use of TypeTokens (Google GenericType catchers) and again ITokens to identify which store we are looking for. As you can see the StandardDataStoreManager, will create a DataStore if it is not already known using our factory system:
image.png

Resetting the RS.

Now that we have all our ducks in a row so to speak resetting the RS to its defaults was easy as this:
image.png
We resetup our SRM to create a new DataStoreManager and to get new ITokens for the respective datastores:
image.png
After that we run our SRM Update logik to register all components back into it again.
Done.

Now it is possible to use a single command to reset the RS, incase it breaks, without having to dig through several NBT files that Minecolonies uses.



Posted on Utopian.io - Rewarding Open Source Contributors

DataStores and resetting the RS | Ecency