mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
Add predicate to recipe's ExactChoice ingredient
This commit is contained in:
committed by
granny
parent
97d90df5da
commit
32db32c5ae
@@ -1,44 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
||||
Date: Fri, 2 Oct 2020 17:43:24 -0500
|
||||
Subject: [PATCH] Add predicate to recipe's ExactChoice ingredient
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/inventory/RecipeChoice.java b/src/main/java/org/bukkit/inventory/RecipeChoice.java
|
||||
index 922bb69b5f218e489a6dd5e0f207743c1f1d3d35..9b3e292be334d21eb978373f434bf3811ec4af2b 100644
|
||||
--- a/src/main/java/org/bukkit/inventory/RecipeChoice.java
|
||||
+++ b/src/main/java/org/bukkit/inventory/RecipeChoice.java
|
||||
@@ -191,6 +191,7 @@ public interface RecipeChoice extends Predicate<ItemStack>, Cloneable {
|
||||
public static class ExactChoice implements RecipeChoice {
|
||||
|
||||
private List<ItemStack> choices;
|
||||
+ private Predicate<ItemStack> predicate; // Purpur
|
||||
|
||||
public ExactChoice(@NotNull ItemStack stack) {
|
||||
this(Arrays.asList(stack));
|
||||
@@ -241,6 +242,7 @@ public interface RecipeChoice extends Predicate<ItemStack>, Cloneable {
|
||||
|
||||
@Override
|
||||
public boolean test(@NotNull ItemStack t) {
|
||||
+ if (predicate != null) return predicate.test(t); // Purpur
|
||||
for (ItemStack match : choices) {
|
||||
if (t.isSimilar(match)) {
|
||||
return true;
|
||||
@@ -250,6 +252,17 @@ public interface RecipeChoice extends Predicate<ItemStack>, Cloneable {
|
||||
return false;
|
||||
}
|
||||
|
||||
+ // Purpur start
|
||||
+ @org.jetbrains.annotations.Nullable
|
||||
+ public Predicate<ItemStack> getPredicate() {
|
||||
+ return predicate;
|
||||
+ }
|
||||
+
|
||||
+ public void setPredicate(@org.jetbrains.annotations.Nullable Predicate<ItemStack> predicate) {
|
||||
+ this.predicate = predicate;
|
||||
+ }
|
||||
+ // Purpur end
|
||||
+
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 7;
|
||||
Reference in New Issue
Block a user