-
-
Notifications
You must be signed in to change notification settings - Fork 4
示例 翻页Title
huanmeng_qwq edited this page Dec 27, 2024
·
1 revision
ArrayList<Button> allButtons = new ArrayList<>();
List<ItemStack> items = IntStream.range(1, 64)
.mapToObj(i -> new ItemStack(Material.values()[i]))
.collect(Collectors.toList());
allButtons.addAll(Button.ofItemStacks(items));
GuiPage guiPage = new GuiPage(context.getPlayer(), allButtons, /*每页显示的数量*/27,/*使用预设的界面样式*/Slots.PATTERN_LINE_PAGE_DEFAULT);
guiPage.title("翻页");
guiPage.line(4);
Button previousButton = Button.of(new ItemBuilder(Material.ARROW, "上一页").build(), updateTitle(guiPage, -1));
Button nextButton = Button.of(new ItemBuilder(Material.ARROW, "下一页").build(), updateTitle(guiPage, 1));
// 设置翻页样式
guiPage.pageSetting(PageSettings.normal(guiPage, previousButton, nextButton));
guiPage.openGui();
private static @NotNull PlayerSimpleCancelInterface updateTitle(GuiPage guiPage, int add) {
return player -> {
guiPage.title("翻页 (" + (guiPage.page() + add) + "/" + guiPage.getPaginationNotNull().getMaxPage() + ")");
};
}