public static boolean canSetClass(AncientRPGClass newClass, final Player p) {
   PlayerData pd = PlayerData.getPlayerData(p.getName());
   if (AncientRPGExperience.isEnabled() && AncientRPGExperience.isWorldEnabled(p)) {
     if (pd.getXpSystem().level < newClass.minlevel) {
       p.sendMessage(
           AncientRPG.brand2
               + "You need to be level "
               + newClass.minlevel
               + " to join this class");
       return false;
     }
   }
   if (!newClass.isWorldEnabled(p)) {
     return false;
   }
   if (newClass.preclass != null
       && !newClass.preclass.equals("")
       && !newClass.preclass.toLowerCase().equals(pd.getClassName().toLowerCase())) {
     return false;
   }
   AncientRPGRace race =
       AncientRPGRace.getRaceByName(PlayerData.getPlayerData(p.getName()).getRacename());
   if (newClass.requiredraces.size() >= 0
       && (race != null && !newClass.requiredraces.contains(race.name.toLowerCase()))) {
     return false;
   }
   if (!(newClass.permissionNode == null || newClass.permissionNode.equalsIgnoreCase(""))
       && !AncientRPG.hasPermissions(p, newClass.permissionNode)) {
     return false;
   }
   return AncientRPG.hasPermissions(p, AncientRPGClass.cNodeClass);
 }
Esempio n. 2
0
 public static void writeConfig(AncientRPG instance) {
   File newconf =
       new File(instance.getDataFolder().getPath() + File.separator + "creaturehpconfig.yml");
   if (!newconf.exists()) {
     try {
       newconf.createNewFile();
     } catch (IOException e) {
       e.printStackTrace();
     }
   }
   YamlConfiguration cfg = new YamlConfiguration();
   try {
     cfg.set(enabledConfig, enabled);
     cfg.set(enabledWorldsConfig, enabledWorlds);
     cfg.set(HpConfigMinTimeBetweenAttacks, minTimeBetweenAttacks);
     cfg.set(configHpBat, hpOfBat);
     cfg.set(configHpBlaze, hpOfBlaze);
     cfg.set(configHpCaveSpider, hpOfCaveSpider);
     cfg.set(configHpChicken, hpOfChicken);
     cfg.set(configHpWither, hpOfWither);
     cfg.set(configHpCow, hpOfCow);
     cfg.set(configHpCreeper, hpOfCreeper);
     cfg.set(configHpEnderman, hpOfEnderman);
     cfg.set(configHpEnderDragon, hpOfEnderDragon);
     cfg.set(configHpGhast, hpOfGhast);
     cfg.set(configHpGiant, hpOfGiant);
     cfg.set(configHpIronGolem, hpOfIronGolem);
     cfg.set(configHpMagmaTiny, hpOfMagmaCubeTiny);
     cfg.set(configHpMagmaCubeSmall, hpOfMagmaCubeSmall);
     cfg.set(configHpMagmaCubeBig, hpOfMagmaCubeBig);
     cfg.set(configHpMooshroom, hpOfMooshroom);
     cfg.set(configHpOcelot, hpOfOcelot);
     cfg.set(configHpPig, hpOfPig);
     cfg.set(configHpZombiePigman, hpOfZombiePigman);
     cfg.set(configHpSheep, hpOfSheep);
     cfg.set(configHpSilverfish, hpOfSilverfish);
     cfg.set(configHpSkeleton, hpOfSkeleton);
     cfg.set(configHpSlimeTiny, hpOfSlimeTiny);
     cfg.set(configHpSlimeSmall, hpOfSlimeSmall);
     cfg.set(configHpSlimeBig, hpOfSlimeBig);
     cfg.set(configHpSnowGolem, hpOfSnowGolem);
     cfg.set(configHpSpider, hpOfSpider);
     cfg.set(configHpSquid, hpOfSquid);
     cfg.set(configHpHorse, hpOfHorse);
     cfg.set(configHpWitch, hpOfWitch);
     cfg.set(configHpVillager, hpOfVillager);
     cfg.set(configHpWolf, hpOfWolf);
     cfg.set(configHpWolfTamed, hpOfWolfTamed);
     cfg.set(configHpZombie, hpOfZombie);
     cfg.set(configHpBabyZombie, hpOfBabyZombie);
     cfg.set(configHpZombieVillager, hpOfZombieVillager);
     cfg.set(configHpZombieBabyVillager, hpOfZombieBabyVillager);
     cfg.set(configHpWitherSkeleton, hpOfWitherSkeleton);
     cfg.save(newconf);
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
 public static boolean senderHasPermissions(CommandSender cs, String perm) {
   return ((cs instanceof ConsoleCommandSender || cs instanceof RemoteConsoleCommandSender)
       || (cs instanceof Player && AncientRPG.hasPermissions((Player) cs, perm)));
 }
 public static boolean senderHasAdminPermissions(CommandSender cs) {
   return ((cs instanceof ConsoleCommandSender || cs instanceof RemoteConsoleCommandSender)
       || (cs instanceof Player
           && AncientRPG.hasPermissions((Player) cs, "AncientRPG.classes.admin")));
 }