LuckPerms

LuckPerms

41.4k Downloads

Wiki: "Developer API: Usage" wrong method in example code

KaiKikuchi opened this issue ยท 3 comments

commented

In this section there is the following example code:

public class CustomCalculator implements ContextCalculator<Player> {

    @Override  
    public void calculate(Player t, ContextConsumer contextConsumer) {
        contextConsumer.add("gamemode", t.getGameMode().name());
    }
    
    @Override
    public ContextSet estimatePotentialContexts() {
        ImmutableContextSet.Builder builder = ImmutableContextSet.builder();
        for (GameMode gameMode : GameMode.values()) {
            builder.add(KEY, gameMode.name().toLowerCase());
        }
        return builder.build();
    }
    
}

ContextConsumer does not have an "add" method, but "accept". Link to ContextConsumer.java

I also suggest to change "KEY" to "gamemode" in order to have a working example.

commented

I made a PR to correct this.

You could do it next time as the wiki is mirrored here.

commented

Okay I will do that next time, thanks!

commented

Thank you both :)