aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/GardenVisitorsWidget.java
blob: 2b0036ad789bc1acf69756c27803b5d9f1f01c2e (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
package de.hysky.skyblocker.skyblock.tabhud.widget;

import de.hysky.skyblocker.skyblock.tabhud.util.PlayerListMgr;
import de.hysky.skyblocker.skyblock.tabhud.widget.component.PlainTextComponent;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;

public class GardenVisitorsWidget extends Widget {
    private static final MutableText TITLE = Text.literal("Visitors").formatted(Formatting.DARK_GREEN, Formatting.BOLD);

    public GardenVisitorsWidget() {
        super(TITLE, Formatting.DARK_GREEN.getColorValue());
    }

    @Override
    public void updateContent() {
    	int offset = (PlayerListMgr.strAt(46) != null) ? 1 : 0;

        if (PlayerListMgr.textAt(54 + offset) == null) {
            this.addComponent(new PlainTextComponent(Text.literal("No visitors!").formatted(Formatting.GRAY)));
            return;
        }

        for (int i = 54 + offset; i < 59 + offset; i++) {
            String text = PlayerListMgr.strAt(i);
            if (text != null)
                this.addComponent(new PlainTextComponent(Text.literal(text)));
        }
    }
}