Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModConfig::getHandler has gone missing #69

Closed
Fuzss opened this issue Jan 14, 2024 · 5 comments
Closed

ModConfig::getHandler has gone missing #69

Fuzss opened this issue Jan 14, 2024 · 5 comments

Comments

@Fuzss
Copy link

Fuzss commented Jan 14, 2024

ModConfig::getHandler was used to get an implementation of ConfigFileTypeHandler for a specific ModConfig.
In #40 all invocations of that method have been inlined with ConfigFileTypeHandler#TOML.

The ability to return a custom file handler instance extending ConfigFileTypeHandler was useful to me, as it allowed to alter some behavior, mainly placing my server config files in .minecraft/config so they can be used globally instead of relying on the default local placement in .minecraft/saves/<world>/serverconfig.
https://github.com/Fuzss/puzzleslib/blob/98f507fdaf1fa4c33eb8e783d3713f15e231af24/1.20.1/Forge/src/main/java/fuzs/puzzleslib/impl/config/core/ForgeConfigFileTypeHandler.java#L73

I'm also aware that the Corail Woodcutter mod uses this method, since I got the idea from there: https://github.com/Corail31/woodcutter/blob/1.20/src/main/java/ovh/corail/woodcutter/config/CustomConfig.java

Getting ModConfig::getHandler back would be much appreciated, as there is no reason ConfigFileTypeHandler#TOML has to be inlined everywhere.
Alternatively giving this suggestion another thought would also solve this issue for me (since implementing that change to the server config file path is the main purpose of my custom ConfigFileTypeHandler).

@Technici4n
Copy link
Member

The behavior you want is now the default: neoforged/NeoForge#376, therefore it is not useful to provide a custom file type handler.

@Fuzss
Copy link
Author

Fuzss commented Jan 14, 2024

Thanks, that's great!

@Fuzss Fuzss closed this as completed Jan 14, 2024
@endorh
Copy link

endorh commented Feb 11, 2024

I used to subclass ModConfig to get away with YAML configs and custom comment parsing (preserving user comments while keeping documentation comments (starting with ##) up to date and translated).

In order to keep compatibility with previous versions of my mods' configs without this extension point, the only option I can see amounts to replicating my own ConfigTracker, which doesn't really amuse me.

Is there any reason for this change I'm not aware of, other than simplifying the configs? (judging from the intent of #40)

@Technici4n
Copy link
Member

Other formats were not meant to be used in the first place. The Forge config system is TOML only.

@endorh
Copy link

endorh commented Feb 11, 2024

Well, I'd say it was night-config only until now, which allowed for arbitrary formats without much trouble, but I understand.

At least this opportunity will help make my config framework easier to port in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants