File registration
Since 1.0.0
As mentioned on "Accessing the API", the MCPlugin class provides easy access to most methods of MCUtils, this methods include file registration. The most basic included file type is the YmlFile, but here are all file types, the order is important as PluginFile extends YmlFile and so on.
PluginFile - This file can also be updated, adding any missing paths by doing so. (Code)
MessagesFile - Also includes message methods with access to every chat feature. (Code)
A more primitive file type that cannot be registered is the CharsetYamlConfiguration.
Registering a file
Any class extending MCPlugin can register files, here is how to do so:
Note that as a more "complex" approach for yml files only is to create your own class extending YmlFile, (Or any other class implementing FileHolder, but we will use YmlFile on this example for the sake of simplicity) then, registering an instance of said class. For other file types, read file types.
Common methods
MCPlugin contains various methods that will perform a certain task for every registered file. MCUtils provides a file updater that can be used on any class extending PluginFile, this method compares the local file stored on the server with the internal file present on the plugin, which is considered to be the latest version of the file, adding any missing paths and removing any unknown path from the local file. Paths can be ignored by the updater by providing a String list with said paths.
Ignored paths also affect child paths, let's see this with a real example. Assume we have the following yml file.
Imagine "Parent" is a path where the end user should be able to include new paths, this paths would need to be ignored by the file updater, otherwise, they would get removed as the local file won't have them. To achieve this, we can use this code:
"ToUpdate" will still be added to the local file if missing, but "Parent" and any path under "Parent", won't.
Last updated