Class ButtonElement

java.lang.Object
net.chen.legacyLand.gui.elements.ButtonElement
All Implemented Interfaces:
GuiElement

public class ButtonElement extends Object implements GuiElement
  • Constructor Details

    • ButtonElement

      public ButtonElement(String id, org.bukkit.Material material, String displayName)
    • ButtonElement

      public ButtonElement(String id, org.bukkit.Material material, String displayName, List<String> lore)
  • Method Details

    • onClick

      public ButtonElement onClick(Consumer<org.bukkit.entity.Player> callback)
    • onRightClick

      public ButtonElement onRightClick(Consumer<org.bukkit.entity.Player> callback)
    • onShiftClick

      public ButtonElement onShiftClick(Consumer<org.bukkit.entity.Player> callback)
    • getId

      public String getId()
      Description copied from interface: GuiElement
      获取元素的唯一标识符
      Specified by:
      getId in interface GuiElement
      Returns:
      元素 ID
    • getDisplayName

      public String getDisplayName()
      获取元素的显示名称
      Specified by:
      getDisplayName in interface GuiElement
      Returns:
      显示名称
    • render

      public org.bukkit.inventory.ItemStack render(GuiSession session)
      Description copied from interface: GuiElement
      渲染元素为物品堆
      Specified by:
      render in interface GuiElement
      Parameters:
      session - 当前会话(包含玩家信息)
      Returns:
      渲染后的物品堆
    • onClick

      public void onClick(org.bukkit.entity.Player player, GuiSession session, org.bukkit.event.inventory.ClickType clickType)
      Description copied from interface: GuiElement
      处理玩家点击事件
      Specified by:
      onClick in interface GuiElement
      Parameters:
      player - 点击的玩家
      session - 当前会话
      clickType - 点击类型
    • validate

      public boolean validate(org.bukkit.entity.Player player)
      验证元素的当前值
      Specified by:
      validate in interface GuiElement
      Parameters:
      player - 目标玩家
      Returns:
      是否通过验证
    • getSlot

      public int getSlot()
      Description copied from interface: GuiElement
      获取元素的槽位位置
      Specified by:
      getSlot in interface GuiElement
      Returns:
      槽位索引(-1 表示自动分配)
    • setSlot

      public void setSlot(int slot)
      Description copied from interface: GuiElement
      设置元素的槽位位置
      Specified by:
      setSlot in interface GuiElement
      Parameters:
      slot - 槽位索引
    • isVisible

      public boolean isVisible(org.bukkit.entity.Player player)
      Description copied from interface: GuiElement
      检查元素是否可见
      Specified by:
      isVisible in interface GuiElement
      Parameters:
      player - 目标玩家
      Returns:
      是否可见
    • isEnabled

      public boolean isEnabled(org.bukkit.entity.Player player)
      Description copied from interface: GuiElement
      检查元素是否可交互
      Specified by:
      isEnabled in interface GuiElement
      Parameters:
      player - 目标玩家
      Returns:
      是否可交互
    • getValidator

      public Consumer<Object> getValidator()
      Description copied from interface: GuiElement
      获取元素的验证器
      Specified by:
      getValidator in interface GuiElement
      Returns:
      验证器(可为 null)
    • setValue

      public void setValue(Object value)
      Description copied from interface: GuiElement
      设置元素的值
      Specified by:
      setValue in interface GuiElement
      Parameters:
      value - 新值
    • getValue

      public Object getValue()
      Description copied from interface: GuiElement
      获取元素的当前值
      Specified by:
      getValue in interface GuiElement
      Returns:
      当前值