Skip to content

Commit

Permalink
Add Remove action to Inventory command.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidcernat committed Jul 2, 2013
1 parent 0df83f7 commit d76a086
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 7 deletions.
21 changes: 20 additions & 1 deletion src/main/java/net/aufdemrand/denizen/objects/dInventory.java
Expand Up @@ -77,7 +77,7 @@ public Inventory getInventory() {
}

/**
* Adds an array of items to this inventory,
* Add an array of items to this inventory
* and return the result
*
* @param items The array of items
Expand Down Expand Up @@ -134,6 +134,25 @@ public int count(ItemStack item, boolean stacks)
return qty;
}

/**
* Remove an array of items from this inventory,
* and return the result
*
* @param items The array of items
* @return The resulting dInventory
*
*/

public dInventory remove(ItemStack[] items) {

for (ItemStack item : items) {

if (item != null) inventory.removeItem(item);
}

return this;
}

/**
* Replace another inventory with this one,
* cropping it if necessary so that it fits.
Expand Down
Expand Up @@ -154,14 +154,16 @@ else if (destinationEntity != null) {
case ADD:
destination.add(origin.getContents());
return;

// Remove origin's contents from destination
case REMOVE:
destination.remove(origin.getContents());
return;

// Clear the content of the destination inventory
case CLEAR:
destination.clear();
return;

case REMOVE:
return;

default:
return;
Expand Down
Expand Up @@ -61,10 +61,10 @@ public void execute(final ScriptEntry scriptEntry) throws CommandExecutionExcept

Block sign = location.getBlock();

if (type.name().equals("WALL_SIGN"))
sign.setType(Material.valueOf("WALL_SIGN"));
if (type.equals(Type.WALL_SIGN))
sign.setType(Material.WALL_SIGN);
else
sign.setType(Material.valueOf("SIGN_POST"));
sign.setType(Material.SIGN_POST);

BlockState signState = sign.getState();

Expand Down

0 comments on commit d76a086

Please sign in to comment.