diff --git a/src/main/java/net/aufdemrand/denizen/objects/dInventory.java b/src/main/java/net/aufdemrand/denizen/objects/dInventory.java index 367d3d4ec8..46c8eab728 100644 --- a/src/main/java/net/aufdemrand/denizen/objects/dInventory.java +++ b/src/main/java/net/aufdemrand/denizen/objects/dInventory.java @@ -316,6 +316,13 @@ public void setContents(ItemStack[] contents) { inventory.setContents(contents); } + public boolean update() { + if (idType.equals("player")) { + dPlayer.valueOf(idHolder).getPlayerEntity().updateInventory(); + return true; + } + return false; + } ///////////////////// // INVENTORY MANIPULATION @@ -721,7 +728,7 @@ public String getAttribute(Attribute attribute) { // @attribute // @returns Element // @description - // Returns Denizen's holder ID for this inventory + // Returns Denizen's holder ID for this inventory. (p@aufdemrand, l@123,321,123, etc.) // --> if (attribute.startsWith("id_holder")) { return new Element(idHolder).getAttribute(attribute.fulfill(1)); @@ -731,7 +738,7 @@ public String getAttribute(Attribute attribute) { // @attribute // @returns Element // @description - // Returns Denizen's type ID for this inventory + // Returns Denizen's type ID for this inventory. (player, location, etc.) // --> if (attribute.startsWith("id_type")) { return new Element(idType).getAttribute(attribute.fulfill(1)); diff --git a/src/main/java/net/aufdemrand/denizen/scripts/commands/CommandRegistry.java b/src/main/java/net/aufdemrand/denizen/scripts/commands/CommandRegistry.java index e25fd324a2..a32b9d0a18 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/commands/CommandRegistry.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/commands/CommandRegistry.java @@ -1321,7 +1321,7 @@ public void registerCoreMembers() { // <--[command] // @Name Inventory - // @Syntax inventory [open/copy/move/swap/add/remove/keep/exclude/fill/clear] (destination:) (origin:/|...) + // @Syntax inventory [open/copy/move/swap/add/remove/keep/exclude/fill/clear/update] (destination:) (origin:/|...) // @Required 1 // @Stable stable // @Short Edits the inventory of a player, NPC, or chest. @@ -1336,7 +1336,7 @@ public void registerCoreMembers() { // Todo // --> registerCoreMember(InventoryCommand.class, - "INVENTORY", "inventory [open/copy/move/swap/add/remove/keep/exclude/fill/clear] (destination:) (origin:/|...)", 1); + "INVENTORY", "inventory [open/copy/move/swap/add/remove/keep/exclude/fill/clear/update] (destination:) (origin:/|...)", 1); // <--[command] diff --git a/src/main/java/net/aufdemrand/denizen/scripts/commands/item/InventoryCommand.java b/src/main/java/net/aufdemrand/denizen/scripts/commands/item/InventoryCommand.java index 23f5d527b4..5c1958a866 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/commands/item/InventoryCommand.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/commands/item/InventoryCommand.java @@ -18,7 +18,7 @@ public class InventoryCommand extends AbstractCommand { - private enum Action { OPEN, COPY, MOVE, SWAP, ADD, REMOVE, KEEP, EXCLUDE, FILL, CLEAR } + private enum Action { OPEN, COPY, MOVE, SWAP, ADD, REMOVE, KEEP, EXCLUDE, FILL, CLEAR, UPDATE } @SuppressWarnings("unchecked") @Override @@ -138,6 +138,13 @@ public void execute(final ScriptEntry scriptEntry) throws CommandExecutionExcept case CLEAR: destination.clear(); break; + + // If this is a player inventory, update it + case UPDATE: + if (!destination.update()) + throw new CommandExecutionException("Only player inventories can be force-updated!"); + break; + } } }