- Non-Encoded
- Encoded (In Base64)
- ConfigManager
- EncodedConfigManager
loadContent()
- Load the Config File contentgetName()
- Return the Config File Nameread()
- Return the Config File content (Non-Encoded)save()
- Save the File (After changing values)writeDefault()
- Write "{}" in the file and erase all others dataset(String key, Object value)
- Write a value in the File (it doesn't save)remove(String key)
- Remove a values from the File (it doesn't save)getHashMap(String key)
- Return an HashMap<Object,Object> from a keygetString(String key)
- Return a String from a keygetList(String key)
- Return a List<Object> from a keygetInt(String key)
- Return an Integer from a keygetFloat(String key)
- Return a Float from a keygetBoolean(String key)
- Return a Boolean from a key
To Initialize the API, you just have to create a new instance of the Config Class (fr.benjimania74.configmanager.Config
)
new Config(String addonName); // Initialize the API
You can create Encoded Config's Files and non Encoded Config's Files by getting the Config()
instance
Config.getInstance().createConfig(String name); // name = Config File's Name
// THAT RETURN a ConfigManager Instance
Config.getInstance().createEncodedConfig(String name); // name = Config File's Name
// THAT RETURN an EncodedConfigManager Instance
If the Config File is already existing, you will get an instance of it.
You can get Encoded and Non-Encoded Config File by getting the Config()
instance.
You can use the name of the file or the File to get it (use the name is recommended)
Config.getInstance().getConfig(String name);
Config.getInstance().getConfig(File file);
Config.getInstance().getEncodedConfig(String name);
Config.getInstance().getEncodedConfig(File file);
import be.alexandre01.dreamnetwork.api.DNClientAPI;
import be.alexandre01.dreamnetwork.api.addons.Addon;
import be.alexandre01.dreamnetwork.api.addons.DreamExtension;
import fr.benjimania74.configmanager.Config;
import fr.benjimania74.configmanager.ConfigManager;
import fr.benjimania74.configmanager.EncodedConfigManager;
public class ExampleClass extends DreamExtension {
public static DNClientAPI clientAPI;
@Override
public void onLoad() {
super.onLoad();
new Config(getAddon().getDreamyName()); // Initialize the API
}
@Override
public void start() {
super.start();
clientAPI = getDnClientAPI();
// Non-Encoded Config
ConfigManager cm = Config.getInstance().createConfig("hello"); // Create "hello" Config File
cm.writeDefault(); // Write "{}"
cm.save(); // Save "{}"
// Encoded Config
EncodedConfigManager ecm = Config.getInstance().getEncodedConfig("encoded"); // Get "encoded" Encoded Config File
ecm.set("isEncoded", true); // Set a boolean value in the file
System.out.println(ecm.getString("hello")); // Print a String value
ecm.save(); // Save the content
}
@Override
public void stop() {
super.stop();
}
public ExampleClass(Addon addon) {
super(addon);
}
}