    001/*
    002 * Forge Mod Loader
    003 * Copyright (c) 2012-2013 cpw.
    004 * All rights reserved. This program and the accompanying materials
    005 * are made available under the terms of the GNU Lesser Public License v2.1
    006 * which accompanies this distribution, and is available at
    007 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
    008 *
    009 * Contributors:
    010 *     cpw - implementation
    011 */
    012
    013package cpw.mods.fml.common.discovery;
    014
    015import java.io.File;
    016import java.util.List;
    017
    018import com.google.common.collect.Lists;
    019
    020import cpw.mods.fml.common.FMLLog;
    021import cpw.mods.fml.common.ModContainer;
    022import cpw.mods.fml.common.discovery.asm.ASMModParser;
    023
    024
    025public class ModCandidate
    026{
    027    private File classPathRoot;
    028    private File modContainer;
    029    private ContainerType sourceType;
    030    private boolean classpath;
    031    private List<String> baseModTypes = Lists.newArrayList();
    032    private boolean isMinecraft;
    033    private List<ASMModParser> baseModCandidateTypes = Lists.newArrayListWithCapacity(1);
    034
    035    public ModCandidate(File classPathRoot, File modContainer, ContainerType sourceType)
    036    {
    037        this(classPathRoot, modContainer, sourceType, false, false);
    038    }
    039    public ModCandidate(File classPathRoot, File modContainer, ContainerType sourceType, boolean isMinecraft, boolean classpath)
    040    {
    041        this.classPathRoot = classPathRoot;
    042        this.modContainer = modContainer;
    043        this.sourceType = sourceType;
    044        this.isMinecraft = isMinecraft;
    045        this.classpath = classpath;
    046    }
    047
    048    public File getClassPathRoot()
    049    {
    050        return classPathRoot;
    051    }
    052
    053    public File getModContainer()
    054    {
    055        return modContainer;
    056    }
    057
    058    public ContainerType getSourceType()
    059    {
    060        return sourceType;
    061    }
    062    public List<ModContainer> explore(ASMDataTable table)
    063    {
    064        List<ModContainer> mods = sourceType.findMods(this, table);
    065        if (!baseModCandidateTypes.isEmpty())
    066        {
    067            FMLLog.info("Attempting to reparse the mod container %s", getModContainer().getName());
    068            return sourceType.findMods(this, table);
    069        }
    070        else
    071        {
    072            return mods;
    073        }
    074    }
    075
    076    public boolean isClasspath()
    077    {
    078        return classpath;
    079    }
    080    public void rememberBaseModType(String className)
    081    {
    082        baseModTypes.add(className);
    083    }
    084    public List<String> getRememberedBaseMods()
    085    {
    086        return baseModTypes;
    087    }
    088    public boolean isMinecraftJar()
    089    {
    090        return isMinecraft;
    091    }
    092    public void rememberModCandidateType(ASMModParser modParser)
    093    {
    094        baseModCandidateTypes.add(modParser);
    095    }
    096}