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
@@ -39,10 +42,16 @@ public PaginatedMenu(PlayerMenuUtility playerMenuUtility) {
39
42
* Set the border and menu buttons for the menu. Override this method to provide a custom menu border or specify custom items in customMenuBorderItems()
* Gets the paginated items, using cache if available
84
+
* @return List of ItemStacks to display
85
+
*/
86
+
protectedList<ItemStack> getItems() {
87
+
if (cachedItems == null) {
88
+
cachedItems = dataToItems();
89
+
}
90
+
returncachedItems;
91
+
}
92
+
93
+
/**
94
+
* Clears the item cache, forcing items to be reloaded next time
95
+
*/
96
+
protectedvoidinvalidateCache() {
97
+
cachedItems = null;
98
+
}
99
+
73
100
/**
74
101
* Place each item in the paginated menu, automatically coded by default but override if you want custom functionality. Calls the loopCode() method you define for each item returned in the getData() method
75
102
*/
76
103
@Override
77
104
publicvoidsetMenuItems() {
78
-
79
105
addMenuBorder();
80
-
81
-
//add the items to the inventory based on the current page and max items per page
82
-
List<ItemStack> items = dataToItems();
106
+
107
+
List<ItemStack> items = getItems(); // Use cached items
108
+
109
+
intslot = 10;
83
110
for (inti = 0; i < maxItemsPerPage; i++) {
84
111
intindex = maxItemsPerPage * page + i;
85
112
if (index >= items.size()) break;
86
-
inventory.addItem(items.get(index));
113
+
114
+
if (slot % 9 == 8) slot += 2;
115
+
116
+
inventory.setItem(slot, items.get(index));
117
+
slot++;
87
118
}
88
-
89
119
}
90
120
91
121
/**
@@ -105,17 +135,68 @@ public boolean prevPage() {
105
135
* @return true if successful, false if already on the last page
106
136
*/
107
137
publicbooleannextPage() {
108
-
if (!((page + 1) * maxItemsPerPage >= dataToItems().size())) {
109
-
page = page + 1;
138
+
inttotalItems = getItems().size(); // Use cached items
0 commit comments