Search in sources :

Example 6 with ForestryModule

use of forestry.api.modules.ForestryModule in project Binnie by ForestryMC.

the class ModuleContainer method isModuleEnabled.

@Override
public boolean isModuleEnabled(IForestryModule module) {
    ForestryModule info = module.getClass().getAnnotation(ForestryModule.class);
    String comment = ForestryPluginUtil.getComment(module);
    Property prop = getModulesConfig().get(CONFIG_CATEGORY, info.moduleID(), true, comment);
    return prop.getBoolean();
}
Also used : ForestryModule(forestry.api.modules.ForestryModule) IForestryModule(forestry.api.modules.IForestryModule) Property(net.minecraftforge.common.config.Property)

Example 7 with ForestryModule

use of forestry.api.modules.ForestryModule in project ForestryMC by ForestryMC.

the class ForestryModEnvWarningCallable method register.

public static void register() {
    Set<IForestryModule> configDisabledModules = ModuleManager.configDisabledModules;
    if (!configDisabledModules.isEmpty()) {
        List<String> disabledModuleNames = new ArrayList<>();
        for (IForestryModule module : configDisabledModules) {
            ForestryModule info = module.getClass().getAnnotation(ForestryModule.class);
            disabledModuleNames.add(info.name());
        }
        String disabledModulesMessage = "Modules have been disabled in the config: " + Joiner.on(", ").join(disabledModuleNames);
        ForestryModEnvWarningCallable callable = new ForestryModEnvWarningCallable(disabledModulesMessage);
        FMLCommonHandler.instance().registerCrashCallable(callable);
    }
}
Also used : ForestryModule(forestry.api.modules.ForestryModule) IForestryModule(forestry.api.modules.IForestryModule) ArrayList(java.util.ArrayList) IForestryModule(forestry.api.modules.IForestryModule)

Example 8 with ForestryModule

use of forestry.api.modules.ForestryModule in project ForestryMC by ForestryMC.

the class ForestryPluginUtil method getComment.

public static String getComment(IForestryModule module) {
    ForestryModule info = module.getClass().getAnnotation(ForestryModule.class);
    String comment = I18n.translateToLocal(info.unlocalizedDescription());
    Set<ResourceLocation> dependencies = module.getDependencyUids();
    if (!dependencies.isEmpty()) {
        Iterator<ResourceLocation> iDependencies = dependencies.iterator();
        StringBuilder builder = new StringBuilder(comment);
        builder.append("\n");
        builder.append("Dependencies: [ ");
        builder.append(iDependencies.next());
        while (iDependencies.hasNext()) {
            ResourceLocation uid = iDependencies.next();
            builder.append(", ").append(uid.toString());
        }
        builder.append(" ]");
        comment = builder.toString();
    }
    return comment;
}
Also used : ForestryModule(forestry.api.modules.ForestryModule) IForestryModule(forestry.api.modules.IForestryModule) ResourceLocation(net.minecraft.util.ResourceLocation)

Example 9 with ForestryModule

use of forestry.api.modules.ForestryModule in project ForestryMC by ForestryMC.

the class ModuleManager method getLootTableFiles.

public static Set<String> getLootTableFiles() {
    Set<String> lootTableNames = new HashSet<>();
    for (IForestryModule module : loadedModules) {
        ForestryModule info = module.getClass().getAnnotation(ForestryModule.class);
        String lootTableFolder = info.lootTable();
        if (!lootTableFolder.isEmpty()) {
            lootTableNames.add(lootTableFolder);
        }
    }
    return lootTableNames;
}
Also used : ForestryModule(forestry.api.modules.ForestryModule) IForestryModule(forestry.api.modules.IForestryModule) IForestryModule(forestry.api.modules.IForestryModule) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Aggregations

ForestryModule (forestry.api.modules.ForestryModule)9 IForestryModule (forestry.api.modules.IForestryModule)9 ArrayList (java.util.ArrayList)3 ResourceLocation (net.minecraft.util.ResourceLocation)3 Property (net.minecraftforge.common.config.Property)3 Log (forestry.core.utils.Log)2 HashSet (java.util.HashSet)2 Iterator (java.util.Iterator)2 LinkedHashMap (java.util.LinkedHashMap)2 LinkedHashSet (java.util.LinkedHashSet)2 List (java.util.List)2 Map (java.util.Map)2 Set (java.util.Set)2 ASMDataTable (net.minecraftforge.fml.common.discovery.ASMDataTable)2 Preconditions (com.google.common.base.Preconditions)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Lists (com.google.common.collect.Lists)1 ForestryAPI (forestry.api.core.ForestryAPI)1 IModuleContainer (forestry.api.modules.IModuleContainer)1