/** * Gives levels to the player for all classes matching the experience source * * @param amount amount of levels to give * @param source source of the levels */ public void giveLevels(int amount, ExpSource source) { for (PlayerClass playerClass : classes.values()) { RPGClass data = playerClass.getData(); if (data.receivesExp(source)) { int exp = 0; int count = 0; int temp = amount; while (temp > 0) { temp--; exp += data.getRequiredExp(playerClass.getLevel() + count++); } playerClass.giveExp(exp, source); } } updateHealthAndMana(getPlayer()); }
/** * Checks whether or not the player can profess into the given class. This checks to make sure the * player is currently professed as the parent of the given class and is high enough of a level to * do so. * * @param rpgClass class to check * @return true if can profess, false otherwise */ public boolean canProfess(RPGClass rpgClass) { if (rpgClass.isNeedsPermission()) { Player p = getPlayer(); if (p == null || (!p.hasPermission(Permissions.CLASS) && !p.hasPermission( Permissions.CLASS + "." + rpgClass.getName().toLowerCase().replace(" ", "-")))) { return false; } } if (classes.containsKey(rpgClass.getGroup())) { PlayerClass current = classes.get(rpgClass.getGroup()); return rpgClass.getParent() == current.getData() && current.getData().getMaxLevel() <= current.getLevel(); } else { return !rpgClass.hasParent(); } }