@@ -615,9 +615,11 @@ public Inventory getInventory() {
615
615
if (isAutomaticPaginationEnabled () != null ) {
616
616
isAutomaticPaginationEnabled = isAutomaticPaginationEnabled ();
617
617
}
618
+
619
+ boolean needsPagination = getMaxPage () > 0 && isAutomaticPaginationEnabled ;
618
620
619
621
Inventory inventory = Bukkit .createInventory (this , (
620
- (getMaxPage () > 0 && isAutomaticPaginationEnabled )
622
+ (needsPagination )
621
623
// Pagination enabled: add the bottom toolbar row.
622
624
? getPageSize () + 9
623
625
// Pagination not required or disabled.
@@ -644,19 +646,21 @@ public Inventory getInventory() {
644
646
}
645
647
646
648
// Render the pagination items.
647
- SGPaginationButtonBuilder paginationButtonBuilder = spiGUI .getDefaultPaginationButtonBuilder ();
648
- if (getPaginationButtonBuilder () != null ) {
649
- paginationButtonBuilder = getPaginationButtonBuilder ();
650
- }
649
+ if (needsPagination ) {
650
+ SGPaginationButtonBuilder paginationButtonBuilder = spiGUI .getDefaultPaginationButtonBuilder ();
651
+ if (getPaginationButtonBuilder () != null ) {
652
+ paginationButtonBuilder = getPaginationButtonBuilder ();
653
+ }
651
654
652
- int pageSize = getPageSize ();
653
- for (int i = pageSize ; i < pageSize + 9 ; i ++) {
654
- int offset = i - pageSize ;
655
+ int pageSize = getPageSize ();
656
+ for (int i = pageSize ; i < pageSize + 9 ; i ++) {
657
+ int offset = i - pageSize ;
655
658
656
- SGButton paginationButton = paginationButtonBuilder .buildPaginationButton (
657
- SGPaginationButtonType .forSlot (offset ),this
658
- );
659
- inventory .setItem (i , paginationButton != null ? paginationButton .getIcon () : null );
659
+ SGButton paginationButton = paginationButtonBuilder .buildPaginationButton (
660
+ SGPaginationButtonType .forSlot (offset ),this
661
+ );
662
+ inventory .setItem (i , paginationButton != null ? paginationButton .getIcon () : null );
663
+ }
660
664
}
661
665
662
666
return inventory ;
0 commit comments