Search in sources :

Example 1 with EventPriority

use of net.minecraftforge.fml.common.eventhandler.EventPriority in project Guide-API by TeamAmeriFrance.

the class AnnotationHandler method gatherBooks.

public static void gatherBooks(ASMDataTable dataTable) {
    for (EventPriority priority : EventPriority.values()) for (ASMDataTable.ASMData data : dataTable.getAll(GuideBook.class.getCanonicalName())) {
        try {
            Class<?> genericClass = Class.forName(data.getClassName());
            if (!IGuideBook.class.isAssignableFrom(genericClass))
                continue;
            IGuideBook guideBook = (IGuideBook) genericClass.newInstance();
            ModAnnotation.EnumHolder holder = (ModAnnotation.EnumHolder) data.getAnnotationInfo().get("priority");
            EventPriority bookPriority = holder == null ? EventPriority.NORMAL : EventPriority.valueOf(holder.getValue());
            if (priority != bookPriority)
                continue;
            Book book = guideBook.buildBook();
            if (book == null)
                continue;
            APISetter.registerBook(book);
            BOOK_CLASSES.add(Pair.of(book, guideBook));
        } catch (Exception e) {
            LogHelper.error("Error registering book for class " + data.getClassName());
            e.printStackTrace();
        }
    }
    APISetter.setIndexedBooks(Lists.newArrayList(GuideAPI.getBooks().values()));
}
Also used : ModAnnotation(net.minecraftforge.fml.common.discovery.asm.ModAnnotation) GuideBook(amerifrance.guideapi.api.GuideBook) IGuideBook(amerifrance.guideapi.api.IGuideBook) Book(amerifrance.guideapi.api.impl.Book) IGuideBook(amerifrance.guideapi.api.IGuideBook) EventPriority(net.minecraftforge.fml.common.eventhandler.EventPriority)

Aggregations

GuideBook (amerifrance.guideapi.api.GuideBook)1 IGuideBook (amerifrance.guideapi.api.IGuideBook)1 Book (amerifrance.guideapi.api.impl.Book)1 ModAnnotation (net.minecraftforge.fml.common.discovery.asm.ModAnnotation)1 EventPriority (net.minecraftforge.fml.common.eventhandler.EventPriority)1