moved skill and stat placeholders to mythiclib

This commit is contained in:
Indyuce 2021-08-26 11:19:44 +02:00
parent 591e92c46c
commit 8f99eedb1b
3 changed files with 1 additions and 85 deletions

View File

@ -125,7 +125,7 @@
<dependency> <dependency>
<groupId>io.lumine</groupId> <groupId>io.lumine</groupId>
<artifactId>MythicLib</artifactId> <artifactId>MythicLib</artifactId>
<version>1.1.2</version> <version>1.1.3</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>

View File

@ -1,12 +1,9 @@
package net.Indyuce.mmocore.comp.mythicmobs; 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.MythicMobs;
import io.lumine.xikage.mythicmobs.api.bukkit.events.MythicDropLoadEvent; import io.lumine.xikage.mythicmobs.api.bukkit.events.MythicDropLoadEvent;
import io.lumine.xikage.mythicmobs.api.bukkit.events.MythicReloadedEvent; import io.lumine.xikage.mythicmobs.api.bukkit.events.MythicReloadedEvent;
import io.lumine.xikage.mythicmobs.skills.SkillMetadata;
import io.lumine.xikage.mythicmobs.skills.placeholders.Placeholder; import io.lumine.xikage.mythicmobs.skills.placeholders.Placeholder;
import io.lumine.xikage.mythicmobs.skills.variables.Variable;
import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.comp.mythicmobs.load.CurrencyItemDrop; import net.Indyuce.mmocore.comp.mythicmobs.load.CurrencyItemDrop;
import net.Indyuce.mmocore.comp.mythicmobs.load.GoldPouchDrop; import net.Indyuce.mmocore.comp.mythicmobs.load.GoldPouchDrop;
@ -41,34 +38,6 @@ public class MythicHook implements Listener {
} }
private void registerPlaceholders() { private void registerPlaceholders() {
MythicMobs.inst().getPlaceholderManager().register("modifier", Placeholder.meta((metadata, arg) -> {
if (!(metadata instanceof SkillMetadata))
throw new RuntimeException("Cannot use this placeholder outside of skill");
Variable var = ((SkillMetadata) metadata).getVariables().get("MMOCoreSkill");
net.Indyuce.mmocore.skill.metadata.SkillMetadata cast = (net.Indyuce.mmocore.skill.metadata.SkillMetadata) var.get();
return String.valueOf(cast.getModifier(arg));
}));
MythicMobs.inst().getPlaceholderManager().register("modifier.int", Placeholder.meta((metadata, arg) -> {
if (!(metadata instanceof SkillMetadata))
throw new RuntimeException("Cannot use this placeholder outside of skill");
Variable var = ((SkillMetadata) metadata).getVariables().get("MMOCoreSkill");
net.Indyuce.mmocore.skill.metadata.SkillMetadata cast = (net.Indyuce.mmocore.skill.metadata.SkillMetadata) var.get();
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("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()))); MythicMobs.inst().getPlaceholderManager().register("stamina", Placeholder.meta((metadata, arg) -> String.valueOf((int) PlayerData.get(metadata.getCaster().getEntity().getUniqueId()).getStamina())));
} }

View File

@ -1,53 +0,0 @@
package net.Indyuce.mmocore.comp.mythicmobs.skill;
import io.lumine.xikage.mythicmobs.skills.variables.Variable;
import org.jetbrains.annotations.NotNull;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
/**
* Used by MMOCore to cache skill modifiers inside a variable.
* The modifiers are cached in a variable with the skill scope.
*
* @deprecated Now using an {@link io.lumine.xikage.mythicmobs.skills.variables.types.AbstractVariable}
*/
@Deprecated
public class MapVariable extends Variable {
@NotNull
private final Map<String, Double> map = new HashMap<>();
public Map<String, Double> getValue() {
return map;
}
@Override
public String toString() {
return "VAR_Map(" + map + ')';
}
@Override
public boolean shouldSave() {
return false;
}
@Override
public Object get() {
return map;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
MapVariable that = (MapVariable) o;
return map.equals(that.map);
}
@Override
public int hashCode() {
return Objects.hash(map);
}
}