return result;
}
private static Map<String,List<Upgrade>> getUpgradeMap(ConfigurationSection config) {
ConfigurationSection section = config.getConfigurationSection("upgrades");
if (section == null) {
return null;
}
Set<String> classes = section.getKeys(false);
if (classes == null || classes.isEmpty()) {
return null;
}
Map<String,List<Upgrade>> upgrades = new HashMap<String,List<Upgrade>>();
String path = "upgrades.";
for (String className : classes) {
String itemList;
// Legacy support
Object val = config.get(path + className, null);
if (val instanceof String) {
itemList = (String) val;
List<ItemStack> stacks = ItemParser.parseItems(itemList);
List<Upgrade> list = new ArrayList<Upgrade>();
for (ItemStack stack : stacks) {
list.add(new GenericUpgrade(stack));
}
upgrades.put(className.toLowerCase(), list);
}
// New complex setup
else if (val instanceof ConfigurationSection) {
ConfigurationSection classSection = (ConfigurationSection) val;
List<Upgrade> list = new ArrayList<Upgrade>();
// Items (Generic + Weapons)
itemList = classSection.getString("items", null);
if (itemList != null) {
for (ItemStack stack : ItemParser.parseItems(itemList)) {
list.add(ArenaClass.isWeapon(stack) ? new WeaponUpgrade(stack) : new GenericUpgrade(stack));
}
}
// Armor
itemList = classSection.getString("armor", null);
if (itemList != null) {
for (ItemStack stack : ItemParser.parseItems(itemList)) {
list.add(new ArmorUpgrade(stack));
}
}
// Permissions
List<String> perms = classSection.getStringList("permissions");
if (!perms.isEmpty()) {
for (String perm : perms) {
list.add(new PermissionUpgrade(perm));
}
}