<commit_before>package com.matt.forgehax.util.mod.loader;

import com.google.common.collect.Lists;
import com.google.common.reflect.ClassPath;
import com.matt.forgehax.Globals;
import com.matt.forgehax.Wrapper;
import com.matt.forgehax.mcversion.IncompatibleMCVersionException;
import com.matt.forgehax.mcversion.MCVersionChecker;
import com.matt.forgehax.util.mod.BaseMod;

import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

/**
 * Created on 5/16/2017 by fr1kin
 */
public class ForgeHaxModLoader implements Globals {
    public static Collection<Class<? extends BaseMod>> getClassesInPackage(String pack) {
        final List<Class<? extends BaseMod>> classes = Lists.newArrayList();
        try {
            ClassPath classPath = ClassPath.from(getClassLoader());
            classPath.getTopLevelClasses(pack).forEach(info -> {
                try {
                    Class<?> clazz = info.load();
                    if(clazz.isAnnotationPresent(RegisterMod.class)
                            && BaseMod.class.isAssignableFrom(clazz)
                            && clazz.getDeclaredConstructor() != null) { // will throw exception if it doesn't exist
                        MCVersionChecker.requireValidVersion(clazz);
                        classes.add((Class<? extends BaseMod>)clazz);
                    }
                } catch (IncompatibleMCVersionException e) {
                    Wrapper.getLog().warn(String.format("Class '%s' has been labeled for Minecraft versions ", info.getSimpleName()));
                } catch (Exception e) {
                    Wrapper.getLog().warn(String.format("[%s] '%s' is not a valid mod class: %s", e.getClass().getSimpleName(), info.getSimpleName(), e.getMessage()));
                }
            });
        } catch (IOException e) {
            e.printStackTrace();
        }
        return Collections.unmodifiableCollection(classes);
    }

    public static Collection<BaseMod> loadClasses(Collection<Class<? extends BaseMod>> classes) {
        List<BaseMod> mods = Lists.newArrayList();
        classes.forEach(clazz -> {
            try {
                mods.add(clazz.getDeclaredConstructor().newInstance());
            } catch (Exception e) {
                Wrapper.getLog().warn(String.format("Failed to create a new instance of '%s'", clazz.getSimpleName()));
            }
        });
        return Collections.unmodifiableCollection(mods);
    }

    private static ClassLoader getClassLoader() {
        return Thread.currentThread().getContextClassLoader();
    }
}<commit_msg>Removed catch thrown when checking MCVersions<commit_after>package com.matt.forgehax.util.mod.loader;

import com.google.common.collect.Lists;
import com.google.common.reflect.ClassPath;
import com.matt.forgehax.Globals;
import com.matt.forgehax.Wrapper;
import com.matt.forgehax.mcversion.IncompatibleMCVersionException;
import com.matt.forgehax.mcversion.MCVersionChecker;
import com.matt.forgehax.util.mod.BaseMod;

import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

/**
 * Created on 5/16/2017 by fr1kin
 */
public class ForgeHaxModLoader implements Globals {
    public static Collection<Class<? extends BaseMod>> getClassesInPackage(String pack) {
        final List<Class<? extends BaseMod>> classes = Lists.newArrayList();
        try {
            ClassPath classPath = ClassPath.from(getClassLoader());
            classPath.getTopLevelClasses(pack).forEach(info -> {
                try {
                    Class<?> clazz = info.load();
                    if(clazz.isAnnotationPresent(RegisterMod.class)
                            && BaseMod.class.isAssignableFrom(clazz)
                            && clazz.getDeclaredConstructor() != null) { // will throw exception if it doesn't exist
                        MCVersionChecker.requireValidVersion(clazz);
                        classes.add((Class<? extends BaseMod>)clazz);
                    }
                } catch (Exception e) {
                    Wrapper.getLog().warn(String.format("[%s] '%s' is not a valid mod class: %s", e.getClass().getSimpleName(), info.getSimpleName(), e.getMessage()));
                }
            });
        } catch (IOException e) {
            e.printStackTrace();
        }
        return Collections.unmodifiableCollection(classes);
    }

    public static Collection<BaseMod> loadClasses(Collection<Class<? extends BaseMod>> classes) {
        List<BaseMod> mods = Lists.newArrayList();
        classes.forEach(clazz -> {
            try {
                mods.add(clazz.getDeclaredConstructor().newInstance());
            } catch (Exception e) {
                Wrapper.getLog().warn(String.format("Failed to create a new instance of '%s'", clazz.getSimpleName()));
            }
        });
        return Collections.unmodifiableCollection(mods);
    }

    private static ClassLoader getClassLoader() {
        return Thread.currentThread().getContextClassLoader();
    }
}
{'fraction_non_alphanumeric': 0.11429135412554284, 'fraction_numerical': 0.0031583103039873666, 'mean_word_length': 2.4539877300613497, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3634685', 'n_tokens_mistral': 1380, 'n_tokens_neox': 1338, 'n_words': 267}