当前位置: 首页>>代码示例>>Java>>正文


Java ASMDataTable.getAll方法代码示例

本文整理汇总了Java中net.minecraftforge.fml.common.discovery.ASMDataTable.getAll方法的典型用法代码示例。如果您正苦于以下问题:Java ASMDataTable.getAll方法的具体用法?Java ASMDataTable.getAll怎么用?Java ASMDataTable.getAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraftforge.fml.common.discovery.ASMDataTable的用法示例。


在下文中一共展示了ASMDataTable.getAll方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getInstancesOfAnnotation

import net.minecraftforge.fml.common.discovery.ASMDataTable; //导入方法依赖的package包/类
public static <T> List<T> getInstancesOfAnnotation(ASMDataTable asmDataTable, Class annotationClass, Class<T> instanceClass) {
	String annotationClassName = annotationClass.getCanonicalName();
	Set<ASMDataTable.ASMData> asmDatas = asmDataTable.getAll(annotationClassName);
	List<T> instances = new ArrayList<>();
	for (ASMDataTable.ASMData asmData : asmDatas) {
		try {
			Class<?> asmClass = Class.forName(asmData.getClassName());
			Class<? extends T> asmInstanceClass = asmClass.asSubclass(instanceClass);
			T instance = asmInstanceClass.newInstance();
			instances.add(instance);
		} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | LinkageError e) {
			HarshenCastle.LOGGER.error("Failed to load: {}", asmData.getClassName(), e);
		}
	}
	return instances;
}
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:17,代码来源:HarshenUtils.java

示例2: getPluginInstances

import net.minecraftforge.fml.common.discovery.ASMDataTable; //导入方法依赖的package包/类
public static List<CustomStuffPlugin> getPluginInstances(ASMDataTable asmDataTable)
{
    String annotationName = CS4Plugin.class.getCanonicalName();
    Set<ASMDataTable.ASMData> asmDatas = asmDataTable.getAll(annotationName);

    List<CustomStuffPlugin> instances = Lists.newArrayList();
    for (ASMDataTable.ASMData asmData : asmDatas)
    {
        try
        {
            Class<?> asmClass = Class.forName(asmData.getClassName());
            if (CustomStuffPlugin.class.isAssignableFrom(asmClass))
            {
                Class<? extends CustomStuffPlugin> instanceClass = asmClass.asSubclass(CustomStuffPlugin.class);
                CustomStuffPlugin instance = instanceClass.newInstance();
                instances.add(instance);
            }
        } catch (ClassNotFoundException | IllegalAccessException | InstantiationException e)
        {
            e.printStackTrace();
        }
    }
    return instances;
}
 
开发者ID:cubex2,项目名称:customstuff4,代码行数:25,代码来源:PluginHelper.java

示例3: loadData

