use of org.bukkit.plugin.java.JavaPlugin in project MyMaid2 by jaoafa.
the class Jail method LoadJailData.
/**
* Jail情報をロードする。
* @return 実行できたかどうか
* @author mine_book000
* @throws Exception 何かしらのExceptionが発生したときに発生(FileNotFoundException, IOException)
*/
@SuppressWarnings("unchecked")
public static boolean LoadJailData() throws Exception {
JSONParser parser = new JSONParser();
String json = "";
try {
JavaPlugin plugin = JavaPlugin();
File file = new File(plugin.getDataFolder(), "jail.json");
BufferedReader br = new BufferedReader(new FileReader(file));
String separator = System.getProperty("line.separator");
String str;
while ((str = br.readLine()) != null) {
json += str + separator;
}
br.close();
} catch (FileNotFoundException e1) {
BugReporter(e1);
throw new FileNotFoundException(e1.getMessage());
} catch (IOException e1) {
BugReporter(e1);
throw new IOException(e1.getMessage());
}
JSONObject obj;
try {
obj = (JSONObject) parser.parse(json);
} catch (ParseException e1) {
obj = new JSONObject();
}
JSONArray JailJSON;
if (obj.containsKey("Jail")) {
JailJSON = (JSONArray) obj.get("Jail");
for (int i = 0; i < JailJSON.size(); i++) {
String player = (String) JailJSON.get(i);
Jail.add(player);
}
}
if (obj.containsKey("Block")) {
for (Entry<String, Boolean> one : (Set<Map.Entry<String, Boolean>>) ((JSONObject) obj.get("Block")).entrySet()) {
block.put(one.getKey(), one.getValue());
}
}
if (obj.containsKey("Area")) {
for (Entry<String, Boolean> one : (Set<Map.Entry<String, Boolean>>) ((JSONObject) obj.get("Area")).entrySet()) {
area.put(one.getKey(), one.getValue());
}
}
if (obj.containsKey("LastText")) {
for (Entry<String, Boolean> one : (Set<Map.Entry<String, Boolean>>) ((JSONObject) obj.get("LastText")).entrySet()) {
lasttext.put(one.getKey(), one.getValue());
}
}
return true;
}
Aggregations