Standalone Rewrite: Alpha Release
Pre-releaseTHIS IS AN ALPHA RELEASE AND NOT CONSIDERED STABLE WHATSOEVER. PLEASE DO NOT USE IT IN A PRODUCTION PLUGIN INTENDED FOR RELEASE (at least before the full CM 2.0.0 release) OR PRODUCTION ENVIRONMENT.
This has been tested exhaustively with production config files though, such as those from AdvancedTeleport and also from HeadsPlus v7.
Absolutely none of this is documented at this time. If you have any questions regarding the code, please ask me. None of the method or even field names in this release are final and will be changed without warning where required.
Whilst CM is not fully standalone (yet), the CMFile class has been deprecated and will be removed in the next major release. It is replaced by a new ConfigFile class that is standalone. You can either load a config file using CM's builtin checks for syntax errors:
ConfigFile config = ConfigFile.loadConfig(configFile);or make your own checks by initialising a ConfigFile object:
ConfigFile config = new ConfigFile(configFile);CM takes a large amount of inspiration from Bukkit for its config system, with a lot of method names taken from that with smaller variations.
To save a file after adding all default values, just use the ConfigFile#save method:
config.save();The main differences still remain:
- Methods like getInteger, getDouble, getFloat and etc. can parse string values as their own type, e.g. '7' will return 7 rather than 0 like in Bukkit's system.
- Calling getList on a value that is a single value (e.g.
foo: bar) will return a list with that single value in it, so if you have a plugin that alternates between using lists and single values on a single option, this is for you. - A builtin
ConfigFile#reloadmethod that is probably broken right now so um have fun with that lol - Example options can be added to the config which only load when the file is new.
- A
ConfigFile#isNewmethod that returns whether the config file is brand new or not. - The API will force an option order on the config as always.
- Safe loading saves a config file with bad syntax to a separate file.
As of currently, there is no title/header API included. That will be implemented in a future alpha release.