From 11c4c05bc119f887d7a54e85c3cd6115820101be Mon Sep 17 00:00:00 2001 From: Aria Date: Fri, 18 Oct 2019 00:00:09 +0200 Subject: [PATCH] Added messages for on cooldown and no mana in spell casting --- .../net/Indyuce/mmocore/listener/SpellCast.java | 15 +++++++++++++-- src/main/resources/default/messages.yml | 5 ++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/Indyuce/mmocore/listener/SpellCast.java b/src/main/java/net/Indyuce/mmocore/listener/SpellCast.java index ba1e8af7..3bab03f3 100644 --- a/src/main/java/net/Indyuce/mmocore/listener/SpellCast.java +++ b/src/main/java/net/Indyuce/mmocore/listener/SpellCast.java @@ -48,7 +48,9 @@ public class SpellCast implements Listener { public class SkillCasting extends BukkitRunnable implements Listener { private final PlayerData playerData; - private final String format = MMOCore.plugin.configManager.getSimpleMessage("casting.action-bar"); + private final String ready = MMOCore.plugin.configManager.getSimpleMessage("casting.action-bar.ready"); + private final String onCooldown = MMOCore.plugin.configManager.getSimpleMessage("casting.action-bar.on-cooldown"); + private final String noMana = MMOCore.plugin.configManager.getSimpleMessage("casting.action-bar.no-mana"); private final String split = MMOCore.plugin.configManager.getSimpleMessage("casting.split"); private int j; @@ -105,11 +107,20 @@ public class SpellCast implements Listener { private String getFormat(PlayerData data) { String str = ""; for (int j = 0; j < data.getBoundSkills().size(); j++) - str += (str.isEmpty() ? "" : split) + format.replace("{index}", "" + (j + 1 + (data.getPlayer().getInventory().getHeldItemSlot() <= j ? 1 : 0))).replace("{skill}", data.getBoundSkill(j).getSkill().getName()); + str += (str.isEmpty() ? "" : split) + (onCooldown(data, j) && data.getBoundSkill(j).getSkill().hasModifier("cooldown") ? onCooldown.replace("{cooldown}", "" + ((int) data.getSkillData().getCooldown(data.getBoundSkill(j)) / 100) / 5) : + noMana(data, j) ? noMana : ready).replace("{index}", "" + (j + 1 + (data.getPlayer().getInventory().getHeldItemSlot() <= j ? 1 : 0))).replace("{skill}", data.getBoundSkill(j).getSkill().getName()); return str; } + private boolean onCooldown(PlayerData data, int index) { + return data.getBoundSkill(index).getSkill().hasModifier("cooldown") && data.getSkillData().getCooldown(data.getBoundSkill(index)) > 0; + } + + private boolean noMana(PlayerData data, int index) { + return data.getBoundSkill(index).getSkill().hasModifier("mana") && data.getBoundSkill(index).getModifier("mana", data.getSkillLevel(data.getBoundSkill(index).getSkill())) > data.getMana(); + } + @Override public void run() { if (!playerData.isOnline() || playerData.getPlayer().isDead()) diff --git a/src/main/resources/default/messages.yml b/src/main/resources/default/messages.yml index 04976ad5..89cbd96f 100644 --- a/src/main/resources/default/messages.yml +++ b/src/main/resources/default/messages.yml @@ -43,7 +43,10 @@ player-input: # Spell Casting casting: - action-bar: '&6[{index}] &a&l{skill}' + action-bar: + ready:'&6[{index}] &a&l{skill}' + on-cooldown: '&6[{index}] &c&l{skill} &6(&c{cooldown}&6)' + no-mana: '&6[{index}] &9&l{skill}' split: '&7 &7 - &7 ' no-longer: '&cYou cancelled skill casting.' no-mana: '&cYou do not have enough mana!'