Package net.eternalclient.api.utilities
Class AccountSettings
- java.lang.Object
-
- net.eternalclient.api.utilities.AccountSettings
-
public class AccountSettings extends java.lang.Object
A class that provides methods for managing and retrieving account settings using a JSON object.
-
-
Constructor Summary
Constructors Constructor Description AccountSettings()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
clearValue(java.lang.String key)
Clears the value associated with the given key.static void
clearValues(java.lang.String... keys)
Clears the values associated with the given keys from the settings object and saves the updated settings.static boolean
getBooleanValue(java.lang.String key)
Returns the boolean value associated with the specified key from the settings object, or false if the key does not exist or the value is null.static boolean
getBooleanValue(java.lang.String key, boolean defaultValue)
Returns the boolean value associated with the specified key from the settings object, or false if the key does not exist or the value is null.static double
getDoubleValue(java.lang.String key)
Returns the double value associated with the given key from the settingsObject, or -1 if the key is not found or the associated value is null.static double
getDoubleValue(java.lang.String key, double defaultValue)
Returns the double value associated with the given key from the settingsObject, or -1 if the key is not found or the associated value is null.static int
getIntValue(java.lang.String key)
Retrieves the integer value associated with the given key from the settings object.static int
getIntValue(java.lang.String key, int defaultValue)
Retrieves the integer value associated with the given key from the settings object.static long
getLongValue(java.lang.String key)
Returns the long value associated with the given key if present, otherwise returns -1.static long
getLongValue(java.lang.String key, long defaultValue)
Returns the long value associated with the given key if present, otherwise returns -1.static java.lang.String
getStringValue(java.lang.String key)
Retrieves the string value associated with the given key from the settings object.static java.lang.String
getStringValue(java.lang.String key, java.lang.String defaultValue)
Retrieves the string value associated with the given key from the settings object.static void
loadSettings()
Loads account settings and assigns them to the settingsObject variable.static void
saveSettings()
Saves the account settings for the current user.static void
setBooleanValue(java.lang.String key, boolean value)
Sets the boolean value of the specified key if it is not already equal to the given value.static void
setDoubleValue(java.lang.String key, double value)
Sets the value of a specific key in the settings object.static void
setIntValue(java.lang.String key, int value)
Sets the value of an integer setting identified by the given key.static void
setLongValue(java.lang.String key, long value)
Sets the long value for the given key if it's not already set to the same value.static void
setStringValue(java.lang.String key, java.lang.String value)
Set a string value for a given key in the settingsObject.
-
-
-
Method Detail
-
saveSettings
public static void saveSettings()
Saves the account settings for the current user.
-
loadSettings
public static void loadSettings()
Loads account settings and assigns them to the settingsObject variable.
-
clearValue
public static void clearValue(java.lang.String key)
Clears the value associated with the given key.- Parameters:
key
- the key for which the value needs to be cleared
-
clearValues
public static void clearValues(java.lang.String... keys)
Clears the values associated with the given keys from the settings object and saves the updated settings.- Parameters:
keys
- the keys whose values need to be cleared
-
setStringValue
public static void setStringValue(java.lang.String key, java.lang.String value)
Set a string value for a given key in the settingsObject. If the key already exists and its current value is not equal to the new value, the value is updated and the settings are saved.- Parameters:
key
- the key for the string valuevalue
- the new value to set for the given key
-
getStringValue
public static java.lang.String getStringValue(java.lang.String key)
Retrieves the string value associated with the given key from the settings object.- Parameters:
key
- the key to retrieve the string value for- Returns:
- the string value if the key exists and is not null, otherwise null
-
getStringValue
public static java.lang.String getStringValue(java.lang.String key, java.lang.String defaultValue)
Retrieves the string value associated with the given key from the settings object.- Parameters:
key
- the key to retrieve the string value fordefaultValue
- the default value to return if not found- Returns:
- the string value if the key exists and is not null, otherwise default value
-
setIntValue
public static void setIntValue(java.lang.String key, int value)
Sets the value of an integer setting identified by the given key. If the value already exists and matches the given value, no action is taken. Saves the updated settings.- Parameters:
key
- the key to identify the settingvalue
- the value to be set
-
getIntValue
public static int getIntValue(java.lang.String key)
Retrieves the integer value associated with the given key from the settings object. Returns -1 if the key is not found or if the value is null.- Parameters:
key
- the key to look for in the settings object- Returns:
- the integer value associated with the given key, or -1 if not found or null
-
getIntValue
public static int getIntValue(java.lang.String key, int defaultValue)
Retrieves the integer value associated with the given key from the settings object. Returns -1 if the key is not found or if the value is null.- Parameters:
key
- the key to look for in the settings objectdefaultValue
- the default value to return if not found- Returns:
- the integer value associated with the given key, or default value if not found or null
-
setLongValue
public static void setLongValue(java.lang.String key, long value)
Sets the long value for the given key if it's not already set to the same value.- Parameters:
key
- the key of the value to be setvalue
- the long value to be set
-
getLongValue
public static long getLongValue(java.lang.String key)
Returns the long value associated with the given key if present, otherwise returns -1.- Parameters:
key
- the key to look for in the settings object- Returns:
- the long value associated with the key, or -1 if not found
-
getLongValue
public static long getLongValue(java.lang.String key, long defaultValue)
Returns the long value associated with the given key if present, otherwise returns -1.- Parameters:
key
- the key to look for in the settings objectdefaultValue
- the default value to return if not found- Returns:
- the long value associated with the key, or default value if not found
-
setDoubleValue
public static void setDoubleValue(java.lang.String key, double value)
Sets the value of a specific key in the settings object.- Parameters:
key
- The key to set the value for.value
- The value to set for the key.
-
getDoubleValue
public static double getDoubleValue(java.lang.String key)
Returns the double value associated with the given key from the settingsObject, or -1 if the key is not found or the associated value is null.- Parameters:
key
- the key to retrieve the double value- Returns:
- the double value associated with the key, or -1 if not found or null
-
getDoubleValue
public static double getDoubleValue(java.lang.String key, double defaultValue)
Returns the double value associated with the given key from the settingsObject, or -1 if the key is not found or the associated value is null.- Parameters:
key
- the key to retrieve the double valuedefaultValue
- the default value to return if not found- Returns:
- the double value associated with the key, or default value if not found or null
-
setBooleanValue
public static void setBooleanValue(java.lang.String key, boolean value)
Sets the boolean value of the specified key if it is not already equal to the given value.- Parameters:
key
- the key to set the boolean value forvalue
- the boolean value to set for the key
-
getBooleanValue
public static boolean getBooleanValue(java.lang.String key)
Returns the boolean value associated with the specified key from the settings object, or false if the key does not exist or the value is null.- Parameters:
key
- the key to search for- Returns:
- the boolean value associated with the key, or false if not found or null
-
getBooleanValue
public static boolean getBooleanValue(java.lang.String key, boolean defaultValue)
Returns the boolean value associated with the specified key from the settings object, or false if the key does not exist or the value is null.- Parameters:
key
- the key to search fordefaultValue
- the default value to return if not found- Returns:
- the boolean value associated with the key, or default value if not found or null
-
-