Skip to content

Commit

Permalink
allow yaml lists under item mechanisms key
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Sep 13, 2019
1 parent ee79c6b commit 7eee969
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
import com.denizenscript.denizen.tags.BukkitTagContext;
import com.denizenscript.denizencore.objects.core.ElementTag;
import com.denizenscript.denizencore.objects.Mechanism;
import com.denizenscript.denizencore.objects.core.ListTag;
import com.denizenscript.denizencore.objects.core.ScriptTag;
import com.denizenscript.denizencore.scripts.ScriptBuilder;
import com.denizenscript.denizencore.scripts.ScriptRegistry;
import com.denizenscript.denizencore.scripts.containers.ScriptContainer;
import com.denizenscript.denizencore.tags.TagManager;
Expand Down Expand Up @@ -188,7 +190,17 @@ public ItemTag getItemFrom(PlayerTag player, NPCTag npc) {
if (contains("MECHANISMS")) {
YamlConfiguration mechs = getConfigurationSection("MECHANISMS");
for (StringHolder key : mechs.getKeys(false)) {
String val = TagManager.tag(mechs.getString(key.str), context);
String val;
if (mechs.isList(key.str)) {
ListTag list = new ListTag();
for (String listVal : mechs.getStringList(key.str)) {
list.add(ScriptBuilder.stripLinePrefix(TagManager.tag(listVal, context)));
};
val = list.identify();
}
else {
val = TagManager.tag(mechs.getString(key.str), context);
}
stack.safeAdjust(new Mechanism(new ElementTag(key.low), new ElementTag(val), context));
}
}
Expand Down

0 comments on commit 7eee969

Please sign in to comment.