diff --git a/build.gradle b/build.gradle index 9a75ad2..e0cdd1d 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ plugins { } group = 'it.fulminazzo' -version = '1.5.11' +version = '1.5.12' repositories { mavenCentral() diff --git a/src/main/java/it/fulminazzo/yamlparser/parsers/CollectionYAMLParser.java b/src/main/java/it/fulminazzo/yamlparser/parsers/CollectionYAMLParser.java index 0ad2b0a..b0a4ee0 100644 --- a/src/main/java/it/fulminazzo/yamlparser/parsers/CollectionYAMLParser.java +++ b/src/main/java/it/fulminazzo/yamlparser/parsers/CollectionYAMLParser.java @@ -33,7 +33,14 @@ public CollectionYAMLParser(@NotNull Class aClass) { return (c, s) -> { if (c.isConfigurationSection(s)) { @Nullable Map map = mapYamlParser.load(c, s); - return map == null ? null : (C) map.values(); + if (map == null) return null; + List result = new LinkedList<>(); + for (Integer k : map.keySet()) { + if (k < 0) throw new IllegalArgumentException(String.format("Invalid number '%s'", k)); + while (result.size() - 1 < k) result.add(null); + result.set(k, map.get(k)); + } + return (C) result; } else return (C) c.getObject(s); };