Skip to content

Commit

Permalink
Added <in@inventory.is_full>
Browse files Browse the repository at this point in the history
  • Loading branch information
Fortifier42 committed Jul 19, 2015
1 parent 8139f74 commit 9b0af96
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/main/java/net/aufdemrand/denizen/objects/dInventory.java
Expand Up @@ -1135,7 +1135,7 @@ public String getAttribute(Attribute attribute) {
// @attribute <in@inventory.can_fit[<item>]>
// @returns Element(Boolean)
// @description
// Returns whether the inventory can fit 1 of an item.
// Returns whether the inventory can fit an item.
// -->
if (attribute.startsWith("can_fit")) {
if (attribute.hasContext(1)) {
Expand Down Expand Up @@ -1185,6 +1185,23 @@ public String getAttribute(Attribute attribute) {
return new Element(empty).getAttribute(attribute.fulfill(1));
}

// <--[tag]
// @attribute <in@inventory.is_full>
// @returns Element(Boolean)
// @description
// Returns whether the inventory is completely full.
// -->
if (attribute.startsWith("is_full")) {
boolean full = false;
for (ItemStack item : getContents()) {
if (item != null && ( item.getType() == Material.AIR ) || ( item.getAmount() < item.getMaxStackSize() ) ) {
full = true;
break;
}
}
return new Element(full).getAttribute(attribute.fulfill(1));
}

// <--[tag]
// @attribute <in@inventory.contains.display[(strict:)<element>]>
// @returns Element(Boolean)
Expand Down

0 comments on commit 9b0af96

Please sign in to comment.