aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/dev/isxander/yacl3/api/LabelOption.java
blob: 16372b09bf6c1f04fb63ad66c86bad8d84c26186 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package dev.isxander.yacl3.api;

import dev.isxander.yacl3.impl.LabelOptionImpl;
import net.minecraft.network.chat.Component;
import org.jetbrains.annotations.NotNull;

import java.util.Collection;

/**
 * A label option is an easier way of creating a label with a {@link dev.isxander.yacl3.gui.controllers.LabelController}.
 * This option is immutable and cannot be disabled. Tooltips are supported through
 * {@link Component} styling.
 */
public interface LabelOption extends Option<Component> {
    @NotNull Component label();

    /**
     * Creates a new label option with the given label, skipping a builder for ease.
     */
    static LabelOption create(@NotNull Component label) {
        return new LabelOptionImpl(label);
    }

    static Builder createBuilder() {
        return new LabelOptionImpl.BuilderImpl();
    }

    interface Builder {
        Builder state(@NotNull StateManager<Component> stateManager);

        /**
         * Appends a line to the label
         */
        Builder line(@NotNull Component line);

        /**
         * Appends multiple lines to the label
         */
        Builder lines(@NotNull Collection<? extends Component> lines);

        LabelOption build();
    }
}