From ebf0d40fbf7bd50f90843c42f93484de97da43aa Mon Sep 17 00:00:00 2001 From: Indyuce Date: Wed, 25 Aug 2021 20:58:39 +0200 Subject: [PATCH] Added as skill placeholder --- .../Indyuce/mmocore/comp/mythicmobs/MythicHook.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/MythicHook.java b/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/MythicHook.java index 706c94a6..7e9f1837 100644 --- a/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/MythicHook.java +++ b/src/main/java/net/Indyuce/mmocore/comp/mythicmobs/MythicHook.java @@ -1,5 +1,6 @@ package net.Indyuce.mmocore.comp.mythicmobs; +import io.lumine.mythic.lib.api.stat.StatMap; import io.lumine.xikage.mythicmobs.MythicMobs; import io.lumine.xikage.mythicmobs.api.bukkit.events.MythicDropLoadEvent; import io.lumine.xikage.mythicmobs.api.bukkit.events.MythicReloadedEvent; @@ -59,6 +60,15 @@ public class MythicHook implements Listener { return String.valueOf((int) cast.getModifier(arg)); })); + MythicMobs.inst().getPlaceholderManager().register("stat", Placeholder.meta((metadata, arg) -> { + if (!(metadata instanceof SkillMetadata)) + throw new RuntimeException("Cannot use this placeholder outside of skill"); + + Variable var = ((SkillMetadata) metadata).getVariables().get("MMOStatMap"); + StatMap.CachedStatMap statMap = (StatMap.CachedStatMap) var.get(); + return String.valueOf(statMap.getStat(arg.toUpperCase())); + })); + MythicMobs.inst().getPlaceholderManager().register("mana", Placeholder.meta((metadata, arg) -> String.valueOf((int) PlayerData.get(metadata.getCaster().getEntity().getUniqueId()).getMana()))); MythicMobs.inst().getPlaceholderManager().register("stamina", Placeholder.meta((metadata, arg) -> String.valueOf((int) PlayerData.get(metadata.getCaster().getEntity().getUniqueId()).getStamina()))); }