namespace Minecraft.Server.FourKit.Inventory.Meta; /// /// Represents the metadata of an , including display name and lore. /// public class ItemMeta { private string? _displayName; private List? _lore; /// /// Checks for existence of a display name. /// /// true if this has a display name. public bool hasDisplayName() => _displayName != null; /// /// Gets the display name that is set. /// Plugins should check that hasDisplayName() returns true before calling this method. /// /// The display name that is set. public string getDisplayName() => _displayName ?? string.Empty; /// /// Sets the display name. /// /// The name to set. public void setDisplayName(string? name) => _displayName = name; /// /// Checks for existence of lore. /// /// true if this has lore. public bool hasLore() => _lore != null && _lore.Count > 0; /// /// Gets the lore that is set. /// Plugins should check if hasLore() returns true before calling this method. /// /// A list of lore that is set. public List getLore() => _lore != null ? new List(_lore) : new List(); /// /// Sets the lore for this item. Removes lore when given null. /// /// The lore that will be set. public void setLore(List? lore) { _lore = lore != null ? new List(lore) : null; } public ItemMeta clone() { var copy = new ItemMeta(); copy._displayName = _displayName; copy._lore = _lore != null ? new List(_lore) : null; return copy; } internal bool isEmpty() { return _displayName == null && (_lore == null || _lore.Count == 0); } }