Class DataManager
java.lang.Object
dev.esophose.playerparticles.manager.Manager
dev.esophose.playerparticles.manager.DataManager
public class DataManager extends Manager
All data changes to PPlayers such as group or fixed effect changes must be done through here,
rather than directly on the PPlayer object
-
Field Summary
-
Constructor Summary
Constructors Constructor Description DataManager(PlayerParticles playerParticles)
-
Method Summary
Modifier and Type Method Description void
disable()
Cleans up the Manager's resourcesDatabaseConnector
getDatabaseConnector()
PPlayer
getPPlayer(java.util.UUID playerUUID)
Gets a PPlayer from cache This method should be used over the other one unless you absolutely need the PPlayer and you don't care about waiting You should always check for a null result when using this methodvoid
getPPlayer(java.util.UUID playerUUID, java.util.function.Consumer<PPlayer> callback)
Gets a player from the save data, creates one if it doesn't exist and caches itjava.lang.String
getTablePrefix()
void
loadFixedEffects()
Loads all PPlayers from the database that own FixedParticleEffectsvoid
reload()
Reloads the Manager's settingsvoid
removeFixedEffect(java.util.UUID playerUUID, int id)
Deletes a fixed effect from save data Does not perform a check to see if a fixed effect with this id already existsvoid
removeParticleGroup(java.util.UUID playerUUID, java.lang.String groupName)
Removes a ParticleGroupvoid
resetActiveParticleGroup(java.lang.String playerName, java.util.function.Consumer<java.lang.Boolean> callback)
Attempts to reset the active particle group for the given player name.void
saveFixedEffect(FixedParticleEffect fixedEffect)
Saves a fixed effect to save data Does not perform a check to see if a fixed effect with this id already existsvoid
saveParticleGroup(java.util.UUID playerUUID, ParticleGroup group)
Saves a ParticleGroup.void
updateFixedEffect(FixedParticleEffect fixedEffect)
Updates a fixed effect's particle valuesvoid
updateSettingParticlesHidden(java.util.UUID playerUUID, boolean particlesHidden)
Updates the particles_hidden setting in the database and for the PPlayervoid
updateSettingParticlesHiddenSelf(java.util.UUID playerUUID, boolean particlesHidden)
Updates the particles_hidden_self setting in the database and for the PPlayer
-
Constructor Details
-
Method Details
-
reload
public void reload()Description copied from class:Manager
Reloads the Manager's settings -
disable
public void disable()Description copied from class:Manager
Cleans up the Manager's resources -
getPPlayer
Gets a PPlayer from cache This method should be used over the other one unless you absolutely need the PPlayer and you don't care about waiting You should always check for a null result when using this method- Parameters:
playerUUID
- The PPlayer to get- Returns:
- The PPlayer from cache
-
getPPlayer
Gets a player from the save data, creates one if it doesn't exist and caches it- Parameters:
playerUUID
- The pplayer to getcallback
- The callback to execute with the found pplayer, or a newly generated one
-
loadFixedEffects
public void loadFixedEffects()Loads all PPlayers from the database that own FixedParticleEffects -
updateSettingParticlesHidden
public void updateSettingParticlesHidden(java.util.UUID playerUUID, boolean particlesHidden)Updates the particles_hidden setting in the database and for the PPlayer- Parameters:
playerUUID
- The player to hide PlayerParticles fromparticlesHidden
- True if the particles should be hidden, otherwise False
-
updateSettingParticlesHiddenSelf
public void updateSettingParticlesHiddenSelf(java.util.UUID playerUUID, boolean particlesHidden)Updates the particles_hidden_self setting in the database and for the PPlayer- Parameters:
playerUUID
- The player to hide their own PlayerParticles fromparticlesHidden
- True if the particles should be hidden, otherwise False
-
saveParticleGroup
Saves a ParticleGroup. If it already exists, update it. If it's empty, delete it.- Parameters:
playerUUID
- The owner of the groupgroup
- The group to create/update
-
removeParticleGroup
public void removeParticleGroup(java.util.UUID playerUUID, java.lang.String groupName)Removes a ParticleGroup- Parameters:
playerUUID
- The owner of the groupgroupName
- The group to remove
-
resetActiveParticleGroup
public void resetActiveParticleGroup(java.lang.String playerName, java.util.function.Consumer<java.lang.Boolean> callback)Attempts to reset the active particle group for the given player name. This works even if the player is offline.- Parameters:
playerName
- The name of the player to reset the active particle group forcallback
- The callback to execute when finished
-
saveFixedEffect
Saves a fixed effect to save data Does not perform a check to see if a fixed effect with this id already exists- Parameters:
fixedEffect
- The fixed effect to save
-
updateFixedEffect
Updates a fixed effect's particle values- Parameters:
fixedEffect
- The fixed effect to update
-
removeFixedEffect
public void removeFixedEffect(java.util.UUID playerUUID, int id)Deletes a fixed effect from save data Does not perform a check to see if a fixed effect with this id already exists- Parameters:
playerUUID
- The player who owns the effectid
- The id of the effect to remove
-
getDatabaseConnector
- Returns:
- The connector to the database
-
getTablePrefix
public java.lang.String getTablePrefix()- Returns:
- the prefix to be used by all table names
-