Customizable langkey pattern config annotation #68
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 andgtnhlib.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 theinterface
category will have a lang key ofgregtech.client.interface.covertabsvisible
and the category will havegregtech.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.javaYou 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.