SPIGOT-6886: Restore previous behaviour of loading unusual config keys

By: blablubbabc <lukas@wirsindwir.de>
This commit is contained in:
Bukkit/Spigot
2022-01-09 10:04:49 +11:00
parent 215952d23f
commit 9003a55038
3 changed files with 34 additions and 5 deletions

View File

@@ -144,8 +144,8 @@ public class YamlConfiguration extends FileConfiguration {
private void fromNodeTree(@NotNull MappingNode input, @NotNull ConfigurationSection section) {
constructor.flattenMapping(input);
for (NodeTuple nodeTuple : input.getValue()) {
ScalarNode key = (ScalarNode) nodeTuple.getKeyNode();
String keyString = key.getValue();
Node key = nodeTuple.getKeyNode();
String keyString = String.valueOf(constructor.construct(key));
Node value = nodeTuple.getValueNode();
while (value instanceof AnchorNode) {
@@ -169,7 +169,9 @@ public class YamlConfiguration extends FileConfiguration {
private boolean hasSerializedTypeKey(MappingNode node) {
for (NodeTuple nodeTuple : node.getValue()) {
String key = ((ScalarNode) nodeTuple.getKeyNode()).getValue();
Node keyNode = nodeTuple.getKeyNode();
if (!(keyNode instanceof ScalarNode)) continue;
String key = ((ScalarNode) keyNode).getValue();
if (key.equals(ConfigurationSerialization.SERIALIZED_TYPE_KEY)) {
return true;
}
@@ -180,7 +182,7 @@ public class YamlConfiguration extends FileConfiguration {
private MappingNode toNodeTree(@NotNull ConfigurationSection section) {
List<NodeTuple> nodeTuples = new ArrayList<>();
for (Map.Entry<String, Object> entry : section.getValues(false).entrySet()) {
ScalarNode key = (ScalarNode) representer.represent(entry.getKey());
Node key = representer.represent(entry.getKey());
Node value;
if (entry.getValue() instanceof ConfigurationSection) {
value = toNodeTree((ConfigurationSection) entry.getValue());

View File

@@ -22,7 +22,7 @@ public class YamlConstructor extends SafeConstructor {
super.flattenMapping(node);
}
@NotNull
@Nullable
public Object construct(@NotNull Node node) {
return constructObject(node);
}