Dev Config

From MBedwars
Revision as of 16:26, 9 November 2016 by Marcely1199 (talk | contribs)
Jump to navigation Jump to search

! Legacy Warning !

You are currently visiting a prehistoric website of the Marcely's Bedwars plugin for v4 and older.

In 2021, we released version 5 and completely overhauled the wiki. A lot of information that you find here likely won't be up-to-date anymore. You may find the updated wiki on: https://wiki.mbedwars.com

First of all, make sure that you have the BedwarsAddon object.
Click here to get to the documentation for that.
To save some things or to allow the user to configurate your AddOn, we added a way that's easier for you to add a configuration file that's looking the same as the configurations of this plugin.
Creating a config file is a bit more complicated than for example creating a command, but after a few minutes you should be able to fully understand how it works because of how simple the API for that is.
First of all we need the ConfigManager object for that.
We can get that through the getConfig method in our BedwarsAddon Object (Example:

ConfigManager cm = bedwarsAddon.getConfig();

). Lets create the base for our loading and saving class:

import de.marcely.bedwars.config.ConfigManager;

public class Config {
	public static ConfigManager cm = BedwarsAddonMultipleBeds.bedwarsAddon.getConfig();
	
 	public static void load(){
		cm.load(); // load the config file
		
		// ...
		
		cm.clear(); // clear the cache in our ConfigManager to get memory space
	}
	
	public static void save(){
		cm.clear(); // clear to prevent that we save some things twice
		
		// ...
		
		cm.clear(); // same reason as in load() but this time optional
	} 
}