public static boolean loadRegion(ConfigFile rf, Region r, String adr) { try { r.priority = ((int)rf.getLong(adr + "priority", 0L)); r.perm = rf.get(adr + "permission", ""); r.blockPlace = rf.getLocation(adr + "blockPlace"); r.creator = rf.get(adr + "creator", ""); if ((!r.creator.isEmpty()) && (r.creator.length() < 17)) { String creatorid = MojangAPI.getUUID(r.creator); if (creatorid != null) r.creator = creatorid; } for (String group : rf.get(adr + "groups").split("\\ ")) r.groups.add(group); for (int i = 1; i < r.groups.size(); i++) { String[] pll = rf.get(adr + "players." + (String)r.groups.get(i), "").split("\\ "); if ((pll.length == 1) && (pll[0].isEmpty())) { r.players.add(new HashSet()); } else { HashSet pls = new HashSet(); for (String p : pll) { if ((p.length() > 16) || (p.equals("<creator>"))) { pls.add(p); } else { String uuid = MojangAPI.getUUID(p); pls.add(uuid == null ? p : uuid); } } r.players.add(pls); } } for (int i = 0; i < r.groups.size(); i++) { Object flags = new HashMap(); String group = (String)r.groups.get(i); for (String flag : rf.mainAdressList(adr + "flags." + group)) { try { ((Map)flags).put(ProtectionCore.FlagType.valueOf(flag), rf.get(adr + "flags." + group + "." + flag)); } catch (Throwable e) { System.out.println("[ProtectionCore] Error on loading " + adr + " regions " + flag + " flag."); } } r.flags.add(flags); } } catch (Throwable e) { System.out.println("[ProtectionCore] Error on loading region " + adr); e.printStackTrace(); return false; } return true; }
public static boolean loadRegions() { boolean loaded = true; rf = new ConfigFile(dir + File.separator + "regions.yml"); for (WorldServer s : MinecraftServer.getServer().worldServers) { rf.set(s.dimensionSetAtCreate, "\r"); } rf.save(); for (String world : rf.mainAdressList()) { System.out.println("Loading dimension " + world); Region.regions.put(Integer.valueOf(world), new ArrayList()); Region.regnames.put(Integer.valueOf(world), new ArrayList()); for (??? = rf.mainAdressList(world).iterator(); ((Iterator)???).hasNext(); ) { String regname = (String)((Iterator)???).next(); String adr = world + "." + regname + "."; Region r = new Region(new Area(rf.get(adr + "area"), Integer.valueOf(world).intValue()), regname, 1, null); loaded = (loadRegion(rf, r, adr)) && (loaded); } if (!((List)Region.regnames.get(Integer.valueOf(world))).contains("{global}")) { System.out.println("Global region creating..."); int min = -2147483648; int max = 2147483647; new Region(new Area(min, min, min, max, max, max, Integer.valueOf(world).intValue()), "{global}", 0, Region.getTemplate("{global}")); } }