Correct reflection loading error on jar

This commit is contained in:
BrokenFire 2018-02-24 18:40:38 +01:00
parent 44ddf2b24e
commit aaeb793b18

View File

@ -3,6 +3,8 @@ package net.Broken.RestApi;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.reflections.Reflections;
import org.reflections.util.ClasspathHelper;
import org.reflections.util.ConfigurationBuilder;
import java.util.HashMap;
import java.util.Set;
@ -12,7 +14,12 @@ public class ApiCommandLoader {
private static Logger logger = LogManager.getLogger();
public static void load(){
logger.info("Loading Api Command...");
Reflections reflections = new Reflections("net.Broken.RestApi.Command");
// Reflections reflections = new Reflections("net.Broken.RestApi.Command");
Reflections reflections = new Reflections(new ConfigurationBuilder().setUrls(ClasspathHelper.forPackage(
"net.Broken.RestApi.Commands",
ClasspathHelper.contextClassLoader(),
ClasspathHelper.staticClassLoader()))
);
Set<Class<? extends CommandInterface>> modules =
reflections.getSubTypesOf(CommandInterface.class);
logger.info("Find " + modules.size() + " Command:");