Search in sources :

Example 1 with SubscriberExceptionContext

use of com.google.common.eventbus.SubscriberExceptionContext in project MinecraftForge by MinecraftForge.

the class LoadController method buildModList.

@Subscribe
public void buildModList(FMLLoadEvent event) {
    Builder<String, EventBus> eventBus = ImmutableMap.builder();
    for (final ModContainer mod : loader.getModList()) {
        //Create mod logger, and make the EventBus logger a child of it.
        EventBus bus = new EventBus(new SubscriberExceptionHandler() {

            @Override
            public void handleException(final Throwable exception, final SubscriberExceptionContext context) {
                LoadController.this.errorOccurred(mod, exception);
            }
        });
        boolean isActive = mod.registerBus(bus, this);
        if (isActive) {
            activeModList.add(mod);
            modStates.put(mod.getModId(), ModState.UNLOADED);
            eventBus.put(mod.getModId(), bus);
            FMLCommonHandler.instance().addModToResourcePack(mod);
        } else {
            FMLLog.log(mod.getModId(), Level.WARN, "Mod %s has been disabled through configuration", mod.getModId());
            modStates.put(mod.getModId(), ModState.UNLOADED);
            modStates.put(mod.getModId(), ModState.DISABLED);
        }
        modNames.put(mod.getModId(), mod.getName());
    }
    eventChannels = eventBus.build();
}
Also used : SubscriberExceptionHandler(com.google.common.eventbus.SubscriberExceptionHandler) SubscriberExceptionContext(com.google.common.eventbus.SubscriberExceptionContext) EventBus(com.google.common.eventbus.EventBus) Subscribe(com.google.common.eventbus.Subscribe)

Aggregations

EventBus (com.google.common.eventbus.EventBus)1 Subscribe (com.google.common.eventbus.Subscribe)1 SubscriberExceptionContext (com.google.common.eventbus.SubscriberExceptionContext)1 SubscriberExceptionHandler (com.google.common.eventbus.SubscriberExceptionHandler)1