Package dev.demeng.pluginbase.menu.model
Class MenuButton
java.lang.Object
dev.demeng.pluginbase.menu.model.MenuButton
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 -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull MenuButtoncreate(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 MenuButtoncreate(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 MenuButtoncreate(int slot, @NotNull org.bukkit.inventory.ItemStack stack, @Nullable Consumer<org.bukkit.event.inventory.InventoryClickEvent> consumer) Creates a new menu button.static @NotNull MenuButtoncreate(@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 MenuButtoncreate(@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 MenuButtoncreateLocalized(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 MenuButtoncreateLocalized(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 MenuButtoncreateLocalized(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 MenuButtoncreateLocalized(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 MenuButtoncreateLocalized(@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 MenuButtoncreateLocalized(@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 MenuButtoncreateLocalized(@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 MenuButtoncreateLocalized(@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.
-
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 placedstack- The item stack of the buttonconsumer- The consumer for theInventoryClickEvent, 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 namedslot. SeeItemSerializerfor the format of item stacks. The slot will always be subtracted by 1.- Parameters:
section- The configuration section containing the button informationtranslator- The translator for strings in the itemconsumer- 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 namedslot. SeeItemSerializerfor the format of item stacks. The slot will always be subtracted by 1.- Parameters:
section- The configuration section containing the button informationconsumer- 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. Unlikecreate(ConfigurationSection, Consumer), the slot is not subtracted 1. SeeItemSerializerfor the format of item stacks.- Parameters:
slot- The slot of the buttonsection- The configuration section containing the button informationtranslator- The translator for strings in the tiemconsumer- 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. Unlikecreate(ConfigurationSection, Consumer), the slot is not subtracted 1. SeeItemSerializerfor the format of item stacks.- Parameters:
slot- The slot of the buttonsection- The configuration section containing the button informationconsumer- 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 informationlocale- The locale to use for localizationtransformer- Additional transformer for strings in the item, applied after localizationconsumer- 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 informationlocale- The locale to use for localizationconsumer- 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 informationsender- The command sender whose locale will be usedtransformer- Additional transformer for strings in the item, applied after localizationconsumer- 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 informationsender- The command sender whose locale will be usedconsumer- 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 buttonsection- The configuration section containing the button informationlocale- The locale to use for localizationtransformer- Additional transformer for strings in the itemconsumer- 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 buttonsection- The configuration section containing the button informationlocale- The locale to use for localizationconsumer- 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 buttonsection- The configuration section containing the button informationsender- The command sender whose locale will be usedtransformer- Additional transformer for strings in the itemconsumer- 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 buttonsection- The configuration section containing the button informationsender- The command sender whose locale will be usedconsumer- The consumer for the button- Returns:
- The button from config
-