Initial 1.7 commit

This commit is contained in:
Chicken-Bomes committed 2014-04-07 14:02:47 +10:00
1 parent 34154fc011
commit ca675b5f31
72 files changed
+2967 -3335

No files matched your search

+50 -78
View File
@@ -8,146 +8,118 @@ import java.io.IOException;
import java.io.PrintWriter;
public class ConfigFile extends ConfigTagParent
{
public ConfigFile(File file)
{
if(!file.exists())
{
try
{
{
public ConfigFile(File file) {
try {
if(!file.getParentFile().exists())
file.getParentFile().mkdirs();
if (!file.exists())
file.createNewFile();
}
catch(IOException e)
{
throw new RuntimeException(e);
}
} catch (IOException e) {
throw new RuntimeException(e);
}
this.file = file;
newlinemode = 2;
loadConfig();
}
private void loadConfig()
{
private void loadConfig() {
loading = true;
BufferedReader reader;
try
{
try {
reader = new BufferedReader(new FileReader(file));
while(true)
{
while (true) {
reader.mark(2000);
String line = reader.readLine();
if(line != null && line.startsWith("#"))
{
if(comment == null || comment.equals(""))
if (line != null && line.startsWith("#")) {
if (comment == null || comment.equals(""))
comment = line.substring(1);
else
comment = comment+"\n"+line.substring(1);
}
else
{
comment = comment + "\n" + line.substring(1);
} else {
reader.reset();
break;
}
}
loadChildren(reader);
reader.close();
}
catch(IOException e)
{
} catch (IOException e) {
throw new RuntimeException(e);
}
loading = false;
}
@Override
public ConfigFile setComment(String header)
{
public ConfigFile setComment(String header) {
super.setComment(header);
return this;
}
@Override
public ConfigFile setSortMode(int mode)
{
public ConfigFile setSortMode(int mode) {
super.setSortMode(mode);
return this;
}
@Override
public String getNameQualifier()
{
public String getNameQualifier() {
return "";
}
public static String readLine(BufferedReader reader) throws IOException
{
public static String readLine(BufferedReader reader) throws IOException {
String line = reader.readLine();
if(line != null)
if (line != null)
return line.replace("\t", "");
return line;
}
public static String formatLine(String line)
{
public static String formatLine(String line) {
line = line.replace("\t", "");
if(line.startsWith("#"))
{
if (line.startsWith("#")) {
return line;
}
else if(line.contains("="))
{
line = line.substring(0, line.indexOf("=")).replace(" ", "")+line.substring(line.indexOf("="));
} else if (line.contains("=")) {
line = line.substring(0, line.indexOf("=")).replace(" ", "") + line.substring(line.indexOf("="));
return line;
}
else
{
} else {
line = line.replace(" ", "");
return line;
}
}
public static void writeLine(PrintWriter writer, String line, int tabs)
{
for(int i = 0; i < tabs; i++)
public static void writeLine(PrintWriter writer, String line, int tabs) {
for (int i = 0; i < tabs; i++)
writer.print('\t');
writer.println(line);
}
public void saveConfig()
{
if(loading)
public void saveConfig() {
if (loading)
return;
PrintWriter writer;
try
{
try {
writer = new PrintWriter(file);
}
catch(FileNotFoundException e)
{
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
writeComment(writer, 0);
ConfigFile.writeLine(writer, "", 0);
saveTagTree(writer, 0, "");
writer.flush();
writer.close();
}
public boolean isLoading()
{
public boolean isLoading() {
return loading;
}
public File file;
private boolean loading;
public static final byte[] lineend = new byte[]{0xD, 0xA};
}