Goldorion / File-Manager-MCreator

A MCreator plugin to manage files for Minecraft
GNU Lesser General Public License v2.1
8 stars 7 forks source link

Removing JSON Properties then writing, replaces all entries #64

Closed smmmadden closed 5 months ago

smmmadden commented 5 months ago

Issue description

I'm trying to replace some JSON Properties in an existing config file by using the Remove JSON Property element. This does work, but what happens when I write the JSON Object into the file with the replaced JSON Properties, the only thing that remains are what I explicitly added. All other content is also deleted. Seems that the write is "replacing" the entire file and not "updating" the file as I'm trying to do. Was also trying to find a way to check for the existence of a JSON Property and replace it with the new one but couldn't find an element that would say if JSON Property "command_mod-commands" existed is true to actually replace it. Not sure if that's possible, but would be great to have. :-)

How to reproduce this issue?

try to remove one or more json properties from an existing config file and then writing it. It will remove them, but all others as well.

Operating system

Windows

Details

FileManager: 5.10 MCreator: 2024.1_Patch 2 Neoforge: 1.20.4

Example workspace

No response

Logs

No response

Issue tracker rule checks (please read carefully)

Goldorion commented 5 months ago

Please provide a minimal reproducible workspace. I'm not sure to understand the problem, so this will help me. (Also, be aware I won't be available until end of May, so it won't be fixed soon).

smmmadden commented 5 months ago

thanks for the quick response :-) Sounds like your classes are keeping you way to busy. Hopefully this helps show what I was trying to do. I think it is just the write does a full replace of the file and not update it. Basically, if I'm removing an entry, it should only remove that entry, nothing else. image image image

Goldorion commented 5 months ago

I finished my classes! I'm going in Greece :D

And please provide a minimal reproducible workspace, not just screenshots

smmmadden commented 5 months ago

Nice! Wouldn't the procedure be enough to see what it's doing? It's the main file that creates/updates the config file with no dependency on any other procedure. CreateSimple_Config.zip

smmmadden commented 5 months ago

Well enjoy your time in Greece! I just figured out what I needed to do to fix it. It would be nice to replace the same row being removed with the new one, but it does remove the old entry and add the new one at the bottom. So I'm okay with it for now. :-)
image