/[projects]/miscJava/bukkit-minecraft-plugins/HoerupUtils/src/main/java/dk/thoerup/bukkit/hoeruputils/secretdoor/DoorStorage.java
ViewVC logotype

Diff of /miscJava/bukkit-minecraft-plugins/HoerupUtils/src/main/java/dk/thoerup/bukkit/hoeruputils/secretdoor/DoorStorage.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1604 by torben, Tue Sep 27 18:27:54 2011 UTC revision 1614 by torben, Thu Oct 20 17:06:20 2011 UTC
# Line 6  import java.io.IOException; Line 6  import java.io.IOException;
6  import java.io.RandomAccessFile;  import java.io.RandomAccessFile;
7  import java.util.HashMap;  import java.util.HashMap;
8  import java.util.LinkedList;  import java.util.LinkedList;
9  import java.util.List;  import java.util.Set;
10    
11  import org.bukkit.util.config.Configuration;  import org.bukkit.configuration.file.YamlConfiguration;
12  import org.bukkit.Location;  import org.bukkit.Location;
13  import org.bukkit.World;  import org.bukkit.World;
14  import org.bukkit.plugin.Plugin;  import org.bukkit.plugin.Plugin;
# Line 42  public class DoorStorage { Line 42  public class DoorStorage {
42          public void saveAll() {          public void saveAll() {
43    
44                  File f2 = new File( plugin.getDataFolder(), "secretdoors.yml");                  File f2 = new File( plugin.getDataFolder(), "secretdoors.yml");
45                  Configuration config = new Configuration(f2);                  YamlConfiguration config = new YamlConfiguration();
46    
47                  int count = 0;                  int count = 0;
48                  for (int i=0; i<doors.size(); i++) {                  for (int i=0; i<doors.size(); i++) {
49                          Door door = doors.get(i);                          Door door = doors.get(i);
50    
51                          config.setProperty( i + ".world", door.getLeftUpper().getWorld().getName() );                          config.set( i + ".world", door.getLeftUpper().getWorld().getName() );
52                          config.setProperty( i + ".x", door.getLeftUpper().getBlockX() );                          config.set( i + ".x", door.getLeftUpper().getBlockX() );
53                          config.setProperty( i + ".y", door.getLeftUpper().getBlockY() );                          config.set( i + ".y", door.getLeftUpper().getBlockY() );
54                          config.setProperty( i + ".z", door.getLeftUpper().getBlockZ() );                          config.set( i + ".z", door.getLeftUpper().getBlockZ() );
55                          config.setProperty( i + ".direction", door.getDirection()  );                          config.set( i + ".direction", door.getDirection()  );
56                          config.setProperty( i + ".width", door.getWidth() );                          config.set( i + ".width", door.getWidth() );
57                          config.setProperty( i + ".height", door.getHeight() );                          config.set( i + ".height", door.getHeight() );
58                          config.setProperty( i + ".owner", door.getOwner() );                          config.set( i + ".owner", door.getOwner() );
59                                                    config.set( i + ".private", door.isPrivate() );                
   
60                  }                  }
61    
62                    try {
63                  config.save();                          config.save(f2);
64                    } catch (java.io.IOException e) {
65                            System.out.println("[SecretDoor] DoorStorage : exception saving doors : " + e.getMessage() );
66                    }
67    
68          }          }
69    
# Line 72  public class DoorStorage { Line 74  public class DoorStorage {
74                          System.out.println("[SecretDoor] coult not find secretdoors.yml");                          System.out.println("[SecretDoor] coult not find secretdoors.yml");
75                          return;                          return;
76                  }                  }
77                  Configuration config = new Configuration(f);                  YamlConfiguration config = new YamlConfiguration();
78                  config.load();                  try {
79                            config.load(f);
80                    } catch (Exception e) {
81                            System.out.println("[SecretDoor] DoorStorage: exception loading doors : " + e.getMessage() );
82                            return;
83                    }
84    
85                  List<String> keys = config.getKeys(); //get all root keys                  Set<String> keys = config.getKeys(false); //get all root keys
86    
87                                                    
88    
# Line 92  public class DoorStorage { Line 99  public class DoorStorage {
99                          int height = config.getInt( key + ".height", 0);                          int height = config.getInt( key + ".height", 0);
100    
101                          String owner = config.getString( key + ".owner");                          String owner = config.getString( key + ".owner");
102    
103                            boolean isPrivate = config.getBoolean( key + ".private", false);
104                                                                    
105                          Door door = new Door(loc, direction, width, height, owner);                          Door door = new Door(loc, direction, width, height, owner, isPrivate);
106                          doors.add( door );                          doors.add( door );
107                          door.registerMap(doormap);                          door.registerMap(doormap);
108                  }                                        }                      

Legend:
Removed from v.1604  
changed lines
  Added in v.1614

  ViewVC Help
Powered by ViewVC 1.1.20