Now when it came to Bukkit/Spigot, it was just a case of getting the main class and using getResource, however I’ve yet to find a way of obtaining an internal text file using Sponge.
I assume that Configurate will have a method of achieving this, however I’m unsure as to how it would know to search for an internal path string, rather than searching in the main data folder.
My apologies if my constant threads are annoying the veterans, after several years of bukkit development this definitely takes some getting used to.
So I’m using the AssetManager, I use getAsset using the plugin argument and the name argument. However I’m confused as to how I can get a readable file from this as Configurate doesn’t seem to have a way of loading an “Asset” (understandable as it’s a third party API).
You can use Asset#copyToFile() to copy the data inside an asset to a java.nio.file.Path. You can then supply Configurate that path and the data from Asset will be retained
And would there be a clean way to read this InputStream? I know with Bukkit we had the likes of YamlConfiguration, loading the resource in the form of an InputStream.
Does Configurate offer such a thing?
Or perhaps, could I get the assets URL, then use the setURL method in HoconConfigurationLoader’s builder?
I’d see if the setURL method works. Hocon is the preferred format for configuration files in Sponge, so I’d adjust to using it. I don’t know if there’s an API for handling Yaml files in Sponge.
Handling in Yaml files is possible with Sponge, at least when it comes to external files. So in theory I would assume the same can be said for internal, I’ll just have to see
Issue I need to resolve now is the plugin refusing to acknowledge that the assets folder exists >.>
Just as a follow-up, if you want this as an editable file, then yes, you can use setURL on your YamlConfigurationLoader. Otherwise, you’d want to copyToFile.
In this particular instance there’s quite a few values saved in this file, so I like to just put them away somewhere so I can easily obtain them, yet not have it cramping up everywhere else.
Then a class Constants that contains the static finals? I dunno, it just seems weird to go to the trouble and processing power of loading and parsing a config that you don’t need.
I suppose that could work, however how would one account for say, when you’ve got values based on certain item id’s, I personally have a text file with the parent of say “item”, then have the plugin check if it contains a child fo the id’s name, etc.
Surely with statis values, you can really check for such a thing, unless you’re checking the class for variable names (I could be entirely wrong, I haven’t gone in to this part too much so I do apologise)
I mean at the end of the day there’s several methods for what we need to do, a lot of the time it comes down to what we’re most comfortable working with.