geforkt von Mirrors/Paper
d33cdcf2e6
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: e25c6a75 PR-638: Add CreativeCategory API for Materials CraftBukkit Changes: 86292d3e0 PR-876: Add CreativeCategory API for Materials
60 Zeilen
2.7 KiB
Diff
60 Zeilen
2.7 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
|
Date: Sat, 15 May 2021 22:10:50 -0700
|
|
Subject: [PATCH] ItemStack repair check API
|
|
|
|
|
|
diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java
|
|
index 2708718e0391960f9e784f38e5753d95e71de2fc..93d139cd498d0c9f616c077ce1c25e3f8e9f55b5 100644
|
|
--- a/src/main/java/org/bukkit/UnsafeValues.java
|
|
+++ b/src/main/java/org/bukkit/UnsafeValues.java
|
|
@@ -165,6 +165,16 @@ public interface UnsafeValues {
|
|
*/
|
|
public io.papermc.paper.inventory.ItemRarity getItemStackRarity(ItemStack itemStack);
|
|
|
|
+ /**
|
|
+ * Checks if an itemstack can be repaired with another itemstack.
|
|
+ * Returns false if either argument's type is not an item ({@link Material#isItem()}).
|
|
+ *
|
|
+ * @param itemToBeRepaired the itemstack to be repaired
|
|
+ * @param repairMaterial the repair material
|
|
+ * @return true if valid repair, false if not
|
|
+ */
|
|
+ public boolean isValidRepairItemStack(@org.jetbrains.annotations.NotNull ItemStack itemToBeRepaired, @org.jetbrains.annotations.NotNull ItemStack repairMaterial);
|
|
+
|
|
/**
|
|
* Returns the server's protocol version.
|
|
*
|
|
diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java
|
|
index ebc44aae46d67ae565eeafb5bb3af74bbc88dbc1..e126c45a4184cd637c94b55c5eb14fe4b5afe32e 100644
|
|
--- a/src/main/java/org/bukkit/inventory/ItemStack.java
|
|
+++ b/src/main/java/org/bukkit/inventory/ItemStack.java
|
|
@@ -890,5 +890,27 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, net.kyor
|
|
public io.papermc.paper.inventory.ItemRarity getRarity() {
|
|
return Bukkit.getUnsafe().getItemStackRarity(this);
|
|
}
|
|
+
|
|
+ /**
|
|
+ * Checks if an itemstack can repair this itemstack.
|
|
+ * Returns false if {@code this} or {@code repairMaterial}'s type is not an item ({@link Material#isItem()}).
|
|
+ *
|
|
+ * @param repairMaterial the repair material
|
|
+ * @return true if it is repairable by, false if not
|
|
+ */
|
|
+ public boolean isRepairableBy(@NotNull ItemStack repairMaterial) {
|
|
+ return Bukkit.getUnsafe().isValidRepairItemStack(this, repairMaterial);
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Checks if this itemstack can repair another.
|
|
+ * Returns false if {@code this} or {@code toBeRepaired}'s type is not an item ({@link Material#isItem()}).
|
|
+ *
|
|
+ * @param toBeRepaired the itemstack to be repaired
|
|
+ * @return true if it can repair, false if not
|
|
+ */
|
|
+ public boolean canRepair(@NotNull ItemStack toBeRepaired) {
|
|
+ return Bukkit.getUnsafe().isValidRepairItemStack(toBeRepaired, this);
|
|
+ }
|
|
// Paper end
|
|
}
|