2
2
3
3
import net .oceanias .opal .plugin .OPlugin ;
4
4
import net .oceanias .opal .utility .extension .OStringExtension ;
5
+ import java .util .ArrayList ;
6
+ import java .util .Collection ;
5
7
import java .util .List ;
6
8
import java .util .Objects ;
7
9
import java .util .stream .Collectors ;
8
10
import java .util .stream .Stream ;
9
11
import org .bukkit .command .CommandSender ;
10
12
import net .kyori .adventure .text .Component ;
11
- import lombok .Builder ;
12
- import lombok .Getter ;
13
- import lombok .Singular ;
13
+ import lombok .*;
14
14
import lombok .experimental .Accessors ;
15
15
import lombok .experimental .ExtensionMethod ;
16
16
import org .jetbrains .annotations .Contract ;
20
20
@ Getter
21
21
@ Accessors (fluent = true )
22
22
@ ExtensionMethod (OStringExtension .class )
23
- @ Builder
23
+ @ AllArgsConstructor ( access = AccessLevel . PRIVATE )
24
24
public final class OMessage {
25
25
private final OPlugin plugin ;
26
26
27
- @ Singular ("line" )
28
27
private List <String > lines ;
29
28
30
- @ Builder . Default
31
- private boolean prefix = true ;
29
+ @ Setter
30
+ private boolean prefix ;
32
31
33
- @ Builder . Default
34
- private boolean dividers = false ;
32
+ @ Setter
33
+ private boolean dividers ;
35
34
36
- @ Builder . Default
37
- private boolean blanks = false ;
35
+ @ Setter
36
+ private boolean blanks ;
38
37
39
38
public @ NotNull Component component () {
40
39
final String addDividers = dividers ? OStringExtension .CHAT_DIVIDER_LONG : null ;
@@ -65,4 +64,45 @@ public OMessage send(final @NotNull Iterable<? extends CommandSender> senders) {
65
64
66
65
return this ;
67
66
}
67
+
68
+ @ Contract (value = "_ -> new" , pure = true )
69
+ public static @ NotNull OMessageBuilder builder (final OPlugin plugin ) {
70
+ return new OMessageBuilder (plugin );
71
+ }
72
+
73
+ @ Getter
74
+ public static class OMessageBuilder {
75
+ private final OPlugin plugin ;
76
+
77
+ private final List <String > lines = new ArrayList <>();
78
+
79
+ @ Setter
80
+ private boolean prefix = true ;
81
+
82
+ @ Setter
83
+ private boolean dividers = false ;
84
+
85
+ @ Setter
86
+ private boolean blanks = false ;
87
+
88
+ public OMessageBuilder (final OPlugin plugin ) {
89
+ this .plugin = plugin ;
90
+ }
91
+
92
+ public OMessageBuilder line (final String line ) {
93
+ lines .add (line );
94
+
95
+ return this ;
96
+ }
97
+
98
+ public OMessageBuilder lines (final Collection <String > lines ) {
99
+ this .lines .addAll (lines );
100
+
101
+ return this ;
102
+ }
103
+
104
+ public OMessage build () {
105
+ return new OMessage (plugin , lines , prefix , dividers , blanks );
106
+ }
107
+ }
68
108
}
0 commit comments