Skip to content

Commit

Permalink
fix flag tag with maps
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Dec 11, 2020
1 parent d297113 commit 6816c7e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
Expand Up @@ -107,17 +107,7 @@ public static <T extends FlaggableObject> void registerFlagHandlers(ObjectTagPro
attribute.echoError("Cannot read flag_map tag for '" + object + "': flag tracker is invalid or unavailable.");
return null;
}
listFlagsTagWarning.warn(attribute.context);
if (tracker instanceof MapTagFlagTracker) {
return ((MapTagFlagTracker) tracker).map;
}
else {
MapTag result = new MapTag();
for (String key : tracker.listAllFlags()) {
result.putObject(key, tracker.getFlagValue(key));
}
return result;
}
return tracker.doFlagMapTag(attribute);
});
}

Expand Down Expand Up @@ -165,4 +155,18 @@ public ListTag doListFlagsTag(Attribute attribute) {
list.addAll(listAllFlags());
return list;
}

public MapTag doFlagMapTag(Attribute attribute) {
listFlagsTagWarning.warn(attribute.context);
if (this instanceof MapTagFlagTracker) {
return ((MapTagFlagTracker) this).map;
}
else {
MapTag result = new MapTag();
for (String key : listAllFlags()) {
result.putObject(key, getFlagValue(key));
}
return result;
}
}
}
Expand Up @@ -41,7 +41,11 @@ public ObjectTag getFlagValueOfType(String key, StringHolder type) {
return null;
}
if (splitKey.size() == 1) {
return map.map.get(type);
ObjectTag returnValue = map.map.get(type);
if (returnValue instanceof MapTag) {
return deflaggedSubMap((MapTag) returnValue);
}
return returnValue;
}
ObjectTag rootValue = map.map.get(valueString);
if (!(rootValue instanceof MapTag)) {
Expand Down

0 comments on commit 6816c7e

Please sign in to comment.