only update nav buttons if there are buttons

This commit is contained in:
jascotty2 2019-09-08 08:10:13 -05:00
parent 9589801db7
commit bb3f26e1a8

View File

@ -47,7 +47,7 @@ public class Gui {
protected final Map<Integer, ItemStack> cellItems = new HashMap<>(); protected final Map<Integer, ItemStack> cellItems = new HashMap<>();
protected final Map<Integer, Map<ClickType, Clickable>> conditionalButtons = new HashMap<>(); protected final Map<Integer, Map<ClickType, Clickable>> conditionalButtons = new HashMap<>();
protected ItemStack blankItem = GuiUtils.getBorderGlassItem(); protected ItemStack blankItem = GuiUtils.getBorderGlassItem();
protected int nextPageIndex, prevPageIndex; protected int nextPageIndex = -1, prevPageIndex = -1;
protected ItemStack nextPage, prevPage; protected ItemStack nextPage, prevPage;
protected Gui parent = null; protected Gui parent = null;
protected static ItemStack AIR = new ItemStack(Material.AIR); protected static ItemStack AIR = new ItemStack(Material.AIR);
@ -650,17 +650,21 @@ public class Gui {
} }
protected void updatePageNavigation() { protected void updatePageNavigation() {
if (page > 1) { if(prevPage != null) {
this.setButton(prevPageIndex, prevPage, ClickType.LEFT, (event) -> this.prevPage()); if (page > 1) {
} else { this.setButton(prevPageIndex, prevPage, ClickType.LEFT, (event) -> this.prevPage());
this.setItem(prevPageIndex, null); } else {
this.clearActions(prevPageIndex); this.setItem(prevPageIndex, null);
this.clearActions(prevPageIndex);
}
} }
if (pages > 1 && page != pages) { if(nextPage != null) {
this.setButton(nextPageIndex, nextPage, ClickType.LEFT, (event) -> this.nextPage()); if (pages > 1 && page != pages) {
} else { this.setButton(nextPageIndex, nextPage, ClickType.LEFT, (event) -> this.nextPage());
this.setItem(nextPageIndex, null); } else {
this.clearActions(nextPageIndex); this.setItem(nextPageIndex, null);
this.clearActions(nextPageIndex);
}
} }
} }