Package me.efekos.simpler.config
Class MapDataManager<K,V extends Storable>
java.lang.Object
me.efekos.simpler.config.MapDataManager<K,V>
- Type Parameters:
K- Type of the keys you will use. ProbablyStringbut you can change it to something else if you want.V- Type of the data you want to store as a list. Be aware that using incompatible types in this type might cause errors. Just to let you know, there is a list of the classes compatible to be used inside V.
-
Constructor Summary
ConstructorsConstructorDescriptionMapDataManager(String path, org.bukkit.plugin.java.JavaPlugin plugin) Constructs a new manager. -
Method Summary
Modifier and TypeMethodDescriptionvoidSearches for a data with the given id and deletes the data found.Grabs a data from the map using itsUUID.getAll()Grabs the entire map and returns it.voidload()Loads all the data from the save before.voidsave()Saves all the data to the plugins data folder using the given path.voidPuts the given data to map.
-
Constructor Details
-
MapDataManager
Constructs a new manager.- Parameters:
path- Path to the file where all the data will be saved withsave(). Must end with.json. You can't choose a path outside your plugins data folder.plugin- Instance of the plugin that will use this database. Recommended to bethis, assuming that you are constructing a database inside yourJavaPlugin.onEnable()method.
-
-
Method Details
-
get
Grabs a data from the map using itsUUID.- Parameters:
id- ID of the data you want to get.- Returns:
- Data if found,
nullotherwise.
-
delete
Searches for a data with the given id and deletes the data found.- Parameters:
id- ID of the data you want to delete
-
set
Puts the given data to map.- Parameters:
key- Key of the data in map.data- Data you want to put to the map.
-
save
public void save()Saves all the data to the plugins data folder using the given path. It will save the data as a '.json' file, topathunder plugins data folder. -
load
public void load()Loads all the data from the save before. You don't have to check if file exists, because method does it. -
getAll
Grabs the entire map and returns it.- Returns:
- All the map of data.
-