Package org.dreambot.api.settings
Class ScriptSettings
- java.lang.Object
-
- org.dreambot.api.settings.ScriptSettings
-
public class ScriptSettings extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description ScriptSettings()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> boolean
exists(@Nullable java.lang.Class<T> clazz, java.lang.String... fileLocationSteps)
Checks if a saved file exists at the provided file location steps and (if provided) checks if it can be loaded as the provided classstatic <T> T
load(java.lang.Class<T> clazz, java.lang.String... fileLocationSteps)
Loads a given class from a settings object, location base is scripts.pathstatic boolean
save(java.lang.Object obj, java.lang.String... fileLocationSteps)
Saves a given object using GSON pretty print to the given file.
-
-
-
Method Detail
-
load
public static <T> T load(java.lang.Class<T> clazz, java.lang.String... fileLocationSteps)
Loads a given class from a settings object, location base is scripts.path- Parameters:
clazz
- Class of the object you're loading, must have empty constructorfileLocationSteps
- Steps in the file location, eg: "MyScript","SubFolder","MySettings.json"- Returns:
- A new instance of your object created from the file settings
-
save
public static boolean save(java.lang.Object obj, java.lang.String... fileLocationSteps)
Saves a given object using GSON pretty print to the given file.- Parameters:
obj
- Object instance to save.fileLocationSteps
- Steps in the file location, eg: "MyScript","SubFolder","MySettings.json"- Returns:
- true if it saves with no exceptions, false if it fails to create folders or throws exceptions
-
exists
public static <T> boolean exists(@Nullable java.lang.Class<T> clazz, java.lang.String... fileLocationSteps)
Checks if a saved file exists at the provided file location steps and (if provided) checks if it can be loaded as the provided class- Parameters:
clazz
- Class of the object you want to check exists, if null this method will only check if a file exists at the given locationfileLocationSteps
- Steps in the file location, eg: "MyScript","SubFolder","MySettings.json"- Returns:
- true if the file exists and can be loaded as the class (if provided), false otherwise
-
-