/** * 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(); } }
/** * Checks whether or not the player is professed as the class or any of its children. * * @param rpgClass class to check * @return true if professed as the class or one of its children, false otherwise */ public boolean isClass(RPGClass rpgClass) { if (rpgClass == null) { return false; } PlayerClass pc = classes.get(rpgClass.getGroup()); if (pc == null) return false; RPGClass temp = pc.getData(); while (temp != null) { if (temp == rpgClass) { return true; } temp = temp.getParent(); } return false; }