diff --git a/src/main/java/net/aufdemrand/denizen/objects/dInventory.java b/src/main/java/net/aufdemrand/denizen/objects/dInventory.java index 894a2f1dad..b7efbb59b3 100644 --- a/src/main/java/net/aufdemrand/denizen/objects/dInventory.java +++ b/src/main/java/net/aufdemrand/denizen/objects/dInventory.java @@ -179,14 +179,12 @@ public dInventory(InventoryHolder holder) { public dInventory(InventoryType type) { inventory = Bukkit.getServer().createInventory(null, type); - idType = "generic"; - idHolder = type.name(); + loadIdentifiers(); } public dInventory(int size) { inventory = Bukkit.getServer().createInventory(null, size); - idType = "generic"; - idHolder = "CHEST"; + loadIdentifiers(); } @@ -220,6 +218,10 @@ else if (holder instanceof Entity) { idHolder = getLocation().identify(); } } + else { + idType = "generic"; + idHolder = getInventory().getType().name(); + } } public void setIdentifiers(String type, String holder) { 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 754c5f7775..b1a03bb871 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 @@ -1,5 +1,7 @@ package net.aufdemrand.denizen.scripts.commands.item; +import org.bukkit.Bukkit; + import net.aufdemrand.denizen.exceptions.CommandExecutionException; import net.aufdemrand.denizen.exceptions.InvalidArgumentsException; import net.aufdemrand.denizen.objects.*; @@ -62,7 +64,7 @@ else if (!scriptEntry.hasObject("destination") public void execute(final ScriptEntry scriptEntry) throws CommandExecutionException { // Get objects - dList actions = (dList) scriptEntry.getObject("action"); + dList actions = (dList) scriptEntry.getObject("actions"); dInventory origin = (dInventory) scriptEntry.getObject("origin"); dInventory destination = (dInventory) scriptEntry.getObject("destination"); @@ -73,7 +75,7 @@ public void execute(final ScriptEntry scriptEntry) throws CommandExecutionExcept + actions.debug()); for (String action : actions) { - switch (Action.valueOf(action)) { + switch (Action.valueOf(action.toUpperCase())) { // Make the attached player open the destination inventory case OPEN: @@ -84,19 +86,18 @@ public void execute(final ScriptEntry scriptEntry) throws CommandExecutionExcept } // Otherwise, open inventory as usual else scriptEntry.getPlayer().getPlayerEntity().openInventory(destination.getInventory()); - - return; + break; // Turn destination's contents into a copy of origin's case COPY: origin.replace(destination); - return; + break; // Copy origin's contents to destination, then empty origin case MOVE: origin.replace(destination); origin.clear(); - return; + break; // Swap the contents of the two inventories case SWAP: @@ -104,40 +105,40 @@ public void execute(final ScriptEntry scriptEntry) throws CommandExecutionExcept .add(destination.getContents()); origin.replace(destination); temp.replace(origin); - return; + break; // Add origin's contents to destination case ADD: destination.add(origin.getContents()); - return; + break; // Remove origin's contents from destination case REMOVE: destination.remove(origin.getContents()); - return; + break; // Keep only items from the origin's contents in the // destination case KEEP: - destination.keep(origin.getContents()); - return; + destination.keep(origin.getContents()); + break; // Exclude all items from the origin's contents in the // destination case EXCLUDE: - destination.exclude(origin.getContents()); - return; + destination.exclude(origin.getContents()); + break; // Add origin's contents over and over to destination // until it is full case FILL: destination.fill(origin.getContents()); - return; + break; // Clear the content of the destination inventory case CLEAR: destination.clear(); - return; + break; } } }