/[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 1614 by torben, Thu Oct 20 17:06:20 2011 UTC miscJava/bukkit-minecraft-plugins/HoerupUtils/src/main/java/dk/thoerup/bukkit/hoeruputils/secretdoor/DoorStorage.java revision 3236 by torben, Sun Jul 15 10:04:25 2018 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.Set;  import java.util.Set;
7    
 import org.bukkit.configuration.file.YamlConfiguration;  
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 44  public class DoorStorage { Line 42  public class DoorStorage {
42                  File f2 = new File( plugin.getDataFolder(), "secretdoors.yml");                  File f2 = new File( plugin.getDataFolder(), "secretdoors.yml");
43                  YamlConfiguration config = new YamlConfiguration();                  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    
# Line 52  public class DoorStorage { Line 50  public class DoorStorage {
50                          config.set( i + ".x", door.getLeftUpper().getBlockX() );                          config.set( i + ".x", door.getLeftUpper().getBlockX() );
51                          config.set( i + ".y", door.getLeftUpper().getBlockY() );                          config.set( i + ".y", door.getLeftUpper().getBlockY() );
52                          config.set( i + ".z", door.getLeftUpper().getBlockZ() );                          config.set( i + ".z", door.getLeftUpper().getBlockZ() );
53                          config.set( i + ".direction", door.getDirection()  );                          config.set( i + ".direction", door.getDirection().toString()  );
54                          config.set( i + ".width", door.getWidth() );                          config.set( i + ".width", door.getWidth() );
55                          config.set( i + ".height", door.getHeight() );                          config.set( i + ".height", door.getHeight() );
56                          config.set( i + ".owner", door.getOwner() );                          config.set( i + ".owner", door.getOwner() );
57                          config.set( i + ".private", door.isPrivate() );                                          config.set( i + ".private", door.isPrivate() );
58                            config.set( i + ".password", door.getPassword() );
59                  }                  }
60    
61                  try {                  try {
# Line 87  public class DoorStorage { Line 86  public class DoorStorage {
86                                                    
87    
88                  for (String key : keys) {                  for (String key : keys) {
89                            try {
90                                                    
91                          World world = plugin.getServer().getWorld( config.getString(key + ".world") );                                  World world = plugin.getServer().getWorld( config.getString(key + ".world") );
92                          int x = config.getInt( key + ".x", 0);                                  int x = config.getInt( key + ".x", 0);
93                          int y = config.getInt( key + ".y", 0);                                  int y = config.getInt( key + ".y", 0);
94                          int z = config.getInt( key + ".z", 0);                                  int z = config.getInt( key + ".z", 0);
95                          Location loc = new Location(world, x, y, z);                                  Location loc = new Location(world, x, y, z);
96                                                                    
97                          int direction = config.getInt( key + ".direction", 0);                                  String directionStr = config.getString( key + ".direction", "");
98                          int width = config.getInt( key + ".width", 0);                                  //BlockFace direction = BlockFace.valueOf(directionStr);
99                          int height = config.getInt( key + ".height", 0);                                  int dir = Integer.parseInt( directionStr );
100    
101                                    BlockFace direction = BlockFace.values()[ dir ];
102                            
103                                    int width = config.getInt( key + ".width", 0);
104                                    int height = config.getInt( key + ".height", 0);
105    
106                          String owner = config.getString( key + ".owner");                                  String owner = config.getString( key + ".owner");
107    
108                          boolean isPrivate = config.getBoolean( key + ".private", false);                                  boolean isPrivate = config.getBoolean( key + ".private", false);
109                                    String password = config.getString( key + ".password", "");
110                            
111                            
112                                                                    
113                          Door door = new Door(loc, direction, width, height, owner, isPrivate);                                  Door door = new Door(loc, direction, width, height, owner, isPrivate, password);
114                          doors.add( door );                                  doors.add( door );
115                          door.registerMap(doormap);                                  door.registerMap(doormap);
116                            } catch (Exception e) {
117                                    System.out.println("[SecretDoor] DoorStorage: exception loading door : " + e.getMessage() );
118                                    e.printStackTrace();
119                            }
120                  }                                        }                      
121                                                    
122                  System.out.println("[SecretDoor] loaded " + doors.size() + " doors");                  System.out.println("[SecretDoor] loaded " + doors.size() + " doors");

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

  ViewVC Help
Powered by ViewVC 1.1.20