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