From 93317c3e397f814792b683a08e16878d5b04bc4c Mon Sep 17 00:00:00 2001 From: Jules Date: Fri, 24 May 2024 14:50:02 -0700 Subject: [PATCH] New %mmocore_id_bound_% PAPI placeholder --- .../comp/placeholder/RPGPlaceholders.java | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/comp/placeholder/RPGPlaceholders.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/comp/placeholder/RPGPlaceholders.java index 20256682..d506a1fc 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/comp/placeholder/RPGPlaceholders.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/comp/placeholder/RPGPlaceholders.java @@ -15,6 +15,7 @@ import net.Indyuce.mmocore.party.AbstractParty; import net.Indyuce.mmocore.skill.CastableSkill; import net.Indyuce.mmocore.skill.ClassSkill; import net.Indyuce.mmocore.skill.RegisteredSkill; +import net.Indyuce.mmocore.skill.binding.BoundSkillInfo; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.OfflinePlayer; @@ -92,9 +93,7 @@ public class RPGPlaceholders extends PlaceholderExpansion { return MythicLib.plugin.getMMOConfig().decimal.format(value); } - /* - * Returns a player's value of a skill parameter. - */ + // Returns a player's value of a skill parameter. else if (identifier.startsWith("skill_modifier_") || identifier.startsWith("skill_parameter_")) { final String[] ids = identifier.substring(identifier.startsWith("skill_modifier_") ? 15 : 16).split(":"); final String parameterId = ids[0]; @@ -152,14 +151,22 @@ public class RPGPlaceholders extends PlaceholderExpansion { else if (identifier.startsWith("since_last_hit")) return playerData.isInCombat() ? MythicLib.plugin.getMMOConfig().decimal.format((System.currentTimeMillis() - playerData.getCombat().getLastHit()) / 1000.) : "-1"; + // Returns the bound skill ID + else if (identifier.startsWith("id_bound_")) { + final int slot = Math.max(1, Integer.parseInt(identifier.substring(9))); + final ClassSkill info = playerData.getBoundSkill(slot); + return info == null ? "" : info.getSkill().getHandler().getId(); + } + + // Returns the bound skill name else if (identifier.startsWith("bound_")) { - int slot = Math.max(0, Integer.parseInt(identifier.substring(6))); - if (playerData.hasSkillBound(slot)) { - ClassSkill skill = playerData.getBoundSkill(slot); - return (playerData.getCooldownMap().isOnCooldown(skill) ? ChatColor.RED : ChatColor.GREEN) + skill.getSkill().getName(); - } else - return MMOCore.plugin.configManager.noSkillBoundPlaceholder; - } else if (identifier.startsWith("cooldown_bound_")) { + final int slot = Math.max(1, Integer.parseInt(identifier.substring(6))); + final ClassSkill skill = playerData.getBoundSkill(slot); + if (skill == null) return MMOCore.plugin.configManager.noSkillBoundPlaceholder; + return (playerData.getCooldownMap().isOnCooldown(skill) ? ChatColor.RED : ChatColor.GREEN) + skill.getSkill().getName(); + } + + else if (identifier.startsWith("cooldown_bound_")) { int slot = Math.max(0, Integer.parseInt(identifier.substring(15))); if (playerData.hasSkillBound(slot)) return Double.toString(playerData.getCooldownMap().getCooldown(playerData.getBoundSkill(slot)));