Max stamina stat for Heroes

This commit is contained in:
Indyuce 2022-07-07 00:12:59 +02:00
parent 611c901e8f
commit 0885263210
3 changed files with 24 additions and 12 deletions

View File

@ -66,6 +66,11 @@
<url>https://mvn.lumine.io/repository/maven-public/</url>
</repository>
<repository>
<id>lumine</id>
<url>https://mvn.lumine.io/repository/maven-private/</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
@ -244,8 +249,8 @@
<dependency>
<groupId>com.herocraftonline</groupId>
<artifactId>heroes</artifactId>
<version>1.9.3</version>
<artifactId>Heroes</artifactId>
<version>1.9.22</version>
<scope>provided</scope>
</dependency>

View File

@ -35,6 +35,7 @@ import net.Indyuce.mmoitems.comp.parse.placeholders.DefaultPlaceholderParser;
import net.Indyuce.mmoitems.comp.parse.placeholders.PlaceholderAPIParser;
import net.Indyuce.mmoitems.comp.parse.placeholders.PlaceholderParser;
import net.Indyuce.mmoitems.comp.rpg.DefaultHook;
import net.Indyuce.mmoitems.comp.rpg.HeroesHook;
import net.Indyuce.mmoitems.comp.rpg.McMMOHook;
import net.Indyuce.mmoitems.comp.rpg.RPGHandler;
import net.Indyuce.mmoitems.gui.PluginInventory;
@ -139,6 +140,9 @@ public class MMOItems extends LuminePlugin {
}
if (Bukkit.getPluginManager().getPlugin("MythicEnchants") != null) enchantPlugins.add(new MythicEnchantsSupport());
if (Bukkit.getPluginManager().getPlugin("Heroes") != null)
statManager.register(HeroesHook.MAX_STAMINA);
}
@Override

View File

@ -16,6 +16,9 @@ import io.lumine.mythic.lib.damage.DamageType;
import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.api.player.PlayerData;
import net.Indyuce.mmoitems.api.player.RPGPlayer;
import net.Indyuce.mmoitems.stat.type.DoubleStat;
import net.Indyuce.mmoitems.stat.type.ItemStat;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@ -24,12 +27,12 @@ import org.jetbrains.annotations.Nullable;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
public class HeroesHook implements RPGHandler, Listener, AttackHandler {
private final Map<SkillType, DamageType> damages = new HashMap<>();
public static final ItemStat MAX_STAMINA = new DoubleStat("MAX_STAMINA", Material.EMERALD, "Max Stamina", new String[]{"Adds stamina to your max stamina bar"});
public HeroesHook() {
MythicLib.plugin.getDamage().registerHandler(this);
@ -46,8 +49,7 @@ public class HeroesHook implements RPGHandler, Listener, AttackHandler {
return null;
Player player = (Player) info.getCharacter().getEntity();
Set<DamageType> types = info.getSkill().getTypes().stream().filter(damages::containsKey).map(damages::get).collect(Collectors.toSet());
DamageMetadata damageMeta = new DamageMetadata(0, types.toArray(new DamageType[0]));
DamageMetadata damageMeta = new DamageMetadata(0, info.getSkill().getTypes().stream().filter(damages::containsKey).map(damages::get).distinct().toArray(DamageType[]::new));
return new AttackMetadata(damageMeta, MMOPlayerData.get(player).getStatMap().cache(EquipmentSlot.MAIN_HAND));
}
@ -56,6 +58,10 @@ public class HeroesHook implements RPGHandler, Listener, AttackHandler {
Hero hero = Heroes.getInstance().getCharacterManager().getHero(data.getPlayer());
hero.removeMaxMana("MMOItems");
hero.addMaxMana("MMOItems", (int) data.getStats().getStat(ItemStats.MAX_MANA));
hero.removeMaxStamina("MMOItems");
hero.addMaxStamina("MMOItems", (int) data.getStats().getStat(MAX_STAMINA));
hero.removeMaxHealth("MMOItems");
hero.addMaxHealth("MMOItems", data.getStats().getStat(ItemStats.MAX_HEALTH));
}
@Override
@ -82,43 +88,40 @@ public class HeroesHook implements RPGHandler, Listener, AttackHandler {
}
public static class HeroesPlayer extends RPGPlayer {
private final Hero hero;
public HeroesPlayer(PlayerData playerData) {
super(playerData);
hero = Heroes.getInstance().getCharacterManager().getHero(getPlayer());
}
@Override
public int getLevel() {
Hero hero = Heroes.getInstance().getCharacterManager().getHero(getPlayer());
return hero.getHeroLevel();
}
@Override
public String getClassName() {
Hero hero = Heroes.getInstance().getCharacterManager().getHero(getPlayer());
return hero.getHeroClass().getName();
}
@Override
public double getMana() {
Hero hero = Heroes.getInstance().getCharacterManager().getHero(getPlayer());
return hero.getMana();
}
@Override
public double getStamina() {
Hero hero = Heroes.getInstance().getCharacterManager().getHero(getPlayer());
return hero.getStamina();
}
@Override
public void setMana(double value) {
Hero hero = Heroes.getInstance().getCharacterManager().getHero(getPlayer());
hero.setMana((int) value);
}
@Override
public void setStamina(double value) {
Hero hero = Heroes.getInstance().getCharacterManager().getHero(getPlayer());
hero.setStamina((int) value);
}
}