Package me.fami6xx.rpuniverse.core
Class DataSystem
java.lang.Object
me.fami6xx.rpuniverse.core.DataSystem
- All Implemented Interfaces:
org.bukkit.event.Listener
The DataSystem is the main class for handling the data.
It is responsible for loading the player data, saving the player data, and handling the data handler.
The DataSystem is a singleton class, so only one instance of it should be created.
The DataSystem is also a listener for the PlayerJoinEvent and PlayerQuitEvent. This means that the DataSystem will also listen for these events and update the player data accordingly.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets the data handler.getPlayerData(String UUID)Retrieves the player data for the specified UUID.getPlayerData(UUID uuid)Gets the player data for the specified UUID.voidonPlayerJoin(org.bukkit.event.player.PlayerJoinEvent event)voidonPlayerQuit(org.bukkit.event.player.PlayerQuitEvent event)voidQueues the player data for saving.voidSaves all data.voidshutdown()Shuts down the data system.
-
Constructor Details
-
DataSystem
public DataSystem()Constructor for the DataSystem. Initializes the data handler, player data map, save queue, and last access time map. Also starts the data handler and schedules the save tasks and expiration task.
-
-
Method Details
-
onPlayerJoin
public void onPlayerJoin(org.bukkit.event.player.PlayerJoinEvent event) -
onPlayerQuit
public void onPlayerQuit(org.bukkit.event.player.PlayerQuitEvent event) -
shutdown
public void shutdown()Shuts down the data system. Cancels the save tasks, saves all player data, and shuts down the data handler. -
getDataHandler
Gets the data handler.- Returns:
- The data handler.
-
getPlayerData
Gets the player data for the specified UUID.- Parameters:
uuid- The UUID of the player to get the data for.- Returns:
- The player data for the specified UUID. Null if not found.
-
getPlayerData
Retrieves the player data for the specified UUID.- Parameters:
UUID- The UUID of the player to get the data for.- Returns:
- The player data for the specified UUID. Null if not found.
-
queuePlayerDataForSaving
Queues the player data for saving.- Parameters:
data- The player data to save.
-
saveAllData
public void saveAllData()Saves all data.
-