Skip to content

Commit

Permalink
Merge pull request #147 from AquaticLabs/feat/gui/update-modpage
Browse files Browse the repository at this point in the history
  • Loading branch information
LeeGodSRC authored Mar 29, 2024
2 parents d482a13 + f262773 commit 0a58370
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 7 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#

# Fairy
fairy.version = 0.7.1b2-SNAPSHOT
fairy.version = 0.7.1b3-SNAPSHOT
gradle-plugin.version = 1.2.0b9

mongojack.version = 4.2.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,23 +74,39 @@ static ItemSelectorGuiSlot.Builder itemSelector(Pane pane, int x, int y) {
}

static GuiSlot nextPage(PaginatedPane pane, ItemStack itemStack) {
return new ModPageGuiSlot(pane, itemStack, 1);
return new ModPageGuiSlot(pane, itemStack, 1, null);
}

static GuiSlot nextPage(PaginatedPane pane, ItemStack itemStack, @Nullable BiConsumer<Player, ClickType> clickCallback) {
return new ModPageGuiSlot(pane, itemStack, 1, clickCallback != null ? event -> clickCallback.accept((Player) event.getWhoClicked(), event.getClick()) : null);
}

static GuiSlot previousPage(PaginatedPane pane, ItemStack itemStack) {
return new ModPageGuiSlot(pane, itemStack, -1);
return new ModPageGuiSlot(pane, itemStack, -1, null);
}

static GuiSlot previousPage(PaginatedPane pane, ItemStack itemStack, @Nullable BiConsumer<Player, ClickType> clickCallback) {
return new ModPageGuiSlot(pane, itemStack, -1, clickCallback != null ? event -> clickCallback.accept((Player) event.getWhoClicked(), event.getClick()) : null);
}

static GuiSlot nextPage(PaginatedPane pane) {
return new ModPageGuiSlot(pane, ItemBuilder.of(XMaterial.ARROW).name("&aNext Page").build(), 1);
return new ModPageGuiSlot(pane, ItemBuilder.of(XMaterial.ARROW).name("&aNext Page").build(), 1, null);
}

static GuiSlot nextPage(PaginatedPane pane, @Nullable BiConsumer<Player, ClickType> clickCallback) {
return new ModPageGuiSlot(pane, ItemBuilder.of(XMaterial.ARROW).name("&aNext Page").build(), 1, clickCallback != null ? event -> clickCallback.accept((Player) event.getWhoClicked(), event.getClick()) : null);
}

static GuiSlot previousPage(PaginatedPane pane) {
return new ModPageGuiSlot(pane, ItemBuilder.of(XMaterial.ARROW).name("&aPrevious Page").build(), -1);
return new ModPageGuiSlot(pane, ItemBuilder.of(XMaterial.ARROW).name("&aPrevious Page").build(), -1, null);
}

static GuiSlot previousPage(PaginatedPane pane, @Nullable BiConsumer<Player, ClickType> clickCallback) {
return new ModPageGuiSlot(pane, ItemBuilder.of(XMaterial.ARROW).name("&aPrevious Page").build(), -1, clickCallback != null ? event -> clickCallback.accept((Player) event.getWhoClicked(), event.getClick()) : null);
}

static GuiSlot modPage(PaginatedPane pane, ItemStack itemStack, int mod) {
return new ModPageGuiSlot(pane, itemStack, mod);
static GuiSlot modPage(PaginatedPane pane, ItemStack itemStack, int mod, @Nullable BiConsumer<Player, ClickType> clickCallback) {
return new ModPageGuiSlot(pane, itemStack, mod, clickCallback != null ? event -> clickCallback.accept((Player) event.getWhoClicked(), event.getClick()) : null);
}

ItemStack getItemStack(@NotNull Player player, @NotNull Gui gui);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,18 @@
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.function.Consumer;

@RequiredArgsConstructor
public class ModPageGuiSlot implements GuiSlot {

private final PaginatedPane pane;
private final ItemStack itemStack;
private final int mod;
@Nullable
private final Consumer<InventoryClickEvent> clickCallback;

@Override
public ItemStack getItemStack(@NotNull Player player, @NotNull Gui gui) {
Expand All @@ -37,6 +42,9 @@ public void onInventoryClick(@NotNull InventoryClickEvent event, @NotNull Gui gu
gui.update(player);

XSound.UI_BUTTON_CLICK.play(player);

if (clickCallback != null)
clickCallback.accept(event);
}

public void sendCannotPrevious(Player player) {
Expand Down

0 comments on commit 0a58370

Please sign in to comment.