package net.avicus.icarus.module.teams;

import net.avicus.icarus.match.Match;
import net.avicus.icarus.module.Parser;
import net.avicus.icarus.module.ParserException;
import net.avicus.icarus.utils.ParserUtils;
import net.avicus.icarus.utils.config.ConfigSection;

import java.util.HashMap;
import java.util.List;

public class TeamsParser implements Parser<TeamsModule> {

    @Override
    public TeamsModule build(Match match) throws ParserException {
        List<ConfigSection> configs = match.getConfig().getSectionList("teams");

        HashMap<String, Team> teams = new HashMap<String, Team>();

        for (ConfigSection cs : configs) {
            try {
                teams.put(cs.getString("id"), parseTeam(cs));
            } catch (Exception e) {
                throw new ParserException(this, "Failed to parse team '" + cs.getString("id") + "'.", e);
            }
        }

        return new TeamsModule(teams);
    }

    public Team parseTeam(ConfigSection cs) throws ParserException {
        if (cs.empty("name"))
            throw new IllegalArgumentException("Team name must be specified.");
        if (cs.empty("color"))
            throw new IllegalArgumentException("Team color must be specified.");
        if (cs.empty("max"))
            throw new IllegalArgumentException("Team max size must be specified.");
        return new Team(cs.getString("name"), ParserUtils.parseChatColor(cs.getString("color")), cs.getInt("max"));
    }

}

@@ -687,32 +687,34 @@
 ms.put(c
-s.getString(%22id%22
+reateIdIfAbsent(cs
 ), parse
@@ -887,24 +887,24 @@
 %0A        %7D%0A%0A
-
         retu
@@ -933,24 +933,439 @@
 ms);%0A    %7D%0A%0A
+    public String createIdIfAbsent(ConfigSection cs) throws ParserException %7B%0A        if (cs.contains(%22id%22)) return cs.getAsString(%22id%22);%0A        if (cs.contains(%22name%22)) return cs.getAsString(%22name%22).toLowerCase().split(%22 %22)%5B0%5D; // %22Red Team%22 =%3E %22red%22%0A        else throw new ParserException(this, %22Team name must be specified.%22); // The team doesn't even have a name, so an error about an id is irrelevant.%0A    %7D%0A%0A
     public T

Add a method to create an id if "id" is not specified.