mirror of
https://github.com/darksaid98/Builders-Utilities.git
synced 2026-12-01 22:14:56 +00:00
* Setup project * Update namespace - Relocate bstats * Some reformatting and documentation * Setup issue templates * chmod+x gradlew * Create pull request template * Apply license * Exclude XMaterial from licensing
60 lines
2.1 KiB
Java
60 lines
2.1 KiB
Java
/*
|
|
* ____ _ _ _ _ _ _ _ _ _ _ _
|
|
* | _ \ (_) | | | | | | | | (_) (_) | (_)
|
|
* | |_) |_ _ _| | __| | ___ _ __ ___ ______| | | | |_ _| |_| |_ _ ___ ___
|
|
* | _ <| | | | | |/ _` |/ _ \ '__/ __|______| | | | __| | | | __| |/ _ \/ __|
|
|
* | |_) | |_| | | | (_| | __/ | \__ \ | |__| | |_| | | | |_| | __/\__ \
|
|
* |____/ \__,_|_|_|\__,_|\___|_| |___/ \____/ \__|_|_|_|\__|_|\___||___/
|
|
*
|
|
* Builder's Utilities is a collection of a lot of tiny features that help with building.
|
|
* Copyright (C) 2020 Arcaniax
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
package net.arcaniax.buildersutilities.menus.inv;
|
|
|
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
|
import org.bukkit.inventory.ItemStack;
|
|
|
|
import java.util.function.Consumer;
|
|
|
|
public class ClickableItem {
|
|
|
|
private final ItemStack item;
|
|
private final Consumer<InventoryClickEvent> consumer;
|
|
|
|
private ClickableItem(ItemStack item, Consumer<InventoryClickEvent> consumer) {
|
|
this.item = item;
|
|
this.consumer = consumer;
|
|
}
|
|
|
|
public static ClickableItem empty(ItemStack item) {
|
|
return of(item, e -> {
|
|
});
|
|
}
|
|
|
|
public static ClickableItem of(ItemStack item, Consumer<InventoryClickEvent> consumer) {
|
|
return new ClickableItem(item, consumer);
|
|
}
|
|
|
|
public void run(InventoryClickEvent e) {
|
|
consumer.accept(e);
|
|
}
|
|
|
|
public ItemStack getItem() {
|
|
return item;
|
|
}
|
|
|
|
}
|