Class DataManager
-
Field Summary
Modifier and TypeFieldDescriptionArrayList for Command Tab Completions.ArrayList for Command Tab Completions for numbers from -1 to 12.ArrayList for Command Tab Completions for numbers from 1 to 12.ArrayList for Command Tab Completions.ArrayList for Command Tab Completions for elitemob entity types.ArrayList for Command Tab Completions for entity types.ArrayList for Command Tab Completions for players. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal Category
createCategory
(String categoryName, Category parentCategory) void
disablePluginAndSaving
(String reason) This will set saving to false, so the plugin will not try to save any kind of data anymore.void
disablePluginAndSaving
(String reason, Object... objects) final Category
getCategory
(String categoryName) Deprecated.final Configuration
final Statement
This returns the MySQL Database Statement, with which Database operations can be performed / executed.final Category
final org.bukkit.configuration.file.FileConfiguration
This will return the general.yml Configuration FileConfiguration object.boolean
boolean
boolean
boolean
final boolean
final boolean
void
loadCategories
(Category parent) final void
The general.yml configuration file is initialized here.void
This will load the Data from Citizens NPCs asynchronously.final void
void
Load values of the standard tab-completion lists.final org.bukkit.configuration.file.YamlConfiguration
loadYAMLConfiguration
(File file) (Taken from API, but this method also throws errors) Creates a newYamlConfiguration
, loading from the given file.void
This will open a MySQL connection statement which is needed to save and load to the MySQL Database.void
void
refreshDatabaseConnection
(boolean newTask) If the plugin has been running for some time, the MySQL Database connection is sometimes interrupted which causes errors when it tries to save data once the plugin is disabled.void
This will LOAD the following data: (1) general.yml General Configuration - in whatever Thread (2) CREATE all the necessary MySQL Database tables if they don't exist yet - in an asynchronous Thread (forced) (3) Load all the Quests Data from the quests.yml - in an asynchronous Thread (forced) (4) AFTER THAT load the Player Data from the MySQL Database - in an asynchronous Thread (forced) (5) Then it will try to load the Data from Citizens NPCsvoid
saveData()
If saving is enabled, this will try to save the following data: (1) Player Data into the MySQL Database (2) The quests.yml Quest Configuration filevoid
This will try to save the general.yml configuration file with the data which is currently in the generalConfig FileConfiguration object.void
saveQuestsConfig
(Category category) void
setAlreadyLoadedGeneral
(boolean alreadyLoadedGeneral) void
setAlreadyLoadedNPCs
(boolean alreadyLoadedNPCs) void
setAlreadyLoadedQuests
(boolean alreadyLoadedQuests) void
setLoadingEnabled
(boolean loadingEnabled) void
setSavingEnabled
(boolean savingEnabled) void
-
Field Details
-
completions
ArrayList for Command Tab Completions. They will be re-used where possible. This is sort of like a buffer for completions. It does not return the real completions, but it's for example used in ObjectivesAdminCommand handleCompletions() which is called by the real Tab Completer CommandNotQuestsAdmin to split it up a little. -
standardPlayerCompletions
ArrayList for Command Tab Completions for players. They will be re-used where possible. -
standardEntityTypeCompletions
ArrayList for Command Tab Completions for entity types. They will be initialized on startup be re-used where possible. -
numberCompletions
ArrayList for Command Tab Completions for numbers from -1 to 12. They will be initialized on startup be re-used where possible. -
numberPositiveCompletions
ArrayList for Command Tab Completions for numbers from 1 to 12. They will be initialized on startup be re-used where possible. -
partialCompletions
ArrayList for Command Tab Completions. They will be re-used where possible. -
standardEliteMobNamesCompletions
ArrayList for Command Tab Completions for elitemob entity types. They will be initialized on startup if the elitemobs integration is enabled and will be re-used where possible.
-
-
Constructor Details
-
DataManager
The Data Manager is initialized here. This mainly creates some Array List for generic Tab Completions for various commands.The actual loading of Data doesn't happen here yet.
- Parameters:
main
- an instance of NotQuests which will be passed over
-
-
Method Details
-
prepareDataFolder
public void prepareDataFolder() -
getCategories
-
getTopLevelOnlyCategories
-
getDefaultCategory
-
loadCategories
-
loadQuestsConfig
public final void loadQuestsConfig() -
getCategory
Deprecated. -
createCategory
-
loadGeneralConfig
public final void loadGeneralConfig()The general.yml configuration file is initialized here. This will create the general.yml config file if it hasn't been created yet. It will also create all the necessary default config values if they are non-existent.This will also load the value from the general.yml config file, like the MySQL Database connection information. If that data is not found, the plugin will stop and throw a warning, since it cannot function without a MySQL database.
-
updateAndReadGeneralConfig
public void updateAndReadGeneralConfig() -
saveGeneralConfig
public void saveGeneralConfig()This will try to save the general.yml configuration file with the data which is currently in the generalConfig FileConfiguration object. -
saveQuestsConfig
-
disablePluginAndSaving
This will set saving to false, so the plugin will not try to save any kind of data anymore. After that, it disables the plugin.- Parameters:
reason
- the reason for disabling saving and the plugin. Will be shown in the console error message
-
disablePluginAndSaving
-
saveData
public void saveData()If saving is enabled, this will try to save the following data: (1) Player Data into the MySQL Database (2) The quests.yml Quest Configuration fileThis will not save the general.yml Configuration file
-
refreshDatabaseConnection
public void refreshDatabaseConnection(boolean newTask) If the plugin has been running for some time, the MySQL Database connection is sometimes interrupted which causes errors when it tries to save data once the plugin is disabled.This is especially bad, because if the plugin has been running for a while, that data will be lost.
This method will try to re-open the database connection statement, so data can be saved to the database safely again.
- Parameters:
newTask
- sets if the plugin should force an asynchronous thread to re-open the database connection. If set to false, it will do it in whatever thread this method is run in.
-
reloadData
public void reloadData()This will LOAD the following data: (1) general.yml General Configuration - in whatever Thread (2) CREATE all the necessary MySQL Database tables if they don't exist yet - in an asynchronous Thread (forced) (3) Load all the Quests Data from the quests.yml - in an asynchronous Thread (forced) (4) AFTER THAT load the Player Data from the MySQL Database - in an asynchronous Thread (forced) (5) Then it will try to load the Data from Citizens NPCs -
isCurrentlyLoading
public boolean isCurrentlyLoading() -
getGeneralConfig
public final org.bukkit.configuration.file.FileConfiguration getGeneralConfig()This will return the general.yml Configuration FileConfiguration object. If it does not exist, it will try to load / create it.- Returns:
- the general.yml Configuration FileConfiguration object
-
openConnection
public void openConnection()This will open a MySQL connection statement which is needed to save and load to the MySQL Database.This is where it tries to log-in to the Database.
-
getDatabaseStatement
This returns the MySQL Database Statement, with which Database operations can be performed / executed.- Returns:
- the MySQL Database Statement
-
isSavingEnabled
public final boolean isSavingEnabled()- Returns:
- if the plugin will try to save data once it's disabled. This should be true unless a severe error occurred during data loading
-
setSavingEnabled
public void setSavingEnabled(boolean savingEnabled) - Parameters:
savingEnabled
- sets if data saving should be enabled or disabled
-
isLoadingEnabled
public final boolean isLoadingEnabled()- Returns:
- if the plugin will try to load data. This should be true unless a severe error occurred during data loading
-
setLoadingEnabled
public void setLoadingEnabled(boolean loadingEnabled) - Parameters:
loadingEnabled
- sets if data loading should be enabled or disabled
-
loadNPCData
public void loadNPCData()This will load the Data from Citizens NPCs asynchronously. It will also make sure that the quests.yml configuration object is valid first.The actual loading of Citizens NPC data will happen in the loadNPCData() function of the Quest Manager. In that function, most of that will run synchronously as that's required for some operations with the Citizens API.
-
isAlreadyLoadedNPCs
public boolean isAlreadyLoadedNPCs()- Returns:
- if Citizen NPCs have been already successfully loaded by the plugin
-
isAlreadyLoadedGeneral
public boolean isAlreadyLoadedGeneral() -
isAlreadyLoadedQuests
public boolean isAlreadyLoadedQuests() -
setAlreadyLoadedNPCs
public void setAlreadyLoadedNPCs(boolean alreadyLoadedNPCs) - Parameters:
alreadyLoadedNPCs
- sets if Citizen NPCs have been already successfully loaded by the plugin
-
setAlreadyLoadedGeneral
public void setAlreadyLoadedGeneral(boolean alreadyLoadedGeneral) -
setAlreadyLoadedQuests
public void setAlreadyLoadedQuests(boolean alreadyLoadedQuests) -
getConfiguration
- Returns:
- the configuration object which contains values from the General.yml
-
loadYAMLConfiguration
public final org.bukkit.configuration.file.YamlConfiguration loadYAMLConfiguration(File file) throws IOException, org.bukkit.configuration.InvalidConfigurationException (Taken from API, but this method also throws errors) Creates a newYamlConfiguration
, loading from the given file.Any errors loading the Configuration will be logged and then ignored. If the specified input is not a valid config, a blank config will be returned.
The encoding used may follow the system dependent default.
- Parameters:
file
- Input file- Returns:
- Resulting configuration
- Throws:
IllegalArgumentException
- Thrown if file is nullIOException
org.bukkit.configuration.InvalidConfigurationException
-
getItemStackCache
-
loadStandardCompletions
public void loadStandardCompletions()Load values of the standard tab-completion lists. This is done in a separate method, because some lists are dependent on the integrations being loaded first.
-