Skip to content

Commit

Permalink
Patch script.yaml_key tags, constant tag too
Browse files Browse the repository at this point in the history
Silly tag, scriptEntry's are for queues!
ConfigSections can be null.
  • Loading branch information
mcmonkey4eva committed Sep 25, 2014
1 parent b11be3d commit d351ccf
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/main/java/net/aufdemrand/denizen/objects/dScript.java
Expand Up @@ -13,6 +13,7 @@
import net.aufdemrand.denizen.tags.Attribute;
import net.aufdemrand.denizen.tags.TagManager;
import net.aufdemrand.denizen.utilities.DenizenAPI;
import org.bukkit.configuration.ConfigurationSection;

public class dScript implements dObject {

Expand Down Expand Up @@ -315,19 +316,21 @@ public String getAttribute(Attribute attribute) {
if (attribute.startsWith("cons")) {
if (!attribute.hasContext(1)) return Element.NULL.getAttribute(attribute.fulfill(1));

Object obj = getContainer().getConfigurationSection("constants").get(attribute.getContext(1).toUpperCase());
ConfigurationSection section = getContainer().getConfigurationSection("constants");
if (section == null) return Element.NULL.getAttribute(attribute.fulfill(1));
Object obj = section.get(attribute.getContext(1).toUpperCase());
if (obj == null) return Element.NULL.getAttribute(attribute.fulfill(1));

if (obj instanceof List) {
dList list = new dList();
for (Object each : (List<Object>) obj)
list.add(TagManager.tag(attribute.getScriptEntry().getPlayer(),
attribute.getScriptEntry().getNPC(), each.toString(), false, attribute.getScriptEntry()));
list.add(TagManager.tag(attribute.getScriptEntry() == null ? null: attribute.getScriptEntry().getPlayer(),
attribute.getScriptEntry() == null ? null: attribute.getScriptEntry().getNPC(), each.toString(), false, attribute.getScriptEntry()));
return list.getAttribute(attribute.fulfill(1));

}
else return new Element(TagManager.tag(attribute.getScriptEntry().getPlayer(),
attribute.getScriptEntry().getNPC(), obj.toString(), false, attribute.getScriptEntry()))
else return new Element(TagManager.tag(attribute.getScriptEntry() == null ? null: attribute.getScriptEntry().getPlayer(),
attribute.getScriptEntry() == null ? null: attribute.getScriptEntry().getNPC(), obj.toString(), false, attribute.getScriptEntry()))
.getAttribute(attribute.fulfill(1));
}

Expand All @@ -345,13 +348,13 @@ else return new Element(TagManager.tag(attribute.getScriptEntry().getPlayer(),
if (obj instanceof List) {
dList list = new dList();
for (Object each : (List<Object>) obj)
list.add(TagManager.tag(attribute.getScriptEntry().getPlayer(),
attribute.getScriptEntry().getNPC(), each.toString(), false, attribute.getScriptEntry()));
list.add(TagManager.tag(attribute.getScriptEntry() == null ? null: attribute.getScriptEntry().getPlayer(),
attribute.getScriptEntry() == null ? null: attribute.getScriptEntry().getNPC(), each.toString(), false, attribute.getScriptEntry()));
return list.getAttribute(attribute.fulfill(1));

}
else return new Element(TagManager.tag(attribute.getScriptEntry().getPlayer(),
attribute.getScriptEntry().getNPC(), obj.toString(), false, attribute.getScriptEntry()))
else return new Element(TagManager.tag(attribute.getScriptEntry() == null ? null: attribute.getScriptEntry().getPlayer(),
attribute.getScriptEntry() == null ? null: attribute.getScriptEntry().getNPC(), obj.toString(), false, attribute.getScriptEntry()))
.getAttribute(attribute.fulfill(1));
}

Expand Down

0 comments on commit d351ccf

Please sign in to comment.