package dk.thoerup.bukkit.hoeruputils.secretdoor; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; 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 { private HashMap doormap = new HashMap(); private LinkedList doors = new LinkedList(); private Plugin plugin; public DoorStorage(Plugin plugin) { this.plugin = plugin; } public Door findDoor(Location location) { return doormap.get( location ); } public void addDoor(Door door) { door.registerMap(doormap); doors.add(door); saveAll(); } public void removeDoor(Door door) { door.unregisterMap(doormap); doors.remove(door); saveAll(); } public void saveAll() { 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"); } }