if (monster == null) {
Messenger.warning(WaveError.SINGLE_MONSTER_MISSING.format(name, arena.configName()));
return null;
}
BossWave result = new BossWave(monster);
// Check if there's a specific boss name
String bossName = config.getString("name");
if (bossName != null && !bossName.equals("")) {
result.setBossName(bossName);
}
// Grab the boss health
String hlth = config.getString("health");
BossHealth health = BossHealth.fromString(hlth);
if (health != null) {
result.setHealth(health);
} else {
try {
int flatHealth;
if (hlth != null) {
flatHealth = Integer.parseInt(hlth);
} else {
flatHealth = config.getInt("health");
}
result.setFlatHealth(flatHealth);
} catch (Exception e) {
String warning = "Unable to parse health of boss '%s' in arena '%s'. Defaulting to medium. Value was '%s'";
Messenger.warning(String.format(warning, name, arena.configName(), hlth));
result.setHealth(BossHealth.MEDIUM);
}
}
// And the abilities.
String ablts = config.getString("abilities");
if (ablts != null) {
String[] parts = ablts.split(",");
for (String ability : parts) {
Ability a = AbilityManager.getAbility(ability.trim());
if (a == null) {
Messenger.warning(WaveError.BOSS_ABILITY.format(ability.trim(), name, arena.configName()));
continue;
}
result.addBossAbility(a);
}
}
// As well as the ability interval and ability announce.
result.setAbilityInterval(config.getInt("ability-interval", 3) * 20);
result.setAbilityAnnounce(config.getBoolean("ability-announce", true));
// Rewards!
String rew = config.getString("reward");
if (rew != null) {
ItemStack item = ItemParser.parseItem(rew);
if (item != null) result.setReward(item);
}
// Drops!
String drp = config.getString("drops");
List<ItemStack> drops = ItemParser.parseItems(drp);
result.setDrops(drops);
return result;
}