• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ASMData类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中cpw.mods.fml.common.discovery.ASMDataTable.ASMData的典型用法代码示例。如果您正苦于以下问题:Java ASMData类的具体用法?Java ASMData怎么用?Java ASMData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ASMData类属于cpw.mods.fml.common.discovery.ASMDataTable包,在下文中一共展示了ASMData类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: unpackInterfaces

import cpw.mods.fml.common.discovery.ASMDataTable.ASMData; //导入依赖的package包/类
private Set<ASMData> unpackInterfaces(Set<ASMData> packedInterfaces)
{
    Set<ASMData> result = Sets.newHashSet();
    for (ASMData data : packedInterfaces)
    {
        @SuppressWarnings("unchecked")
        List<Map<String,Object>> packedList = (List<Map<String,Object>>) data.getAnnotationInfo().get("value");
        for (Map<String,Object> packed : packedList)
        {
            ASMData newData = data.copy(packed);
            result.add(newData);
        }
    }

    return result;
}
 
开发者ID:SchrodingersSpy,项目名称:TRHS_Club_Mod_2016,代码行数:17,代码来源:ModAPITransformer.java


示例2: addRoot

import cpw.mods.fml.common.discovery.ASMDataTable.ASMData; //导入依赖的package包/类
public void addRoot(ASMData asmData) {
	Map<String, Object> annotationInfo = asmData.getAnnotationInfo();

	String packageName = asmData.getClassName();

	int pkgIndex = packageName.lastIndexOf('.');
	if (pkgIndex > -1)
		packageName = packageName.substring(0, pkgIndex);
	packageName = packageName.replace(".", "/");

	if (!containerMap.containsKey(packageName)) {
		DPLogger.info("Discovered config controller inside: " + packageName);

		File defaultConfig = getConfigForPackage(annotationInfo);

		DPLogger.info("Setting config: " + defaultConfig);

		containerMap.put(packageName, new ConfigContainer(defaultConfig));
	} else {
		DPLogger.warning("Config controller discovered in the same root: " + packageName);
		DPLogger.warning("THIS IS AN ERROR! Ignoring " + asmData.getClassName());
	}
}
 
开发者ID:NPException,项目名称:Dimensional-Pockets,代码行数:24,代码来源:ConfigData.java


示例3: processAllClasses

import cpw.mods.fml.common.discovery.ASMDataTable.ASMData; //导入依赖的package包/类
public void processAllClasses(ASMDataTable dataTable, Map<Class<? extends Annotation>, Class<? extends ConfigEntry<? extends Annotation, ?>>> staticMap) {
    for (Map.Entry<Class<? extends Annotation>, Class<? extends ConfigEntry<? extends Annotation, ?>>> entry : staticMap.entrySet()) {
        try {
            annotationMap.put(entry.getKey(), entry.getValue().newInstance().setConfig(config));
        } catch (InstantiationException | IllegalAccessException e) {
            DPLogger.severe("Failed to create instance of the registered ConfigEntry!", e);
        }
    }

    ArrayList<String> processedClasses = new ArrayList<>();
    for (Class<? extends Annotation> clazz : annotationMap.keySet()) {
        for (ASMData asmData : dataTable.getAll(clazz.getName())) {
            String className = asmData.getClassName();
            if (childClasses.contains(className) && !processedClasses.contains(className)) {
                processedClasses.add(className);
                processClass(className);
            }
        }
    }
}
 
开发者ID:NPException,项目名称:Dimensional-Pockets,代码行数:21,代码来源:ConfigContainer.java


示例4: addRoot

