Added captive defaults
This commit is contained in:
@@ -2,10 +2,12 @@ package com.willfp.eco.core.gui.slot;
|
||||
|
||||
import com.willfp.eco.core.Eco;
|
||||
import com.willfp.eco.core.gui.slot.functional.SlotProvider;
|
||||
import com.willfp.eco.core.items.TestableItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
@@ -28,6 +30,14 @@ public interface Slot {
|
||||
*/
|
||||
boolean isCaptive();
|
||||
|
||||
/**
|
||||
* Get default captive item.
|
||||
*
|
||||
* @param player The player.
|
||||
* @return The item, or null if no captive default was found.
|
||||
*/
|
||||
@Nullable TestableItem getCaptiveDefault(@NotNull Player player);
|
||||
|
||||
/**
|
||||
* Create a builder for an ItemStack.
|
||||
*
|
||||
|
||||
@@ -3,10 +3,14 @@ package com.willfp.eco.core.gui.slot;
|
||||
import com.willfp.eco.core.gui.slot.functional.SlotHandler;
|
||||
import com.willfp.eco.core.gui.slot.functional.SlotModifier;
|
||||
import com.willfp.eco.core.gui.slot.functional.SlotUpdater;
|
||||
import com.willfp.eco.core.items.TestableItem;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* Builder to create slots.
|
||||
@@ -130,7 +134,17 @@ public interface SlotBuilder {
|
||||
*
|
||||
* @return The builder.
|
||||
*/
|
||||
SlotBuilder setCaptive();
|
||||
default SlotBuilder setCaptive() {
|
||||
return setCaptive(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set slot to be a captive default with a default provider.
|
||||
*
|
||||
* @param provider The provider.
|
||||
* @return The builder.
|
||||
*/
|
||||
SlotBuilder setCaptive(@Nullable Function<Player, TestableItem> provider);
|
||||
|
||||
/**
|
||||
* Build the slot.
|
||||
|
||||
Reference in New Issue
Block a user