Skip to content

Commit

Permalink
Fix defaultObject, add <s@script.container_type>, comment ZapCommand.
Browse files Browse the repository at this point in the history
  • Loading branch information
aufdemrand committed Aug 10, 2013
1 parent 2a05725 commit 29998c4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/main/java/net/aufdemrand/denizen/objects/dScript.java
Expand Up @@ -134,6 +134,10 @@ public dObject setPrefix(String prefix) {
public String getAttribute(Attribute attribute) {
if (attribute == null) return "null";

if (attribute.startsWith("container_type"))
return new Element(getContainer().getType())
.getAttribute(attribute.fulfill(1));

return new Element(identify()).getAttribute(attribute.fulfill(0));
}

Expand Down
Expand Up @@ -93,7 +93,7 @@ public ScriptEntry addObject(String key, Object object) {
*/

public ScriptEntry defaultObject(String key, Object... objects) throws InvalidArgumentsException {
if (!this.objects.containsKey(key))
if (!this.objects.containsKey(key.toUpperCase()))
for (Object obj : objects)
if (obj != null) {
this.addObject(key, obj);
Expand Down
Expand Up @@ -55,6 +55,7 @@ public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException

for (aH.Argument arg : aH.interpret(scriptEntry.getArguments())) {

// If the scripter uses the 'script:step' format, handle it.
if (!scriptEntry.hasObject("script")
&& !scriptEntry.hasObject("step")
&& arg.hasPrefix()
Expand All @@ -63,24 +64,28 @@ public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException
scriptEntry.addObject("step", arg.asElement());
}

// If a script is found, use that to ZAP
else if (!scriptEntry.hasObject("script")
&& arg.matchesArgumentType(dScript.class)
&& !arg.matchesPrefix("step"))
scriptEntry.addObject("script", arg.asType(dScript.class));

// Add argument as step
else if (!scriptEntry.hasObject("step"))
scriptEntry.addObject("step", arg.asElement());

// Lastly duration
else if (!scriptEntry.hasObject("duration")
&& arg.matchesArgumentType(Duration.class))
scriptEntry.addObject("duration", arg.asType(Duration.class));
}

// Add default script if none was specified.
scriptEntry.defaultObject("script", scriptEntry.getScript());

// Check if player is valid
if (!scriptEntry.hasPlayer() || !scriptEntry.getPlayer().isValid())
throw new InvalidArgumentsException("Must have player context!");

}

//"PlayerName,ScriptName", TaskID
Expand All @@ -90,7 +95,6 @@ else if (!scriptEntry.hasObject("duration")
public void execute(final ScriptEntry scriptEntry) throws CommandExecutionException {

final dScript script = (dScript) scriptEntry.getObject("script");

Duration duration = (Duration) scriptEntry.getObject("duration");

dB.report(getName(), scriptEntry.getPlayer().debug() + script.debug()
Expand Down

0 comments on commit 29998c4

Please sign in to comment.