Skip to content

Commit

Permalink
Implement BracedCommand changes for ForEach
Browse files Browse the repository at this point in the history
  • Loading branch information
Morphan1 committed Sep 14, 2013
1 parent 90b4e6b commit a5346bf
Showing 1 changed file with 7 additions and 6 deletions.
@@ -1,6 +1,7 @@
package net.aufdemrand.denizen.scripts.commands.core;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.UUID;

import net.aufdemrand.denizen.exceptions.CommandExecutionException;
Expand Down Expand Up @@ -34,7 +35,7 @@ public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException
if (!scriptEntry.hasObject("list"))
throw new InvalidArgumentsException(Messages.ERROR_MISSING_OTHER, "LIST");

scriptEntry.addObject("entries", getBracedCommands(scriptEntry, 1));
scriptEntry.addObject("braces", getBracedCommands(scriptEntry, 1));

}

Expand All @@ -44,7 +45,7 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {

// Get objects
dList list = (dList) scriptEntry.getObject("list");
ArrayList<ScriptEntry> entries = (ArrayList<ScriptEntry>) scriptEntry.getObject("entries");
ArrayList<ScriptEntry> bracedSections = ((LinkedHashMap<String, ArrayList<ScriptEntry>>) scriptEntry.getObject("braces")).get("FOREACH");

// Report to dB
dB.report(getName(), list.debug() );
Expand All @@ -54,11 +55,11 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
if (scriptEntry.getResidingQueue().getWasCleared())
return;
ArrayList<ScriptEntry> newEntries = (ArrayList<ScriptEntry>) new ArrayList<ScriptEntry>();
for (ScriptEntry entr: entries) {
for (ScriptEntry entry : bracedSections) {
try {
ScriptEntry toadd = entr.clone();
toadd.getObjects().clear();
newEntries.add(toadd);
ScriptEntry toAdd = entry.clone();
toAdd.getObjects().clear();
newEntries.add(toAdd);
}
catch (Throwable e) {
e.printStackTrace();
Expand Down

0 comments on commit a5346bf

Please sign in to comment.