import cpw.mods.fml.common.discovery.ASMDataTable.ASMData; //导入依赖的package包/类
public void addRoot(ASMData asmData) {
    Map<String, Object> annotationInfo = asmData.getAnnotationInfo();

    String packageName = asmData.getClassName();

    int pkgIndex = packageName.lastIndexOf('.');
    if (pkgIndex > -1)
        packageName = packageName.substring(0, pkgIndex);
    packageName = packageName.replace(".", "/");

    if (!containerMap.containsKey(packageName)) {
        CoreProperties.logger.info("Discovered config controller inside: {}", packageName);

        File defaultConfig = getConfigForPackage(annotationInfo);

        CoreProperties.logger.info("Setting config: {}", defaultConfig);

        containerMap.put(packageName, new ConfigContainer(defaultConfig));
    } else {
        CoreProperties.logger.warn("Config controller discovered in the same root: {}. ", packageName);
        CoreProperties.logger.warn("THIS IS AN ERROR! Ignoring {}", asmData.getClassName());
    }
}
 
开发者ID:Jezza,项目名称:OmnisCore,代码行数:24,代码来源:ConfigData.java


示例5: processAllClasses

import cpw.mods.fml.common.discovery.ASMDataTable.ASMData; //导入依赖的package包/类
public void processAllClasses(ASMDataTable dataTable, Map<Class<? extends Annotation>, Class<? extends ConfigEntry<? extends Annotation, ?>>> staticMap) {
    for (Map.Entry<Class<? extends Annotation>, Class<? extends ConfigEntry<? extends Annotation, ?>>> entry : staticMap.entrySet()) {
        try {
            annotationMap.put(entry.getKey(), entry.getValue().newInstance().setConfig(config));
        } catch (InstantiationException | IllegalAccessException e) {
            CoreProperties.logger.fatal("Failed to create instance of the registered ConfigEntry!", e);
        }
    }

    ArrayList<String> processedClasses = new ArrayList<>();
    for (Class<? extends Annotation> clazz : annotationMap.keySet()) {
        for (ASMData asmData : dataTable.getAll(clazz.getName())) {
            String className = asmData.getClassName();
            if (childClasses.contains(className) && !processedClasses.contains(className)) {
                processedClasses.add(className);
                processClass(className);
            }
        }
    }
}
 
开发者ID:Jezza,项目名称:OmnisCore,代码行数:21,代码来源:ConfigContainer.java


示例6: initTable

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


示例7: addData

import cpw.mods.fml.common.discovery.ASMDataTable.ASMData; //导入依赖的package包/类
private void addData(Set<ASMData> interfaces)
{
    for (ASMData data : interfaces)
    {
        optionals.put(data.getClassName(),data);
    }
}
 
开发者ID:SchrodingersSpy,项目名称:TRHS_Club_Mod_2016,代码行数:8,代码来源:ModAPITransformer.java


示例8: constructMod

import cpw.mods.fml.common.discovery.ASMDataTable.ASMData; //导入依赖的package包/类
@Subscribe
public void constructMod(FMLConstructionEvent event) {
    log.info("LambdaLib|Core is loading.");

    // Get annotation information from forge asm data table.
    // This must be done before PreInit stage.
    ASMDataTable data = event.getASMHarvestedData();

    Set<String> removedClasses = Sets.newHashSet();
    { // Get removed classes
        String startupSide = FMLCommonHandler.instance().getSide().toString();
        Set<ASMData> sideData = data.getAll("cpw.mods.fml.relauncher.SideOnly");
        for (ASMData ad : sideData) if (ad.getClassName().equals(ad.getObjectName())) { // If is a class
            EnumHolder enumHolder = (EnumHolder) ad.getAnnotationInfo().get("value");
            try {
                String value = (String) ehFieldValue.get(enumHolder);
                if (!value.equals(startupSide)) {
                    removedClasses.add(ad.getClassName());
                }
            } catch (IllegalAccessException ex) {
                throw Throwables.propagate(ex);
            }
        }
    }

    LLModContainer.removedClasses.addAll(removedClasses);

    Set<String> registrants = mapToClass(data.getAll("cn.lambdalib.annoreg.core.Registrant"));
    registrants.removeAll(removedClasses);
    RegistrationManager.INSTANCE.annotationList(registrants);

    Set<String> registryTypes = mapToClass(data.getAll("cn.lambdalib.annoreg.core.RegistryTypeDecl"));
    registryTypes.removeAll(removedClasses);
    RegistrationManager.INSTANCE.addRegistryTypes(registryTypes);

    Set<String> registryMods = mapToClass(data.getAll("cn.lambdalib.annoreg.core.RegistrationMod"));
    registryMods.removeAll(removedClasses);
    RegistrationManager.INSTANCE.addAnnotationMod(registryMods);
}
 
