/** * Apply attributes to mana regen * * @param event event details */ @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onManaRegen(PlayerManaGainEvent event) { // Bonus to regen from attributes if (event.getSource() == ManaSource.REGEN) { double newAmount = event.getPlayerData().scaleStat(AttributeManager.MANA_REGEN, event.getAmount()); event.setAmount(newAmount); } }
/** * Gives mana to the player from the given mana source. This will not cause the player's mana to * go above the max amount. * * @param amount amount of mana to give * @param source source of the mana */ public void giveMana(double amount, ManaSource source) { PlayerManaGainEvent event = new PlayerManaGainEvent(this, amount, source); Bukkit.getPluginManager().callEvent(event); if (!event.isCancelled()) { mana += event.getAmount(); if (mana > maxMana) { mana = maxMana; } if (mana < 0) { mana = 0; } } }