Skip to content

Commit beeca43

Browse files
committed
Fix VelocityConfigurationAdapter#getKeys()
1 parent 7d2ef1e commit beeca43

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

commandapi-platforms/commandapi-velocity/commandapi-velocity-plugin/src/main/java/dev/jorel/commandapi/config/VelocityConfigurationAdapter.java

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,7 @@ public String[] getComment(String key) {
4848

4949
@Override
5050
public Set<String> getKeys() {
51-
Set<String> keys = new HashSet<>();
52-
for (Object key : config.childrenMap().keySet()) {
53-
keys.add((String) key);
54-
}
55-
return keys;
51+
return new HashSet<>(nestedOptions(config));
5652
}
5753

5854
@Override
@@ -133,4 +129,19 @@ private CommentedConfigurationNode node(String path) {
133129
return config.node(path.split("\\."));
134130
}
135131

132+
private Set<String> nestedOptions(ConfigurationNode node) {
133+
Set<String> keys = new HashSet<>();
134+
for (Object key : node.childrenMap().keySet()) {
135+
ConfigurationNode nestedNode = node.childrenMap().get(key);
136+
if (nestedNode.childrenMap().isEmpty()) {
137+
keys.add((String) key);
138+
} else {
139+
for (String nestedKey : nestedOptions(nestedNode)) {
140+
keys.add(key + "." + nestedKey);
141+
}
142+
}
143+
}
144+
return keys;
145+
}
146+
136147
}

0 commit comments

Comments
 (0)