updated managers to make more sense, removed old

This commit is contained in:
Sxtanna
2020-07-24 14:30:57 -04:00
parent 60a74258ec
commit f3ba9d588e
21 changed files with 996 additions and 990 deletions

View File

@@ -38,45 +38,33 @@ public class FileUtil
{
@NotNull
public static <T> List<@NotNull Class<? extends T>> getClasses(@NotNull final File folder, @NotNull final Class<T> clazz)
public static <T> List<@NotNull Class<? extends T>> getClasses(@NotNull final File folder, @NotNull final Class<T> clazz) throws IOException, ClassNotFoundException
{
return getClasses(folder, clazz, null);
}
@NotNull
public static <T> List<@NotNull Class<? extends T>> getClasses(@NotNull final File folder, @NotNull final Class<T> clazz, @Nullable final String target)
public static <T> List<@NotNull Class<? extends T>> getClasses(@NotNull final File folder, @NotNull final Class<T> clazz, @Nullable final String target) throws IOException, ClassNotFoundException
{
if (!folder.exists())
{
return Collections.emptyList();
}
try
final File[] jars = folder.listFiles((dir, name) -> name.endsWith(".jar") && (target == null || name.replace(".jar", "").equalsIgnoreCase(target.replace(".jar", ""))));
if (jars == null)
{
final FilenameFilter filter =
(dir, name) -> name.endsWith(".jar") && (target == null || name.replace(".jar", "").equalsIgnoreCase(target.replace(".jar", "")));
final File[] jars = folder.listFiles(filter);
if (jars == null)
{
return Collections.emptyList();
}
final List<@NotNull Class<? extends T>> list = new ArrayList<>();
for (File file : jars)
{
gather(file.toURI().toURL(), clazz, list);
}
return list;
}
catch (final Throwable ex)
{
ex.printStackTrace();
return Collections.emptyList();
}
return Collections.emptyList();
final List<@NotNull Class<? extends T>> list = new ArrayList<>();
for (final File file : jars)
{
gather(file.toURI().toURL(), clazz, list);
}
return list;
}
private static <T> void gather(@NotNull final URL jar, @NotNull final Class<T> clazz, @NotNull final List<@NotNull Class<? extends T>> list) throws IOException, ClassNotFoundException
@@ -101,7 +89,8 @@ public class FileUtil
}
}
catch (final NoClassDefFoundError ignored)
{ }
{
}
}
}
}