开发者ID:LambdaInnovation,项目名称:LambdaLib,代码行数:40,代码来源:LLModContainer.java


示例9: parseControllers

import cpw.mods.fml.common.discovery.ASMDataTable.ASMData; //导入依赖的package包/类
public void parseControllers(FMLPreInitializationEvent event) {
    if (init)
        return;
    init = true;

    ASMDataTable asmDataTable = event.getAsmData();
    Set<ASMData> asmDataSet = asmDataTable.getAll(Controller.class.getName());

    // Filters out all controller annotations and places them with their associated mod.
    for (ASMData data : asmDataSet) {
        ModCandidate candidate = data.getCandidate();
        for (ModContainer modContainer : candidate.getContainedMods()) {
            String modId = modContainer.getModId();
            if (!configMap.containsKey(modId))
                configMap.put(modId, new ConfigData(modContainer, candidate.getClassList()));
            configMap.get(modId).addRoot(data);
        }
    }

    // Process all potential registrars first.
    for (ConfigData configValue : configMap.values())
        if (configValue.isRegistrar)
            configValue.processIConfigRegistrar(this);
    processed = true;

    for (ConfigData configData : configMap.values()) {
        // Organise all sub-packages.
        configData.processRoots();

        // Process all current classes associated with the ConfigContainer.
        configData.processConfigContainers(asmDataTable, annotationMap);
    }
    postProcessed = true;
}
 
开发者ID:NPException,项目名称:Dimensional-Pockets,代码行数:35,代码来源:ConfigHandler.java


示例10: NetworkModHandler

import cpw.mods.fml.common.discovery.ASMDataTable.ASMData; //导入依赖的package包/类
public NetworkModHandler(ModContainer container, Class<?> networkModClass, ASMDataTable table)
{
    this(container, networkModClass.getAnnotation(NetworkMod.class));
    if (this.mod == null)
    {
        return;
    }

    Set<ASMData> versionCheckHandlers = table.getAnnotationsFor(container).get(NetworkMod.VersionCheckHandler.class.getName());
    String versionCheckHandlerMethod = null;
    for (ASMData vch : versionCheckHandlers)
    {
        if (vch.getClassName().equals(networkModClass.getName()))
        {
            versionCheckHandlerMethod = vch.getObjectName();
            versionCheckHandlerMethod = versionCheckHandlerMethod.substring(0,versionCheckHandlerMethod.indexOf('('));
            break;
        }
    }
    if (versionCheckHandlerMethod != null)
    {
        try
        {
            Method checkHandlerMethod = networkModClass.getDeclaredMethod(versionCheckHandlerMethod, String.class);
            if (checkHandlerMethod.isAnnotationPresent(NetworkMod.VersionCheckHandler.class))
            {
                this.checkHandler = checkHandlerMethod;
            }
        }
        catch (Exception e)
        {
            FMLLog.log(Level.WARNING, e, "The declared version check handler method %s on network mod id %s is not accessible", versionCheckHandlerMethod, container.getModId());
        }
    }

    configureNetworkMod(container);
}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:38,代码来源:NetworkModHandler.java


示例11: unpackInterfaces

