3
3
import minevalley .core .api .modifiers .LocationModifier ;
4
4
import minevalley .core .api .modifiers .VisibilityModifier ;
5
5
6
+ import javax .annotation .Nonnegative ;
7
+ import javax .annotation .Nonnull ;
8
+
6
9
@ SuppressWarnings ("unused" )
7
10
public interface Hologram extends LocationModifier , VisibilityModifier {
8
11
@@ -11,24 +14,28 @@ public interface Hologram extends LocationModifier, VisibilityModifier {
11
14
*
12
15
* @return the lines of the hologram.
13
16
*/
17
+ @ Nonnull
14
18
String [] getLines ();
15
19
16
20
/**
17
21
* Returns the line at the specified index.
18
22
*
19
23
* @param line the index of the line.
20
24
* @return the line at the specified index.
25
+ * @throws IndexOutOfBoundsException if the line is out of bounds.
21
26
*/
22
- default String getLine (int line ) {
27
+ default String getLine (@ Nonnegative int line ) throws IndexOutOfBoundsException {
23
28
return getLines ()[line ];
24
29
}
25
30
26
31
/**
27
32
* Adds a line to the hologram.
28
33
*
29
34
* @param text the text of the line.
35
+ * @throws IllegalArgumentException if the text is null.
30
36
*/
31
- default void addLine (String text ) {
37
+ default void addLine (@ Nonnull String text ) throws IllegalArgumentException {
38
+ if (text == null ) throw new IllegalArgumentException ("The text cannot be null." );
32
39
addLineAfter (getLines ().length - 1 , text );
33
40
}
34
41
@@ -37,21 +44,26 @@ default void addLine(String text) {
37
44
*
38
45
* @param line the index of the line.
39
46
* @param text the text of the line.
47
+ * @throws IndexOutOfBoundsException if the line is out of bounds.
48
+ * @throws IllegalArgumentException if the text is null.
40
49
*/
41
- void addLineAfter (int line , String text );
50
+ void addLineAfter (@ Nonnegative int line , @ Nonnull String text ) throws IndexOutOfBoundsException , IllegalArgumentException ;
42
51
43
52
/**
44
53
* Changes the line at the specified index.
45
54
*
46
55
* @param line the index of the line.
47
56
* @param text the new text of the line.
57
+ * @throws IndexOutOfBoundsException if the line is out of bounds.
58
+ * @throws IllegalArgumentException if the text is null.
48
59
*/
49
- void changeLine (int line , String text );
60
+ void changeLine (@ Nonnegative int line , @ Nonnull String text ) throws IndexOutOfBoundsException , IllegalArgumentException ;
50
61
51
62
/**
52
63
* Removes the line at the specified index.
53
64
*
54
65
* @param line the index of the line.
66
+ * @throws IndexOutOfBoundsException if the line is out of bounds.
55
67
*/
56
- void removeLine (int line );
68
+ void removeLine (@ Nonnegative int line ) throws IndexOutOfBoundsException ;
57
69
}
0 commit comments