Package net.minestom.server.storage
Class StorageManager
java.lang.Object
net.minestom.server.storage.StorageManager
public final class StorageManager
extends java.lang.Object
Manager used to retrieve
StorageLocation
with getLocation(String, StorageOptions, StorageSystem)
and define the default StorageSystem
with defineDefaultStorageSystem(Supplier)
.-
Constructor Summary
Constructors Constructor Description StorageManager()
-
Method Summary
Modifier and Type Method Description void
defineDefaultStorageSystem(java.util.function.Supplier<StorageSystem> storageSystemSupplier)
Defines the defaultStorageSystem
used forStorageLocation
.java.util.Collection<StorageLocation>
getLoadedLocations()
Gets all theStorageLocation
which have been loaded bygetLocation(String)
orgetLocation(String, StorageOptions, StorageSystem)
.StorageLocation
getLocation(java.lang.String location)
Used to get an access to the specified location.StorageLocation
getLocation(java.lang.String location, StorageOptions storageOptions)
Used to get an access to the specified location.StorageLocation
getLocation(java.lang.String location, StorageOptions storageOptions, StorageSystem storageSystem)
Used to get an access to the specified location.boolean
isDefaultStorageSystemDefined()
Gets if the defaultStorageSystem
is set.boolean
locationExists(java.lang.String location)
CallslocationExists(String, StorageSystem)
with the defaultStorageSystem
.boolean
locationExists(java.lang.String location, StorageSystem storageSystem)
Used to know if the specified location already exist or not.
-
Constructor Details
-
StorageManager
public StorageManager()
-
-
Method Details
-
getLocation
public StorageLocation getLocation(@NotNull java.lang.String location, @NotNull StorageOptions storageOptions, @NotNull StorageSystem storageSystem)Used to get an access to the specified location. WARNING: aStorageLocation
needs to be created with an uniqueStorageSystem
linked you cannot open the save location with two or more differentStorageSystem
implementation.- Parameters:
location
- the locationstorageOptions
- theStorageOptions
storageSystem
- theStorageSystem
used in the specified location- Returns:
- the specified
StorageLocation
-
getLocation
public StorageLocation getLocation(@NotNull java.lang.String location, @NotNull StorageOptions storageOptions)Used to get an access to the specified location. The defaultStorageSystem
provider will be used.- Parameters:
location
- the locationstorageOptions
- theStorageOptions
- Returns:
- the
StorageLocation
atlocation
with the defaultStorageSystem
- Throws:
java.lang.NullPointerException
- if no defaultStorageSystem
is defined withdefineDefaultStorageSystem(Supplier)
-
getLocation
Used to get an access to the specified location. The defaultStorageSystem
provider will be used.- Parameters:
location
- the location- Returns:
- the
StorageLocation
atlocation
with the defaultStorageSystem
- Throws:
java.lang.NullPointerException
- if no default StorageSystem is defineddefineDefaultStorageSystem(Supplier)
-
locationExists
public boolean locationExists(@NotNull java.lang.String location, @NotNull StorageSystem storageSystem)Used to know if the specified location already exist or not.- Parameters:
location
- the locationstorageSystem
- theStorageSystem
to use- Returns:
- true if the location exists, false otherwise
-
locationExists
public boolean locationExists(@NotNull java.lang.String location)CallslocationExists(String, StorageSystem)
with the defaultStorageSystem
.- Parameters:
location
- the location- Returns:
- true if the location exists
-
getLoadedLocations
Gets all theStorageLocation
which have been loaded bygetLocation(String)
orgetLocation(String, StorageOptions, StorageSystem)
.- Returns:
- an unmodifiable list of all the loaded
StorageLocation
-
defineDefaultStorageSystem
public void defineDefaultStorageSystem(@NotNull java.util.function.Supplier<StorageSystem> storageSystemSupplier)Defines the defaultStorageSystem
used forStorageLocation
.- Parameters:
storageSystemSupplier
- the supplier called to get the defaultStorageSystem
-
isDefaultStorageSystemDefined
public boolean isDefaultStorageSystemDefined()Gets if the defaultStorageSystem
is set.- Returns:
- true if a default
StorageSystem
is set
-