Beispiel #1
0
 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();
 }
Beispiel #2
0
 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;
 }