EnumCycler#allowedOrdinals() has inverted implementation logic

Open Beginner friendly
#332 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
java
Domain
tooling

Research direction

Open src/main/java/dev/isxander/yacl3/config/v2/impl/autogen/EnumCyclerImpl.java at the referenced implementation and compare its ordinal filtering with the documented allowedOrdinals behavior. Use the DifficultySetting example to verify that the listed ordinals are selectable and that an omitted ordinal is rejected; done means the implementation matches the documentation.

Written by the indexing model from the issue text.

Description

Using 3.9.2+26.1-fabric, the logic for the implementation of EnumCycler#allowedOrdinals appears to be inverted from how it is described in the documentation. The documentation says:

The allowed ordinals of the enum class. If empty, all ordinals are allowed.
This is only used if the enum does not implement {@link CyclableEnum}.

However, the logic here uses noneMatch, which will mean that the filter will only allow any ordinal which is not included in the allowedOrdinals array. It should instead use anyMatch.

https://github.com/isXander/YetAnotherConfigLib/blob/e7fcc32cd16c5f36706a1f20f067333558b3be7a/src/main/java/dev/isxander/yacl3/config/v2/impl/autogen/EnumCyclerImpl.java#L27

Example

In my mod using this enum:

public enum DifficultySetting implements StringRepresentable {
    AUTOMATIC("automatic"),
    PEACEFUL("peaceful"),
    EASY("easy"),
    NORMAL("normal"),
    HARD("hard");

    private final String name;

    DifficultySetting(String name) {
        this.name = name;
    }

    @Override
    public String getSerializedName() {
        return this.name;
    }
}

This setting will only allow the setting PEACEFUL to be selected, and not any of the others:

@AutoGen(category = "main")
@SerialEntry
@EnumCycler(allowedOrdinals = {0, 2, 3, 4})
DifficultySetting frostBiteAmplifierDifficulty = DifficultySetting.AUTOMATIC;
Dominant language
Java
Stars
155
Forks
68
Avg merge
3d 7h
Merged PRs (30d)
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.

More from isXander/YetAnotherConfigLib

All issues in isXander/YetAnotherConfigLib

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.