forked from PurpurMC/Purpur
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PaperMC/Paper#9996 I merged this change, added @NotNull tags to get the API to build, and deleted the existing Purpur item predicate API since it was conflicting.
- Loading branch information
1 parent
9ac3b40
commit b822661
Showing
254 changed files
with
493 additions
and
298 deletions.
There are no files selected for viewing
52 changes: 0 additions & 52 deletions
52
patches/api/0023-Add-predicate-to-recipe-s-ExactChoice-ingredient.patch
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
78 changes: 78 additions & 0 deletions
78
patches/api/0055-Adding-PredicateChoice-to-Paper-API.patch
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,78 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: derverdox <[email protected]> | ||
Date: Mon, 4 Dec 2023 01:54:38 +0100 | ||
Subject: [PATCH] Adding PredicateChoice to Paper API | ||
|
||
|
||
diff --git a/src/main/java/org/bukkit/inventory/RecipeChoice.java b/src/main/java/org/bukkit/inventory/RecipeChoice.java | ||
index 523818cbb0d6c90481ec97123e7fe0e2ff4eea14..63fa194621b68f3c25567a1acb59d08b0506bdd2 100644 | ||
--- a/src/main/java/org/bukkit/inventory/RecipeChoice.java | ||
+++ b/src/main/java/org/bukkit/inventory/RecipeChoice.java | ||
@@ -233,4 +233,67 @@ public interface RecipeChoice extends Predicate<ItemStack>, Cloneable { | ||
return "ExactChoice{" + "choices=" + choices + '}'; | ||
} | ||
} | ||
+ | ||
+ /** | ||
+ * Represents a choice that matches when the item predicate is fulfilled. | ||
+ */ | ||
+ public static class PredicateChoice implements RecipeChoice { | ||
+ private final ItemPredicate itemPredicate; | ||
+ | ||
+ public PredicateChoice(@NotNull ItemPredicate itemPredicate) { | ||
+ Preconditions.checkArgument(itemPredicate != null, "itemPredicate"); | ||
+ Preconditions.checkArgument(!itemPredicate.recipeBookExamples().isEmpty(), "Must have at least one template"); | ||
+ this.itemPredicate = itemPredicate; | ||
+ } | ||
+ | ||
+ @NotNull | ||
+ @Override | ||
+ public final boolean test(final @NotNull ItemStack stack) { | ||
+ return itemPredicate.test(stack); | ||
+ } | ||
+ | ||
+ @Override | ||
+ public @NotNull ItemStack getItemStack() { | ||
+ ItemStack stack = new ItemStack(itemPredicate.recipeBookExamples().get(0)); | ||
+ // For compat | ||
+ if (itemPredicate.recipeBookExamples().size() > 1) { | ||
+ stack.setDurability(Short.MAX_VALUE); | ||
+ } | ||
+ | ||
+ return stack; | ||
+ } | ||
+ | ||
+ @NotNull | ||
+ @Override | ||
+ public PredicateChoice clone() { | ||
+ return new PredicateChoice(new ItemPredicate() { | ||
+ @NotNull | ||
+ @Override | ||
+ public List<@NotNull ItemStack> recipeBookExamples() { | ||
+ return List.copyOf(itemPredicate.recipeBookExamples()); | ||
+ } | ||
+ | ||
+ @Override | ||
+ public boolean test(final @NotNull ItemStack stack) { | ||
+ return itemPredicate.test(stack); | ||
+ } | ||
+ }); | ||
+ } | ||
+ | ||
+ public @NotNull ItemPredicate getItemPredicate() { | ||
+ return itemPredicate; | ||
+ } | ||
+ | ||
+ @Override | ||
+ public boolean equals(final Object o) { | ||
+ if (this == o) return true; | ||
+ if (o == null || getClass() != o.getClass()) return false; | ||
+ PredicateChoice that = (PredicateChoice) o; | ||
+ return Objects.equals(itemPredicate, that.itemPredicate); | ||
+ } | ||
+ | ||
+ public static interface ItemPredicate extends Predicate<ItemStack> { | ||
+ List<@NotNull ItemStack> recipeBookExamples(); | ||
+ } | ||
+ } | ||
} |
43 changes: 0 additions & 43 deletions
43
patches/server/0093-Add-predicate-to-recipe-s-ExactChoice-ingredient.patch
This file was deleted.
Oops, something went wrong.
File renamed without changes.
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
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
File renamed without changes.
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
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
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
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
File renamed without changes.
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
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
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
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
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
Oops, something went wrong.