Ejemplo n.º 1
0
  /**
   * Resets the class data for the owner under the given group. This will remove the profession
   * entirely, leaving no remaining data until the player professes again to a starting class.
   *
   * @param group group to reset
   */
  public void reset(String group) {
    stopPassives(getPlayer());
    clearBonuses();
    PlayerClass playerClass = classes.remove(group);
    if (playerClass != null) {
      // Remove skills
      RPGClass data = playerClass.getData();
      for (Skill skill : data.getSkills()) {
        skills.remove(skill.getName());
        combos.removeSkill(skill);
      }

      // Update GUI features
      if (getPlayer() != null) {
        ClassBoardManager.clear(new VersionPlayer(getPlayer()));
      }

      // Call the event
      Bukkit.getPluginManager().callEvent(new PlayerClassChangeEvent(playerClass, data, null));
    }

    // Restore default class if applicable
    GroupSettings settings = SkillAPI.getSettings().getGroupSettings(group);
    RPGClass rpgClass = settings.getDefault();
    if (rpgClass != null && settings.getPermission() == null) {
      setClass(rpgClass);
    }
    updateHealthAndMana(player.getPlayer());
  }
Ejemplo n.º 2
0
  /**
   * Sets the professed class for the player for the corresponding group. This will not save any
   * skills, experience, or levels of the previous class if there was any. The new class will start
   * at level 1 with 0 experience.
   *
   * @param rpgClass class to assign to the player
   * @return the player-specific data for the new class
   */
  public PlayerClass setClass(RPGClass rpgClass) {
    PlayerClass c = classes.remove(rpgClass.getGroup());
    if (c != null) {
      for (Skill skill : c.getData().getSkills()) {
        skills.remove(skill.getName().toLowerCase());
        combos.removeSkill(skill);
      }
    }

    PlayerClass classData = new PlayerClass(this, rpgClass);
    classes.put(rpgClass.getGroup(), classData);

    // Add in missing skills
    for (Skill skill : rpgClass.getSkills()) {
      giveSkill(skill, classData);
    }

    updateHealthAndMana(getPlayer());
    updateScoreboard();
    return classes.get(rpgClass.getGroup());
  }