Skip to content

Commit 8b211cf

Browse files
Add documentation
1 parent 1f03ccd commit 8b211cf

File tree

1 file changed

+39
-13
lines changed

1 file changed

+39
-13
lines changed

src/main/java/me/flame/menus/menu/fillers/Filler.java

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,25 @@
99
import org.jetbrains.annotations.Contract;
1010
import org.jetbrains.annotations.NotNull;
1111

12-
public class Filler {
12+
public final class Filler implements MenuFiller {
13+
@NotNull
1314
private final BaseMenu<?> menu;
1415

15-
Filler(@NotNull BaseMenu<?> menu) {
16+
private Filler(@NotNull BaseMenu<?> menu) {
1617
this.menu = menu;
1718
}
1819

20+
@NotNull
1921
@Contract(value = "_ -> new", pure = true)
20-
public static @NotNull Filler from(@NotNull BaseMenu<?> menu) {
22+
public static Filler from(@NotNull BaseMenu<?> menu) {
2123
return new Filler(menu);
2224
}
2325

26+
/**
27+
* Fills the menu with the specified border material.
28+
*
29+
* @param borderMaterial the material to be used for filling the borders
30+
*/
2431
public void fill(Material borderMaterial) {
2532
final int size = menu.getSize();
2633

@@ -32,17 +39,26 @@ public void fill(Material borderMaterial) {
3239
}
3340
}
3441

42+
/**
43+
* Fills the menu with the specified border material.
44+
* @param menuItem the material to be used for filling the borders
45+
*/
3546
public void fill(@NotNull MenuItem menuItem) {
3647
final int size = menu.getSize();
3748

3849
for (int i = 0; i < size; i++) {
3950
val item = menu.getItem(i);
4051
if (item == null || item.getType() == Material.AIR) {
41-
menu.setItem(i, menuItem.getItemStack());
52+
menu.setItem(i, menuItem);
4253
}
4354
}
4455
}
4556

57+
/**
58+
* Fills the with the specified border material.
59+
*
60+
* @param itemStack the material to be used for filling the borders
61+
*/
4662
public void fill(ItemStack itemStack) {
4763
final int size = menu.getSize();
4864

@@ -54,33 +70,43 @@ public void fill(ItemStack itemStack) {
5470
}
5571
}
5672

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+
*/
5778
public void fillBorders(Material borderMaterial) {
5879
final int size = menu.getSize();
5980
final var itemStack = new ItemStack(borderMaterial);
6081

6182
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);
6384
}
6485
}
6586

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+
*/
6692
public void fillBorders(@NotNull MenuItem borderMaterial) {
6793
final int size = menu.getSize();
68-
final var itemStack = borderMaterial.getItemStack();
6994

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);
7297
}
7398
}
7499

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+
*/
75105
public void fillBorders(ItemStack itemStack) {
76106
final int size = menu.getSize();
77107

78108
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);
80110
}
81111
}
82-
83-
private static boolean isBorderSlot(int i, int size) {
84-
return (i < 9 || i >= size - 9) || (i % 9 == 0 || i % 9 == 8);
85-
}
86112
}

0 commit comments

Comments
 (0)