--- miscJava/bukkit-minecraft-plugins/HoerupUtils/src/dk/thoerup/bukkit/hoeruputils/secretdoor/DoorStorage.java 2011/06/29 18:16:51 1538 +++ miscJava/bukkit-minecraft-plugins/HoerupUtils/src/dk/thoerup/bukkit/hoeruputils/secretdoor/DoorStorage.java 2011/10/20 17:06:20 1614 @@ -6,8 +6,11 @@ import java.io.RandomAccessFile; import java.util.HashMap; import java.util.LinkedList; +import java.util.Set; +import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.Location; +import org.bukkit.World; import org.bukkit.plugin.Plugin; public class DoorStorage { @@ -37,48 +40,75 @@ } 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"); + YamlConfiguration config = new YamlConfiguration(); + + int count = 0; + for (int i=0; i keys = config.getKeys(false); //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"); + + boolean isPrivate = config.getBoolean( key + ".private", false); + + Door door = new Door(loc, direction, width, height, owner, isPrivate); + doors.add( door ); + door.registerMap(doormap); + } + + System.out.println("[SecretDoor] loaded " + doors.size() + " doors"); + }