isXander / isXander/YetAnotherConfigLib

[API Request] Allow `AutoGen` Config to Set `OptionFlag`

Open
#147 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
155
Forks
68
PR merge metrics
No merged PRs in 30d

Description

Now there is no way to set OptionFlag for AutoGen config.

I wrote a mixin for temporary use. (It's cumbersome to open a PR for a new project.)

@Mixin(SimpleOptionFactory.class)
abstract class MSimpleOptionFactory<A extends Annotation, T> implements OptionFactory<A, T> {
    @Inject(method = "flags", at = @At("RETURN"), cancellable = true)
    private void setFlags(A annotation, ConfigField<T> field, OptionAccess storage, CallbackInfoReturnable<Set<OptionFlag>> cir) {
        if (field.access().getAnnotation(GameRestart.class).isPresent()) {
            var set = new HashSet<>(cir.getReturnValue());
            set.add(OptionFlag.GAME_RESTART);
            cir.setReturnValue(set);
        }
    }
}
public class PSEConfig {
    @AutoGen(category = Categories.MAIN)
    @SerialEntry
    @IntField(min = 1, max = 64, format = "%d")
    @GameRestart
    public int potionMaxStack = 1
}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Trace AutoGen handling into SimpleOptionFactory.flags and inspect how OptionFlag values are produced. Confirm the API can express an OptionFlag such as GAME_RESTART for an AutoGen field, and verify that generated options retain it.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.