You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* @return A list of the data being paginated. usually this is a list of items but it can be anything
27
+
* @return A list of ItemStacks that you want to be placed in the menu. This is the data that will be paginated
28
+
* You can also use this as a way to convert your data to items if you need to
32
29
*/
33
-
publicabstractList<?> getData();
34
-
35
-
/**
36
-
* @param object A single element of the data list that you do something with. It is recommended that you turn this into an item if it is not already and then put it into the inventory as you would with a normal Menu. You can execute any other logic in here as well.
37
-
*/
38
-
publicabstractvoidloopCode(Objectobject);
30
+
publicabstractList<ItemStack> dataToItems();
39
31
40
32
/**
41
33
* @return A hashmap of items you want to be placed in the paginated menu border. This will override any items already placed by default. Key = slot, Value = Item
@@ -86,20 +78,14 @@ public void setMenuItems() {
86
78
87
79
addMenuBorder();
88
80
89
-
List<Object> data = (List<Object>) getData();
90
-
91
-
if (data != null && !data.isEmpty()) {
92
-
for (inti = 0; i < getMaxItemsPerPage(); i++) {
93
-
index = getMaxItemsPerPage() * page + i;
94
-
System.out.println(index);
95
-
if (index >= data.size()) break;
96
-
if (data.get(index) != null) {
97
-
loopCode(data.get(index)); //run the code defined by the user
98
-
}
99
-
}
81
+
//add the items to the inventory based on the current page and max items per page
82
+
List<ItemStack> items = dataToItems();
83
+
for (inti = 0; i < maxItemsPerPage; i++) {
84
+
intindex = maxItemsPerPage * page + i;
85
+
if (index >= items.size()) break;
86
+
inventory.addItem(items.get(index));
100
87
}
101
88
102
-
103
89
}
104
90
105
91
/**
@@ -119,7 +105,7 @@ public boolean prevPage() {
119
105
* @return true if successful, false if already on the last page
120
106
*/
121
107
publicbooleannextPage() {
122
-
if (!((index + 1) >= getData().size())) {
108
+
if (!((page + 1) * maxItemsPerPage>= dataToItems().size())) {
0 commit comments