java类cpw.mods.fml.common.event.FMLEvent的实例源码

FMLModContainer.java 文件源码 项目:TRHS_Club_Mod_2016 阅读 24 收藏 0 点赞 0 评论 0
@Subscribe
public void handleModStateEvent(FMLEvent event)
{
    if (!eventMethods.containsKey(event.getClass()))
    {
        return;
    }
    try
    {
        for (Method m : eventMethods.get(event.getClass()))
        {
            m.invoke(modInstance, event);
        }
    }
    catch (Throwable t)
    {
        controller.errorOccurred(this, t);
    }
}
FMLModContainer.java 文件源码 项目:CauldronGit 阅读 24 收藏 0 点赞 0 评论 0
@Subscribe
public void handleModStateEvent(FMLEvent event)
{
    if (!eventMethods.containsKey(event.getClass()))
    {
        return;
    }
    try
    {
        for (Method m : eventMethods.get(event.getClass()))
        {
            m.invoke(modInstance, event);
        }
    }
    catch (Throwable t)
    {
        controller.errorOccurred(this, t);
    }
}
FMLModContainer.java 文件源码 项目:Cauldron 阅读 32 收藏 0 点赞 0 评论 0
@Subscribe
public void handleModStateEvent(FMLEvent event)
{
    if (!eventMethods.containsKey(event.getClass()))
    {
        return;
    }
    try
    {
        for (Method m : eventMethods.get(event.getClass()))
        {
            m.invoke(modInstance, event);
        }
    }
    catch (Throwable t)
    {
        controller.errorOccurred(this, t);
    }
}
FMLModContainer.java 文件源码 项目:Cauldron 阅读 26 收藏 0 点赞 0 评论 0
@Subscribe
public void handleModStateEvent(FMLEvent event)
{
    if (!eventMethods.containsKey(event.getClass()))
    {
        return;
    }
    try
    {
        for (Method m : eventMethods.get(event.getClass()))
        {
            m.invoke(modInstance, event);
        }
    }
    catch (Throwable t)
    {
        controller.errorOccurred(this, t);
    }
}
FMLModContainer.java 文件源码 项目:Cauldron 阅读 28 收藏 0 点赞 0 评论 0
@Subscribe
public void handleModStateEvent(FMLEvent event)
{
    if (!eventMethods.containsKey(event.getClass()))
    {
        return;
    }
    try
    {
        for (Method m : eventMethods.get(event.getClass()))
        {
            m.invoke(modInstance, event);
        }
    }
    catch (Throwable t)
    {
        controller.errorOccurred(this, t);
    }
}
FMLModContainer.java 文件源码 项目:RuneCraftery 阅读 27 收藏 0 点赞 0 评论 0
@Subscribe
public void handleModStateEvent(FMLEvent event)
{
    if (!eventMethods.containsKey(event.getClass()))
    {
        return;
    }
    try
    {
        for (Method m : eventMethods.get(event.getClass()))
        {
            m.invoke(modInstance, event);
        }
    }
    catch (Throwable t)
    {
        controller.errorOccurred(this, t);
    }
}
FMLModContainer.java 文件源码 项目:RuneCraftery 阅读 23 收藏 0 点赞 0 评论 0
@Subscribe
public void handleModStateEvent(FMLEvent event)
{
    if (!eventMethods.containsKey(event.getClass()))
    {
        return;
    }
    try
    {
        for (Method m : eventMethods.get(event.getClass()))
        {
            m.invoke(modInstance, event);
        }
    }
    catch (Throwable t)
    {
        controller.errorOccurred(this, t);
    }
}
FMLModContainer.java 文件源码 项目:BetterNutritionMod 阅读 23 收藏 0 点赞 0 评论 0
@Subscribe
public void handleModStateEvent(FMLEvent event)
{
    if (!eventMethods.containsKey(event.getClass()))
    {
        return;
    }
    try
    {
        for (Method m : eventMethods.get(event.getClass()))
        {
            m.invoke(modInstance, event);
        }
    }
    catch (Throwable t)
    {
        controller.errorOccurred(this, t);
    }
}
LoadController.java 文件源码 项目:TRHS_Club_Mod_2016 阅读 32 收藏 0 点赞 0 评论 0
@Subscribe
public void propogateStateMessage(FMLEvent stateEvent)
{
    if (stateEvent instanceof FMLPreInitializationEvent)
    {
        modObjectList = buildModObjectList();
    }
    ProgressBar bar = ProgressManager.push(stateEvent.description(), activeModList.size());
    for (ModContainer mc : activeModList)
    {
        bar.step(mc.getName());
        sendEventToModContainer(stateEvent, mc);
    }
    ProgressManager.pop(bar);
}
LoadController.java 文件源码 项目:TRHS_Club_Mod_2016 阅读 20 收藏 0 点赞 0 评论 0
private void sendEventToModContainer(FMLEvent stateEvent, ModContainer mc)
{
    String modId = mc.getModId();
    Collection<String> requirements =  Collections2.transform(mc.getRequirements(),new ArtifactVersionNameFunction());
    for (ArtifactVersion av : mc.getDependencies())
    {
        if (av.getLabel()!= null && requirements.contains(av.getLabel()) && modStates.containsEntry(av.getLabel(),ModState.ERRORED))
        {
            FMLLog.log(modId, Level.ERROR, "Skipping event %s and marking errored mod %s since required dependency %s has errored", stateEvent.getEventType(), modId, av.getLabel());
            modStates.put(modId, ModState.ERRORED);
            return;
        }
    }
    activeContainer = mc;
    stateEvent.applyModContainer(activeContainer());
    ThreadContext.put("mod", modId);
    FMLLog.log(modId, Level.TRACE, "Sending event %s to mod %s", stateEvent.getEventType(), modId);
    eventChannels.get(modId).post(stateEvent);
    FMLLog.log(modId, Level.TRACE, "Sent event %s to mod %s", stateEvent.getEventType(), modId);
    ThreadContext.remove("mod");
    activeContainer = null;
    if (stateEvent instanceof FMLStateEvent)
    {
        if (!errors.containsKey(modId))
        {
            modStates.put(modId, ((FMLStateEvent)stateEvent).getModState());
        }
        else
        {
            modStates.put(modId, ModState.ERRORED);
        }
    }
}
FMLModContainer.java 文件源码 项目:TRHS_Club_Mod_2016 阅读 29 收藏 0 点赞 0 评论 0
@SuppressWarnings("unchecked")
private Method gatherAnnotations(Class<?> clazz) throws Exception
{
    Method factoryMethod = null;
    for (Method m : clazz.getDeclaredMethods())
    {
        for (Annotation a : m.getAnnotations())
        {
            if (a.annotationType().equals(Mod.EventHandler.class))
            {
                if (m.getParameterTypes().length == 1 && FMLEvent.class.isAssignableFrom(m.getParameterTypes()[0]))
                {
                    m.setAccessible(true);
                    eventMethods.put((Class<? extends FMLEvent>) m.getParameterTypes()[0],m);
                }
                else
                {
                    FMLLog.log(getModId(), Level.ERROR,"The mod %s appears to have an invalid event annotation %s. This annotation can only apply to methods with recognized event arguments - it will not be called", getModId(), a.annotationType().getSimpleName());
                }
            }
            else if (a.annotationType().equals(Mod.InstanceFactory.class))
            {
                if (Modifier.isStatic(m.getModifiers()) && m.getParameterTypes().length == 0 && factoryMethod == null)
                {
                    m.setAccessible(true);
                    factoryMethod = m;
                }
                else if (!(Modifier.isStatic(m.getModifiers()) && m.getParameterTypes().length == 0))
                {
                    FMLLog.log(getModId(),  Level.ERROR, "The InstanceFactory annotation can only apply to a static method, taking zero arguments - it will be ignored on %s(%s)", m.getName(), Arrays.asList(m.getParameterTypes()));
                }
                else if (factoryMethod != null)
                {
                    FMLLog.log(getModId(), Level.ERROR, "The InstanceFactory annotation can only be used once, the application to %s(%s) will be ignored", m.getName(), Arrays.asList(m.getParameterTypes()));
                }
            }
        }
    }
    return factoryMethod;
}
LoadController.java 文件源码 项目:CauldronGit 阅读 29 收藏 0 点赞 0 评论 0
@Subscribe
public void propogateStateMessage(FMLEvent stateEvent)
{
    if (stateEvent instanceof FMLPreInitializationEvent)
    {
        modObjectList = buildModObjectList();
    }
    for (ModContainer mc : activeModList)
    {
        sendEventToModContainer(stateEvent, mc);
    }
}
LoadController.java 文件源码 项目:CauldronGit 阅读 24 收藏 0 点赞 0 评论 0
private void sendEventToModContainer(FMLEvent stateEvent, ModContainer mc)
{
    String modId = mc.getModId();
    Collection<String> requirements =  Collections2.transform(mc.getRequirements(),new ArtifactVersionNameFunction());
    for (ArtifactVersion av : mc.getDependencies())
    {
        if (av.getLabel()!= null && requirements.contains(av.getLabel()) && modStates.containsEntry(av.getLabel(),ModState.ERRORED))
        {
            FMLLog.log(modId, Level.ERROR, "Skipping event %s and marking errored mod %s since required dependency %s has errored", stateEvent.getEventType(), modId, av.getLabel());
            modStates.put(modId, ModState.ERRORED);
            return;
        }
    }
    activeContainer = mc;
    stateEvent.applyModContainer(activeContainer());
    ThreadContext.put("mod", modId);
    FMLLog.log(modId, Level.TRACE, "Sending event %s to mod %s", stateEvent.getEventType(), modId);
    eventChannels.get(modId).post(stateEvent);
    FMLLog.log(modId, Level.TRACE, "Sent event %s to mod %s", stateEvent.getEventType(), modId);
    ThreadContext.remove("mod");
    activeContainer = null;
    if (stateEvent instanceof FMLStateEvent)
    {
        if (!errors.containsKey(modId))
        {
            modStates.put(modId, ((FMLStateEvent)stateEvent).getModState());
        }
        else
        {
            modStates.put(modId, ModState.ERRORED);
        }
    }
}
FMLModContainer.java 文件源码 项目:CauldronGit 阅读 22 收藏 0 点赞 0 评论 0
@SuppressWarnings("unchecked")
private Method gatherAnnotations(Class<?> clazz) throws Exception
{
    Method factoryMethod = null;
    for (Method m : clazz.getDeclaredMethods())
    {
        for (Annotation a : m.getAnnotations())
        {
            if (a.annotationType().equals(Mod.EventHandler.class))
            {
                if (m.getParameterTypes().length == 1 && FMLEvent.class.isAssignableFrom(m.getParameterTypes()[0]))
                {
                    m.setAccessible(true);
                    eventMethods.put((Class<? extends FMLEvent>) m.getParameterTypes()[0],m);
                }
                else
                {
                    FMLLog.log(getModId(), Level.ERROR,"The mod %s appears to have an invalid event annotation %s. This annotation can only apply to methods with recognized event arguments - it will not be called", getModId(), a.annotationType().getSimpleName());
                }
            }
            else if (a.annotationType().equals(Mod.InstanceFactory.class))
            {
                if (Modifier.isStatic(m.getModifiers()) && m.getParameterTypes().length == 0 && factoryMethod == null)
                {
                    m.setAccessible(true);
                    factoryMethod = m;
                }
                else if (!(Modifier.isStatic(m.getModifiers()) && m.getParameterTypes().length == 0))
                {
                    FMLLog.log(getModId(),  Level.ERROR, "The InstanceFactory annotation can only apply to a static method, taking zero arguments - it will be ignored on %s(%s)", m.getName(), Arrays.asList(m.getParameterTypes()));
                }
                else if (factoryMethod != null)
                {
                    FMLLog.log(getModId(), Level.ERROR, "The InstanceFactory annotation can only be used once, the application to %s(%s) will be ignored", m.getName(), Arrays.asList(m.getParameterTypes()));
                }
            }
        }
    }
    return factoryMethod;
}
LoadController.java 文件源码 项目:Cauldron 阅读 21 收藏 0 点赞 0 评论 0
@Subscribe
public void propogateStateMessage(FMLEvent stateEvent)
{
    if (stateEvent instanceof FMLPreInitializationEvent)
    {
        modObjectList = buildModObjectList();
    }
    for (ModContainer mc : activeModList)
    {
        sendEventToModContainer(stateEvent, mc);
    }
}
LoadController.java 文件源码 项目:Cauldron 阅读 39 收藏 0 点赞 0 评论 0
private void sendEventToModContainer(FMLEvent stateEvent, ModContainer mc)
{
    String modId = mc.getModId();
    Collection<String> requirements =  Collections2.transform(mc.getRequirements(),new ArtifactVersionNameFunction());
    for (ArtifactVersion av : mc.getDependencies())
    {
        if (av.getLabel()!= null && requirements.contains(av.getLabel()) && modStates.containsEntry(av.getLabel(),ModState.ERRORED))
        {
            FMLLog.log(modId, Level.ERROR, "Skipping event %s and marking errored mod %s since required dependency %s has errored", stateEvent.getEventType(), modId, av.getLabel());
            modStates.put(modId, ModState.ERRORED);
            return;
        }
    }
    activeContainer = mc;
    stateEvent.applyModContainer(activeContainer());
    ThreadContext.put("mod", modId);
    FMLLog.log(modId, Level.TRACE, "Sending event %s to mod %s", stateEvent.getEventType(), modId);
    eventChannels.get(modId).post(stateEvent);
    FMLLog.log(modId, Level.TRACE, "Sent event %s to mod %s", stateEvent.getEventType(), modId);
    ThreadContext.remove("mod");
    activeContainer = null;
    if (stateEvent instanceof FMLStateEvent)
    {
        if (!errors.containsKey(modId))
        {
            modStates.put(modId, ((FMLStateEvent)stateEvent).getModState());
        }
        else
        {
            modStates.put(modId, ModState.ERRORED);
        }
    }
}
FMLModContainer.java 文件源码 项目:Cauldron 阅读 25 收藏 0 点赞 0 评论 0
@SuppressWarnings("unchecked")
private Method gatherAnnotations(Class<?> clazz) throws Exception
{
    Method factoryMethod = null;
    for (Method m : clazz.getDeclaredMethods())
    {
        for (Annotation a : m.getAnnotations())
        {
            if (a.annotationType().equals(Mod.EventHandler.class))
            {
                if (m.getParameterTypes().length == 1 && FMLEvent.class.isAssignableFrom(m.getParameterTypes()[0]))
                {
                    m.setAccessible(true);
                    eventMethods.put((Class<? extends FMLEvent>) m.getParameterTypes()[0],m);
                }
                else
                {
                    FMLLog.log(getModId(), Level.ERROR,"The mod %s appears to have an invalid event annotation %s. This annotation can only apply to methods with recognized event arguments - it will not be called", getModId(), a.annotationType().getSimpleName());
                }
            }
            else if (a.annotationType().equals(Mod.InstanceFactory.class))
            {
                if (Modifier.isStatic(m.getModifiers()) && m.getParameterTypes().length == 0 && factoryMethod == null)
                {
                    m.setAccessible(true);
                    factoryMethod = m;
                }
                else if (!(Modifier.isStatic(m.getModifiers()) && m.getParameterTypes().length == 0))
                {
                    FMLLog.log(getModId(),  Level.ERROR, "The InstanceFactory annotation can only apply to a static method, taking zero arguments - it will be ignored on %s(%s)", m.getName(), Arrays.asList(m.getParameterTypes()));
                }
                else if (factoryMethod != null)
                {
                    FMLLog.log(getModId(), Level.ERROR, "The InstanceFactory annotation can only be used once, the application to %s(%s) will be ignored", m.getName(), Arrays.asList(m.getParameterTypes()));
                }
            }
        }
    }
    return factoryMethod;
}
LoadController.java 文件源码 项目:Cauldron 阅读 21 收藏 0 点赞 0 评论 0
@Subscribe
public void propogateStateMessage(FMLEvent stateEvent)
{
    if (stateEvent instanceof FMLPreInitializationEvent)
    {
        modObjectList = buildModObjectList();
    }
    for (ModContainer mc : activeModList)
    {
        sendEventToModContainer(stateEvent, mc);
    }
}
LoadController.java 文件源码 项目:Cauldron 阅读 22 收藏 0 点赞 0 评论 0
private void sendEventToModContainer(FMLEvent stateEvent, ModContainer mc)
{
    String modId = mc.getModId();
    Collection<String> requirements =  Collections2.transform(mc.getRequirements(),new ArtifactVersionNameFunction());
    for (ArtifactVersion av : mc.getDependencies())
    {
        if (av.getLabel()!= null && requirements.contains(av.getLabel()) && modStates.containsEntry(av.getLabel(),ModState.ERRORED))
        {
            FMLLog.log(modId, Level.ERROR, "Skipping event %s and marking errored mod %s since required dependency %s has errored", stateEvent.getEventType(), modId, av.getLabel());
            modStates.put(modId, ModState.ERRORED);
            return;
        }
    }
    activeContainer = mc;
    stateEvent.applyModContainer(activeContainer());
    ThreadContext.put("mod", modId);
    FMLLog.log(modId, Level.TRACE, "Sending event %s to mod %s", stateEvent.getEventType(), modId);
    eventChannels.get(modId).post(stateEvent);
    FMLLog.log(modId, Level.TRACE, "Sent event %s to mod %s", stateEvent.getEventType(), modId);
    ThreadContext.remove("mod");
    activeContainer = null;
    if (stateEvent instanceof FMLStateEvent)
    {
        if (!errors.containsKey(modId))
        {
            modStates.put(modId, ((FMLStateEvent)stateEvent).getModState());
        }
        else
        {
            modStates.put(modId, ModState.ERRORED);
        }
    }
}
FMLModContainer.java 文件源码 项目:Cauldron 阅读 26 收藏 0 点赞 0 评论 0
@SuppressWarnings("unchecked")
private Method gatherAnnotations(Class<?> clazz) throws Exception
{
    Method factoryMethod = null;
    for (Method m : clazz.getDeclaredMethods())
    {
        for (Annotation a : m.getAnnotations())
        {
            if (a.annotationType().equals(Mod.EventHandler.class))
            {
                if (m.getParameterTypes().length == 1 && FMLEvent.class.isAssignableFrom(m.getParameterTypes()[0]))
                {
                    m.setAccessible(true);
                    eventMethods.put((Class<? extends FMLEvent>) m.getParameterTypes()[0],m);
                }
                else
                {
                    FMLLog.log(getModId(), Level.ERROR,"The mod %s appears to have an invalid event annotation %s. This annotation can only apply to methods with recognized event arguments - it will not be called", getModId(), a.annotationType().getSimpleName());
                }
            }
            else if (a.annotationType().equals(Mod.InstanceFactory.class))
            {
                if (Modifier.isStatic(m.getModifiers()) && m.getParameterTypes().length == 0 && factoryMethod == null)
                {
                    m.setAccessible(true);
                    factoryMethod = m;
                }
                else if (!(Modifier.isStatic(m.getModifiers()) && m.getParameterTypes().length == 0))
                {
                    FMLLog.log(getModId(),  Level.ERROR, "The InstanceFactory annotation can only apply to a static method, taking zero arguments - it will be ignored on %s(%s)", m.getName(), Arrays.asList(m.getParameterTypes()));
                }
                else if (factoryMethod != null)
                {
                    FMLLog.log(getModId(), Level.ERROR, "The InstanceFactory annotation can only be used once, the application to %s(%s) will be ignored", m.getName(), Arrays.asList(m.getParameterTypes()));
                }
            }
        }
    }
    return factoryMethod;
}
LoadController.java 文件源码 项目:Cauldron 阅读 29 收藏 0 点赞 0 评论 0
@Subscribe
public void propogateStateMessage(FMLEvent stateEvent)
{
    if (stateEvent instanceof FMLPreInitializationEvent)
    {
        modObjectList = buildModObjectList();
    }
    for (ModContainer mc : activeModList)
    {
        sendEventToModContainer(stateEvent, mc);
    }
}
LoadController.java 文件源码 项目:Cauldron 阅读 29 收藏 0 点赞 0 评论 0
private void sendEventToModContainer(FMLEvent stateEvent, ModContainer mc)
{
    String modId = mc.getModId();
    Collection<String> requirements =  Collections2.transform(mc.getRequirements(),new ArtifactVersionNameFunction());
    for (ArtifactVersion av : mc.getDependencies())
    {
        if (av.getLabel()!= null && requirements.contains(av.getLabel()) && modStates.containsEntry(av.getLabel(),ModState.ERRORED))
        {
            FMLLog.log(modId, Level.ERROR, "Skipping event %s and marking errored mod %s since required dependency %s has errored", stateEvent.getEventType(), modId, av.getLabel());
            modStates.put(modId, ModState.ERRORED);
            return;
        }
    }
    activeContainer = mc;
    stateEvent.applyModContainer(activeContainer());
    ThreadContext.put("mod", modId);
    FMLLog.log(modId, Level.TRACE, "Sending event %s to mod %s", stateEvent.getEventType(), modId);
    eventChannels.get(modId).post(stateEvent);
    FMLLog.log(modId, Level.TRACE, "Sent event %s to mod %s", stateEvent.getEventType(), modId);
    ThreadContext.remove("mod");
    activeContainer = null;
    if (stateEvent instanceof FMLStateEvent)
    {
        if (!errors.containsKey(modId))
        {
            modStates.put(modId, ((FMLStateEvent)stateEvent).getModState());
        }
        else
        {
            modStates.put(modId, ModState.ERRORED);
        }
    }
}
FMLModContainer.java 文件源码 项目:Cauldron 阅读 38 收藏 0 点赞 0 评论 0
@SuppressWarnings("unchecked")
private Method gatherAnnotations(Class<?> clazz) throws Exception
{
    Method factoryMethod = null;
    for (Method m : clazz.getDeclaredMethods())
    {
        for (Annotation a : m.getAnnotations())
        {
            if (a.annotationType().equals(Mod.EventHandler.class))
            {
                if (m.getParameterTypes().length == 1 && FMLEvent.class.isAssignableFrom(m.getParameterTypes()[0]))
                {
                    m.setAccessible(true);
                    eventMethods.put((Class<? extends FMLEvent>) m.getParameterTypes()[0],m);
                }
                else
                {
                    FMLLog.log(getModId(), Level.ERROR,"The mod %s appears to have an invalid event annotation %s. This annotation can only apply to methods with recognized event arguments - it will not be called", getModId(), a.annotationType().getSimpleName());
                }
            }
            else if (a.annotationType().equals(Mod.InstanceFactory.class))
            {
                if (Modifier.isStatic(m.getModifiers()) && m.getParameterTypes().length == 0 && factoryMethod == null)
                {
                    m.setAccessible(true);
                    factoryMethod = m;
                }
                else if (!(Modifier.isStatic(m.getModifiers()) && m.getParameterTypes().length == 0))
                {
                    FMLLog.log(getModId(),  Level.ERROR, "The InstanceFactory annotation can only apply to a static method, taking zero arguments - it will be ignored on %s(%s)", m.getName(), Arrays.asList(m.getParameterTypes()));
                }
                else if (factoryMethod != null)
                {
                    FMLLog.log(getModId(), Level.ERROR, "The InstanceFactory annotation can only be used once, the application to %s(%s) will be ignored", m.getName(), Arrays.asList(m.getParameterTypes()));
                }
            }
        }
    }
    return factoryMethod;
}
LoadController.java 文件源码 项目:RuneCraftery 阅读 66 收藏 0 点赞 0 评论 0
@Subscribe
public void propogateStateMessage(FMLEvent stateEvent)
{
    if (stateEvent instanceof FMLPreInitializationEvent)
    {
        modObjectList = buildModObjectList();
    }
    for (ModContainer mc : activeModList)
    {
        sendEventToModContainer(stateEvent, mc);
    }
}
LoadController.java 文件源码 项目:RuneCraftery 阅读 45 收藏 0 点赞 0 评论 0
private void sendEventToModContainer(FMLEvent stateEvent, ModContainer mc)
{
    String modId = mc.getModId();
    Collection<String> requirements =  Collections2.transform(mc.getRequirements(),new ArtifactVersionNameFunction());
    for (ArtifactVersion av : mc.getDependencies())
    {
        if (av.getLabel()!= null && requirements.contains(av.getLabel()) && modStates.containsEntry(av.getLabel(),ModState.ERRORED))
        {
            FMLLog.log(modId, Level.SEVERE, "Skipping event %s and marking errored mod %s since required dependency %s has errored", stateEvent.getEventType(), modId, av.getLabel());
            modStates.put(modId, ModState.ERRORED);
            return;
        }
    }
    activeContainer = mc;
    stateEvent.applyModContainer(activeContainer());
    FMLLog.log(modId, Level.FINEST, "Sending event %s to mod %s", stateEvent.getEventType(), modId);
    eventChannels.get(modId).post(stateEvent);
    FMLLog.log(modId, Level.FINEST, "Sent event %s to mod %s", stateEvent.getEventType(), modId);
    activeContainer = null;
    if (stateEvent instanceof FMLStateEvent)
    {
        if (!errors.containsKey(modId))
        {
            modStates.put(modId, ((FMLStateEvent)stateEvent).getModState());
        }
        else
        {
            modStates.put(modId, ModState.ERRORED);
        }
    }
}
LoadController.java 文件源码 项目:RuneCraftery 阅读 31 收藏 0 点赞 0 评论 0
@Subscribe
public void propogateStateMessage(FMLEvent stateEvent)
{
    if (stateEvent instanceof FMLPreInitializationEvent)
    {
        modObjectList = buildModObjectList();
    }
    for (ModContainer mc : activeModList)
    {
        sendEventToModContainer(stateEvent, mc);
    }
}
LoadController.java 文件源码 项目:RuneCraftery 阅读 23 收藏 0 点赞 0 评论 0
private void sendEventToModContainer(FMLEvent stateEvent, ModContainer mc)
{
    String modId = mc.getModId();
    Collection<String> requirements =  Collections2.transform(mc.getRequirements(),new ArtifactVersionNameFunction());
    for (ArtifactVersion av : mc.getDependencies())
    {
        if (av.getLabel()!= null && requirements.contains(av.getLabel()) && modStates.containsEntry(av.getLabel(),ModState.ERRORED))
        {
            FMLLog.log(modId, Level.SEVERE, "Skipping event %s and marking errored mod %s since required dependency %s has errored", stateEvent.getEventType(), modId, av.getLabel());
            modStates.put(modId, ModState.ERRORED);
            return;
        }
    }
    activeContainer = mc;
    stateEvent.applyModContainer(activeContainer());
    FMLLog.log(modId, Level.FINEST, "Sending event %s to mod %s", stateEvent.getEventType(), modId);
    eventChannels.get(modId).post(stateEvent);
    FMLLog.log(modId, Level.FINEST, "Sent event %s to mod %s", stateEvent.getEventType(), modId);
    activeContainer = null;
    if (stateEvent instanceof FMLStateEvent)
    {
        if (!errors.containsKey(modId))
        {
            modStates.put(modId, ((FMLStateEvent)stateEvent).getModState());
        }
        else
        {
            modStates.put(modId, ModState.ERRORED);
        }
    }
}
LoadController.java 文件源码 项目:BetterNutritionMod 阅读 57 收藏 0 点赞 0 评论 0
@Subscribe
public void propogateStateMessage(FMLEvent stateEvent)
{
    if (stateEvent instanceof FMLPreInitializationEvent)
    {
        modObjectList = buildModObjectList();
    }
    for (ModContainer mc : activeModList)
    {
        sendEventToModContainer(stateEvent, mc);
    }
}
LoadController.java 文件源码 项目:BetterNutritionMod 阅读 28 收藏 0 点赞 0 评论 0
private void sendEventToModContainer(FMLEvent stateEvent, ModContainer mc)
{
    String modId = mc.getModId();
    Collection<String> requirements =  Collections2.transform(mc.getRequirements(),new ArtifactVersionNameFunction());
    for (ArtifactVersion av : mc.getDependencies())
    {
        if (av.getLabel()!= null && requirements.contains(av.getLabel()) && modStates.containsEntry(av.getLabel(),ModState.ERRORED))
        {
            FMLLog.log(modId, Level.SEVERE, "Skipping event %s and marking errored mod %s since required dependency %s has errored", stateEvent.getEventType(), modId, av.getLabel());
            modStates.put(modId, ModState.ERRORED);
            return;
        }
    }
    activeContainer = mc;
    stateEvent.applyModContainer(activeContainer());
    FMLLog.log(modId, Level.FINEST, "Sending event %s to mod %s", stateEvent.getEventType(), modId);
    eventChannels.get(modId).post(stateEvent);
    FMLLog.log(modId, Level.FINEST, "Sent event %s to mod %s", stateEvent.getEventType(), modId);
    activeContainer = null;
    if (stateEvent instanceof FMLStateEvent)
    {
        if (!errors.containsKey(modId))
        {
            modStates.put(modId, ((FMLStateEvent)stateEvent).getModState());
        }
        else
        {
            modStates.put(modId, ModState.ERRORED);
        }
    }
}
FMLModContainer.java 文件源码 项目:RuneCraftery 阅读 23 收藏 0 点赞 0 评论 0
private Method gatherAnnotations(Class<?> clazz) throws Exception
{
    Method factoryMethod = null;
    for (Method m : clazz.getDeclaredMethods())
    {
        for (Annotation a : m.getAnnotations())
        {
            if (modTypeAnnotations.containsKey(a.annotationType()))
            {
                Class<?>[] paramTypes = new Class[] { modTypeAnnotations.get(a.annotationType()) };
                if (Arrays.equals(m.getParameterTypes(), paramTypes))
                {
                    m.setAccessible(true);
                    eventMethods.put(modTypeAnnotations.get(a.annotationType()), m);
                }
                else
                {
                    FMLLog.log(getModId(), Level.SEVERE,"The mod %s appears to have an invalid method annotation %s. This annotation can only apply to methods with argument types %s -it will not be called", getModId(), a.annotationType().getSimpleName(), Arrays.toString(paramTypes));
                }
            }
            else if (a.annotationType().equals(Mod.EventHandler.class))
            {
                if (m.getParameterTypes().length == 1 && modAnnotationTypes.containsKey(m.getParameterTypes()[0]))
                {
                    m.setAccessible(true);
                    eventMethods.put((Class<? extends FMLEvent>) m.getParameterTypes()[0],m);
                }
                else
                {
                    FMLLog.log(getModId(), Level.SEVERE,"The mod %s appears to have an invalid event annotation %s. This annotation can only apply to methods with recognized event arguments - it will not be called", getModId(), a.annotationType().getSimpleName());
                }
            }
            else if (a.annotationType().equals(Mod.InstanceFactory.class))
            {
                if (Modifier.isStatic(m.getModifiers()) && m.getParameterTypes().length == 0 && factoryMethod == null)
                {
                    m.setAccessible(true);
                    factoryMethod = m;
                }
                else if (!(Modifier.isStatic(m.getModifiers()) && m.getParameterTypes().length == 0))
                {
                    FMLLog.log(getModId(),  Level.SEVERE, "The InstanceFactory annotation can only apply to a static method, taking zero arguments - it will be ignored on %s(%s)", m.getName(), Arrays.asList(m.getParameterTypes()));
                }
                else if (factoryMethod != null)
                {
                    FMLLog.log(getModId(), Level.SEVERE, "The InstanceFactory annotation can only be used once, the application to %s(%s) will be ignored", m.getName(), Arrays.asList(m.getParameterTypes()));
                }
            }
        }
    }
    return factoryMethod;
}


问题


面经


文章

微信
公众号

扫码关注公众号