- 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)
newConfig(StringaddonName); // Initialize the APIYou can create Encoded Config's Files and non Encoded Config's Files by getting the Config() instance
Config.getInstance().createConfig(Stringname); // name = Config File's Name// THAT RETURN a ConfigManager InstanceConfig.getInstance().createEncodedConfig(Stringname); // name = Config File's Name// THAT RETURN an EncodedConfigManager InstanceIf 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(Stringname);
Config.getInstance().getConfig(Filefile);Config.getInstance().getEncodedConfig(Stringname);
Config.getInstance().getEncodedConfig(Filefile);importbe.alexandre01.dreamnetwork.api.DNClientAPI;
importbe.alexandre01.dreamnetwork.api.addons.Addon;
importbe.alexandre01.dreamnetwork.api.addons.DreamExtension;
importfr.benjimania74.configmanager.Config;
importfr.benjimania74.configmanager.ConfigManager;
importfr.benjimania74.configmanager.EncodedConfigManager;
publicclassExampleClassextendsDreamExtension {
publicstaticDNClientAPIclientAPI;
@OverridepublicvoidonLoad() {
super.onLoad();
newConfig(getAddon().getDreamyName()); // Initialize the API
}
@Overridepublicvoidstart() {
super.start();
clientAPI = getDnClientAPI();
// Non-Encoded ConfigConfigManagercm = Config.getInstance().createConfig("hello"); // Create "hello" Config Filecm.writeDefault(); // Write "{}"cm.save(); // Save "{}"// Encoded ConfigEncodedConfigManagerecm = Config.getInstance().getEncodedConfig("encoded"); // Get "encoded" Encoded Config Fileecm.set("isEncoded", true); // Set a boolean value in the fileSystem.out.println(ecm.getString("hello")); // Print a String valueecm.save(); // Save the content
}
@Overridepublicvoidstop() {
super.stop();
}
publicExampleClass(Addonaddon) {
super(addon);
}
}