Add effective name to ItemStack (#11770)
This commit is contained in:
@ -5,6 +5,7 @@ import com.google.common.collect.ImmutableMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
@ -710,6 +711,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 @NotNull Component effectiveName() {
|
||||
return this.craftDelegate.effectiveName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Minecraft updates are converting simple item stacks into more complex NBT oriented Item Stacks.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user