@@ -117,21 +117,49 @@ public MenuBuilder pages(final int pages) {
117
117
return this ;
118
118
}
119
119
120
- public void nextPageItem (int nextItemSlot , MenuItem nextItem ) {
120
+ public MenuBuilder nextPageItem (int nextItemSlot , MenuItem nextItem ) {
121
121
this .nextItemSlot = nextItemSlot ;
122
122
this .nextItem = nextItem ;
123
+ return this ;
123
124
}
124
125
125
- public void previousPageItem (int previousItemSlot , MenuItem previousItem ) {
126
+ public MenuBuilder previousPageItem (int previousItemSlot , MenuItem previousItem ) {
126
127
this .previousItemSlot = previousItemSlot ;
127
128
this .previousItem = previousItem ;
129
+ return this ;
130
+ }
131
+
132
+ public MenuBuilder nextPageItem (Slot nextItemSlot , MenuItem nextItem ) {
133
+ if (!nextItemSlot .isValid ()) {
134
+ throw new IllegalArgumentException (
135
+ "Next item slot is not valid" +
136
+ " (slot: " + nextItemSlot .slot + ", item: " + nextItem + ")" +
137
+ "\n Fix: The slot is not in the range of 0-" + (rows * 9 - 1 ) +
138
+ " (rows: " + rows + "), and slot row: " + (nextItemSlot .row ) + ", column: " + (nextItemSlot .column )
139
+ );
140
+ }
141
+ return nextPageItem (nextItemSlot .slot , nextItem );
142
+ }
143
+
144
+ public MenuBuilder previousPageItem (@ NotNull Slot previousItemSlot , MenuItem previousItem ) {
145
+ if (!previousItemSlot .isValid ()) {
146
+ throw new IllegalArgumentException (
147
+ "Next item slot is not valid" +
148
+ " (slot: " + previousItemSlot .slot + ", item: " + nextItem + ")" +
149
+ "\n Fix: The slot is not in the range of 0-" + (rows * 9 - 1 ) +
150
+ " (rows: " + rows + "), and slot row: " + (previousItemSlot .row ) + ", column: " + (previousItemSlot .column )
151
+ );
152
+ }
153
+ return previousPageItem (previousItemSlot .slot , previousItem );
128
154
}
129
155
130
156
@ NotNull
131
157
@ Contract (" -> new" )
132
158
public Menu normal () {
133
159
checkRequirements (rows , title );
134
- return type == MenuType .CHEST ? Menu .create (title , rows , modifiers ) : Menu .create (title , type , modifiers );
160
+ return type == MenuType .CHEST
161
+ ? Menu .create (title , rows , modifiers )
162
+ : Menu .create (title , type , modifiers );
135
163
}
136
164
137
165
@ NotNull
0 commit comments