All Downloads are FREE. Search and download functionalities are using the official Maven repository.

me.huanmeng.opensource.bukkit.gui.button.Button Maven / Gradle / Ivy

There is a newer version: 2.2.2
Show newest version
package me.huanmeng.opensource.bukkit.gui.button;

import me.huanmeng.opensource.bukkit.gui.AbstractGui;
import me.huanmeng.opensource.bukkit.gui.button.function.PlayerClickCancelInterface;
import me.huanmeng.opensource.bukkit.gui.button.function.PlayerClickInterface;
import me.huanmeng.opensource.bukkit.gui.button.function.PlayerItemInterface;
import me.huanmeng.opensource.bukkit.gui.button.function.PlayerSimpleCancelInterface;
import me.huanmeng.opensource.bukkit.gui.enums.Result;
import me.huanmeng.opensource.bukkit.gui.slot.Slot;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.ItemStack;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.jetbrains.annotations.Contract;

import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * 2023/3/17
* Gui
* * @author huanmeng_qwq */ @SuppressWarnings("unused") @FunctionalInterface public interface Button { /** * 获取显示物品 * * @param player 玩家 * @return 物品 */ @Nullable ItemStack getShowItem(@NonNull Player player); /** * 空按钮 */ Button EMPTY = (p) -> null; @NonNull default Result onClick(@NonNull AbstractGui gui, @NonNull Slot slot, @NonNull Player player, @NonNull ClickType click, @NonNull InventoryAction action, InventoryType.@NonNull SlotType slotType, int slotKey, int hotBarKey, @NonNull InventoryClickEvent e) { return Result.CANCEL; } /** * 展示型按钮 * * @param item 物品 * @return {@link Button} */ @Contract(value = "!null -> new", pure = true) static Button of(PlayerItemInterface item) { return new EmptyButton(item); } /** * 点击型按钮 * * @param item 物品 * @param clickable 点击事件 * @return {@link Button} */ @Contract(value = "null, null -> new", pure = true) static Button of(PlayerItemInterface item, PlayerClickInterface clickable) { return new ClickButton(item, clickable); } /** * 点击型按钮 * * @param item 物品 * @param clickable 点击事件 * @return {@link Button} */ @Contract(value = "null, !null, null -> new", pure = true) static <@NonNull T extends PlayerClickInterface> Button of(PlayerItemInterface item, Class cls, T clickable) { return new ClickButton(item, clickable); } /** * 点击型按钮 * * @param item 物品 * @param clickable 点击事件 * @return {@link Button} */ @Contract(value = "null, null -> new", pure = true) static Button of(PlayerItemInterface item, PlayerClickCancelInterface clickable) { return new ClickButton(item, clickable); } /** * 点击型按钮 * * @param item 物品 * @param playerSimpleCancelInterface 点击事件 * @return {@link Button} */ @Contract(value = "null, null -> new", pure = true) static Button of(PlayerItemInterface item, PlayerSimpleCancelInterface playerSimpleCancelInterface) { return new ClickButton(item, playerSimpleCancelInterface); } /** * 点击型按钮 * * @param impl 实现了{@link PlayerItemInterface}和{@link PlayerClickInterface}的类 * @param 实现了{@link PlayerItemInterface}和{@link PlayerClickInterface}的类 * @return {@link Button} */ @Contract(value = "null -> new", pure = true) static <@NonNull IMPL extends PlayerItemInterface & PlayerClickInterface> Button ofInstance(IMPL impl) { return new ClickButton(impl, impl); } /** * 点击型按钮 * * @param impl 实现了{@link PlayerItemInterface}和{@link PlayerClickInterface}的类 * @param 实现了{@link PlayerItemInterface}和{@link PlayerClickInterface}的类 * @return {@link Button} */ @NonNull static <@NonNull IMPL extends PlayerItemInterface & PlayerClickInterface> List




© 2015 - 2024 Weber Informatics LLC | Privacy Policy