Skip to content

Commit

Permalink
Add tag npc.constant[constant_name]
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Oct 6, 2013
1 parent f1036b0 commit 85d1bf8
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/main/java/net/aufdemrand/denizen/objects/dNPC.java
Expand Up @@ -2,10 +2,7 @@

import net.aufdemrand.denizen.flags.FlagManager;
import net.aufdemrand.denizen.npc.dNPCRegistry;
import net.aufdemrand.denizen.npc.traits.AssignmentTrait;
import net.aufdemrand.denizen.npc.traits.HealthTrait;
import net.aufdemrand.denizen.npc.traits.NicknameTrait;
import net.aufdemrand.denizen.npc.traits.TriggerTrait;
import net.aufdemrand.denizen.npc.traits.*;
import net.aufdemrand.denizen.scripts.commands.npc.EngageCommand;
import net.aufdemrand.denizen.scripts.containers.core.InteractScriptContainer;
import net.aufdemrand.denizen.scripts.containers.core.InteractScriptHelper;
Expand Down Expand Up @@ -391,6 +388,26 @@ && getCitizen().getTrait(Anchors.class).getAnchor(attribute.getContext(1)) != nu
else return "null";
}

// <--[tag]
// @attribute <npc.constant[constant_name]>
// @returns Element
// @description
// returns the specified constant from the NPC.
// -->
if (attribute.startsWith("constant")) {
String constant_name;
if (attribute.hasContext(1)) {
if (getCitizen().hasTrait(ConstantsTrait.class)
&& getCitizen().getTrait(ConstantsTrait.class).getConstant(attribute.getContext(1)) != null) {
return new Element(getCitizen().getTrait(ConstantsTrait.class)
.getConstant(attribute.getContext(1))).getAttribute(attribute.fulfill(1));
}
else {
return "null";
}
}
}

// <--[tag]
// @attribute <npc.id>
// @returns Element(number)
Expand Down

0 comments on commit 85d1bf8

Please sign in to comment.