Search in sources :

Example 1 with ModFileScanData

use of net.minecraftforge.forgespi.language.ModFileScanData in project MinecraftForge by MinecraftForge.

the class ForgeGameTestHooks method registerGametests.

@SuppressWarnings("deprecation")
public static void registerGametests() {
    if (!registeredGametests && isGametestEnabled()) {
        Set<String> enabledNamespaces = getEnabledNamespaces();
        LOGGER.info("Enabled Gametest Namespaces: {}", enabledNamespaces);
        Set<Method> gameTestMethods = new HashSet<>();
        RegisterGameTestsEvent event = new RegisterGameTestsEvent(gameTestMethods);
        ModLoader.get().postEvent(event);
        ModList.get().getAllScanData().stream().map(ModFileScanData::getAnnotations).flatMap(Collection::stream).filter(a -> GAME_TEST_HOLDER.equals(a.annotationType())).forEach(a -> addGameTestMethods(a, gameTestMethods));
        for (Method gameTestMethod : gameTestMethods) {
            GameTestRegistry.register(gameTestMethod, enabledNamespaces);
        }
        registeredGametests = true;
    }
}
Also used : ModLoader(net.minecraftforge.fml.ModLoader) Arrays(java.util.Arrays) AnnotationData(net.minecraftforge.forgespi.language.ModFileScanData.AnnotationData) Collection(java.util.Collection) ModList(net.minecraftforge.fml.ModList) Set(java.util.Set) GameTestRegistry(net.minecraft.gametest.framework.GameTestRegistry) Type(org.objectweb.asm.Type) Collectors(java.util.stream.Collectors) HashSet(java.util.HashSet) FMLLoader(net.minecraftforge.fml.loading.FMLLoader) Logger(org.apache.logging.log4j.Logger) RegisterGameTestsEvent(net.minecraftforge.event.RegisterGameTestsEvent) SharedConstants(net.minecraft.SharedConstants) ModFileScanData(net.minecraftforge.forgespi.language.ModFileScanData) GameTest(net.minecraft.gametest.framework.GameTest) LogManager(org.apache.logging.log4j.LogManager) Method(java.lang.reflect.Method) RegisterGameTestsEvent(net.minecraftforge.event.RegisterGameTestsEvent) Collection(java.util.Collection) Method(java.lang.reflect.Method) HashSet(java.util.HashSet)

Example 2 with ModFileScanData

use of net.minecraftforge.forgespi.language.ModFileScanData in project MinecraftForge by MinecraftForge.

the class Scanner method scan.

public ModFileScanData scan() {
    ModFileScanData result = new ModFileScanData();
    result.addModFileInfo(fileToScan.getModFileInfo());
    fileToScan.scanFile(p -> fileVisitor(p, result));
    final List<IModLanguageProvider> loaders = fileToScan.getLoaders();
    if (loaders != null) {
        loaders.forEach(loader -> {
            LOGGER.debug(LogMarkers.SCAN, "Scanning {} with language loader {}", fileToScan.getFilePath(), loader.name());
            loader.getFileVisitor().accept(result);
        });
    }
    return result;
}
Also used : ModFileScanData(net.minecraftforge.forgespi.language.ModFileScanData) IModLanguageProvider(net.minecraftforge.forgespi.language.IModLanguageProvider)

Aggregations

ModFileScanData (net.minecraftforge.forgespi.language.ModFileScanData)2 Method (java.lang.reflect.Method)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 SharedConstants (net.minecraft.SharedConstants)1 GameTest (net.minecraft.gametest.framework.GameTest)1 GameTestRegistry (net.minecraft.gametest.framework.GameTestRegistry)1 RegisterGameTestsEvent (net.minecraftforge.event.RegisterGameTestsEvent)1 ModList (net.minecraftforge.fml.ModList)1 ModLoader (net.minecraftforge.fml.ModLoader)1 FMLLoader (net.minecraftforge.fml.loading.FMLLoader)1 IModLanguageProvider (net.minecraftforge.forgespi.language.IModLanguageProvider)1 AnnotationData (net.minecraftforge.forgespi.language.ModFileScanData.AnnotationData)1 LogManager (org.apache.logging.log4j.LogManager)1 Logger (org.apache.logging.log4j.Logger)1 Type (org.objectweb.asm.Type)1