Package wtf.choco.veinminer.data
Class PersistentDataStorageJSON
java.lang.Object
wtf.choco.veinminer.data.PersistentDataStorageJSON
- All Implemented Interfaces:
PersistentDataStorage
An implementation of
PersistentDataStorage
for JSON files in a directory.-
Nested Class Summary
Nested classes/interfaces inherited from interface wtf.choco.veinminer.data.PersistentDataStorage
PersistentDataStorage.Type
-
Constructor Summary
ConstructorDescriptionPersistentDataStorageJSON
(@NotNull VeinMinerServer veinMiner, @NotNull File directory) Construct a newPersistentDataStorageJSON
. -
Method Summary
Modifier and TypeMethodDescription@NotNull PersistentDataStorage.Type
getType()
Get thePersistentDataStorage.Type
of persistent storage.@NotNull CompletableFuture<Void>
init()
Initialize this persistent storage.@NotNull CompletableFuture<List<VeinMinerPlayer>>
load
(@NotNull Collection<? extends VeinMinerPlayer> players) Load the data of the given list ofVeinMinerPlayers
from disk.@NotNull CompletableFuture<VeinMinerPlayer>
load
(@NotNull VeinMinerPlayer player) Load the data of the givenVeinMinerPlayer
from disk.@NotNull CompletableFuture<List<VeinMinerPlayer>>
save
(@NotNull Collection<? extends VeinMinerPlayer> players) Save the data of the given list ofVeinMinerPlayers
to disk.@NotNull CompletableFuture<VeinMinerPlayer>
save
(@NotNull VeinMinerPlayer player) Save the data of the givenVeinMinerPlayer
to disk.
-
Constructor Details
-
PersistentDataStorageJSON
public PersistentDataStorageJSON(@NotNull @NotNull VeinMinerServer veinMiner, @NotNull @NotNull File directory) Construct a newPersistentDataStorageJSON
.- Parameters:
veinMiner
- the vein miner server instancedirectory
- the directory where all JSON files are held
-
-
Method Details
-
getType
Description copied from interface:PersistentDataStorage
Get thePersistentDataStorage.Type
of persistent storage.- Specified by:
getType
in interfacePersistentDataStorage
- Returns:
- the type
-
init
Description copied from interface:PersistentDataStorage
Initialize this persistent storage.- Specified by:
init
in interfacePersistentDataStorage
- Returns:
- a
CompletableFuture
completed when the initialization has finished
-
save
@NotNull public @NotNull CompletableFuture<VeinMinerPlayer> save(@NotNull @NotNull VeinMinerPlayer player) Description copied from interface:PersistentDataStorage
Save the data of the givenVeinMinerPlayer
to disk.If the VeinMinerPlayer is not dirty (according to
VeinMinerPlayer.isDirty()
), this method will complete immediately and not perform a save.- Specified by:
save
in interfacePersistentDataStorage
- Parameters:
player
- the player to save- Returns:
- a
CompletableFuture
completed when saving has finished
-
save
@NotNull public @NotNull CompletableFuture<List<VeinMinerPlayer>> save(@NotNull @NotNull Collection<? extends VeinMinerPlayer> players) Description copied from interface:PersistentDataStorage
Save the data of the given list ofVeinMinerPlayers
to disk.- Specified by:
save
in interfacePersistentDataStorage
- Parameters:
players
- the players to save- Returns:
- a
CompletableFuture
completed when saving has finished
-
load
@NotNull public @NotNull CompletableFuture<VeinMinerPlayer> load(@NotNull @NotNull VeinMinerPlayer player) Description copied from interface:PersistentDataStorage
Load the data of the givenVeinMinerPlayer
from disk.- Specified by:
load
in interfacePersistentDataStorage
- Parameters:
player
- the player whose data to load- Returns:
- a
CompletableFuture
completed when loading has finished
-
load
@NotNull public @NotNull CompletableFuture<List<VeinMinerPlayer>> load(@NotNull @NotNull Collection<? extends VeinMinerPlayer> players) Description copied from interface:PersistentDataStorage
Load the data of the given list ofVeinMinerPlayers
from disk.- Specified by:
load
in interfacePersistentDataStorage
- Parameters:
players
- the players whose data to load- Returns:
- a
CompletableFuture
completed when loading has finished
-