mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-14 19:56:19 +00:00
api to access Loader
This commit is contained in:
@@ -21,6 +21,8 @@ public interface ConfigPack extends LoaderRegistrar, LoaderHolder, RegistryHolde
|
||||
|
||||
void registerConfigType(ConfigType<?, ?> type, String id, int priority);
|
||||
|
||||
Loader getLoader();
|
||||
|
||||
Set<TerraAddon> addons();
|
||||
|
||||
String getID();
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.dfsek.terra.api.config;
|
||||
|
||||
import com.dfsek.tectonic.config.Configuration;
|
||||
import com.dfsek.tectonic.exception.ConfigException;
|
||||
import com.dfsek.terra.api.util.ExceptionalConsumer;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public interface Loader {
|
||||
/**
|
||||
* Do something with the InputStreams.
|
||||
*
|
||||
* @param consumer Something to do with the streams.
|
||||
*/
|
||||
Loader then(ExceptionalConsumer<List<Configuration>> consumer) throws ConfigException;
|
||||
|
||||
Loader thenNames(ExceptionalConsumer<List<String>> consumer) throws ConfigException;
|
||||
|
||||
Loader thenEntries(ExceptionalConsumer<Set<Map.Entry<String, InputStream>>> consumer) throws ConfigException;
|
||||
|
||||
/**
|
||||
* Get a single file from this Loader.
|
||||
*
|
||||
* @param singleFile File to get
|
||||
* @return InputStream from file.
|
||||
*/
|
||||
InputStream get(String singleFile) throws IOException;
|
||||
|
||||
/**
|
||||
* Open a subdirectory.
|
||||
*
|
||||
* @param directory Directory to open
|
||||
* @param extension
|
||||
*/
|
||||
Loader open(String directory, String extension);
|
||||
|
||||
/**
|
||||
* Close all InputStreams opened.
|
||||
*/
|
||||
Loader close();
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.dfsek.terra.api.util;
|
||||
|
||||
import com.dfsek.tectonic.exception.ConfigException;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface ExceptionalConsumer<T> {
|
||||
void accept(T t) throws ConfigException;
|
||||
}
|
||||
Reference in New Issue
Block a user