Fix cooldown reduction

This commit is contained in:
Indyuce 2019-11-03 00:23:24 +01:00
parent 3418a02ffa
commit 270a552abc

View File

@ -393,8 +393,7 @@ public class PlayerData {
} }
public void heal(double heal) { public void heal(double heal) {
getPlayer().setHealth(Math.max(0, getPlayer().setHealth(Math.max(0, Math.min(player.getHealth() + heal, player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue())));
Math.min(player.getHealth() + heal, player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue())));
} }
public void addFriend(UUID uuid) { public void addFriend(UUID uuid) {
@ -521,7 +520,8 @@ public class PlayerData {
public void giveMana(double amount) { public void giveMana(double amount) {
if (mana != (mana = Math.max(0, Math.min(getStats().getStat(StatType.MAX_MANA), mana + amount)))) if (mana != (mana = Math.max(0, Math.min(getStats().getStat(StatType.MAX_MANA), mana + amount))))
if(MMOCore.plugin.getConfig().getBoolean("display.mana")) displayMana(); if (MMOCore.plugin.getConfig().getBoolean("display.mana"))
displayMana();
} }
public void giveStamina(double amount) { public void giveStamina(double amount) {
@ -593,7 +593,6 @@ public class PlayerData {
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(getProfess().getManaDisplay().generateBar(getMana(), getStats().getStat(StatType.MAX_MANA)))); player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(getProfess().getManaDisplay().generateBar(getMana(), getStats().getStat(StatType.MAX_MANA))));
} }
public void setAttributes(PlayerAttribute attribute, int value) { public void setAttributes(PlayerAttribute attribute, int value) {
setAttributes(attribute.getId(), value); setAttributes(attribute.getId(), value);
} }
@ -756,7 +755,13 @@ public class PlayerData {
} }
if (!nocd) { if (!nocd) {
skillData.setLastCast(cast.getSkill(), System.currentTimeMillis() + (long) (getStats().getStat(StatType.COOLDOWN_REDUCTION) * cast.getCooldown() * 10));
// calculate skill cooldown reduction only if stat is higher than 0
// to save performance
double red = getStats().getStat(StatType.COOLDOWN_REDUCTION) * 10;
red *= red > 0 ? skill.getModifier("cooldown", getSkillLevel(skill.getSkill())) : 0;
skillData.setLastCast(cast.getSkill(), System.currentTimeMillis() - (long) red);
giveMana(-cast.getManaCost()); giveMana(-cast.getManaCost());
} }