Skip to content

Commit

Permalink
don't add glass pane if preview menu
Browse files Browse the repository at this point in the history
  • Loading branch information
ryderbelserion committed Sep 23, 2024
1 parent 6869cab commit d27c013
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ public final PaginatedGui getGui() {
}

// Adds the back button
public void setBackButton(final int row, final int column) {
public void setBackButton(final int row, final int column, final boolean isPreview) {
if (this.gui.getCurrentPageNumber() <= 1) {
setNavigationItem(row, column);
setFillerItem(row, column, isPreview);

return;
}
Expand All @@ -87,31 +87,33 @@ public void setBackButton(final int row, final int column) {
final int page = this.gui.getCurrentPageNumber();

if (page <= 1) {
setNavigationItem(row, column);
setFillerItem(row, column, isPreview);
} else {
setBackButton(row, column);
setBackButton(row, column, isPreview);
}

if (page < this.gui.getMaxPages()) {
setNextButton(this.gui.getRows(), 6);
setNextButton(this.gui.getRows(), 6, isPreview);
}
}));

addMenuButton(this.player, this.crate, this.gui, this.gui.getRows(), 5);
}

private void setNavigationItem(int row, int column) {
private void setFillerItem(int row, int column, boolean isPreview) {
if (this.crate != null && this.crate.isBorderToggle()) {
this.gui.setItem(row, column, this.crate.getBorderItem().asGuiItem());
} else {
this.gui.removeItem(row, column);
if (!isPreview) {
this.gui.removeItem(row, column);

this.gui.setItem(row, column, new GuiItem(Material.BLACK_STAINED_GLASS_PANE));
this.gui.setItem(row, column, new GuiItem(Material.BLACK_STAINED_GLASS_PANE));
}
}
}

// Adds the next button
public void setNextButton(final int row, final int column) {
public void setNextButton(final int row, final int column, final boolean isPreview) {
if (this.gui.getCurrentPageNumber() >= this.gui.getMaxPages()) {
return;
}
Expand All @@ -124,9 +126,9 @@ public void setNextButton(final int row, final int column) {
final int page = this.gui.getCurrentPageNumber();

if (page >= this.gui.getMaxPages()) {
setNavigationItem(row, column);
setFillerItem(row, column, isPreview);
} else {
setNextButton(row, column);
setNextButton(row, column, isPreview);
}

final int rows = this.gui.getRows();
Expand All @@ -135,12 +137,14 @@ public void setNextButton(final int row, final int column) {
if (this.crate != null && this.crate.isBorderToggle()) {
this.gui.setItem(rows, 4, this.crate.getBorderItem().asGuiItem());
} else {
this.gui.removeItem(rows, 4);
if (!isPreview) {
this.gui.removeItem(rows, 4);

this.gui.setItem(rows, 4, new GuiItem(Material.BLACK_STAINED_GLASS_PANE));
this.gui.setItem(rows, 4, new GuiItem(Material.BLACK_STAINED_GLASS_PANE));
}
}
} else {
setBackButton(rows, 4);
setBackButton(rows, 4, isPreview);
}
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,7 @@ public void open() {
}
})));

setBackButton(6, 4);
setNextButton(6, 6);

gui.open(this.player, gui -> {
this.gui.open(this.player, gui -> {
final int rows = gui.getRows();

gui.setItem(rows, 5, new ItemBuilder(Material.CHEST)
Expand Down Expand Up @@ -132,8 +129,8 @@ public void open() {
}
}));

setBackButton(rows, 4);
setNextButton(rows, 6);
setBackButton(rows, 4, false);
setNextButton(rows, 6, false);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public void open() {
this.gui.open(this.player, gui -> {
final int rows = gui.getRows();

setBackButton(rows, 4);
setNextButton(rows, 6);
setBackButton(rows, 4, true);
setNextButton(rows, 6, true);

addMenuButton(this.player, crate, this.gui, rows, 5);
});
Expand Down

0 comments on commit d27c013

Please sign in to comment.