    001    package cpw.mods.fml.common.event;
    002
    003    import java.io.File;
    004    import java.util.Properties;
    005    import java.util.logging.Logger;
    006
    007    import cpw.mods.fml.common.FMLLog;
    008    import cpw.mods.fml.common.LoaderState.ModState;
    009    import cpw.mods.fml.common.FMLModContainer;
    010    import cpw.mods.fml.common.ModContainer;
    011    import cpw.mods.fml.common.ModMetadata;
    012    import cpw.mods.fml.common.discovery.ASMDataTable;
    013
    014    public class FMLPreInitializationEvent extends FMLStateEvent
    015    {
    016        private ModMetadata modMetadata;
    017        private File sourceFile;
    018        private File configurationDir;
    019        private File suggestedConfigFile;
    020        private ASMDataTable asmData;
    021        private ModContainer modContainer;
    022
    023        public FMLPreInitializationEvent(Object... data)
    024        {
    025            super(data);
    026            this.asmData = (ASMDataTable)data[0];
    027            this.configurationDir = (File)data[1];
    028        }
    029
    030        @Override
    031        public ModState getModState()
    032        {
    033            return ModState.PREINITIALIZED;
    034        }
    035
    036        @Override
    037        public void applyModContainer(ModContainer activeContainer)
    038        {
    039            this.modContainer = activeContainer;
    040            this.modMetadata = activeContainer.getMetadata();
    041            this.sourceFile = activeContainer.getSource();
    042            this.suggestedConfigFile = new File(configurationDir, activeContainer.getModId()+".cfg");
    043        }
    044
    045        public File getSourceFile()
    046        {
    047            return sourceFile;
    048        }
    049
    050        public ModMetadata getModMetadata()
    051        {
    052            return modMetadata;
    053        }
    054
    055        public File getModConfigurationDirectory()
    056        {
    057            return configurationDir;
    058        }
    059
    060        public File getSuggestedConfigurationFile()
    061        {
    062            return suggestedConfigFile;
    063        }
    064
    065        public ASMDataTable getAsmData()
    066        {
    067            return asmData;
    068        }
    069
    070        public Properties getVersionProperties()
    071        {
    072            if (this.modContainer instanceof FMLModContainer)
    073            {
    074                return ((FMLModContainer)this.modContainer).searchForVersionProperties();
    075            }
    076
    077            return null;
    078        }
    079
    080        /**
    081         * Get a logger instance configured to write to the FML Log as a parent, identified by modid. Handy for mod logging!
    082         *
    083         * @return A logger
    084         */
    085        public Logger getModLog()
    086        {
    087            Logger log = Logger.getLogger(modContainer.getModId());
    088            log.setParent(FMLLog.getLogger());
    089            return log;
    090        }
    091    }