Dev Config: Difference between revisions
Jump to navigation
Jump to search
Marcely1199 (talk | contribs) (Created page with "First of all, make sure that you have the BedwarsAddon object.<br /> Click here to get to the documentation for that.<br /> To save some things or to allow the u...") |
Marcely1199 (talk | contribs) No edit summary |
||
Line 10: | Line 10: | ||
public class Config { | 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 | |||
} | |||
} | } |
Revision as of 16:25, 9 November 2016
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 } }