import cpw.mods.fml.common.discovery.ASMDataTable.ASMData; //导入依赖的package包/类
private Set<ASMData> unpackInterfaces(Set<ASMData> packedInterfaces)
{
    Set<ASMData> result = Sets.newHashSet();
    for (ASMData data : packedInterfaces)
    {
        List<Map<String,Object>> packedList = (List<Map<String,Object>>) data.getAnnotationInfo().get("value");
        for (Map<String,Object> packed : packedList)
        {
            ASMData newData = data.copy(packed);
            result.add(newData);
        }
    }

    return result;
}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:16,代码来源:ModAPITransformer.java


示例12: loadFeatureGroupsFromAnnotations

import cpw.mods.fml.common.discovery.ASMDataTable.ASMData; //导入依赖的package包/类
public void loadFeatureGroupsFromAnnotations(ASMDataTable asmData) {
	for (ASMData fgAnnotation : asmData.getAll(FeatureGroup.class.getName())) {
		@SuppressWarnings("unchecked")
		final List<String> featureGroups = (List<String>)fgAnnotation.getAnnotationInfo().get("value");
		for (String featureGroup : featureGroups)
			ensureExists(featureGroup);
	}
}
 
开发者ID:OpenMods,项目名称:OpenPeripheral,代码行数:9,代码来源:FeatureGroupManager.java


示例13: inject

import cpw.mods.fml.common.discovery.ASMDataTable.ASMData; //导入依赖的package包/类
public static void inject(ModContainer mod, ASMDataTable data, Side side, ILanguageAdapter languageAdapter)
{
    FMLLog.fine("Attempting to inject @SidedProxy classes into %s", mod.getModId());
    Set<ASMData> targets = data.getAnnotationsFor(mod).get(SidedProxy.class.getName());
    ClassLoader mcl = Loader.instance().getModClassLoader();

    for (ASMData targ : targets)
    {
        try
        {
            Class<?> proxyTarget = Class.forName(targ.getClassName(), true, mcl);
            Field target = proxyTarget.getDeclaredField(targ.getObjectName());
            if (target == null)
            {
                // Impossible?
                FMLLog.severe("Attempted to load a proxy type into %s.%s but the field was not found", targ.getClassName(), targ.getObjectName());
                throw new LoaderException(String.format("Attempted to load a proxy type into %s.%s but the field was not found", targ.getClassName(), targ.getObjectName()));
            }
            target.setAccessible(true);

            SidedProxy annotation = target.getAnnotation(SidedProxy.class);
            if (!Strings.isNullOrEmpty(annotation.modId()) && !annotation.modId().equals(mod.getModId()))
            {
                FMLLog.fine("Skipping proxy injection for %s.%s since it is not for mod %s", targ.getClassName(), targ.getObjectName(), mod.getModId());
                continue;
            }
            String targetType = side.isClient() ? annotation.clientSide() : annotation.serverSide();
            Object proxy=Class.forName(targetType, true, mcl).newInstance();

            if (languageAdapter.supportsStatics() && (target.getModifiers() & Modifier.STATIC) == 0 )
            {
                FMLLog.severe("Attempted to load a proxy type %s into %s.%s, but the field is not static", targetType, targ.getClassName(), targ.getObjectName());
                throw new LoaderException(String.format("Attempted to load a proxy type %s into %s.%s, but the field is not static", targetType, targ.getClassName(), targ.getObjectName()));
            }
            if (!target.getType().isAssignableFrom(proxy.getClass()))
            {
                FMLLog.severe("Attempted to load a proxy type %s into %s.%s, but the types don't match", targetType, targ.getClassName(), targ.getObjectName());
                throw new LoaderException(String.format("Attempted to load a proxy type %s into %s.%s, but the types don't match", targetType, targ.getClassName(), targ.getObjectName()));
            }
            languageAdapter.setProxy(target, proxyTarget, proxy);
        }
        catch (Exception e)
        {
            FMLLog.log(Level.ERROR, e, "An error occured trying to load a proxy into %s.%s", targ.getAnnotationInfo(), targ.getClassName(), targ.getObjectName());
            throw new LoaderException(e);
        }
    }

    // Allow language specific proxy injection.
    languageAdapter.setInternalProxies(mod, side, mcl);
}
 
