[API Request] Allow `AutoGen` Config to Set `OptionFlag`
Phoupraw opened this issue ยท 0 comments
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
}