-
Notifications
You must be signed in to change notification settings - Fork 88
Shop (Dutch)
stefvanschie edited this page Nov 30, 2021
·
3 revisions
Talen: Engels (English)
Voorbeeldcode voor een winkel-gui. Deze gui kan wordne gebruikt om spelers items te laten kopen.
ChestGui gui = new ChestGui(6, "Shop");
PaginatedPane paginas = new PaginatedPane(0, 0, 9, 5);
paginas.populateWithItemStacks(Arrays.asList(
new ItemStack(Material.GOLDEN_SWORD),
new ItemStack(Material.LIGHT_GRAY_GLAZED_TERRACOTTA, 16),
new ItemStack(Material.COOKED_COD, 64)
));
paginas.setOnClick(event -> {
//koop item
});
gui.addPane(paginas);
OutlinePane achtergrond = new OutlinePane(0, 5, 9, 1);
achtergrond.addItem(new GuiItem(new ItemStack(Material.BLACK_STAINED_GLASS_PANE)));
achtergrond.setRepeat(true);
achtergrond.setPriority(Pane.Priority.LOWEST);
gui.addPane(achtergrond);
StaticPane navigatie = new StaticPane(0, 5, 9, 1);
navigatie.addItem(new GuiItem(new ItemStack(Material.RED_WOOL), event -> {
if (paginas.getPage() > 0) {
paginas.setPage(paginas.getPage() - 1);
gui.update();
}
}), 0, 0);
navigatie.addItem(new GuiItem(new ItemStack(Material.GREEN_WOOL), event -> {
if (paginas.getPage() < paginas.getPages() - 1) {
paginas.setPage(paginas.getPage() + 1);
gui.update();
}
}), 8, 0);
navigatie.addItem(new GuiItem(new ItemStack(Material.BARRIER), event ->
event.getWhoClicked().closeInventory()), 4, 0);
gui.addPane(navigatie);
<chestgui title="Winkel" rows="6">
<paginatedpane x="0" y="0" length="9" height="5">
<page>
<outlinepane x="0" y="0" length="9" height="5">
<item id="golden_sword" />
<item id="light_gray_glazed_terracotta" amount="16" />
<item id="cooked_cod" amount="64" />
</outlinepane>
</page>
</paginatedpane>
<outlinepane x="0" y="5" length="9" height="1" priority="lowest" repeat="true">
<item id="black_stained_glass_pane" />
</outlinepane>
<staticpane x="0" y="5" length="9" height="1">
<item id="red_wool" x="0" y="0" />
<item id="barrier" x="4" y="0" />
<item id="green_wool" x="8" y="0" />
</staticpane>
</chestgui>