开发者ID:SchrodingersSpy,项目名称:TRHS_Club_Mod_2016,代码行数:52,代码来源:ProxyInjector.java


示例14: transform

import cpw.mods.fml.common.discovery.ASMDataTable.ASMData; //导入依赖的package包/类
@Override
public byte[] transform(String name, String transformedName, byte[] basicClass)
{
    String lookupName = name;
    if(name.endsWith("$class"))
    {
        lookupName = name.substring(0, name.length() - 6);
    }
    if (optionals == null || !optionals.containsKey(lookupName))
    {
        return basicClass;
    }
    ClassNode classNode = new ClassNode();
    ClassReader classReader = new ClassReader(basicClass);
    classReader.accept(classNode, 0);

    if (logDebugInfo) FMLRelaunchLog.finer("Optional removal - found optionals for class %s - processing", name);
    for (ASMData optional : optionals.get(lookupName))
    {
        String modId = (String) optional.getAnnotationInfo().get("modid");

        if (Loader.isModLoaded(modId) || ModAPIManager.INSTANCE.hasAPI(modId))
        {
            if (logDebugInfo) FMLRelaunchLog.finer("Optional removal skipped - mod present %s", modId);
            continue;
        }
        if (logDebugInfo) FMLRelaunchLog.finer("Optional on %s triggered - mod missing %s", name, modId);

        if (optional.getAnnotationInfo().containsKey("iface"))
        {
            Boolean stripRefs = (Boolean)optional.getAnnotationInfo().get("striprefs");
            if (stripRefs == null) stripRefs = Boolean.FALSE;
            stripInterface(classNode,(String)optional.getAnnotationInfo().get("iface"), stripRefs);
        }
        else
        {
            stripMethod(classNode, (String)optional.getObjectName());
        }

    }
    if (logDebugInfo) FMLRelaunchLog.finer("Optional removal - class %s processed", name);

    ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS);
    classNode.accept(writer);
    return writer.toByteArray();
}
 
开发者ID:SchrodingersSpy,项目名称:TRHS_Club_Mod_2016,代码行数:47,代码来源:ModAPITransformer.java


示例15: parseSimpleFieldAnnotation

import cpw.mods.fml.common.discovery.ASMDataTable.ASMData; //导入依赖的package包/类
private void parseSimpleFieldAnnotation(SetMultimap<String, ASMData> annotations, String annotationClassName, Function<ModContainer, Object> retreiver) throws IllegalAccessException
{
    String[] annName = annotationClassName.split("\\.");
    String annotationName = annName[annName.length - 1];
    for (ASMData targets : annotations.get(annotationClassName))
    {
        String targetMod = (String) targets.getAnnotationInfo().get("value");
        Field f = null;
        Object injectedMod = null;
        ModContainer mc = this;
        boolean isStatic = false;
        Class<?> clz = modInstance.getClass();
        if (!Strings.isNullOrEmpty(targetMod))
        {
            if (Loader.isModLoaded(targetMod))
            {
                mc = Loader.instance().getIndexedModList().get(targetMod);
            }
            else
            {
                mc = null;
            }
        }
        if (mc != null)
        {
            try
            {
                clz = Class.forName(targets.getClassName(), true, Loader.instance().getModClassLoader());
                f = clz.getDeclaredField(targets.getObjectName());
                f.setAccessible(true);
                isStatic = Modifier.isStatic(f.getModifiers());
                injectedMod = retreiver.apply(mc);
            }
            catch (Exception e)
            {
                Throwables.propagateIfPossible(e);
                FMLLog.log(getModId(), Level.WARN, e, "Attempting to load @%s in class %s for %s and failing", annotationName, targets.getClassName(), mc.getModId());
            }
        }
        if (f != null)
        {
            Object target = null;
            if (!isStatic)
            {
                target = modInstance;
                if (!modInstance.getClass().equals(clz))
                {
                    FMLLog.log(getModId(), Level.WARN, "Unable to inject @%s in non-static field %s.%s for %s as it is NOT the primary mod instance", annotationName, targets.getClassName(), targets.getObjectName(), mc.getModId());
                    continue;
                }
            }
            f.set(target, injectedMod);
        }
    }
}
 
