mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-27 23:10:16 +01:00
Add ItemStack#effectiveName
This commit is contained in:
parent
2e97b7fe6b
commit
e4c48cb651
2 changed files with 18 additions and 0 deletions
|
@ -710,6 +710,17 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat
|
|||
return Bukkit.getServer().getItemFactory().displayName(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the effective name of this item stack shown to player in inventory.
|
||||
* It takes into account the display name (with italics) from the item meta,
|
||||
* the potion effect, translatable name, rarity etc.
|
||||
*
|
||||
* @return the effective name of this item stack
|
||||
*/
|
||||
public net.kyori.adventure.text.@NotNull Component effectiveName() {
|
||||
return this.craftDelegate.effectiveName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Minecraft updates are converting simple item stacks into more complex NBT oriented Item Stacks.
|
||||
*
|
||||
|
|
|
@ -467,6 +467,13 @@ public final class CraftItemStack extends ItemStack {
|
|||
return true;
|
||||
}
|
||||
|
||||
// Paper start - add ItemStack#effectiveName
|
||||
@Override
|
||||
public net.kyori.adventure.text.Component effectiveName() {
|
||||
return this.handle == null ? net.kyori.adventure.text.Component.empty() : io.papermc.paper.adventure.PaperAdventure.asAdventure(this.handle.getStyledHoverName());
|
||||
}
|
||||
// Paper end - add ItemStack#effectiveName
|
||||
|
||||
@Override
|
||||
public boolean isSimilar(ItemStack stack) {
|
||||
if (stack == null) {
|
||||
|
|
Loading…
Reference in a new issue