Skip to content

Commit

Permalink
Small cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidcernat committed Oct 20, 2013
1 parent 1845cc1 commit 5a42c0b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
10 changes: 6 additions & 4 deletions src/main/java/net/aufdemrand/denizen/objects/dInventory.java
Expand Up @@ -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();
}


Expand Down Expand Up @@ -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) {
Expand Down
@@ -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.*;
Expand Down Expand Up @@ -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");
Expand All @@ -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:
Expand All @@ -84,60 +86,59 @@ 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:
dInventory temp = new dInventory(destination.getInventoryType())
.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;
}
}
}
Expand Down

0 comments on commit 5a42c0b

Please sign in to comment.