Refactoring for naming, updated to 6.47.0

This commit is contained in:
Auxilor
2022-11-23 21:56:07 +00:00
parent eccb146852
commit 823ef6477b
10 changed files with 33 additions and 32 deletions

View File

@@ -51,14 +51,14 @@ public abstract class CustomSlot implements Slot {
}
@Override
public final boolean canCaptivateItem(@NotNull final Player player,
public final boolean isAllowedCaptive(@NotNull final Player player,
@NotNull final Menu menu,
@Nullable final ItemStack itemStack) {
if (delegate == null) {
throw new IllegalStateException("Custom Slot was not initialized!");
}
return delegate.canCaptivateItem(player, menu, itemStack);
return delegate.isAllowedCaptive(player, menu, itemStack);
}
@Override

View File

@@ -41,10 +41,10 @@ public abstract class ReactiveSlot implements Slot {
}
@Override
public final boolean canCaptivateItem(@NotNull final Player player,
@NotNull final Menu menu,
@Nullable final ItemStack itemStack) {
return getSlot(player, menu).canCaptivateItem(player, menu, itemStack);
public final boolean isAllowedCaptive(@NotNull final Player player,
@NotNull final Menu menu,
@Nullable final ItemStack itemStack) {
return getSlot(player, menu).isAllowedCaptive(player, menu, itemStack);
}
@Override

View File

@@ -47,14 +47,14 @@ public interface Slot extends GUIComponent {
}
/**
* If the slot is captive for a given item (can this item be placed in it).
* If the slot allows a certain item to be placed in it.
*
* @param player The player.
* @param menu The menu.
* @param itemStack The item; use null if the item is unknown.
* @return If captive.
*/
default boolean canCaptivateItem(@NotNull final Player player,
default boolean isAllowedCaptive(@NotNull final Player player,
@NotNull final Menu menu,
@Nullable final ItemStack itemStack) {
return true;

View File

@@ -1,6 +1,6 @@
package com.willfp.eco.core.gui.slot;
import com.willfp.eco.core.gui.slot.functional.CaptiveCondition;
import com.willfp.eco.core.gui.slot.functional.CaptiveFilter;
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;
@@ -149,10 +149,10 @@ public interface SlotBuilder {
/**
* Set a whitelist for allowed captive items.
*
* @param condition The condition. Returns true when the slot should be captive.
* @param filter The filter.
* @return The builder.
*/
default SlotBuilder setCaptiveCondition(@NotNull final CaptiveCondition condition) {
default SlotBuilder setCaptiveFilter(@NotNull final CaptiveFilter filter) {
return this;
}

View File

@@ -7,19 +7,19 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Interface to test if a captive slot is captive given a player, menu, and item.
* Interface to test if a captive slot is allowed to contain an item given a player and a menu.
*/
@FunctionalInterface
public interface CaptiveCondition {
public interface CaptiveFilter {
/**
* Get if the slot is captive.
* Get if allowed.
*
* @param player The player.
* @param menu The menu.
* @param itemStack The item.
* @return If captive.
*/
boolean isCaptive(@NotNull Player player,
boolean isAllowed(@NotNull Player player,
@NotNull Menu menu,
@Nullable ItemStack itemStack);
}

View File

@@ -74,9 +74,9 @@ fun SlotBuilder.onClick(clickType: ClickType, action: (Player, InventoryClickEve
fun SlotBuilder.notCaptiveFor(test: (Player) -> Boolean): SlotBuilder =
this.notCaptiveFor { test(it) }
/** @see SlotBuilder.setCaptiveCondition */
fun SlotBuilder.setCaptiveCondition(test: (Player, Menu, ItemStack?) -> Boolean): SlotBuilder =
this.setCaptiveCondition { a, b, c -> test(a, b, c) }
/** @see SlotBuilder.setCaptiveFilter */
fun SlotBuilder.setCaptiveFilter(test: (Player, Menu, ItemStack?) -> Boolean): SlotBuilder =
this.setCaptiveFilter { a, b, c -> test(a, b, c) }
/**
* @see SlotBuilder.setModifier