コード例 #1
0
ファイル: Utils.java プロジェクト: gyurix/ProtectionCore
 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;
 }
コード例 #2
0
ファイル: Utils.java プロジェクト: gyurix/ProtectionCore
 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}"));
     }
   }
コード例 #3
0
ファイル: Utils.java プロジェクト: gyurix/ProtectionCore
 public static void loadConfig() {
   dir = KFA.fileCopy(MyPlugin.pl, "config.yml", false);
   kf = new ConfigFile(dir + File.separator + "config.yml");
   long oldver = kf.getLong("version", 0L);
   if (oldver < 7L) {
     dir = KFA.fileCopy(MyPlugin.pl, "config.yml", true);
     kf = new ConfigFile(dir + File.separator + "config.yml");
     verchange = true;
   }
   else if (oldver == 7L) {
     kf.set("forcelangcopy", "+");
     kf.set("version", "8");
     verchange = false;
   }
   if (kf.getBoolean("forcelangcopy")) {
     KFA.lf.insert(new LangFile(KFA.getFileStream(MyPlugin.pl, "lang.lng")));
     kf.set("forcelangcopy", "-");
   }
   kf.repair_missing = true;
   opperms = kf.getBoolean("permissions.op", true);
   dfcheck = kf.getBoolean("permissions.disableflagcheck", true);
   silktouch = kf.getBoolean("creatorblock.silktouch", true);
   ProtectionCore.movecheckrate = (int)kf.getLong("movecheckrate", 10L);
   try {
     String[] tool = (kf.get("tools.wand", "271") + ":0").split("\\:");
     wandtool = KFA.srv.createItemStack(Integer.valueOf(tool[0]).intValue(), 1, Integer.valueOf(tool[1]).intValue());
     tool = (kf.get("tools.info", "268") + ":0").split("\\:");
     infotool = KFA.srv.createItemStack(Integer.valueOf(tool[0]).intValue(), 1, Integer.valueOf(tool[1]).intValue());
   }
   catch (Throwable e) {
     System.out.println("[ProtectionCore] Error in configuration, the tools aren't defined properly");
     e.printStackTrace();
   }
   limits = new int[0];
   for (String s : kf.get("regionlimits").split("\\ ")) {
     try {
       limits = ArrayUtils.add(limits, Integer.valueOf(s).intValue());
     }
     catch (Throwable e) {
       System.out.println("[ProtectionCore] Error the limit \"" + s + "\" is not number!");
     }
   }
   kf.save();
 }