Class SettingsUtilsJSON
-
- All Implemented Interfaces:
public final class SettingsUtilsJSONUtility class to store and retrieve preferences
-
-
Constructor Summary
Constructors Constructor Description SettingsUtilsJSON(String plugin)
-
Method Summary
Modifier and Type Method Description final BooleanresetFile()Resets All Settings final BooleantoggleBool(String key, Boolean defVal)Toggles Boolean and returns it final Booleanremove(String key)Removes Item from settings final List<String>getAllKeys()Gets All Keys from settings final Booleanexists(String key)Check if Key exists in settings final BooleangetBool(String key, Boolean defValue)Get a boolean from the preferences final UnitsetBool(String key, Boolean value)Set a boolean item final IntegergetInt(String key, Integer defValue)Get an int from the preferences final UnitsetInt(String key, Integer value)Set an int item final FloatgetFloat(String key, Float defValue)Get a float from the preferences final UnitsetFloat(String key, Float value)Set a float item final LonggetLong(String key, Long defValue)Get a long from the preferences final UnitsetLong(String key, Long value)Set a long item final StringgetString(String key, String defValue)Get a String from the preferences final UnitsetString(String key, String value)Set a String item final JSONObjectgetJSONObject(String key, JSONObject defValue)Get a JSONObject item final UnitsetJSONObject(String key, JSONObject value)Set a JSONObject item final <T extends Any> TgetObject(String key, T defValue)Get an Object from the preferences final <T extends Any> TgetObject(String key, T defValue, Type type)Get an Object from the preferences final UnitsetObject(String key, Object value)Set an Object item -
-
Constructor Detail
-
SettingsUtilsJSON
SettingsUtilsJSON(String plugin)
-
-
Method Detail
-
toggleBool
final Boolean toggleBool(String key, Boolean defVal)
Toggles Boolean and returns it
- Parameters:
key- Key of the valuedefVal- Default Value if setting doesn't exist- Returns:
Toggled boolean
-
remove
@Synchronized() final Boolean remove(String key)
Removes Item from settings
- Parameters:
key- Key of the value- Returns:
True if removed, else false
-
getAllKeys
final List<String> getAllKeys()
Gets All Keys from settings
- Returns:
List of all keys
-
exists
final Boolean exists(String key)
Check if Key exists in settings
- Parameters:
key- Key of the value- Returns:
True if found, else false
-
getBool
final Boolean getBool(String key, Boolean defValue)
Get a boolean from the preferences
- Parameters:
key- Key of the valuedefValue- Default value- Returns:
Value if found, else the defValue
-
setBool
final Unit setBool(String key, Boolean value)
Set a boolean item
- Parameters:
key- Key of the itemvalue- Value
-
getInt
final Integer getInt(String key, Integer defValue)
Get an int from the preferences
- Parameters:
key- Key of the valuedefValue- Default value- Returns:
Value if found, else the defValue
-
setInt
final Unit setInt(String key, Integer value)
Set an int item
- Parameters:
key- Key of the itemvalue- Value
-
getFloat
final Float getFloat(String key, Float defValue)
Get a float from the preferences
- Parameters:
key- Key of the valuedefValue- Default value- Returns:
Value if found, else the defValue
-
setFloat
final Unit setFloat(String key, Float value)
Set a float item
- Parameters:
key- Key of the itemvalue- Value
-
getLong
final Long getLong(String key, Long defValue)
Get a long from the preferences
- Parameters:
key- Key of the valuedefValue- Default value- Returns:
Value if found, else the defValue
-
setLong
final Unit setLong(String key, Long value)
Set a long item
- Parameters:
key- Key of the itemvalue- Value
-
getString
final String getString(String key, String defValue)
Get a String from the preferences
- Parameters:
key- Key of the valuedefValue- Default value- Returns:
Value if found, else the defValue
-
setString
final Unit setString(String key, String value)
Set a String item
- Parameters:
key- Key of the itemvalue- Value
-
getJSONObject
final JSONObject getJSONObject(String key, JSONObject defValue)
Get a JSONObject item
- Parameters:
key- Key of the itemdefValue- Default value- Returns:
Value if found, else the defValue
-
setJSONObject
final Unit setJSONObject(String key, JSONObject value)
Set a JSONObject item
- Parameters:
key- Key of the itemvalue- Value
-
getObject
final <T extends Any> T getObject(String key, T defValue)
Get an Object from the preferences
- Parameters:
key- Key of the valuedefValue- Default value- Returns:
Value if found, else the defValue
-
getObject
final <T extends Any> T getObject(String key, T defValue, Type type)
Get an Object from the preferences
- Parameters:
key- Key of the valuedefValue- Default valuetype- Type of the object- Returns:
Value if found, else the defValue
-
-
-
-