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()));
}
Aggregations