Package com.ranull.graves.manager
Class DataManager
java.lang.Object
com.ranull.graves.manager.DataManager
Manages data storage and retrieval for the Graves plugin.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumEnum representing the types of databases supported. -
Constructor Summary
ConstructorsConstructorDescriptionDataManager(Graves plugin) Initializes the DataManager with the specified plugin instance and sets up the database connection. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddBlockData(BlockData blockData) Adds block data to the database.voidaddEntityData(EntityData entityData) Adds entity data to the database.voidAdds a grave to the database.voidaddHologramData(HologramData hologramData) Adds hologram data to the database.voidCloses the database connection.Returns the table name for the specified entity data type.getChunkData(org.bukkit.Location location) Retrieves chunk data for a specified location.getColumnList(String tableName) Retrieves a list of columns for a specified table.Retrieves the version of the database connection type.Retrieves the versions of supported databases.getType()booleanhasChunkData(org.bukkit.Location location) Checks if chunk data exists for a specified location.booleanhasGraveAtLocation(org.bukkit.Location location) Deprecated, for removal: This API element is subject to removal in a future version.Unused API.voidLoads the block map from the database (Folia-safe)voidLoads the grave map from the database.voidLoads the hologram map from the database.voidloadType(DataManager.Type type) Loads the database type and sets up the data source.voidreload()Reloads the data manager with the current type.voidreload(DataManager.Type type) Reloads the data manager with the specified type.voidremoveBlockData(org.bukkit.Location location) Removes block data from the database.voidremoveChunkData(ChunkData chunkData) Removes chunk data.voidremoveEntityData(EntityData entityData) Removes entity data from the database.voidremoveEntityData(List<EntityData> entityDataList) Removes a list of entity data from the database.voidremoveGrave(Grave grave) Removes a grave from the database.voidremoveGrave(UUID uuid) voidremoveHologramData(Grave grave) Removes hologram entries from the database based on the grave UUID.resultSetToGrave(ResultSet resultSet) Converts a ResultSet to a Grave object.voidSets up the block table in the database.voidSets up the grave table in the database.voidSets up the hologram table in the database.booleantableExists(String tableName) Checks if a table exists in the database.voidupdateGrave(Grave grave, String column, int integer) Updates a grave in the database.voidupdateGrave(Grave grave, String column, String string) Updates a grave in the database.voidupdateGraveMainThread(Grave grave, String column, String string) Updates a grave in the database using the main thread.
-
Constructor Details
-
DataManager
Initializes the DataManager with the specified plugin instance and sets up the database connection.- Parameters:
plugin- the Graves plugin instance.
-
-
Method Details
-
getType
-
reload
public void reload()Reloads the data manager with the current type. -
reload
Reloads the data manager with the specified type.- Parameters:
type- the type of database.
-
loadType
Loads the database type and sets up the data source.- Parameters:
type- the type of database.
-
hasChunkData
public boolean hasChunkData(org.bukkit.Location location) Checks if chunk data exists for a specified location.- Parameters:
location- the location to check.- Returns:
- true if chunk data exists, false otherwise.
-
getChunkData
Retrieves chunk data for a specified location.- Parameters:
location- the location to retrieve chunk data for.- Returns:
- the chunk data.
-
removeChunkData
Removes chunk data.- Parameters:
chunkData- the chunk data to remove.
-
getColumnList
Retrieves a list of columns for a specified table.- Parameters:
tableName- the table name.- Returns:
- the list of columns.
-
tableExists
Checks if a table exists in the database.- Parameters:
tableName- the table name.- Returns:
- true if the table exists, false otherwise.
-
setupGraveTable
Sets up the grave table in the database.- Throws:
SQLException- if an SQL error occurs.
-
setupBlockTable
Sets up the block table in the database.- Throws:
SQLException- if an SQL error occurs.
-
setupHologramTable
Sets up the hologram table in the database.- Throws:
SQLException- if an SQL error occurs.
-
loadGraveMap
public void loadGraveMap()Loads the grave map from the database. -
loadBlockMap
public void loadBlockMap()Loads the block map from the database (Folia-safe). - Reads DB asynchronously. - Batches rows per chunk and applies them on the chunk's region thread using plugin.getGravesXScheduler().execute(anchorLocation, ...). -
loadHologramMap
public void loadHologramMap()Loads the hologram map from the database. -
addBlockData
Adds block data to the database.- Parameters:
blockData- the block data to add.
-
removeBlockData
public void removeBlockData(org.bukkit.Location location) Removes block data from the database.Uses GravesXScheduler (UniversalScheduler) to run the in-memory cache update at the block's location (Folia-safe). The database delete runs asynchronously.
- Parameters:
location- the location of the block data to remove.
-
addHologramData
Adds hologram data to the database.Uses GravesXScheduler (UniversalScheduler) to execute the in-memory cache update at the hologram's location (Folia-safe). The database write is performed asynchronously.
- Parameters:
hologramData- the hologram data to add.
-
removeHologramData
Removes hologram entries from the database based on the grave UUID. This is a fallback if entity data is not loaded in memory.- Parameters:
grave- the grave to remove hologram data.
-
addEntityData
Adds entity data to the database.- Parameters:
entityData- the entity data to add.
-
removeEntityData
Removes entity data from the database.- Parameters:
entityData- the entity data to remove.
-
removeEntityData
Removes a list of entity data from the database.- Parameters:
entityDataList- the list of entity data to remove.
-
hasGraveAtLocation
@Deprecated(since="4.9.9.1", forRemoval=true) @ScheduledForRemoval(inVersion="4.9.11.1") public boolean hasGraveAtLocation(org.bukkit.Location location) Deprecated, for removal: This API element is subject to removal in a future version.Unused API. Deprecated as of 4.9.9.1 and scheduled for removal in 4.9.11.1.Checks whether a grave exists at the given location.Unused. This method is deprecated and will be removed.
- Parameters:
location- the location to check- Returns:
trueif a grave exists at the location;falseotherwise
-
entityDataTypeTable
Returns the table name for the specified entity data type.- Parameters:
type- the entity data type.- Returns:
- the table name.
-
addGrave
Adds a grave to the database.- Parameters:
grave- the grave to add.
-
removeGrave
Removes a grave from the database.- Parameters:
grave- the grave to remove.
-
removeGrave
-
updateGrave
Updates a grave in the database.- Parameters:
grave- the grave to update.column- the column to update.integer- the new integer value for the column.
-
updateGrave
Updates a grave in the database.- Parameters:
grave- the grave to update.column- the column to update.string- the new value for the column.
-
updateGraveMainThread
Updates a grave in the database using the main thread.- Parameters:
grave- the grave to update.column- the column to update.string- the new value for the column.
-
resultSetToGrave
Converts a ResultSet to a Grave object.- Parameters:
resultSet- the ResultSet to convert.- Returns:
- the Grave object, or null if an error occurs.
-
getDatabaseVersions
Retrieves the versions of supported databases.- Returns:
- a map of database types and their versions as integers.
- Throws:
SQLException- if a database access error occurs.
-
getDatabaseVersion
Retrieves the version of the database connection type.- Returns:
- the database version as a string.
-
closeConnection
public void closeConnection()Closes the database connection.
-