Avoid a crash when reading malformed .mt files

Handle excess commas in .mt files, such as files with a comma after the last item in the list.
master
Treer 2018-04-28 12:29:59 +10:00
parent 5a105b0e42
commit b0c1ced5f2
1 changed files with 6 additions and 0 deletions

View File

@ -126,6 +126,12 @@ public class MinetestBiomeProfileImpl implements BiomeProfile {
@Override
public boolean validate() {
// Before validation, remove any null biomes the JSON reader may have created due
// to excess commas, such as files with a comma after the last item in the list.
for (int i = biomeList.size() - 1; i >= 0; i--) {
if (biomeList.get(i) == null) biomeList.remove(i);
}
for (MinetestBiome biome : biomeList) {
if (!biome.validate()) {
AmidstLogger.info("Biome in biomeprofile invalid");