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

Customizable langkey pattern config annotation #68

Merged
merged 4 commits into from
Sep 11, 2024
Merged

Conversation

Lyfts
Copy link
Member

@Lyfts Lyfts commented Sep 3, 2024

Instead of defining a @Config.Langkey for every single config option and category this will allow you to define a pattern from which the lang key will be generated. This applies to all fields in the annotated class including potential subcategories (along with their fields).

Examples:
For the default pattern of: %mod.%cat.%field
The field "exampleBool "in the category "general" for the mod gtnhlib will turned into a lang key of gtnhlib.general.examplebool for the field and gtnhlib.general for the category.

For a pattern of %mod.%file.%cat.%field
https://github.com/GTNewHorizons/GT5-Unofficial/blob/master/src/main/java/gregtech/common/config/client/ConfigInterface.java
The field coverTabsVisible in the interface category will have a lang key of gregtech.client.interface.covertabsvisible and the category will have gregtech.client.interface.

There's no requirement to use placeholders (except for %cat and %field) so for https://github.com/GTNewHorizons/GT5-Unofficial/blob/master/src/main/java/gregtech/common/config/other/ConfigGeneral.java
You can use a pattern of gregtech.client.%cat.%field to keep a consistent scheme with the example above. (Nvm lol that one is not in the client package but example is still relevant)

All of this is done as efficiently as possible with some stringbuilder magic, so there shouldn't be any noticeable performance difference.

@Config.RequiresWorldRestart & @Config.RequiresMcRestart were applicable to classes but there was no logic for them if not attached to a field. This has been changed so that applying them to a class makes it apply for every subcategory and field within.

@Lyfts Lyfts requested a review from a team September 3, 2024 16:41
@boubou19 boubou19 merged commit 5f46d25 into master Sep 11, 2024
1 check passed
@boubou19 boubou19 deleted the lang-pattern branch September 11, 2024 14:35
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

Successfully merging this pull request may close these issues.

2 participants