mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-12-28 05:37:44 +01:00
Fixed x2 cooldown issue
This commit is contained in:
parent
75344e2b6f
commit
35a8905179
@ -28,6 +28,11 @@ public class PlayerSkillData {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
/*
|
||||
* any method which returns long RETURNS milliseconds (cooldowns are either
|
||||
* stored in double when it's the actual value or in long when it's precise
|
||||
* up to 3 digits)
|
||||
*/
|
||||
public long getCooldown(SkillInfo skill) {
|
||||
return Math.max(0, lastCast(skill.getSkill()) + 1000 * (long) skill.getModifier("cooldown", data.getSkillLevel(skill.getSkill())) - System.currentTimeMillis());
|
||||
}
|
||||
@ -59,7 +64,7 @@ public class PlayerSkillData {
|
||||
public void cacheModifiers(MythicMobSkill mmSkill, SkillResult cast) {
|
||||
for (String modifier : cast.getSkill().getModifiers())
|
||||
cacheModifier(mmSkill, modifier, cast.getModifier(modifier));
|
||||
|
||||
|
||||
cacheModifier(mmSkill, "level", cast.getLevel());
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,7 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.skill.Skill.SkillInfo;
|
||||
|
||||
public class SpellCast implements Listener {
|
||||
@EventHandler
|
||||
@ -106,21 +107,27 @@ 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) + (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());
|
||||
for (int j = 0; j < data.getBoundSkills().size(); j++) {
|
||||
SkillInfo skill = data.getBoundSkill(j);
|
||||
str += (str.isEmpty() ? "" : split) + (onCooldown(data, skill) ? onCooldown.replace("{cooldown}", "" + data.getSkillData().getCooldown(skill) / 1000) : noMana(data, skill) ? 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;
|
||||
/*
|
||||
* no longer use index as arguments because data.getBoundSkill(int) has
|
||||
* n-complexity, it has to iterate through a list. using skillInfo
|
||||
* argument uses only one iteration
|
||||
*/
|
||||
private boolean onCooldown(PlayerData data, SkillInfo skill) {
|
||||
return skill.getSkill().hasModifier("cooldown") && data.getSkillData().getCooldown(skill) > 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();
|
||||
private boolean noMana(PlayerData data, SkillInfo skill) {
|
||||
return skill.getSkill().hasModifier("mana") && skill.getModifier("mana", data.getSkillLevel(skill.getSkill())) > data.getMana();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (!playerData.isOnline() || playerData.getPlayer().isDead())
|
||||
|
@ -185,19 +185,22 @@ public class ConfigManager {
|
||||
}
|
||||
|
||||
public class SimpleMessage {
|
||||
String message;
|
||||
|
||||
SimpleMessage(String m) {
|
||||
message = m;
|
||||
private final String message;
|
||||
|
||||
SimpleMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public String message()
|
||||
{ return message.startsWith("%") ? message.substring(1) : message; }
|
||||
|
||||
|
||||
public String message() {
|
||||
return message.startsWith("%") ? message.substring(1) : message;
|
||||
}
|
||||
|
||||
public boolean send(Player player) {
|
||||
if(!message.isEmpty()) {
|
||||
if(message.startsWith("%")) PlayerData.get(player.getUniqueId()).displayActionBar(message.substring(1));
|
||||
else player.sendMessage(message);
|
||||
if (!message.isEmpty()) {
|
||||
if (message.startsWith("%"))
|
||||
PlayerData.get(player.getUniqueId()).displayActionBar(message.substring(1));
|
||||
else
|
||||
player.sendMessage(message);
|
||||
}
|
||||
return !message.isEmpty();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user