import net.minecraftforge.fml.common.discovery.ASMDataTable; //导入方法依赖的package包/类
public static void loadData(ASMDataTable data)
{
    FMLLog.fine("Loading @Config anotation data");
    for (ASMData target : data.getAll(Config.class.getName()))
    {
        String modid = (String)target.getAnnotationInfo().get("modid");
        Multimap<Config.Type, ASMData> map = asm_data.get(modid);
        if (map == null)
        {
            map = ArrayListMultimap.create();
            asm_data.put(modid, map);
        }

        EnumHolder tholder = (EnumHolder)target.getAnnotationInfo().get("type");
        Config.Type type = tholder == null ? Config.Type.INSTANCE : Config.Type.valueOf(tholder.getValue());

        map.put(type, target);
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:20,代码来源:ConfigManager.java

示例4: scrapeData

import net.minecraftforge.fml.common.discovery.ASMDataTable; //导入方法依赖的package包/类
public static void scrapeData(ASMDataTable dataTable) {
    ImmutableList.Builder<IConfigureNEI> plugins = ImmutableList.builder();
    for (ASMDataTable.ASMData data : dataTable.getAll(NEIPlugin.class.getName())) {
        try {
            Class<?> pluginClass = Class.forName(data.getClassName());
            if (IConfigureNEI.class.isAssignableFrom(pluginClass)) {
                IConfigureNEI pluginInstance = (IConfigureNEI) pluginClass.newInstance();
                plugins.add(pluginInstance);
            } else {
                LogHelper.error("Found class with annotation @NEIPlugin but class does not implement IConfigureNEI.. Class: " + data.getClassName());
            }

        } catch (Exception e) {
            LogHelper.fatalError("Fatal exception occurred whilst loading a plugin! Class: %s", e, data.getClassName());
        }
    }
    NEIInitialization.plugins = plugins.build();

}
 
开发者ID:TheCBProject,项目名称:NotEnoughItems,代码行数:20,代码来源:NEIInitialization.java

示例5: registerEvents

import net.minecraftforge.fml.common.discovery.ASMDataTable; //导入方法依赖的package包/类
private static void registerEvents(@Nonnull ASMDataTable dataTable) {
    String className = EventRegister.class.getCanonicalName();
    Set<ASMDataTable.ASMData> dataSet = new HashSet<>(dataTable.getAll(className));
    for (ASMDataTable.ASMData data : dataSet) {
        try {
            Class clazz = Class.forName(data.getClassName());
            if (EventRegister.IOptionalEvent.class.isAssignableFrom(clazz)) {
                EventRegister.IOptionalEvent eventActive = (EventRegister.IOptionalEvent) clazz.newInstance();
                if (eventActive.isActive()) {
                    MinecraftForge.EVENT_BUS.register(clazz.newInstance());
                }
            } else {
                MinecraftForge.EVENT_BUS.register(clazz.newInstance());
            }
        } catch (Exception ignored) {
        }
    }
}
 
开发者ID:GirafiStudios,项目名称:Culinary-Cultivation,代码行数:19,代码来源:CommonProxy.java

示例6: getInstances

import net.minecraftforge.fml.common.discovery.ASMDataTable; //导入方法依赖的package包/类
/**
 * Loads classes with a specific annotation from an asm data table.
 *
 * Borrowed from JEI's source code, which is licensed under the MIT license.
 *
 * @param <T> The type of class to load.
 * @param asm The asm data table to load classes from.
 * @param anno The annotation marking classes of interest.
 * @param type The class type to load, as to get around Type erasure.
 * @return A list of the loaded classes, instantiated.
 */
private static <T> List<T> getInstances(ASMDataTable asm, Class anno, Class<T> type) {
    List<T> instances = new ArrayList<>();
    for (ASMDataTable.ASMData asmData : asm.getAll(anno.getCanonicalName())) {
        try {
            T instance = Class.forName(asmData.getClassName()).asSubclass(type).newInstance();
            instances.add(instance);
        } catch (ClassNotFoundException | NoClassDefFoundError | IllegalAccessException | InstantiationException e) {
            AgriCore.getLogger("agricraft-plugins").debug(
                    "%nFailed to load AgriPlugin%n\tOf class: {0}!%n\tFor annotation: {1}!%n\tAs Instanceof: {2}!",
                    asmData.getClassName(),
                    anno.getCanonicalName(),
                    type.getCanonicalName()
            );
        }
    }
    return instances;
}
 
开发者ID:AgriCraft,项目名称:AgriCraft,代码行数:29,代码来源:PluginHandler.java

示例7: initTable

import net.minecraftforge.fml.common.discovery.ASMDataTable; //导入方法依赖的package包/类
public void initTable(ASMDataTable dataTable)
{
    optionals = ArrayListMultimap.create();
    Set<ASMData> interfaceLists = dataTable.getAll("net.minecraftforge.fml.common.Optional$InterfaceList");
    addData(unpackInterfaces(interfaceLists));
    Set<ASMData> interfaces = dataTable.getAll("net.minecraftforge.fml.common.Optional$Interface");
    addData(interfaces);
    Set<ASMData> methods = dataTable.getAll("net.minecraftforge.fml.common.Optional$Method");
    addData(methods);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:11,代码来源:ModAPITransformer.java

示例8: getInstances

import net.minecraftforge.fml.common.discovery.ASMDataTable; //导入方法依赖的package包/类
public static <T> List<T> getInstances (ASMDataTable asmDataTable, Class<? extends Annotation> annotationClass, Class<T> instanceClass) {
    final String annotationClassName = annotationClass.getCanonicalName();
    final Set<ASMDataTable.ASMData> asmDatas = asmDataTable.getAll(annotationClassName);
    final List<T> instances = new ArrayList<>();
    for (final ASMDataTable.ASMData asmData : asmDatas)
        try {
            instances.add(Class.forName(asmData.getClassName()).asSubclass(instanceClass).newInstance());
        }
        catch (final Exception e) {
            MMDLib.LOG.error("Failed to load: {}", asmData.getClassName(), e);
        }
    return instances;
}
 
开发者ID:MinecraftModDevelopmentMods,项目名称:MMDLib-old,代码行数:14,代码来源:AnnotationChecker.java

示例9: registerCommands

import net.minecraftforge.fml.common.discovery.ASMDataTable; //导入方法依赖的package包/类
public static void registerCommands(@Nonnull ASMDataTable asmDataTable) {
    String annotationClassName = Command.class.getCanonicalName();
    Set<ASMData> asmDatas = new HashSet<ASMData>(asmDataTable.getAll(annotationClassName));

    for (ASMDataTable.ASMData asmData : asmDatas) {
        try {
            Class<?> asmClass = Class.forName(asmData.getClassName());
            Class<? extends AbstractCommand> asmInstanceClass = asmClass.asSubclass(AbstractCommand.class);
            AbstractCommand instance = asmInstanceClass.newInstance();
            CommandManager.INSTANCE.registerCommand(instance);
        } catch (Exception e) { e.printStackTrace(); }
    }
}
 
开发者ID:joshiejack,项目名称:Progression,代码行数:14,代码来源:CommandManager.java

示例10: fetchPlugins

import net.minecraftforge.fml.common.discovery.ASMDataTable; //导入方法依赖的package包/类
private <T> List<T> fetchPlugins(ASMDataTable asmDataTable, Class annotationClass, Class<T> instanceClass){
	String annotationClassName = annotationClass.getCanonicalName();
	Set<ASMDataTable.ASMData> asmDatas = asmDataTable.getAll(annotationClassName);
	List<T> instances = new ArrayList<>();
	for (ASMDataTable.ASMData asmData : asmDatas)
		try {
			Class<?> asmClass = Class.forName(asmData.getClassName());
			Class<? extends T> asmInstanceClass = asmClass.asSubclass(instanceClass);
			T instance = asmInstanceClass.newInstance();
			instances.add(instance);
		} catch (ClassNotFoundException | IllegalAccessException | InstantiationException e) {
			ACLogger.severe("Failed to load: {}", asmData.getClassName(), e);
		}
	return instances;
}
 
开发者ID:Shinoow,项目名称:AbyssalCraft,代码行数:16,代码来源:IntegrationHandler.java

示例11: fillAllHolders

import net.minecraftforge.fml.common.discovery.ASMDataTable; //导入方法依赖的package包/类
public void fillAllHolders(ASMDataTable data) {
	final Map<Field, Class<?>> classTargetToSource = Maps.newHashMap();
	final Map<Field, Class<?>> fieldTargetToSource = Maps.newHashMap();

	for (ASMData target : data.getAll(TypeVariableHolder.class.getName()))
		findTargets(target, classTargetToSource, fieldTargetToSource);

	fillFields(classTargetToSource, fieldTargetToSource);
}
 
开发者ID:OpenMods,项目名称:OpenModsLib,代码行数:10,代码来源:TypeVariableHolderHandler.java

示例12: fillTargetFields

import net.minecraftforge.fml.common.discovery.ASMDataTable; //导入方法依赖的package包/类
private static <A> void fillTargetFields(final ApiProviderRegistry<A> registry, ASMDataTable table, Class<? extends Annotation> fieldMarker, Class<A> interfaceMarker) {
	final ClassInfoCache clsCache = new ClassInfoCache();
	final Set<ASMData> targets = table.getAll(fieldMarker.getName());

	for (ASMData data : targets)
		fillTargetField(clsCache, registry, data, interfaceMarker);
}
 
开发者ID:OpenMods,项目名称:OpenModsLib,代码行数:8,代码来源:ApiFactory.java

示例13: registerRules

import net.minecraftforge.fml.common.discovery.ASMDataTable; //导入方法依赖的package包/类
public static void registerRules(@Nonnull ASMDataTable asmDataTable) {
    Class annotationClass = ProgressionRule.class;
    String annotationClassName = annotationClass.getCanonicalName();
    Set<ASMData> asmDatas = new HashSet<ASMData>(asmDataTable.getAll(annotationClassName));

    topLoop:
    for (ASMDataTable.ASMData asmData : asmDatas) {
        try {
            Class<?> asmClass = Class.forName(asmData.getClassName());
            Class<? extends IRule> asmInstanceClass = asmClass.asSubclass(IRule.class);
            IRule instance = asmInstanceClass.newInstance();
            Map<String, Object> data = asmData.getAnnotationInfo();
            String modData = (String) data.get("mod");
            if (modData != null) {
                String[] mods = modData.replace(" ", "").split(",");
                for (String mod: mods) {
                    if (mod != null && !Loader.isModLoaded(mod)) continue topLoop;
                }
            }


            String name = (String) data.get("name");
            int color = 0xFFCCCCCC;
            if (data.get("color") != null) {
                color = (Integer) data.get("color");
            }

            String icon = (String) data.get("icon");
            String meta = (String) data.get("meta");
            boolean isCancelable = false;
            if (data.get("cancelable") != null) {
                isCancelable = (Boolean) data.get("cancelable");
            }

            ItemStack stack = StackHelper.getStackFromString(icon);
            if (stack == null) stack = new ItemStack(Progression.item);
            if (meta != null) {
                for (ItemMeta item: ItemMeta.values()) {
                    if (item.name().equalsIgnoreCase(meta)) {
                        stack.setItemDamage(item.ordinal());
                        break;
                    }
                }
            }

            if (instance instanceof IReward) {
                APIHandler.registerRewardType(instance, name, color).setIcon(stack);
            } else if (instance instanceof ITrigger) {
                ITriggerProvider provider = APIHandler.registerTriggerType(instance, name, color).setIcon(stack);
                if (isCancelable) {
                    provider.setCancelable();
                }
            } else if (instance instanceof ICondition) {
                APIHandler.registerConditionType(instance, name).setIcon(stack);
            } else if (instance instanceof IFilter) {
                APIHandler.registerFilterType(instance, name, color);
            }
        } catch (Exception e) { e.printStackTrace(); }
    }
}
 
开发者ID:joshiejack,项目名称:Progression,代码行数:61,代码来源:RuleHandler.java

示例14: getData

import net.minecraftforge.fml.common.discovery.ASMDataTable; //导入方法依赖的package包/类
/**
 * Gets the ASMData for all classes annotated with the annotation class.
 *
 * @param table The ASMDataTable. This is generated from forge an can be accessed from the
 *        initialization events.
 * @param annotation The annotation to search for.
 * @return A set of ASMData for classes with the passed annotation.
 */
public static <A extends Annotation> Set<ASMData> getData (ASMDataTable table, Class<A> annotation) {

    return table.getAll(annotation.getCanonicalName());
}
 
开发者ID:Darkhax-Minecraft,项目名称:Bookshelf,代码行数:13,代码来源:AnnotationUtils.java


注:本文中的net.minecraftforge.fml.common.discovery.ASMDataTable.getAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。