mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-01 16:29:45 +01:00
fe53b0e76f
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: 1d522878 PR-966: Introduce getRespawnLocation as a replacement for getBedSpawnLocation cc01b745 PR-965: Add DragonBattle#setPreviouslyKilled 28e3702f SPIGOT-6921, PR-957: Add methods to remove all enchantments on an ItemStack 8872404e PR-961: Add BlockData#copyTo 4054cc7b PR-956: Add method to get an offline player's location CraftBukkit Changes: 292ec79e0 SPIGOT-7568: Call EntityChangeBlockEvent for DecoratedPot b44bf5aa8 SPIGOT-7575: SuspiciousStewMeta creates invalid PotionEffect data 161784713 PR-1340: Centralize the conversion from and to Minecraft / Bukkit registry items even more and add a test case for them b93c5a30d PR-1338: Introduce getRespawnLocation as a replacement for getBedSpawnLocation fb973486c SPIGOT-7570: PrepareItemCraftEvent#isRepair() always returns false c9c24535e PR-1337: Add DragonBattle#setPreviouslyKilled c8b4da803 SPIGOT-6921, PR-1330: Add methods to remove all enchantments on an ItemStack 95bc1c4f5 PR-1333: Add BlockData#copyTo 36e2f9ce1 PR-1329: Add method to get an offline player's location Spigot Changes: c198da22 SPIGOT-7563: Update to latest release of bungeecord-chat
60 lines
2.7 KiB
Diff
60 lines
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 3ae23a15a2c8757d3003041425ced583187d3d21..6b8013b072c9ca0a6f5ba86f37de3744fc70979e 100644
|
|
--- a/src/main/java/org/bukkit/UnsafeValues.java
|
|
+++ b/src/main/java/org/bukkit/UnsafeValues.java
|
|
@@ -168,6 +168,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 569f67ee3f89d6af4fe1420cecc74811550b6507..78ea59c8f63b5a71ba092cf1783183bb5d0a3b79 100644
|
|
--- a/src/main/java/org/bukkit/inventory/ItemStack.java
|
|
+++ b/src/main/java/org/bukkit/inventory/ItemStack.java
|
|
@@ -898,5 +898,27 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat
|
|
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
|
|
}
|