Exemple #1
0
  /**
   * Invests a point in the attribute if the player has any remaining attribute points. If the
   * player has no remaining points, this will do nothing.
   *
   * @param key attribute key
   */
  public void upAttribute(String key) {
    key = key.toLowerCase();
    int current = getAttribute(key);
    int max = SkillAPI.getAttributeManager().getAttribute(key).getMax();
    if (attribPoints > 0 && current < max) {
      PlayerUpAttributeEvent event = new PlayerUpAttributeEvent(this, key);
      Bukkit.getPluginManager().callEvent(event);
      if (event.isCancelled()) return;

      attributes.put(key, current + 1);
      attribPoints--;
    }
  }