示例#1
0
 /**
  * Gives the player a skill using the class data as a parent. This skill will not show up in a
  * skill tree.
  *
  * @param skill skill to give the player
  * @param parent parent class data
  */
 public void giveSkill(Skill skill, PlayerClass parent) {
   String key = skill.getKey();
   if (!skills.containsKey(key)) {
     PlayerSkill data = new PlayerSkill(this, skill, parent);
     combos.addSkill(skill);
     skills.put(key, data);
     autoLevel(skill);
   }
 }
示例#2
0
  /**
   * Professes the player into the class if they are able to. This will reset the class data if the
   * group options are set to reset upon profession. Otherwise, all skills, experience, and levels
   * of the current class under the group will be retained and carried over into the new profession.
   *
   * @param rpgClass class to profess into
   * @return true if successfully professed, false otherwise
   */
  public boolean profess(RPGClass rpgClass) {
    if (rpgClass != null && canProfess(rpgClass)) {
      // Reset data if applicable
      if (SkillAPI.getSettings().getGroupSettings(rpgClass.getGroup()).isProfessReset()) {
        reset(rpgClass.getGroup());
      }

      // Inherit previous class data if any
      PlayerClass current = classes.get(rpgClass.getGroup());
      RPGClass previous;
      if (current == null) {
        previous = null;
        current = new PlayerClass(this, rpgClass);
        classes.put(rpgClass.getGroup(), current);
      } else {
        previous = current.getData();
        current.setClassData(rpgClass);
      }

      // Add skills
      for (Skill skill : rpgClass.getSkills()) {
        if (!skills.containsKey(skill.getKey())) {
          skills.put(skill.getKey(), new PlayerSkill(this, skill, current));
          combos.addSkill(skill);
        }
      }

      Bukkit.getPluginManager()
          .callEvent(new PlayerClassChangeEvent(current, previous, current.getData()));
      updateHealthAndMana(getPlayer());
      updateScoreboard();
      return true;
    } else {
      return false;
    }
  }
示例#3
0
  private void autoLevel(Skill skill) {
    PlayerSkill data = skills.get(skill.getKey());
    if (data == null) return;

    if (!SkillAPI.isLoaded()) return;

    int lastLevel = data.getLevel();
    while (data.getData().canAutoLevel()
        && !data.isMaxed()
        && data.getLevelReq() <= data.getPlayerClass().getLevel()) {
      upgradeSkill(skill);
      if (lastLevel == data.getLevel()) {
        break;
      }
      lastLevel++;
    }
  }