diff --git a/src/main/java/net/minecraftforge/common/ForgeModContainer.java b/src/main/java/net/minecraftforge/common/ForgeModContainer.java index 78e5e69bc..ec73c8e65 100644 --- a/src/main/java/net/minecraftforge/common/ForgeModContainer.java +++ b/src/main/java/net/minecraftforge/common/ForgeModContainer.java @@ -452,9 +452,9 @@ public void modConstruction(FMLConstructionEvent evt) } List all = Lists.newArrayList(); - for (ASMData asm : evt.getASMHarvestedData().getAll(ICrashReportDetail.class.getName().replace('.', '/'))) + for (ASMData asm : evt.getASMHarvestedData().getAll(ICrashReportDetail.class)) all.add(asm.getClassName()); - for (ASMData asm : evt.getASMHarvestedData().getAll(ICrashCallable.class.getName().replace('.', '/'))) + for (ASMData asm : evt.getASMHarvestedData().getAll(ICrashCallable.class)) all.add(asm.getClassName()); // Add table classes for mod list tabulation all.add("net/minecraftforge/common/util/TextTable"); diff --git a/src/main/java/net/minecraftforge/common/MinecraftForge.java b/src/main/java/net/minecraftforge/common/MinecraftForge.java index c0e84d2b4..54a6f6fe6 100644 --- a/src/main/java/net/minecraftforge/common/MinecraftForge.java +++ b/src/main/java/net/minecraftforge/common/MinecraftForge.java @@ -103,9 +103,9 @@ public static void preloadCrashClasses(ASMDataTable table, String modID, Set all = Lists.newArrayList(); - for (ASMData asm : table.getAll(ICrashReportDetail.class.getName().replace('.', '/'))) + for (ASMData asm : table.getAll(ICrashReportDetail.class)) all.add(asm.getClassName()); - for (ASMData asm : table.getAll(ICrashCallable.class.getName().replace('.', '/'))) + for (ASMData asm : table.getAll(ICrashCallable.class)) all.add(asm.getClassName()); all.retainAll(classes); diff --git a/src/main/java/net/minecraftforge/common/capabilities/CapabilityManager.java b/src/main/java/net/minecraftforge/common/capabilities/CapabilityManager.java index 5f718e19e..d24ae24b9 100644 --- a/src/main/java/net/minecraftforge/common/capabilities/CapabilityManager.java +++ b/src/main/java/net/minecraftforge/common/capabilities/CapabilityManager.java @@ -102,7 +102,7 @@ public void register(Class type, Capability.IStorage storage, Callable private IdentityHashMap, Object>>> callbacks = Maps.newIdentityHashMap(); public void injectCapabilities(ASMDataTable data) { - for (ASMDataTable.ASMData entry : data.getAll(CapabilityInject.class.getName())) + for (ASMDataTable.ASMData entry : data.getAll(CapabilityInject.class)) { final String targetClass = entry.getClassName(); final String targetName = entry.getObjectName(); diff --git a/src/main/java/net/minecraftforge/common/config/ConfigManager.java b/src/main/java/net/minecraftforge/common/config/ConfigManager.java index e5170ad0b..3ff4aa2e0 100644 --- a/src/main/java/net/minecraftforge/common/config/ConfigManager.java +++ b/src/main/java/net/minecraftforge/common/config/ConfigManager.java @@ -106,7 +106,7 @@ private static void register(Class cls, ITypeAdapter adpt) public static void loadData(ASMDataTable data) { FMLLog.log.debug("Loading @Config anotation data"); - for (ASMData target : data.getAll(Config.class.getName())) + for (ASMData target : data.getAll(Config.class)) { String modid = (String)target.getAnnotationInfo().get("modid"); Multimap map = asm_data.computeIfAbsent(modid, k -> ArrayListMultimap.create()); diff --git a/src/main/java/net/minecraftforge/fml/common/LoadController.java b/src/main/java/net/minecraftforge/fml/common/LoadController.java index ba982db55..d1dc17318 100644 --- a/src/main/java/net/minecraftforge/fml/common/LoadController.java +++ b/src/main/java/net/minecraftforge/fml/common/LoadController.java @@ -147,7 +147,7 @@ public void distributeStateMessage(LoaderState state, Object... eventData) MixinBooterPlugin.LOGGER.info("Instantiating all ILateMixinLoader implemented classes..."); - for (ASMDataTable.ASMData asmData : asmDataTable.getAll(ILateMixinLoader.class.getName().replace('.', '/'))) { + for (ASMDataTable.ASMData asmData : asmDataTable.getAll(ILateMixinLoader.class)) { if (!log) { MixinBooterPlugin.LOGGER.info("Instantiating all ILateMixinLoader implemented classes..."); log = true; diff --git a/src/main/java/net/minecraftforge/fml/common/discovery/ASMDataTable.java b/src/main/java/net/minecraftforge/fml/common/discovery/ASMDataTable.java index 493903fa8..cc8ee8d08 100644 --- a/src/main/java/net/minecraftforge/fml/common/discovery/ASMDataTable.java +++ b/src/main/java/net/minecraftforge/fml/common/discovery/ASMDataTable.java @@ -55,22 +55,30 @@ public ASMData(ModCandidate candidate, String annotationName, String className, this.objectName = objectName; this.annotationInfo = info; } + public ModCandidate getCandidate() { return candidate; } + public String getAnnotationName() { return annotationName; } + + /** + * @return the internal name + */ public String getClassName() { return className; } + public String getObjectName() { return objectName; } + public Map getAnnotationInfo() { return annotationInfo; @@ -108,9 +116,9 @@ public boolean apply(ASMData data) private Map> containerAnnotationData; private List containers = Lists.newArrayList(); - private SetMultimap packageMap = HashMultimap.create(); + private SetMultimap packageMap = HashMultimap.create(); - public SetMultimap getAnnotationsFor(ModContainer container) + public SetMultimap getAnnotationsFor(ModContainer container) { if (containerAnnotationData == null) { @@ -122,9 +130,27 @@ public SetMultimap getAnnotationsFor(ModContainer container) return containerAnnotationData.get(container); } - public Set getAll(String annotation) + /** + * @param type The canonical name of a annotation type + * Or the internal name of a interface type + * @return the asm datas + */ + public Set getAll(String type) + { + return globalAnnotationData.get(type); + } + + /** + * @param type interface of annotation + * @return the asm datas + */ + public Set getAll(Class type) { - return globalAnnotationData.get(annotation); + if (type.isInterface()) { + return this.getAll(type.getName().replace('.', '/')); + } else if (type.isAnnotation()) { + return this.getAll(type.getName()); + } else throw new IllegalArgumentException("The type are trying to be got from ASMDataTable is neither annotation nor interface"); } public void addASMData(ModCandidate candidate, String annotation, String className, @Nullable String objectName, @Nullable Map annotationInfo) diff --git a/src/main/java/net/minecraftforge/fml/common/registry/ItemStackHolderInjector.java b/src/main/java/net/minecraftforge/fml/common/registry/ItemStackHolderInjector.java index 9b8ba3dbb..c199ae46a 100644 --- a/src/main/java/net/minecraftforge/fml/common/registry/ItemStackHolderInjector.java +++ b/src/main/java/net/minecraftforge/fml/common/registry/ItemStackHolderInjector.java @@ -47,7 +47,7 @@ public void inject() { public void findHolders(ASMDataTable table) { FMLLog.log.info("Identifying ItemStackHolder annotations"); - Set allItemStackHolders = table.getAll(GameRegistry.ItemStackHolder.class.getName()); + Set allItemStackHolders = table.getAll(GameRegistry.ItemStackHolder.class); Map> classCache = Maps.newHashMap(); for (ASMData data : allItemStackHolders) { diff --git a/src/main/java/net/minecraftforge/registries/ObjectHolderRegistry.java b/src/main/java/net/minecraftforge/registries/ObjectHolderRegistry.java index 63de0981a..6a50dd9be 100644 --- a/src/main/java/net/minecraftforge/registries/ObjectHolderRegistry.java +++ b/src/main/java/net/minecraftforge/registries/ObjectHolderRegistry.java @@ -49,10 +49,10 @@ public enum ObjectHolderRegistry public void findObjectHolders(ASMDataTable table) { FMLLog.log.info("Processing ObjectHolder annotations"); - Set allObjectHolders = table.getAll(GameRegistry.ObjectHolder.class.getName()); + Set allObjectHolders = table.getAll(GameRegistry.ObjectHolder.class); Map classModIds = Maps.newHashMap(); Map> classCache = Maps.newHashMap(); - for (ASMData data : table.getAll(Mod.class.getName())) + for (ASMData data : table.getAll(Mod.class)) { String modid = (String)data.getAnnotationInfo().get("modid"); classModIds.put(data.getClassName(), modid);