-
Notifications
You must be signed in to change notification settings - Fork 89
Shop
stefvanschie edited this page Sep 5, 2021
·
4 revisions
Languages: Dutch (Nederlands)
Example code for a shop gui. This gui can be used to let players buy items.
ChestGui gui = new ChestGui(6, "Shop");
PaginatedPane pages = new PaginatedPane(0, 0, 9, 5);
pages.populateWithItemStacks(Arrays.asList(
new ItemStack(Material.GOLDEN_SWORD),
new ItemStack(Material.LIGHT_GRAY_GLAZED_TERRACOTTA, 16),
new ItemStack(Material.COOKED_COD, 64)
));
pages.setOnClick(event -> {
//buy item
});
gui.addPane(pages);
OutlinePane background = new OutlinePane(0, 5, 9, 1);
background.addItem(new GuiItem(new ItemStack(Material.BLACK_STAINED_GLASS_PANE)));
background.setRepeat(true);
background.setPriority(Pane.Priority.LOWEST);
gui.addPane(background);
StaticPane navigation = new StaticPane(0, 5, 9, 1);
navigation.addItem(new GuiItem(new ItemStack(Material.RED_WOOL), event -> {
if (pages.getPage() > 0) {
pages.setPage(pages.getPage() - 1);
gui.update();
}
}), 0, 0);
navigation.addItem(new GuiItem(new ItemStack(Material.GREEN_WOOL), event -> {
if (pages.getPage() < pages.getPages() - 1) {
pages.setPage(pages.getPage() + 1);
gui.update();
}
}), 8, 0);
navigation.addItem(new GuiItem(new ItemStack(Material.BARRIER), event ->
event.getWhoClicked().closeInventory()), 4, 0);
gui.addPane(navigation);