Class StatsData

java.lang.Object
me.deecaad.weaponmechanics.wrappers.StatsData

public class StatsData extends Object
  • Constructor Details

    • StatsData

      public StatsData(UUID uuid)
  • Method Details

    • isSync

      public boolean isSync()
      Returns:
      whether these stats have been synced with database
    • add

      public void add(PlayerStat stat, int data)
      Adds given data to player stat. Doesn't do anything if this hasn't yet been synced with database.
      Parameters:
      stat - the stat
      data - the amount to add
    • add

      public void add(PlayerStat stat, float data)
      Adds given data to player stat. Doesn't do anything if this hasn't yet been synced with database.
      Parameters:
      stat - the stat
      data - the amount to add
    • set

      public void set(PlayerStat stat, String data)
      Set given data to player stat. Doesn't do anything if this hasn't yet been synced with database.
      Parameters:
      stat - the stat
      data - the data to set
    • get

      public Object get(PlayerStat stat)
      Used to get the synced data. When data isn't yet synced, default value is always returned. Assigns default value to be 0 or null depending on stat type
      Parameters:
      stat - the player stat
      Returns:
      the data object
    • get

      public Object get(PlayerStat stat, Object defaultValue)
      Used to get the synced data. When data isn't yet synced, default value is always returned.
      Parameters:
      stat - the player stat
      defaultValue - the default value for player stat
      Returns:
      the data object
    • add

      public void add(String weaponTitle, WeaponStat stat, int data)
      Adds given data to weapon's weapon stat. Doesn't do anything if this hasn't yet been synced with database.
      Parameters:
      weaponTitle - the weapon title
      stat - the stat
      data - the amount to add
    • add

      public void add(String weaponTitle, WeaponStat stat, float data)
      Adds given data to weapon's weapon stat. Doesn't do anything if this hasn't yet been synced with database.
      Parameters:
      weaponTitle - the weapon title
      stat - the stat
      data - the amount to add
    • set

      public void set(String weaponTitle, WeaponStat stat, BiFunction<WeaponStat,Object,Float> compute)
      Set given data to weapon's weapon stat using BiFunction. Doesn't do anything if this hasn't yet been synced with database. Useful when you want to update stat's value conditionally (e.g. longest distance hit)
      Parameters:
      weaponTitle - the weapon title
      stat - the stat
      compute - the BiFunction
    • set

      public void set(String weaponTitle, WeaponStat stat, String data)
      Set given data to weapon's weapon stat. Doesn't do anything if this hasn't yet been synced with database.
      Parameters:
      weaponTitle - the weapon title
      stat - the stat
      data - the data to set
    • addToSet

      public void addToSet(String weaponTitle, WeaponStat stat, String data)
      Adds given data to weapon's weapon stat set. Doesn't do anything if this hasn't yet been synced with database.
      Parameters:
      weaponTitle - the weapon title
      stat - the stat
      data - the data to add
    • removeFromSet

      public void removeFromSet(String weaponTitle, WeaponStat stat, String data)
      Removes given data from weapon's weapon stat set. Doesn't do anything if this hasn't yet been synced with database.
      Parameters:
      weaponTitle - the weapon title
      stat - the stat
      data - the data to remove
    • getWeapons

      public Set<String> getWeapons()
      Returns:
      the weapon titles which have some data saved, null if not synced yet
    • get

      public Object get(String weaponTitle, WeaponStat stat)
      Used to get the synced data. When data isn't yet synced, default value is always returned. Assigns default value to be 0 or null depending on stat type
      Parameters:
      weaponTitle - the weapon title
      stat - the weapon stat
      Returns:
      the data object
    • get

      public Object get(String weaponTitle, WeaponStat stat, Object defaultValue)
      Used to get the synced data. When data isn't yet synced, default value is always returned.
      Parameters:
      weaponTitle - the weapon title
      stat - the weapon stat
      defaultValue - the default value for weapon stat
      Returns:
      the data object
    • setData

      public void setData(Map<PlayerStat,Object> playerData, Map<String,Map<WeaponStat,Object>> weaponData)
      This method can only be used once during StatsData object lifetime. Used to insert the database data via hashmaps.
      Parameters:
      playerData - the player data
      weaponData - the weapon data
    • getPlayerData

      public List<String> getPlayerData()
    • getWeaponData

      public List<String> getWeaponData(String weapon)
    • toString

      public String toString()
      Overrides:
      toString in class Object