package net.minecraft.client;

import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.components.OptionButton;
import net.minecraft.client.gui.components.AbstractWidget;
import java.util.function.BiFunction;
import java.util.function.BiConsumer;

public class CycleOption extends Option {
    private final BiConsumer<Options, Integer> setter;
    private final BiFunction<Options, CycleOption, String> toString;
    
    public CycleOption(final String string, final BiConsumer<Options, Integer> biConsumer, final BiFunction<Options, CycleOption, String> biFunction) {
        super(string);
        this.setter = biConsumer;
        this.toString = biFunction;
    }
    
    public void toggle(final Options dbr, final int integer) {
        this.setter.accept(dbr, integer);
        dbr.save();
    }
    
    @Override
    public AbstractWidget createButton(final Options dbr, final int integer2, final int integer3, final int integer4) {
        return new OptionButton(integer2, integer3, integer4, 20, this, this.getMessage(dbr), dcv -> {
            this.toggle(dbr, 1);
            dcv.setMessage(this.getMessage(dbr));
        });
    }
    
    public String getMessage(final Options dbr) {
        return this.toString.apply(dbr, this);
    }
}
