aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/thatgravyboat/skyblockhud/ComponentBuilder.java
blob: e5299d52293e0a3ddb125e3ad58ec33a6445a5e1 (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
44
45
46
47
48
49
50
51
52
53
54
55
package com.thatgravyboat.skyblockhud;

public class ComponentBuilder {

        public StringBuilder builder;

        public ComponentBuilder(){
            this.builder = new StringBuilder();
        }

        public ComponentBuilder apd(String text) {
            return apd(text, '7');
        }

        public ComponentBuilder apd(String text, char[] colors) {
            for (char color: colors) {
                builder.append("\u00A7").append(color);
            }
            builder.append(text).append("\u00A7").append('r');
            return this;
        }

        public ComponentBuilder apd(String text, char color) {
            builder.append("\u00A7").append(color).append(text).append("\u00A7").append('r');
            return this;
        }

        public ComponentBuilder nl(){
            builder.append("\n");
            return this;
        }

        public ComponentBuilder nl(String text, char color){
            apd(text, color);
            builder.append("\n");
            return this;
        }

        public ComponentBuilder nl(String text, char[] colors){
            apd(text, colors);
            builder.append("\n");
            return this;
        }

        public ComponentBuilder nl(String text){
            apd(text);
            builder.append("\n");
            return this;
        }

        public String build() {
            return builder.toString();
        }

}