I wrote a bit a day or two ago about how the AssetManager works, so I’m going to redirect the general idea to that post rather than reiterate it here.
And if you’d like to see my ramble about how it works internally, that one is here.
Relating to your specific issue, the logs point to Files#createFile() as the issue. There are a couple of reasons why this might fail, but the one that should stand out is IOException - if an I/O error occurs or the parent directory does not exist.
This is indeed the case - the parent directory does not exist because the file is pointing to /experienceforclaims/config.conf. This is because you did not create your Path correctly in line 72 (25 in the paste) as Path#getFileName only returns the last element of the path, not all of them. You should be using Path#resolve instead.
Couple other notes on issues I saw or general recommendations:
- You don’t have to store the
Optional<Asset>(just get it when you need it, which should be once anyways). I’d also store the loader as aHoconConfigurationLoaderdirectly, but that’s a personal choice. - In line 72 (30 in the paste), you make a call to
Asset#copyToFilewhich internally usesFiles#copy. This will result in aFileAlreadyExistsExceptionbecause it’s already been created - see the first post I linked for two possibilities on how to this instead. - Many of your exceptions are marked as
TODO(which is fine), but note that they will also stack up quickly - if one fails, then the ones after it will fail and result in fields not be initialized, which then cause aNullPointerException. You should make sure that your exceptions are grouped so these subsequent methods are only being called if the config has been loaded successfully. - Instead of using
System.out.print()(which should beprintln()anyways), you should use theLoggerfor your plugin. - Your loading message shouldn’t be determined by the config; it should be a standard message that provides meaningful information. The same holds true for any log message in your plugin - as nice as translations are, they should be standardized so you know exactly where they’re coming from. I’d expect few people to touch this anyways.
If you have any followup questions, feel free to let me know. Welcome to Sponge!