Class MenuButton

java.lang.Object
dev.demeng.pluginbase.menu.model.MenuButton

public class MenuButton extends Object
Represents a "button", or rather item stack, that will be put inside a Menu. Each button is assigned with a nullable consumer for InventoryClickEvent, which will be accepted on click.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static @NotNull MenuButton
    create(int slot, @NotNull org.bukkit.configuration.ConfigurationSection section, @Nullable Consumer<org.bukkit.event.inventory.InventoryClickEvent> consumer)
    Creates a new menu button from a configuration section, but overrides any slot values the configuration section may have.
    static @NotNull MenuButton
    create(int slot, @NotNull org.bukkit.configuration.ConfigurationSection section, @Nullable UnaryOperator<String> translator, @Nullable Consumer<org.bukkit.event.inventory.InventoryClickEvent> consumer)
    Creates a new menu button from a configuration section, but overrides any slot values the configuration section may have.
    static @NotNull MenuButton
    create(int slot, @NotNull org.bukkit.inventory.ItemStack stack, @Nullable Consumer<org.bukkit.event.inventory.InventoryClickEvent> consumer)
    Creates a new menu button.
    static @NotNull MenuButton
    create(@NotNull org.bukkit.configuration.ConfigurationSection section, @Nullable Consumer<org.bukkit.event.inventory.InventoryClickEvent> consumer)
    Creates a new menu button from a configuration section.
    static @NotNull MenuButton
    create(@NotNull org.bukkit.configuration.ConfigurationSection section, @Nullable UnaryOperator<String> translator, @Nullable Consumer<org.bukkit.event.inventory.InventoryClickEvent> consumer)
    Creates a new menu button from a configuration section.
    static @NotNull MenuButton
    createLocalized(int slot, @NotNull org.bukkit.configuration.ConfigurationSection section, @NotNull org.bukkit.command.CommandSender sender, @Nullable Consumer<org.bukkit.event.inventory.InventoryClickEvent> consumer)
    Creates a new menu button from a configuration section with localization support, overriding the slot, using the sender's locale.
    static @NotNull MenuButton
    createLocalized(int slot, @NotNull org.bukkit.configuration.ConfigurationSection section, @NotNull org.bukkit.command.CommandSender sender, @Nullable UnaryOperator<String> transformer, @Nullable Consumer<org.bukkit.event.inventory.InventoryClickEvent> consumer)
    Creates a new menu button from a configuration section with localization support, overriding the slot, using the sender's locale.
    static @NotNull MenuButton
    createLocalized(int slot, @NotNull org.bukkit.configuration.ConfigurationSection section, @Nullable Locale locale, @Nullable Consumer<org.bukkit.event.inventory.InventoryClickEvent> consumer)
    Creates a new menu button from a configuration section with localization support, overriding the slot.
    static @NotNull MenuButton
    createLocalized(int slot, @NotNull org.bukkit.configuration.ConfigurationSection section, @Nullable Locale locale, @Nullable UnaryOperator<String> transformer, @Nullable Consumer<org.bukkit.event.inventory.InventoryClickEvent> consumer)
    Creates a new menu button from a configuration section with localization support, overriding the slot.
    static @NotNull MenuButton
    createLocalized(@NotNull org.bukkit.configuration.ConfigurationSection section, @NotNull org.bukkit.command.CommandSender sender, @Nullable Consumer<org.bukkit.event.inventory.InventoryClickEvent> consumer)
    Creates a new menu button from a configuration section with localization support, using the sender's locale.
    static @NotNull MenuButton
    createLocalized(@NotNull org.bukkit.configuration.ConfigurationSection section, @NotNull org.bukkit.command.CommandSender sender, @Nullable UnaryOperator<String> transformer, @Nullable Consumer<org.bukkit.event.inventory.InventoryClickEvent> consumer)
    Creates a new menu button from a configuration section with localization support, using the sender's locale.
    static @NotNull MenuButton
    createLocalized(@NotNull org.bukkit.configuration.ConfigurationSection section, @Nullable Locale locale, @Nullable Consumer<org.bukkit.event.inventory.InventoryClickEvent> consumer)
    Creates a new menu button from a configuration section with localization support.
    static @NotNull MenuButton
    createLocalized(@NotNull org.bukkit.configuration.ConfigurationSection section, @Nullable Locale locale, @Nullable UnaryOperator<String> transformer, @Nullable Consumer<org.bukkit.event.inventory.InventoryClickEvent> consumer)
    Creates a new menu button from a configuration section with localization support.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MenuButton

      public MenuButton()
  • Method Details

    • create

      @NotNull public static @NotNull MenuButton create(int slot, @NotNull @NotNull org.bukkit.inventory.ItemStack stack, @Nullable @Nullable Consumer<org.bukkit.event.inventory.InventoryClickEvent> consumer)
      Creates a new menu button.
      Parameters:
      slot - The slot the button should show up in. Must be less than the inventory size minus 1. Note that inventory slots start at 0. In single-page menus, this button will be ignored and not be placed inside the menu if the slot is negative. In paged menus, this slot must be set to -1. If it is higher, the button will be placed in the specified slot on the first page. If it is lower, the button will not be placed
      stack - The item stack of the button
      consumer - The consumer for the InventoryClickEvent, which will be accepted when this button is clicked
      Returns:
      The button
    • create

      @NotNull public static @NotNull MenuButton create(@NotNull @NotNull org.bukkit.configuration.ConfigurationSection section, @Nullable @Nullable UnaryOperator<String> translator, @Nullable @Nullable Consumer<org.bukkit.event.inventory.InventoryClickEvent> consumer)
      Creates a new menu button from a configuration section. The slot value must be an integer named slot. See ItemSerializer for the format of item stacks. The slot will always be subtracted by 1.
      Parameters:
      section - The configuration section containing the button information
      translator - The translator for strings in the item
      consumer - The consumer for the button
      Returns:
      The button from config
    • create

      @NotNull public static @NotNull MenuButton create(@NotNull @NotNull org.bukkit.configuration.ConfigurationSection section, @Nullable @Nullable Consumer<org.bukkit.event.inventory.InventoryClickEvent> consumer)
      Creates a new menu button from a configuration section. The slot value must be an integer named slot. See ItemSerializer for the format of item stacks. The slot will always be subtracted by 1.
      Parameters:
      section - The configuration section containing the button information
      consumer - The consumer for the button
      Returns:
      The button from config
    • create

      @NotNull public static @NotNull MenuButton create(int slot, @NotNull @NotNull org.bukkit.configuration.ConfigurationSection section, @Nullable @Nullable UnaryOperator<String> translator, @Nullable @Nullable Consumer<org.bukkit.event.inventory.InventoryClickEvent> consumer)
      Creates a new menu button from a configuration section, but overrides any slot values the configuration section may have. Unlike create(ConfigurationSection, Consumer), the slot is not subtracted 1. See ItemSerializer for the format of item stacks.
      Parameters:
      slot - The slot of the button
      section - The configuration section containing the button information
      translator - The translator for strings in the tiem
      consumer - The consumer for the button
      Returns:
      The button from config
    • create

      @NotNull public static @NotNull MenuButton create(int slot, @NotNull @NotNull org.bukkit.configuration.ConfigurationSection section, @Nullable @Nullable Consumer<org.bukkit.event.inventory.InventoryClickEvent> consumer)
      Creates a new menu button from a configuration section, but overrides any slot values the configuration section may have. Unlike create(ConfigurationSection, Consumer), the slot is not subtracted 1. See ItemSerializer for the format of item stacks.
      Parameters:
      slot - The slot of the button
      section - The configuration section containing the button information
      consumer - The consumer for the button
      Returns:
      The button from config
    • createLocalized

      @NotNull public static @NotNull MenuButton createLocalized(@NotNull @NotNull org.bukkit.configuration.ConfigurationSection section, @Nullable @Nullable Locale locale, @Nullable @Nullable UnaryOperator<String> transformer, @Nullable @Nullable Consumer<org.bukkit.event.inventory.InventoryClickEvent> consumer)
      Creates a new menu button from a configuration section with localization support. Translation key placeholders (#{key}) in item strings will be resolved using the given locale. The slot will always be subtracted by 1.
      Parameters:
      section - The configuration section containing the button information
      locale - The locale to use for localization
      transformer - Additional transformer for strings in the item, applied after localization
      consumer - The consumer for the button
      Returns:
      The button from config
    • createLocalized

      @NotNull public static @NotNull MenuButton createLocalized(@NotNull @NotNull org.bukkit.configuration.ConfigurationSection section, @Nullable @Nullable Locale locale, @Nullable @Nullable Consumer<org.bukkit.event.inventory.InventoryClickEvent> consumer)
      Creates a new menu button from a configuration section with localization support. Translation key placeholders (#{key}) in item strings will be resolved using the given locale. The slot will always be subtracted by 1.
      Parameters:
      section - The configuration section containing the button information
      locale - The locale to use for localization
      consumer - The consumer for the button
      Returns:
      The button from config
    • createLocalized

      @NotNull public static @NotNull MenuButton createLocalized(@NotNull @NotNull org.bukkit.configuration.ConfigurationSection section, @NotNull @NotNull org.bukkit.command.CommandSender sender, @Nullable @Nullable UnaryOperator<String> transformer, @Nullable @Nullable Consumer<org.bukkit.event.inventory.InventoryClickEvent> consumer)
      Creates a new menu button from a configuration section with localization support, using the sender's locale. The slot will always be subtracted by 1.
      Parameters:
      section - The configuration section containing the button information
      sender - The command sender whose locale will be used
      transformer - Additional transformer for strings in the item, applied after localization
      consumer - The consumer for the button
      Returns:
      The button from config
    • createLocalized

      @NotNull public static @NotNull MenuButton createLocalized(@NotNull @NotNull org.bukkit.configuration.ConfigurationSection section, @NotNull @NotNull org.bukkit.command.CommandSender sender, @Nullable @Nullable Consumer<org.bukkit.event.inventory.InventoryClickEvent> consumer)
      Creates a new menu button from a configuration section with localization support, using the sender's locale. The slot will always be subtracted by 1.
      Parameters:
      section - The configuration section containing the button information
      sender - The command sender whose locale will be used
      consumer - The consumer for the button
      Returns:
      The button from config
    • createLocalized

      @NotNull public static @NotNull MenuButton createLocalized(int slot, @NotNull @NotNull org.bukkit.configuration.ConfigurationSection section, @Nullable @Nullable Locale locale, @Nullable @Nullable UnaryOperator<String> transformer, @Nullable @Nullable Consumer<org.bukkit.event.inventory.InventoryClickEvent> consumer)
      Creates a new menu button from a configuration section with localization support, overriding the slot. Unlike the non-slot variant, the slot is not subtracted by 1.
      Parameters:
      slot - The slot of the button
      section - The configuration section containing the button information
      locale - The locale to use for localization
      transformer - Additional transformer for strings in the item
      consumer - The consumer for the button
      Returns:
      The button from config
    • createLocalized

      @NotNull public static @NotNull MenuButton createLocalized(int slot, @NotNull @NotNull org.bukkit.configuration.ConfigurationSection section, @Nullable @Nullable Locale locale, @Nullable @Nullable Consumer<org.bukkit.event.inventory.InventoryClickEvent> consumer)
      Creates a new menu button from a configuration section with localization support, overriding the slot. Unlike the non-slot variant, the slot is not subtracted by 1.
      Parameters:
      slot - The slot of the button
      section - The configuration section containing the button information
      locale - The locale to use for localization
      consumer - The consumer for the button
      Returns:
      The button from config
    • createLocalized

      @NotNull public static @NotNull MenuButton createLocalized(int slot, @NotNull @NotNull org.bukkit.configuration.ConfigurationSection section, @NotNull @NotNull org.bukkit.command.CommandSender sender, @Nullable @Nullable UnaryOperator<String> transformer, @Nullable @Nullable Consumer<org.bukkit.event.inventory.InventoryClickEvent> consumer)
      Creates a new menu button from a configuration section with localization support, overriding the slot, using the sender's locale. Unlike the non-slot variant, the slot is not subtracted by 1.
      Parameters:
      slot - The slot of the button
      section - The configuration section containing the button information
      sender - The command sender whose locale will be used
      transformer - Additional transformer for strings in the item
      consumer - The consumer for the button
      Returns:
      The button from config
    • createLocalized

      @NotNull public static @NotNull MenuButton createLocalized(int slot, @NotNull @NotNull org.bukkit.configuration.ConfigurationSection section, @NotNull @NotNull org.bukkit.command.CommandSender sender, @Nullable @Nullable Consumer<org.bukkit.event.inventory.InventoryClickEvent> consumer)
      Creates a new menu button from a configuration section with localization support, overriding the slot, using the sender's locale. Unlike the non-slot variant, the slot is not subtracted by 1.
      Parameters:
      slot - The slot of the button
      section - The configuration section containing the button information
      sender - The command sender whose locale will be used
      consumer - The consumer for the button
      Returns:
      The button from config