mirror of
https://github.com/Minestom/Minestom.git
synced 2024-11-22 02:25:48 +01:00
Updated Storage (markdown)
parent
591adf601c
commit
9fea26e06c
22
Storage.md
22
Storage.md
@ -21,4 +21,26 @@ byte[] data;
|
||||
...
|
||||
storageFolder.set("test", data);
|
||||
data = storageFolder.get("test");
|
||||
```
|
||||
|
||||
## Integration with SerializableData
|
||||
Most of the data that you will store will be in the form of SerializableData.
|
||||
|
||||
There are two kind of SerializableData that you would want to store:
|
||||
1. A Data object which should not change but be unique and applied to multiple objects
|
||||
2. A Data object linked to an element and which should be synchronized
|
||||
|
||||
For the first type you would need:
|
||||
```java
|
||||
// The data is gonna be retrieved, cloned and applied to the DataContainer specified
|
||||
storageFolder.getAndCloneData(key, dataContainer);
|
||||
```
|
||||
And for the second:
|
||||
```java
|
||||
// The data is gonna be retrieved, applied to the DataContainer
|
||||
// And the storage folder will cache it for further saving
|
||||
storageFolder.getAndCacheData(key, dataContainer);
|
||||
...
|
||||
// Save all the cached SerializableData
|
||||
storageFolder.saveCachedData();
|
||||
```
|
Loading…
Reference in New Issue
Block a user