Class StatsData
java.lang.Object
me.deecaad.weaponmechanics.wrappers.StatsData
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(String weaponTitle, WeaponStat stat, float data) Adds given data to weapon's weapon stat.voidadd(String weaponTitle, WeaponStat stat, int data) Adds given data to weapon's weapon stat.voidadd(PlayerStat stat, float data) Adds given data to player stat.voidadd(PlayerStat stat, int data) Adds given data to player stat.voidaddToSet(String weaponTitle, WeaponStat stat, String data) Adds given data to weapon's weapon stat set.get(String weaponTitle, WeaponStat stat) Used to get the synced data.get(String weaponTitle, WeaponStat stat, Object defaultValue) Used to get the synced data.get(PlayerStat stat) Used to get the synced data.get(PlayerStat stat, Object defaultValue) Used to get the synced data.getWeaponData(String weapon) booleanisSync()voidremoveFromSet(String weaponTitle, WeaponStat stat, String data) Removes given data from weapon's weapon stat set.voidset(String weaponTitle, WeaponStat stat, String data) Set given data to weapon's weapon stat.voidset(String weaponTitle, WeaponStat stat, BiFunction<WeaponStat, Object, Float> compute) Set given data to weapon's weapon stat using BiFunction.voidset(PlayerStat stat, String data) Set given data to player stat.voidsetData(Map<PlayerStat, Object> playerData, Map<String, Map<WeaponStat, Object>> weaponData) This method can only be used once during StatsData object lifetime.toString()
-
Constructor Details
-
StatsData
-
-
Method Details
-
isSync
public boolean isSync()- Returns:
- whether these stats have been synced with database
-
add
Adds given data to player stat. Doesn't do anything if this hasn't yet been synced with database.- Parameters:
stat- the statdata- the amount to add
-
add
Adds given data to player stat. Doesn't do anything if this hasn't yet been synced with database.- Parameters:
stat- the statdata- the amount to add
-
set
Set given data to player stat. Doesn't do anything if this hasn't yet been synced with database.- Parameters:
stat- the statdata- the data to set
-
get
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
Used to get the synced data. When data isn't yet synced, default value is always returned.- Parameters:
stat- the player statdefaultValue- the default value for player stat- Returns:
- the data object
-
add
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 titlestat- the statdata- the amount to add
-
add
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 titlestat- the statdata- the amount to add
-
set
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 titlestat- the statcompute- the BiFunction
-
set
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 titlestat- the statdata- the data to set
-
addToSet
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 titlestat- the statdata- the data to add
-
removeFromSet
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 titlestat- the statdata- the data to remove
-
getWeapons
- Returns:
- the weapon titles which have some data saved, null if not synced yet
-
get
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 titlestat- the weapon stat- Returns:
- the data object
-
get
Used to get the synced data. When data isn't yet synced, default value is always returned.- Parameters:
weaponTitle- the weapon titlestat- the weapon statdefaultValue- 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 dataweaponData- the weapon data
-
getPlayerData
-
getWeaponData
-
toString
-