📝File types
Since 1.0.0
Since the very first version of MCUtils, any class that extends the FileHolder interface can be registered to any MCPlugin. On this page, we will see every file-related interface that comes with MCUtils, starting from the most basic one.
FileHolder
The FileHolder interface is the most basic one, and as such, it only requires three pretty much expected methods to be implemented. For this one, an example is better than any amount of words.
And that's it. You are not even required to return the File that your FileHolder should, well, hold. This is because FileHolders are allowed to hold multiple files. For example, on my network, a LangManager exists that actually holds multiple files, one per language supported by the plugin. Now, back to MCUtils. We still have two more interfaces left.
FileUpdater
Only for FileHolders that can be updated to newer versions, such as the PluginFile.
MessagesFileHolder
Now, this one is a bit more tricky. It extends the FileHolder interface, not the FileUpdater one, so you can implement both FileUpdater and MessagesFileHolder if you really want to do so.
But that's not all! Each of those two methods have two more defaults with Replacer support, so getString(String, Replacer)
and getString(String, Object...)
are also provided, same for the string list getter. There are also message senders included for CommandSenders, these defaults work by path and automatically detect if you are trying to send a list of messages to the sender or just a single message. Here is how the CustomMsgFile
class would be used.
We strongly recommend you to check and read the documentation of every default method from this class, really. They are useful, but also have probably unexpected behavior if you only read their name and assume how they work, such as ignoring empty messages to avoid sending blank messages to players. By the way, for yaml files the MessagesFile already exists, have you checked that one?
Last updated