Package me.efekos.simpler.config
Class ListDataManager<T extends Storable>
java.lang.Object
me.efekos.simpler.config.ListDataManager<T>
- Type Parameters:
T
- 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 T of database.
-
Constructor Summary
ConstructorDescriptionListDataManager
(String path, org.bukkit.plugin.java.JavaPlugin plugin) Constructs a new manager. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds the given data to list.void
Searches for a data with the given id and deletes the data found.Grabs a data from the list using itsUUID
.getAll()
Grabs the entire list and returns it.void
load()
Loads all the data from the save before.void
save()
Saves all the data to the plugins data folder using the given path.Finds a data with the given id, and replaces it with the new one.
-
Constructor Details
-
ListDataManager
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 list using itsUUID
.- Parameters:
id
- ID of the data you want to get.- Returns:
- Data if found,
null
otherwise.
-
delete
Searches for a data with the given id and deletes the data found.- Parameters:
id
- ID of the data you want to delete
-
add
Adds the given data to list.- Parameters:
data
- Data you want to add to the list.
-
update
Finds a data with the given id, and replaces it with the new one.- Parameters:
id
- ID of the data you want to update. You can just doStorable.getUniqueId()
for this.newData
- New data to replace with the old one- Returns:
- New data.
-
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, topath
under 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 list and returns it.- Returns:
- All the list of datas.
-