Katherine1 Posted May 20, 2018 Posted May 20, 2018 In my mod, I have scripts for initializing and updating the database it will be using as separate resources. They are all in the same folder and named with <number>.sql Now, I can access any of them with new ResourceLocation("modid", "sql/1.sql"); The issue is that this list of files may grow and it'd be preferable to iterate over these files. Is there a way to get how many files are in that sql folder? Quote
jabelar Posted May 20, 2018 Posted May 20, 2018 Minecraft is using normal Java, so just Google search for information on Java file functions. All of those are available to you. Quote Check out my tutorials here: http://jabelarminecraft.blogspot.com/
KaptainWutax Posted May 20, 2018 Posted May 20, 2018 You probably want a custom location in the config folder to make it dynamic. Scanner objects in Java can help you with the parsing. Quote
Katherine1 Posted May 20, 2018 Author Posted May 20, 2018 I think I got it. I tossed out using Forge's resource loader for Java's. I can get the folder as a File object, and then I can get an array of files contained by the folder, which gives me a count of the schema revisions in the app. Then it's simply a matter of iterating through the files in that folder in numeric order and running the SQL scripts against the database. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.