开发者ID:SchrodingersSpy,项目名称:TRHS_Club_Mod_2016,代码行数:56,代码来源:FMLModContainer.java


示例16: mapToClass

import cpw.mods.fml.common.discovery.ASMDataTable.ASMData; //导入依赖的package包/类
private Set<String> mapToClass(Set<ASMData> adset) {
    return adset.stream().map(ASMData::getClassName).collect(Collectors.toSet());
}
 
开发者ID:LambdaInnovation,项目名称:LambdaLib,代码行数:4,代码来源:LLModContainer.java


示例17: inject

import cpw.mods.fml.common.discovery.ASMDataTable.ASMData; //导入依赖的package包/类
public static void inject(ModContainer mod, ASMDataTable data, Side side, ILanguageAdapter languageAdapter)
{
    FMLLog.fine("Attempting to inject @SidedProxy classes into %s", mod.getModId());
    Set<ASMData> targets = data.getAnnotationsFor(mod).get(SidedProxy.class.getName());
    ClassLoader mcl = Loader.instance().getModClassLoader();

    for (ASMData targ : targets)
    {
        try
        {
            Class<?> proxyTarget = Class.forName(targ.getClassName(), true, mcl);
            Field target = proxyTarget.getDeclaredField(targ.getObjectName());
            if (target == null)
            {
                // Impossible?
                FMLLog.severe("Attempted to load a proxy type into %s.%s but the field was not found", targ.getClassName(), targ.getObjectName());
                throw new LoaderException();
            }
            target.setAccessible(true);

            SidedProxy annotation = target.getAnnotation(SidedProxy.class);
            if (!Strings.isNullOrEmpty(annotation.modId()) && !annotation.modId().equals(mod.getModId()))
            {
                FMLLog.fine("Skipping proxy injection for %s.%s since it is not for mod %s", targ.getClassName(), targ.getObjectName(), mod.getModId());
                continue;
            }
            String targetType = side.isClient() ? annotation.clientSide() : annotation.serverSide();
            Object proxy=Class.forName(targetType, true, mcl).newInstance();

            if (languageAdapter.supportsStatics() && (target.getModifiers() & Modifier.STATIC) == 0 )
            {
                FMLLog.severe("Attempted to load a proxy type %s into %s.%s, but the field is not static", targetType, targ.getClassName(), targ.getObjectName());
                throw new LoaderException();
            }
            if (!target.getType().isAssignableFrom(proxy.getClass()))
            {
                FMLLog.severe("Attempted to load a proxy type %s into %s.%s, but the types don't match", targetType, targ.getClassName(), targ.getObjectName());
                throw new LoaderException();
            }
            languageAdapter.setProxy(target, proxyTarget, proxy);
        }
        catch (Exception e)
        {
            FMLLog.log(Level.ERROR, e, "An error occured trying to load a proxy into %s.%s", targ.getAnnotationInfo(), targ.getClassName(), targ.getObjectName());
            throw new LoaderException(e);
        }
    }

    // Allow language specific proxy injection.
    languageAdapter.setInternalProxies(mod, side, mcl);
}
 
开发者ID:alexandrage,项目名称:CauldronGit,代码行数:52,代码来源:ProxyInjector.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java NMWebApp类代码示例发布时间:2022-05-22
下一篇:
Java Utils4J类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap