mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 07:20:24 +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);
|
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.
|
* 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;
|
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
|
@Override
|
||||||
public boolean isSimilar(ItemStack stack) {
|
public boolean isSimilar(ItemStack stack) {
|
||||||
if (stack == null) {
|
if (stack == null) {
|
||||||
|
|
Loading…
Reference in a new issue