for (String option : groupParts)
{
String[] optionParts = option.split(":");
if (optionParts.length != 2)
{
throw new InvalidConfigException("Invalid JSON structure near " + option);
}
String key = optionParts[0].trim();
String value = optionParts[1].trim();
if (key.equalsIgnoreCase("\"mob\""))
{
// Remove the quotes from the mob name
mobName = removeFirstAndLastChar(value);
}
if (key.equalsIgnoreCase("\"weight\""))
{
weight = StringHelper.readInt(value, 0, 1000);
}
if (key.equalsIgnoreCase("\"min\""))
{
min = StringHelper.readInt(value, 0, 1000);
}
if (key.equalsIgnoreCase("\"max\""))
{
max = StringHelper.readInt(value, 0, 1000);
}
}
// Check if data is complete and valid
if (mobName == null || min == -1 || max == -1 || weight == -1)
{
throw new InvalidConfigException("Excepted mob, weight, min and max, but one or more were missing in mob group " + json);
}
if (min > max)
{
throw new InvalidConfigException("Minimum group size may not be larger that maximum group size for mob group " + json);
}
return new WeightedMobSpawnGroup(mobName, weight, min, max);
}