-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for enchantments in recipes
- Loading branch information
Showing
2 changed files
with
121 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
eco-api/src/main/java/com/willfp/eco/core/recipe/parts/ModifiedTestableItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package com.willfp.eco.core.recipe.parts; | ||
|
||
import com.willfp.eco.core.items.TestableItem; | ||
import lombok.Getter; | ||
import org.bukkit.inventory.ItemStack; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.function.Predicate; | ||
|
||
public class ModifiedTestableItem implements TestableItem { | ||
/** | ||
* The item. | ||
*/ | ||
private final TestableItem handle; | ||
|
||
/** | ||
* The amount. | ||
*/ | ||
@Getter | ||
private final Predicate<ItemStack> test; | ||
|
||
/** | ||
* The item for the modified test. | ||
*/ | ||
private final ItemStack example; | ||
|
||
/** | ||
* Create a new modified testable item. | ||
* | ||
* @param item The item. | ||
* @param test The test. | ||
* @param example The example. | ||
*/ | ||
public ModifiedTestableItem(@NotNull final TestableItem item, | ||
@NotNull final Predicate<ItemStack> test, | ||
@NotNull final ItemStack example) { | ||
this.handle = item; | ||
this.test = test; | ||
this.example = example; | ||
} | ||
|
||
/** | ||
* If the item matches the material. | ||
* | ||
* @param itemStack The item to test. | ||
* @return If the item is of the specified material. | ||
*/ | ||
@Override | ||
public boolean matches(@Nullable final ItemStack itemStack) { | ||
return itemStack != null && handle.matches(itemStack) && test.test(itemStack); | ||
} | ||
|
||
@Override | ||
public ItemStack getItem() { | ||
return example; | ||
} | ||
} |