--- miscJava/bukkit-minecraft-plugins/HoerupUtils/src/dk/thoerup/bukkit/hoeruputils/secretdoor/DoorStorage.java 2011/09/26 19:04:28 1603 +++ miscJava/bukkit-minecraft-plugins/HoerupUtils/src/dk/thoerup/bukkit/hoeruputils/secretdoor/DoorStorage.java 2011/09/27 18:27:54 1604 @@ -6,8 +6,11 @@ import java.io.RandomAccessFile; import java.util.HashMap; import java.util.LinkedList; +import java.util.List; +import org.bukkit.util.config.Configuration; import org.bukkit.Location; +import org.bukkit.World; import org.bukkit.plugin.Plugin; public class DoorStorage { @@ -37,48 +40,66 @@ } public void saveAll() { - try { - File f = new File( plugin.getDataFolder(), "secretdoors.csv"); - RandomAccessFile out = new RandomAccessFile( f, "rw" ); - out.setLength(0); - - for (Door door : doors) { - out.writeBytes( door.toCsv() ); - out.writeBytes( "\n"); - } - - out.close(); - } catch (IOException e) { - System.out.println(e.getMessage() ); - e.printStackTrace(); + File f2 = new File( plugin.getDataFolder(), "secretdoors.yml"); + Configuration config = new Configuration(f2); + + int count = 0; + for (int i=0; i keys = config.getKeys(); //get all root keys + + + + for (String key : keys) { + + World world = plugin.getServer().getWorld( config.getString(key + ".world") ); + int x = config.getInt( key + ".x", 0); + int y = config.getInt( key + ".y", 0); + int z = config.getInt( key + ".z", 0); + Location loc = new Location(world, x, y, z); + + int direction = config.getInt( key + ".direction", 0); + int width = config.getInt( key + ".width", 0); + int height = config.getInt( key + ".height", 0); + + String owner = config.getString( key + ".owner"); + + Door door = new Door(loc, direction, width, height, owner); + doors.add( door ); + door.registerMap(doormap); + } + + System.out.println("[SecretDoor] loaded " + doors.size() + " doors"); + }