Skip to content

Commit

Permalink
add item.has_display
Browse files Browse the repository at this point in the history
Returns whether the item has a custom display name.
This is to prevent comparing to 'null', and to prevent 'unfilled
attributes' errors.
  • Loading branch information
mcmonkey4eva committed Nov 9, 2013
1 parent 120590b commit cceb018
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/main/java/net/aufdemrand/denizen/objects/dItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,23 @@ public String getAttribute(Attribute attribute) {
if (attribute.startsWith("material"))
return getMaterial().getAttribute(attribute.fulfill(1));

// <--[tag]
// @attribute <i@item.has_display>
// @returns Element(Boolean)
// @description
// Returns whether the item has a custom set display name.
// -->
if (attribute.startsWith("has_display")) {
if (getItemStack().hasItemMeta() && getItemStack().getItemMeta().hasDisplayName()) {
return Element.TRUE
.getAttribute(attribute.fulfill(1));
}
else {
return Element.FALSE
.getAttribute(attribute.fulfill(1));
}
}

// <--[tag]
// @attribute <i@item.display>
// @returns Element
Expand Down

0 comments on commit cceb018

Please sign in to comment.