!Compatibility with very latest MMOLib

This commit is contained in:
Indyuce 2020-07-12 16:26:02 +02:00
parent d01976a314
commit a8cf3f5190
3 changed files with 8 additions and 6 deletions

Binary file not shown.

View File

@ -22,6 +22,7 @@ import net.mmogroup.mmolib.MMOLib;
import net.mmogroup.mmolib.api.AttackResult;
import net.mmogroup.mmolib.api.DamageHandler;
import net.mmogroup.mmolib.api.DamageType;
import net.mmogroup.mmolib.api.RegisteredAttack;
public class HeroesHook implements RPGHandler, Listener, DamageHandler {
private final Map<SkillType, DamageType> damages = new HashMap<>();
@ -40,10 +41,10 @@ public class HeroesHook implements RPGHandler, Listener, DamageHandler {
}
@Override
public AttackResult getDamage(Entity entity) {
public RegisteredAttack getDamage(Entity entity) {
SkillUseInfo info = Heroes.getInstance().getDamageManager().getSpellTargetInfo(entity);
return new AttackResult(true, 0, info.getSkill().getTypes().stream().filter(type -> damages.containsKey(type)).map(type -> damages.get(type))
.collect(Collectors.toSet()));
return new RegisteredAttack(new AttackResult(true, 0, info.getSkill().getTypes().stream().filter(type -> damages.containsKey(type))
.map(type -> damages.get(type)).collect(Collectors.toSet())), info.getCharacter().getEntity());
}
@Override

View File

@ -21,9 +21,10 @@ import net.mmogroup.mmolib.MMOLib;
import net.mmogroup.mmolib.api.AttackResult;
import net.mmogroup.mmolib.api.DamageHandler;
import net.mmogroup.mmolib.api.DamageType;
import net.mmogroup.mmolib.api.RegisteredAttack;
public class SkillAPIHook implements RPGHandler, Listener, DamageHandler {
private final Map<Integer, AttackResult> damageInfo = new HashMap<>();
private final Map<Integer, RegisteredAttack> damageInfo = new HashMap<>();
public SkillAPIHook() {
MMOLib.plugin.getDamage().registerHandler(this);
@ -35,7 +36,7 @@ public class SkillAPIHook implements RPGHandler, Listener, DamageHandler {
}
@Override
public AttackResult getDamage(Entity entity) {
public RegisteredAttack getDamage(Entity entity) {
return damageInfo.get(entity.getEntityId());
}
@ -46,7 +47,7 @@ public class SkillAPIHook implements RPGHandler, Listener, DamageHandler {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void a(SkillDamageEvent event) {
damageInfo.put(event.getTarget().getEntityId(), new AttackResult(event.getDamage(), DamageType.SKILL));
damageInfo.put(event.getTarget().getEntityId(), new RegisteredAttack(new AttackResult(event.getDamage(), DamageType.SKILL), event.getDamager()));
if (event.getDamager() instanceof Player)
event.setDamage(event.getDamage() * (1 + net.Indyuce.mmoitems.api.player.PlayerData.get((Player) event.getDamager()).getStats().getStat(ItemStat.MAGIC_DAMAGE) / 100));