// Path: src/main/java/de/maxgb/minecraft/second_screen/util/Logger.java
// public class Logger {
// 
// 	public static void d(String tag, String msg) {
// 		if(Configs.debug_mode){
// 			log(Level.INFO, "[" + tag + "]" + msg);
// 		}
// 
// 	}
// 
// 	public static void e(String tag, String msg) {
// 		log(Level.ERROR, "[" + tag + "]" + msg);
// 	}
// 
// 	public static void e(String tag, String msg, Throwable t) {
// 		String stacktrace = "";
// 		
// 		PrintStream p;
// 		try {
// 			p = new PrintStream(stacktrace);
// 			t.printStackTrace(p);
// 		} catch (FileNotFoundException e1) {
// 			stacktrace = t.getMessage();
// 		}
// 		log(Level.ERROR, "[" + tag + "]" + msg + "\nThrowable: "+t.getClass().getCanonicalName()+"\nStacktrace: " + stacktrace+"\nMessage: "+t.getMessage());
// 	}
// 
// 
// 	public static void i(String tag, String msg) {
// 		log(Level.INFO, "[" + tag + "]" + msg);
// 	}
// 
// 
// 	private static void log(Level level, String msg) {
// 		FMLLog.log(Constants.MOD_ID, level, msg);
// 	}
// 
// 	public static void w(String tag, String msg) {
// 		log(Level.WARN, "[" + tag + "]" + msg);
// 
// 	}
// }


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import net.minecraftforge.common.DimensionManager;
import de.maxgb.minecraft.second_screen.util.Logger;

	/**
	 * Reads from a file in the world folder
	 * @param filename
	 * @return lines of file, null if error
	 */
	public static ArrayList<String> readFromWorldFile(String filename) {
		File f = new File(getSaveDir(), filename);

		return readFromFile(f);

	}


	private static void writeToFile(File file, ArrayList<String> lines) {
		try {
			getSaveDir().mkdirs();
			file.createNewFile();
			file.setReadable(true);
			file.setWritable(true);
			BufferedWriter writer = new BufferedWriter(new FileWriter(file));
			for (String line : lines) {
				writer.append(line);
				writer.newLine();
			}
			writer.flush();
			writer.close();

		} catch (IOException e) {
			e.printStackTrace();
// Path: src/main/java/de/maxgb/minecraft/second_screen/util/Logger.java
// public class Logger {
// 
// 	public static void d(String tag, String msg) {
// 		if(Configs.debug_mode){
// 			log(Level.INFO, "[" + tag + "]" + msg);
// 		}
// 
// 	}
// 
// 	public static void e(String tag, String msg) {
// 		log(Level.ERROR, "[" + tag + "]" + msg);
// 	}
// 
// 	public static void e(String tag, String msg, Throwable t) {
// 		String stacktrace = "";
// 		
// 		PrintStream p;
// 		try {
// 			p = new PrintStream(stacktrace);
// 			t.printStackTrace(p);
// 		} catch (FileNotFoundException e1) {
// 			stacktrace = t.getMessage();
// 		}
// 		log(Level.ERROR, "[" + tag + "]" + msg + "\nThrowable: "+t.getClass().getCanonicalName()+"\nStacktrace: " + stacktrace+"\nMessage: "+t.getMessage());
// 	}
// 
// 
// 	public static void i(String tag, String msg) {
// 		log(Level.INFO, "[" + tag + "]" + msg);
// 	}
// 
// 
// 	private static void log(Level level, String msg) {
// 		FMLLog.log(Constants.MOD_ID, level, msg);
// 	}
// 
// 	public static void w(String tag, String msg) {
// 		log(Level.WARN, "[" + tag + "]" + msg);
// 
// 	}
// }


// Path: src/main/java/de/maxgb/minecraft/second_screen/data/DataStorageDriver.java
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import net.minecraftforge.common.DimensionManager;
import de.maxgb.minecraft.second_screen.util.Logger;


	/**
	 * Reads from a file in the world folder
	 * @param filename
	 * @return lines of file, null if error
	 */
	public static ArrayList<String> readFromWorldFile(String filename) {
		File f = new File(getSaveDir(), filename);

		return readFromFile(f);

	}


	private static void writeToFile(File file, ArrayList<String> lines) {
		try {
			getSaveDir().mkdirs();
			file.createNewFile();
			file.setReadable(true);
			file.setWritable(true);
			BufferedWriter writer = new BufferedWriter(new FileWriter(file));
			for (String line : lines) {
				writer.append(line);
				writer.newLine();
			}
			writer.flush();
			writer.close();

		} catch (IOException e) {
			e.printStackTrace();
			Logger.e(TAG, "Failed writing the String Array to the file: " + file.getAbsolutePath(), e);