The plugin continues its journey here.
File Manager is a plugin adding new procedure blocks allowing you to create and read your files!
File Types
- JSON
- TXT (simple file reader/writer)
- ZIP (5.7+)
Important Information
- This version supports Forge 1.19.4 and 1.20.1 and Fabric 1.20.1
The 2 following examples require File Manager 5.0 or after.
Create a JSON file
Read a JSON file
I made a tutorial covering this here.
Credits/License
Tutorial on sub-JSON objects by NorthWestTrees
Icon by Tobi-Wan#0482
Licensed under the GNU Lesser General Public License, version 2.1
- Appropriate credit must be provided to the creators and maintainers of this plugin.
- Forked versions of this plugin must be distributed under the same license as this with attribution if distributed.
- Changes must be stated if any modified works are to be distributed.
- Under no circumstances you can state that the original creator endorses modified works.
Changelog
To see a complete changelog of the plugin, check this file.
5.10
* [#48] Add a new parameter to write lines at the end of TXT files
* Note: Existing workspaces will get a build error due to the missing parameter. Previous behaviour was FALSE.
* [Bugfix #62] Write Json object caused a build error due to a missing import (again)
5.9.1
* [Bugfix #61] Some procedure blocks could cause build errors due to a missing import
* Added Persian language support
5.9
* Updated to MCreator 2024.1.15713
* Added support for NeoForge 1.20.4
Comments
Hey,
I think there's an mistake in File.mkdirs(); method.
File object is a directory and not a file.
As the result of this program creates a folder named file.json instead of file with json expansion xdd.
You can change it to something like:
File file = new File(filePath);
file.getParentFile().mkdirs();
Sorry, my small mistake.
Yes, file variable is file or directory.
But mkdirs() method is only directory so when you want to create file AND new folder hierarchy to it, it creates a folder instead of the file. In that situation it is a mistake, but you just have to add .getParentFile() before .mkdirs() to fix it.
I just read javadoc to be sure >:3.
Could you create one with a read json file? The two examples for writing the file look great, but that assumes the file is already present. There is a [Set Local: configFile to _____] element (purple), but no way to attach the text of the filename. I cannot find any element that can be used to set the file name to read the json file (or check if the file exists) without locking the code and manually updating File file = new File("configfile.json);
Thanks!!
Hello
im only able to create files with File Manager but if i try write things in the files i get a silent error with
https://pastebin.com/reAnj4Hb
If i do it like your example picture in the plugin description it wont work.
if i remove the write part it works.
it wont generate or change the code of the class with the write parts.
Already tested the latest build of file manager and one version lower too and also installed all snapshots of mcreator for 1.16.5 to test it with all versions.
Also builded the file manager with gradle on my own to test if uploaded version is maybe broken but nothing help.
Same error everytime.
What im doing wrong xD
Yes that is the case. There isn't a SET option for FileManager variables so the only way I found was to unlock the code for the procedure and update: File myFile = new File("serverbasicsconfig.json");
with the actual name. This sets the filename before checking if it exists or not. Not ideal, but a workaround for now. Just have to check it in/out again when making changes to that procedure which is a pain initially.
Okay, we are wrong tho. There is a block to set file variable, just it's name is kinda misleading.
This block is "Create the file with name located at directory".
It creates a variable File and puts the directory into it.
When u used read blocks in procedure it checks if file exists in the directory and if it doesn't exist, it creates it. If it exists it does nothing, you have full access to info inside it.
I'm Using It On 2021.3 Forge 1.17.1