Пример #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--;
    }
  }
Пример #2
0
 /**
  * Applies health and mana attribute bonuses on upgrading the attribute
  *
  * @param event event details
  */
 @EventHandler
 public void onInvest(PlayerUpAttributeEvent event) {
   updatePlayer(event.getPlayerData());
 }