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

    Fields inherited from class dev.esophose.playerparticles.manager.Manager

    playerParticles
  • Constructor Summary

    Constructors 
    Constructor Description
    DataManager​(PlayerParticles playerParticles)  
  • Method Summary

    Modifier and Type Method Description
    void disable()
    Cleans up the Manager's resources
    DatabaseConnector 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 method
    void 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 it
    java.lang.String getTablePrefix()  
    void loadFixedEffects()
    Loads all PPlayers from the database that own FixedParticleEffects
    void reload()
    Reloads the Manager's settings
    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
    void removeParticleGroup​(java.util.UUID playerUUID, java.lang.String groupName)
    Removes a ParticleGroup
    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.
    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 exists
    void saveParticleGroup​(java.util.UUID playerUUID, ParticleGroup group)
    Saves a ParticleGroup.
    void updateFixedEffect​(FixedParticleEffect fixedEffect)
    Updates a fixed effect's particle values
    void updateSettingParticlesHidden​(java.util.UUID playerUUID, boolean particlesHidden)
    Updates the particles_hidden setting in the database and for the PPlayer
    void updateSettingParticlesHiddenSelf​(java.util.UUID playerUUID, boolean particlesHidden)
    Updates the particles_hidden_self setting in the database and for the PPlayer

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • reload

      public void reload()
      Description copied from class: Manager
      Reloads the Manager's settings
      Specified by:
      reload in class Manager
    • disable

      public void disable()
      Description copied from class: Manager
      Cleans up the Manager's resources
      Specified by:
      disable in class Manager
    • getPPlayer

      public 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 method
      Parameters:
      playerUUID - The PPlayer to get
      Returns:
      The PPlayer from cache
    • getPPlayer

      public void 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 it
      Parameters:
      playerUUID - The pplayer to get
      callback - 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 from
      particlesHidden - 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 from
      particlesHidden - True if the particles should be hidden, otherwise False
    • saveParticleGroup

      public void saveParticleGroup​(java.util.UUID playerUUID, ParticleGroup group)
      Saves a ParticleGroup. If it already exists, update it. If it's empty, delete it.
      Parameters:
      playerUUID - The owner of the group
      group - 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 group
      groupName - 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 for
      callback - The callback to execute when finished
    • saveFixedEffect

      public 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 exists
      Parameters:
      fixedEffect - The fixed effect to save
    • updateFixedEffect

      public void updateFixedEffect​(FixedParticleEffect fixedEffect)
      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 effect
      id - The id of the effect to remove
    • getDatabaseConnector

      public DatabaseConnector getDatabaseConnector()
      Returns:
      The connector to the database
    • getTablePrefix

      public java.lang.String getTablePrefix()
      Returns:
      the prefix to be used by all table names