mirror of
https://github.com/PaperMC/Paper.git
synced 2025-03-02 11:22:01 +01:00
ItemStack repair check API
This commit is contained in:
parent
d30a14d638
commit
fce24f3b52
@ -187,5 +187,15 @@ public interface UnsafeValues {
|
||||
* @return the server's protocol version
|
||||
*/
|
||||
int getProtocolVersion();
|
||||
|
||||
/**
|
||||
* 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);
|
||||
// Paper end
|
||||
}
|
||||
|
@ -1006,5 +1006,27 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat
|
||||
public io.papermc.paper.inventory.ItemRarity getRarity() {
|
||||
return io.papermc.paper.inventory.ItemRarity.valueOf(this.getItemMeta().getRarity().name());
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user