mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-29 22:23:59 +01:00
Add shift click to edit special shop page items
This commit is contained in:
parent
a7c6195b37
commit
2082a98a79
@ -241,10 +241,14 @@ public class ShopTrait extends Trait {
|
|||||||
InventoryMenuSlot prev = ctx.getSlot(4 * 9 + 3);
|
InventoryMenuSlot prev = ctx.getSlot(4 * 9 + 3);
|
||||||
InventoryMenuSlot edit = ctx.getSlot(4 * 9 + 4);
|
InventoryMenuSlot edit = ctx.getSlot(4 * 9 + 4);
|
||||||
InventoryMenuSlot next = ctx.getSlot(4 * 9 + 5);
|
InventoryMenuSlot next = ctx.getSlot(4 * 9 + 5);
|
||||||
prev.clear();
|
|
||||||
if (page > 0) {
|
if (page > 0) {
|
||||||
prev.setItemStack(new ItemStack(Material.FEATHER, 1), "Previous page (" + (page) + ")");
|
prev.setItemStack(new ItemStack(Material.FEATHER, 1), "Previous page (" + (page) + ")");
|
||||||
|
Consumer<CitizensInventoryClickEvent> prevItemEditor = prev.getClickHandlers().get(0);
|
||||||
prev.setClickHandler(evt -> {
|
prev.setClickHandler(evt -> {
|
||||||
|
if (evt.isShiftClick()) {
|
||||||
|
prevItemEditor.accept(evt);
|
||||||
|
return;
|
||||||
|
}
|
||||||
evt.setCancelled(true);
|
evt.setCancelled(true);
|
||||||
changePage(page - 1);
|
changePage(page - 1);
|
||||||
});
|
});
|
||||||
@ -252,13 +256,25 @@ public class ShopTrait extends Trait {
|
|||||||
|
|
||||||
next.setItemStack(new ItemStack(Material.FEATHER, 1),
|
next.setItemStack(new ItemStack(Material.FEATHER, 1),
|
||||||
page + 1 >= shop.pages.size() ? "New page" : "Next page (" + (page + 1) + ")");
|
page + 1 >= shop.pages.size() ? "New page" : "Next page (" + (page + 1) + ")");
|
||||||
|
Consumer<CitizensInventoryClickEvent> nextItemEditor = next.getClickHandlers().get(0);
|
||||||
next.setClickHandler(evt -> {
|
next.setClickHandler(evt -> {
|
||||||
|
if (evt.isShiftClick()) {
|
||||||
|
nextItemEditor.accept(evt);
|
||||||
|
return;
|
||||||
|
}
|
||||||
evt.setCancelled(true);
|
evt.setCancelled(true);
|
||||||
changePage(page + 1);
|
changePage(page + 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Consumer<CitizensInventoryClickEvent> editPageItem = edit.getClickHandlers().get(0);
|
||||||
edit.setItemStack(new ItemStack(Material.BOOK), "Edit page");
|
edit.setItemStack(new ItemStack(Material.BOOK), "Edit page");
|
||||||
edit.setClickHandler(evt -> ctx.getMenu().transition(new NPCShopPageSettings(shop.getOrCreatePage(page))));
|
edit.setClickHandler(evt -> {
|
||||||
|
if (evt.isShiftClick()) {
|
||||||
|
editPageItem.accept(evt);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ctx.getMenu().transition(new NPCShopPageSettings(shop.getOrCreatePage(page)));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user