9
9
import org .jetbrains .annotations .Contract ;
10
10
import org .jetbrains .annotations .NotNull ;
11
11
12
- public class Filler {
12
+ public final class Filler implements MenuFiller {
13
+ @ NotNull
13
14
private final BaseMenu <?> menu ;
14
15
15
- Filler (@ NotNull BaseMenu <?> menu ) {
16
+ private Filler (@ NotNull BaseMenu <?> menu ) {
16
17
this .menu = menu ;
17
18
}
18
19
20
+ @ NotNull
19
21
@ Contract (value = "_ -> new" , pure = true )
20
- public static @ NotNull Filler from (@ NotNull BaseMenu <?> menu ) {
22
+ public static Filler from (@ NotNull BaseMenu <?> menu ) {
21
23
return new Filler (menu );
22
24
}
23
25
26
+ /**
27
+ * Fills the menu with the specified border material.
28
+ *
29
+ * @param borderMaterial the material to be used for filling the borders
30
+ */
24
31
public void fill (Material borderMaterial ) {
25
32
final int size = menu .getSize ();
26
33
@@ -32,17 +39,26 @@ public void fill(Material borderMaterial) {
32
39
}
33
40
}
34
41
42
+ /**
43
+ * Fills the menu with the specified border material.
44
+ * @param menuItem the material to be used for filling the borders
45
+ */
35
46
public void fill (@ NotNull MenuItem menuItem ) {
36
47
final int size = menu .getSize ();
37
48
38
49
for (int i = 0 ; i < size ; i ++) {
39
50
val item = menu .getItem (i );
40
51
if (item == null || item .getType () == Material .AIR ) {
41
- menu .setItem (i , menuItem . getItemStack () );
52
+ menu .setItem (i , menuItem );
42
53
}
43
54
}
44
55
}
45
56
57
+ /**
58
+ * Fills the with the specified border material.
59
+ *
60
+ * @param itemStack the material to be used for filling the borders
61
+ */
46
62
public void fill (ItemStack itemStack ) {
47
63
final int size = menu .getSize ();
48
64
@@ -54,33 +70,43 @@ public void fill(ItemStack itemStack) {
54
70
}
55
71
}
56
72
73
+ /**
74
+ * Fills the borders of the menu with the specified border material.
75
+ *
76
+ * @param borderMaterial the material to be used for filling the borders
77
+ */
57
78
public void fillBorders (Material borderMaterial ) {
58
79
final int size = menu .getSize ();
59
80
final var itemStack = new ItemStack (borderMaterial );
60
81
61
82
for (int i = 0 ; i < size ; i ++) {
62
- if (isBorderSlot (i , size )) menu .setItem (i , itemStack );
83
+ if (MenuFiller . isBorderSlot (i , size )) menu .setItem (i , itemStack );
63
84
}
64
85
}
65
86
87
+ /**
88
+ * Fills the borders of the menu with the specified border material.
89
+ *
90
+ * @param borderMaterial the material to be used for filling the borders
91
+ */
66
92
public void fillBorders (@ NotNull MenuItem borderMaterial ) {
67
93
final int size = menu .getSize ();
68
- final var itemStack = borderMaterial .getItemStack ();
69
94
70
- for (int i = 1 ; i < size ; i ++) {
71
- if (isBorderSlot (i , size )) menu .setItem (i , itemStack );
95
+ for (int i = 0 ; i < size ; i ++) {
96
+ if (MenuFiller . isBorderSlot (i , size )) menu .setItem (i , borderMaterial );
72
97
}
73
98
}
74
99
100
+ /**
101
+ * Fills the borders of the menu with the specified border material.
102
+ *
103
+ * @param itemStack the material to be used for filling the borders
104
+ */
75
105
public void fillBorders (ItemStack itemStack ) {
76
106
final int size = menu .getSize ();
77
107
78
108
for (int i = 0 ; i < size ; i ++) {
79
- if (isBorderSlot (i , size )) menu .setItem (i , itemStack );
109
+ if (MenuFiller . isBorderSlot (i , size )) menu .setItem (i , itemStack );
80
110
}
81
111
}
82
-
83
- private static boolean isBorderSlot (int i , int size ) {
84
- return (i < 9 || i >= size - 9 ) || (i % 9 == 0 || i % 9 == 8 );
85
- }
86
112
}
0 commit comments