codechicken.nei.api.IConfigureNEI Java Examples

The following examples show how to use codechicken.nei.api.IConfigureNEI. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NEIInitialization.java    From NotEnoughItems with MIT License 6 votes vote down vote up
private static void replaceMetadata() {

        StringBuilder builder = new StringBuilder("\n\n");

        if (plugins.isEmpty()) {
            builder.append(TextFormatting.RED).append("No installed plugins.");
        } else {
            builder.append(TextFormatting.GREEN).append("Installed plugins: ");
            for (IConfigureNEI plugin : plugins) {
                builder.append("\n");
                builder.append("      ").append(TextFormatting.GREEN);
                builder.append(plugin.getName()).append(", Version: ").append(plugin.getVersion());

            }
        }
        builder.append("\n\n");
        //String desc = ModDescriptionEnhancer.enhanceDesc(NotEnoughItems.metadata.description);
        NotEnoughItems.metadata.description = NotEnoughItems.metadata.description.replace("<plugins>", builder.toString());
    }
 
Example #2
Source File: NEIInitialization.java    From NotEnoughItems with MIT License 6 votes vote down vote up
public static void scrapeData(ASMDataTable dataTable) {
    ImmutableList.Builder<IConfigureNEI> plugins = ImmutableList.builder();
    for (ASMDataTable.ASMData data : dataTable.getAll(NEIPlugin.class.getName())) {
        try {
            Class<?> pluginClass = Class.forName(data.getClassName());
            if (IConfigureNEI.class.isAssignableFrom(pluginClass)) {
                IConfigureNEI pluginInstance = (IConfigureNEI) pluginClass.newInstance();
                plugins.add(pluginInstance);
            } else {
                LogHelper.error("Found class with annotation @NEIPlugin but class does not implement IConfigureNEI.. Class: " + data.getClassName());
            }

        } catch (Exception e) {
            LogHelper.fatalError("Fatal exception occurred whilst loading a plugin! Class: %s", e, data.getClassName());
        }
    }
    NEIInitialization.plugins = plugins.build();

}
 
Example #3
Source File: NEIModContainer.java    From NotEnoughItems with MIT License 6 votes vote down vote up
@Override
public ModMetadata getMetadata() {
    String s_plugins = "";
    if (plugins.size() == 0) {
        s_plugins += EnumChatFormatting.RED+"No installed plugins.";
    } else {
        s_plugins += EnumChatFormatting.GREEN+"Installed plugins: ";
        for (int i = 0; i < plugins.size(); i++) {
            if (i > 0)
                s_plugins += ", ";
            IConfigureNEI plugin = plugins.get(i);
            s_plugins += plugin.getName() + " " + plugin.getVersion();
        }
        s_plugins += ".";
    }

    ModMetadata meta = super.getMetadata();
    meta.description = description.replace("<plugins>", s_plugins);
    return meta;
}
 
Example #4
Source File: NEIInitialization.java    From NotEnoughItems with MIT License 4 votes vote down vote up
/**
 * Called to do first initialization of NEI's core components.
 * Including default item filters, Plugin initialization. ect.
 */
public static void bootNEI() {
    long start = System.nanoTime();
    LogHelper.info("Loading NEI.");
    LogHelper.trace("Loading save states..");
    NEIClientConfig.loadStates();
    LogHelper.trace("Loading potion helper..");
    PotionRecipeHelper.init();
    LogHelper.trace("Loading default hide's..");
    hideVanillaItems();
    LogHelper.trace("Loading subsets..");
    LogHelper.trace(" Base subsets..");
    addBaseSubsets();
    LogHelper.trace(" Default subsets..");
    loadDefaultSubsets();
    LogHelper.trace(" Potion subsets..");
    loadPotionSubsets();
    LogHelper.trace(" Mod subsets..");
    loadModSubsets();
    LogHelper.trace("Loading dumps..");
    loadRegistryDumps();
    LogHelper.trace("Adding filters..");
    API.addItemFilter(() -> item -> !ItemInfo.hiddenItems.contains(item));
    API.addItemFilter(() -> item -> !JEIIntegrationManager.isBlacklisted(item));
    LogHelper.trace("Registering search callback..");
    ItemList.registerLoadCallback(ItemInfo.itemSearchNames::clear);
    LogHelper.trace("Registering gui handlers..");
    API.registerNEIGuiHandler(new NEIChestGuiHandler());
    API.registerNEIGuiHandler(new NEIDummySlotHandler());
    GuiInfo.load();
    LogHelper.trace("Loading LayoutManager..");
    LayoutManager.load();
    LogHelper.trace("Loading NEIController..");
    NEIController.load();

    LogHelper.trace("Loading plugins..");
    for (IConfigureNEI plugin : plugins) {
        try {
            plugin.loadConfig();
            LogHelper.debug("Loaded Plugin: %s[%s]", plugin.getName(), plugin.getClass().getName());
        } catch (Exception e) {
            LogHelper.fatalError("Caught fatal exception from an NEI plugin! Class: ", e, plugin.getClass().getName());
        }
    }

    replaceMetadata();

    LogHelper.trace("Loading ItemSorter..");
    ItemSorter.loadConfig();
    LogHelper.info("Finished NEI Initialization after %s ms", TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start));

}