DimDoors/StevenDimDoors/mod_pocketDim/util/BaseConfigurationProcessor.java
SenseiKiwi f372b9ccb5 Basic Configurable Dungeon Chains
Completed a basic version of configurable dungeon chains. Almost all of
the final funcionality is present. However, the configuration is
hardcoded at the moment, not read from a file. This was done for testing
purposes. I'll add reading from config files soon.

Dungeon packs are partially implemented. Built-in and custom dungeons
are currently thrown into the default pack, Ruins. The next step is to
generalize the dungeon registration code in DungeonHelper so that we can
detect dungeon packs, read their config files, and register dungeons
with their corresponding pack. dd-export will need to support packs as
well. dd-rift will have issues dealing with duplicate dungeon names
across packs, but this isn't a major concern and can be dealt with in
the long term.
2013-08-05 20:16:45 -04:00

52 lines
1.4 KiB
Java

package StevenDimDoors.mod_pocketDim.util;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
public abstract class BaseConfigurationProcessor<T>
{
public BaseConfigurationProcessor() { }
public boolean canRead()
{
return true;
}
public boolean canWrite()
{
return true;
}
public T readFromFile(String path) throws FileNotFoundException, ConfigurationProcessingException
{
return readFromFile(new File(path));
}
public T readFromFile(File file) throws FileNotFoundException, ConfigurationProcessingException
{
return readFromStream(new FileInputStream(file));
}
public T readFromResource(String resourcePath) throws ConfigurationProcessingException
{
return readFromStream(this.getClass().getResourceAsStream(resourcePath));
}
public abstract T readFromStream(InputStream inputStream) throws ConfigurationProcessingException;
public void writeToFile(File file, T data) throws FileNotFoundException, ConfigurationProcessingException
{
writeToStream(new FileOutputStream(file), data);
}
public void writeToFile(String path, T data) throws FileNotFoundException, ConfigurationProcessingException
{
writeToFile(new File(path), data);
}
public abstract void writeToStream(OutputStream outputStream, T data) throws ConfigurationProcessingException;
}