Skip to content

Commit

Permalink
Fixed self player top island counts as a paged object causing some is…
Browse files Browse the repository at this point in the history
…lands to not be seen in top islands menu (#963)
  • Loading branch information
OmerBenGera committed Mar 4, 2022
1 parent 5135660 commit 13a215c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
Expand Up @@ -35,6 +35,10 @@ public int getObjectIndex() {
return objectIndex;
}

public boolean countTowardsPageObjects() {
return true;
}

@Nullable
@Override
public ItemStack getButtonItem(M superiorMenu) {
Expand Down
Expand Up @@ -49,6 +49,11 @@ private TopIslandsPagedObjectButton(String requiredPermission, SoundWrapper lack
this.getNullItem().getEditableBuilder().asSkullOf((SuperiorPlayer) null);
}

@Override
public boolean countTowardsPageObjects() {
return !this.isSelfPlayerIsland;
}

@Override
public ItemStack modifyButtonItem(ItemStack buttonItem, MenuTopIslands superiorMenu, Island island) {
if (islandItem == null)
Expand Down
Expand Up @@ -25,7 +25,8 @@ public final class PagedMenuPattern<M extends PagedSuperiorMenu<M, T>, T> extend
private PagedMenuPattern(String title, InventoryType inventoryType, SuperiorMenuButton<M>[] buttons,
SoundWrapper openingSound, boolean isPreviousMoveAllowed) {
super(title, inventoryType, buttons, openingSound, isPreviousMoveAllowed);
objectsPerPage = (int) Arrays.stream(buttons).filter(button -> button instanceof PagedObjectButton).count();
objectsPerPage = (int) Arrays.stream(buttons).filter(button -> button instanceof PagedObjectButton &&
((PagedObjectButton<?, ?>) button).countTowardsPageObjects()).count();
}

public int getObjectsPerPage() {
Expand Down

0 comments on commit 13a215c

Please sign in to comment.