public class TextButton extends RenderObjectWidget
TextButton 是一个显示文本的按钮 Widget。

它使用彩色玻璃板作为按钮背景,上面显示文本。

使用示例:


 TextButton.builder()
     .text("Confirm")
     .color(Colors.GREEN)
     .slot(13)
     .onClick(() -> {
         player.sendMessage("Confirmed!");
         player.closeInventory();
     })
     .build();
 
Since:
6.2.0
Version:
1.0.0
Author:
UltiTools Team
  • Field Details

    • text

      @NotNull private final @NotNull String text
    • color

      @NotNull private final @NotNull String color
    • slot

      private final int slot
    • lore

      @Nullable private final @Nullable String[] lore
    • clickHandler

      @Nullable private final @Nullable Consumer<org.bukkit.event.inventory.InventoryClickEvent> clickHandler
  • Constructor Details

  • Method Details

    • builder

      @NotNull public static @NotNull TextButton.Builder builder()
      创建 Builder。
      Returns:
      Builder
    • getText

      @NotNull public @NotNull String getText()
    • getColor

      @NotNull public @NotNull String getColor()
    • getSlot

      public int getSlot()
    • getLore

      @Nullable public @Nullable String[] getLore()
    • getClickHandler

      @Nullable public @Nullable Consumer<org.bukkit.event.inventory.InventoryClickEvent> getClickHandler()
    • createElement

      @NotNull public @NotNull RenderObjectElement createElement()
      Description copied from class: Widget
      为此 Widget 创建对应的 Element。

      这是框架内部使用的方法,子类应该根据 Widget 类型返回适当的 Element 实现。

      Specified by:
      createElement in class RenderObjectWidget
      Returns:
      对应的 Element 实例