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; |
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; |
|
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.setProperty( i + ".private", door.isPrivate() ); |
config.set( i + ".private", door.isPrivate() ); |
60 |
|
config.set( i + ".password", door.getPassword() ); |
61 |
} |
} |
62 |
|
|
63 |
|
try { |
64 |
config.save(); |
config.save(f2); |
65 |
|
} catch (java.io.IOException e) { |
66 |
|
System.out.println("[SecretDoor] DoorStorage : exception saving doors : " + e.getMessage() ); |
67 |
|
} |
68 |
|
|
69 |
} |
} |
70 |
|
|
75 |
System.out.println("[SecretDoor] coult not find secretdoors.yml"); |
System.out.println("[SecretDoor] coult not find secretdoors.yml"); |
76 |
return; |
return; |
77 |
} |
} |
78 |
Configuration config = new Configuration(f); |
YamlConfiguration config = new YamlConfiguration(); |
79 |
config.load(); |
try { |
80 |
|
config.load(f); |
81 |
|
} catch (Exception e) { |
82 |
|
System.out.println("[SecretDoor] DoorStorage: exception loading doors : " + e.getMessage() ); |
83 |
|
return; |
84 |
|
} |
85 |
|
|
86 |
List<String> keys = config.getKeys(); //get all root keys |
Set<String> keys = config.getKeys(false); //get all root keys |
87 |
|
|
88 |
|
|
89 |
|
|
102 |
String owner = config.getString( key + ".owner"); |
String owner = config.getString( key + ".owner"); |
103 |
|
|
104 |
boolean isPrivate = config.getBoolean( key + ".private", false); |
boolean isPrivate = config.getBoolean( key + ".private", false); |
105 |
|
String password = config.getString( key + ".password", ""); |
106 |
|
|
107 |
Door door = new Door(loc, direction, width, height, owner, isPrivate); |
Door door = new Door(loc, direction, width, height, owner, isPrivate, password); |
108 |
doors.add( door ); |
doors.add( door ); |
109 |
door.registerMap(doormap); |
door.registerMap(doormap); |
110 |
} |
} |