Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public final class AssetsLoaderHelper
- {
- public static void loadAndProcessAssets(String directory, String extension, Consumer<Path> processor)
- {
- String PATH = "assets/" + Reference.MOD_ID + "/" + directory;
- ModContainer containerMageTech = FMLCommonHandler.instance().findContainerFor(MageTech.INSTANCE);
- File sourceMageTech = containerMageTech.getSource();
- try
- {
- FileSystem fileSystemMageTech = FileSystems.newFileSystem(sourceMageTech.toPath(), null);
- Path pathDirectory = fileSystemMageTech.getPath("/" + PATH);
- Iterator<Path> iterator = Files.walk(pathDirectory).iterator();
- while (iterator.hasNext())
- {
- Path pathFile = iterator.next();
- if (pathFile.toString().endsWith(extension))
- processor.accept(pathFile);
- }
- IOUtils.closeQuietly(fileSystemMageTech);
- }
- catch (IOException e)
- {
- LogHelper.error(e);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment