/[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

miscJava/bukkit-minecraft-plugins/HoerupUtils/src/dk/thoerup/bukkit/hoeruputils/secretdoor/DoorStorage.java revision 1604 by torben, Tue Sep 27 18:27:54 2011 UTC miscJava/bukkit-minecraft-plugins/HoerupUtils/src/main/java/dk/thoerup/bukkit/hoeruputils/secretdoor/DoorStorage.java revision 3134 by torben, Fri Nov 18 13:23:24 2016 UTC
# Line 1  Line 1 
1  package dk.thoerup.bukkit.hoeruputils.secretdoor;  package dk.thoerup.bukkit.hoeruputils.secretdoor;
2    
3  import java.io.File;  import java.io.File;
 import java.io.FileNotFoundException;  
 import java.io.IOException;  
 import java.io.RandomAccessFile;  
4  import java.util.HashMap;  import java.util.HashMap;
5  import java.util.LinkedList;  import java.util.LinkedList;
6  import java.util.List;  import java.util.Set;
7    
 import org.bukkit.util.config.Configuration;  
8  import org.bukkit.Location;  import org.bukkit.Location;
9  import org.bukkit.World;  import org.bukkit.World;
10    import org.bukkit.block.BlockFace;
11    import org.bukkit.configuration.file.YamlConfiguration;
12  import org.bukkit.plugin.Plugin;  import org.bukkit.plugin.Plugin;
13    
14  public class DoorStorage {  public class DoorStorage {
# Line 42  public class DoorStorage { Line 40  public class DoorStorage {
40          public void saveAll() {          public void saveAll() {
41    
42                  File f2 = new File( plugin.getDataFolder(), "secretdoors.yml");                  File f2 = new File( plugin.getDataFolder(), "secretdoors.yml");
43                  Configuration config = new Configuration(f2);                  YamlConfiguration config = new YamlConfiguration();
44    
45                  int count = 0;                  
46                  for (int i=0; i<doors.size(); i++) {                  for (int i=0; i<doors.size(); i++) {
47                          Door door = doors.get(i);                          Door door = doors.get(i);
48    
49                          config.setProperty( i + ".world", door.getLeftUpper().getWorld().getName() );                          config.set( i + ".world", door.getLeftUpper().getWorld().getName() );
50                          config.setProperty( i + ".x", door.getLeftUpper().getBlockX() );                          config.set( i + ".x", door.getLeftUpper().getBlockX() );
51                          config.setProperty( i + ".y", door.getLeftUpper().getBlockY() );                          config.set( i + ".y", door.getLeftUpper().getBlockY() );
52                          config.setProperty( i + ".z", door.getLeftUpper().getBlockZ() );                          config.set( i + ".z", door.getLeftUpper().getBlockZ() );
53                          config.setProperty( i + ".direction", door.getDirection()  );                          config.set( i + ".direction", door.getDirection().toString()  );
54                          config.setProperty( i + ".width", door.getWidth() );                          config.set( i + ".width", door.getWidth() );
55                          config.setProperty( i + ".height", door.getHeight() );                          config.set( i + ".height", door.getHeight() );
56                          config.setProperty( i + ".owner", door.getOwner() );                          config.set( i + ".owner", door.getOwner() );
57                                                    config.set( i + ".private", door.isPrivate() );
58                            config.set( i + ".password", door.getPassword() );
59                  }                  }
60    
61                    try {
62                  config.save();                          config.save(f2);
63                    } catch (java.io.IOException e) {
64                            System.out.println("[SecretDoor] DoorStorage : exception saving doors : " + e.getMessage() );
65                    }
66    
67          }          }
68    
# Line 72  public class DoorStorage { Line 73  public class DoorStorage {
73                          System.out.println("[SecretDoor] coult not find secretdoors.yml");                          System.out.println("[SecretDoor] coult not find secretdoors.yml");
74                          return;                          return;
75                  }                  }
76                  Configuration config = new Configuration(f);                  YamlConfiguration config = new YamlConfiguration();
77                  config.load();                  try {
78                            config.load(f);
79                    } catch (Exception e) {
80                            System.out.println("[SecretDoor] DoorStorage: exception loading doors : " + e.getMessage() );
81                            return;
82                    }
83    
84                  List<String> keys = config.getKeys(); //get all root keys                  Set<String> keys = config.getKeys(false); //get all root keys
85    
86                                                    
87    
# Line 87  public class DoorStorage { Line 93  public class DoorStorage {
93                          int z = config.getInt( key + ".z", 0);                          int z = config.getInt( key + ".z", 0);
94                          Location loc = new Location(world, x, y, z);                          Location loc = new Location(world, x, y, z);
95                                                                    
96                          int direction = config.getInt( key + ".direction", 0);                          String directionStr = config.getString( key + ".direction", "");
97                            //BlockFace direction = BlockFace.valueOf(directionStr);
98                            int dir = Integer.parseInt( directionStr );
99    
100                            BlockFace direction = BlockFace.values()[ dir ];
101                            
102                          int width = config.getInt( key + ".width", 0);                          int width = config.getInt( key + ".width", 0);
103                          int height = config.getInt( key + ".height", 0);                          int height = config.getInt( key + ".height", 0);
104    
105                          String owner = config.getString( key + ".owner");                          String owner = config.getString( key + ".owner");
106    
107                            boolean isPrivate = config.getBoolean( key + ".private", false);
108                            String password = config.getString( key + ".password", "");
109                            
110                            
111                                                                    
112                          Door door = new Door(loc, direction, width, height, owner);                          Door door = new Door(loc, direction, width, height, owner, isPrivate, password);
113                          doors.add( door );                          doors.add( door );
114                          door.registerMap(doormap);                          door.registerMap(doormap);
115                  }                                        }                      

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

  ViewVC Help
Powered by ViewVC 1.1.20