diff --git a/hamster-core-bukkit/src/main/java/cn/hamster3/mc/plugin/core/bukkit/page/handler/PageableHandler.java b/hamster-core-bukkit/src/main/java/cn/hamster3/mc/plugin/core/bukkit/page/handler/PageableHandler.java index 8422d8d..3b943a1 100644 --- a/hamster-core-bukkit/src/main/java/cn/hamster3/mc/plugin/core/bukkit/page/handler/PageableHandler.java +++ b/hamster-core-bukkit/src/main/java/cn/hamster3/mc/plugin/core/bukkit/page/handler/PageableHandler.java @@ -3,7 +3,9 @@ package cn.hamster3.mc.plugin.core.bukkit.page.handler; import cn.hamster3.mc.plugin.core.bukkit.page.ButtonGroup; import cn.hamster3.mc.plugin.core.bukkit.page.PageConfig; import org.bukkit.Material; +import org.bukkit.Sound; import org.bukkit.entity.HumanEntity; +import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import org.bukkit.event.inventory.InventoryAction; import org.bukkit.event.inventory.InventoryClickEvent; @@ -78,6 +80,36 @@ public abstract class PageableHandler extends FixedPageHandler { } } + @Override + public void onPlayButtonSound(@NotNull ClickType clickType, @NotNull InventoryAction action, int index) { + HumanEntity player = getPlayer(); + if (!(player instanceof Player)) { + return; + } + PageConfig config = getPageConfig(); + String buttonName = getButtonGroup().getButtonName(index); + Sound sound = config.getButtonSound(buttonName); + if (sound == null) { + switch (buttonName) { + case "empty": + case "barrier": { + break; + } + default: { + sound = config.getButtonSound("default"); + break; + } + } + } + if (buttonName.equals("element") && elementSlot.get(index) == null) { + sound = null; + } + if (sound == null) { + return; + } + ((Player) player).playSound(player.getLocation(), sound, 1, 1); + } + @Override public void initPage() { super.initPage();