geforkt von Mirrors/Paper
ItemStack repair check API
Dieser Commit ist enthalten in:
Ursprung
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
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren