attacks may now have multiple damage types (mmocore comp)

This commit is contained in:
Indyuce 2019-08-29 13:42:10 +02:00
parent 4161db27e2
commit eaddf9161e
59 changed files with 201 additions and 169 deletions

Binary file not shown.

View File

@ -12,8 +12,8 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult;
import net.Indyuce.mmoitems.api.DamageInfo.DamageType;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.manager.DamageManager.DamageType;
import net.Indyuce.mmoitems.stat.data.AbilityData;
public class Bouncy_Fireball extends Ability {
@ -74,7 +74,7 @@ public class Bouncy_Fireball extends Ability {
for (Entity entity : MMOUtils.getNearbyChunkEntities(loc))
if (entity.getLocation().distanceSquared(loc) < radius * radius)
if (MMOUtils.canDamage(stats.getPlayer(), entity)) {
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) entity, damage, DamageType.MAGIC);
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) entity, damage, DamageType.SKILL, DamageType.PROJECTILE, DamageType.MAGICAL);
((LivingEntity) entity).setFireTicks((int) (ignite * 20));
}

View File

@ -13,8 +13,8 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult;
import net.Indyuce.mmoitems.api.DamageInfo.DamageType;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.manager.DamageManager.DamageType;
import net.Indyuce.mmoitems.stat.data.AbilityData;
public class Burning_Hands extends Ability implements Listener {
@ -58,7 +58,7 @@ public class Burning_Hands extends Ability implements Listener {
if (entity.getLocation().distanceSquared(loc) < 60)
if (stats.getPlayer().getEyeLocation().getDirection().angle(entity.getLocation().toVector().subtract(stats.getPlayer().getLocation().toVector())) < Math.PI / 6)
if (MMOUtils.canDamage(stats.getPlayer(), entity))
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) entity, damage1, DamageType.MAGIC);
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) entity, damage1, DamageType.SKILL, DamageType.MAGICAL);
}
}.runTaskTimer(MMOItems.plugin, 0, 2);

View File

@ -13,8 +13,8 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult;
import net.Indyuce.mmoitems.api.DamageInfo.DamageType;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.manager.DamageManager.DamageType;
import net.Indyuce.mmoitems.stat.data.AbilityData;
public class Circular_Slash extends Ability {
@ -39,7 +39,7 @@ public class Circular_Slash extends Ability {
stats.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 2, 254));
for (Entity entity : stats.getPlayer().getNearbyEntities(radius, radius, radius)) {
if (MMOUtils.canDamage(stats.getPlayer(), entity)) {
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) entity, damage1, DamageType.PHYSICAL);
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) entity, damage1, DamageType.SKILL, DamageType.PHYSICAL);
Vector v1 = entity.getLocation().toVector();
Vector v2 = stats.getPlayer().getLocation().toVector();
double y = .5;

View File

@ -11,8 +11,8 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult;
import net.Indyuce.mmoitems.api.DamageInfo.DamageType;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.manager.DamageManager.DamageType;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.Indyuce.mmoitems.version.VersionSound;
@ -60,7 +60,7 @@ public class Contamination extends Ability {
loc.getWorld().playSound(loc, VersionSound.ENTITY_ENDERMAN_HURT.toSound(), 2, 1);
for (Entity entity : MMOUtils.getNearbyChunkEntities(loc))
if (MMOUtils.canDamage(stats.getPlayer(), entity) && entity.getLocation().distanceSquared(loc) <= 25)
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) entity, dps, DamageType.MAGIC, false);
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) entity, dps, false, DamageType.SKILL, DamageType.MAGICAL);
}
}
}.runTaskTimer(MMOItems.plugin, 0, 1);

View File

@ -12,8 +12,8 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult;
import net.Indyuce.mmoitems.api.DamageInfo.DamageType;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.manager.DamageManager.DamageType;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.Indyuce.mmoitems.version.VersionSound;
@ -53,7 +53,7 @@ public class Corrupt extends Ability {
for (Entity entity : MMOUtils.getNearbyChunkEntities(loc))
if (MMOUtils.canDamage(stats.getPlayer(), entity) && entity.getLocation().distanceSquared(loc) <= radius * radius) {
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) entity, damage1, DamageType.MAGIC);
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) entity, damage1, DamageType.SKILL, DamageType.MAGICAL);
((LivingEntity) entity).removePotionEffect(PotionEffectType.WITHER);
((LivingEntity) entity).addPotionEffect(new PotionEffect(PotionEffectType.WITHER, (int) (duration * 20), (int) amplifier));
}

View File

@ -15,8 +15,8 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult;
import net.Indyuce.mmoitems.api.DamageInfo.DamageType;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.manager.DamageManager.DamageType;
import net.Indyuce.mmoitems.stat.data.AbilityData;
public class Corrupted_Fangs extends Ability implements Listener {
@ -63,7 +63,7 @@ public class Corrupted_Fangs extends Ability implements Listener {
Object[] data = MMOItems.plugin.getEntities().getEntityData(damager);
TemporaryStats stats = (TemporaryStats) data[0];
if (MMOUtils.canDamage(stats.getPlayer(), event.getEntity()))
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) event.getEntity(), (double) data[1], DamageType.MAGIC);
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) event.getEntity(), (double) data[1], DamageType.SKILL, DamageType.MAGICAL);
}
}
}

View File

@ -16,8 +16,8 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult;
import net.Indyuce.mmoitems.api.DamageInfo.DamageType;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.manager.DamageManager.DamageType;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.Indyuce.mmoitems.version.VersionSound;
@ -66,7 +66,7 @@ public class Cursed_Beam extends Ability {
for (Entity aoeTarget : entities)
if (MMOUtils.canDamage(stats.getPlayer(), aoeTarget) && loc.distanceSquared(aoeTarget.getLocation().add(0, 1, 0)) < 9) {
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) aoeTarget, damage, DamageType.MAGIC);
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) aoeTarget, damage, DamageType.SKILL, DamageType.PROJECTILE, DamageType.MAGICAL);
((LivingEntity) aoeTarget).addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, (int) (duration * 20), 0));
}
cancel();

View File

@ -17,8 +17,8 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult;
import net.Indyuce.mmoitems.api.DamageInfo.DamageType;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.manager.DamageManager.DamageType;
import net.Indyuce.mmoitems.stat.data.AbilityData;
public class Earthquake extends Ability {
@ -62,7 +62,7 @@ public class Earthquake extends Ability {
for (Entity entity : MMOUtils.getNearbyChunkEntities(loc))
if (MMOUtils.canDamage(stats.getPlayer(), entity) && loc.distanceSquared(entity.getLocation()) < 2 && !hit.contains(entity.getEntityId())) {
hit.add(entity.getEntityId());
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) entity, damage1, DamageType.MAGIC);
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) entity, damage1, DamageType.SKILL, DamageType.MAGICAL);
((LivingEntity) entity).addPotionEffect(new PotionEffect(PotionEffectType.SLOW, (int) (slowDuration * 20), (int) slowAmplifier));
}
}

View File

@ -13,8 +13,8 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult;
import net.Indyuce.mmoitems.api.DamageInfo.DamageType;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.manager.DamageManager.DamageType;
import net.Indyuce.mmoitems.stat.data.AbilityData;
public class Explosive_Turkey extends Ability {
@ -71,7 +71,7 @@ public class Explosive_Turkey extends Ability {
chicken.getWorld().playSound(chicken.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 2, 1.5f);
for (Entity entity : MMOUtils.getNearbyChunkEntities(chicken.getLocation()))
if (!entity.isDead() && entity.getLocation().distanceSquared(chicken.getLocation()) < radiusSquared && MMOUtils.canDamage(stats.getPlayer(), entity)) {
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) entity, damage1, DamageType.MAGIC);
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) entity, damage1, DamageType.SKILL, DamageType.PROJECTILE, DamageType.MAGICAL);
entity.setVelocity(entity.getLocation().toVector().subtract(chicken.getLocation().toVector()).multiply(.1 * knockback).setY(.4 * knockback));
}
cancel();

View File

@ -13,8 +13,8 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult;
import net.Indyuce.mmoitems.api.DamageInfo.DamageType;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.manager.DamageManager.DamageType;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.Indyuce.mmoitems.version.VersionSound;
@ -57,7 +57,7 @@ public class Fire_Meteor extends Ability {
double radius = data.getModifier("radius");
for (Entity entity : loc.getWorld().getEntitiesByClass(LivingEntity.class))
if (MMOUtils.canDamage(stats.getPlayer(), entity) && entity.getLocation().distanceSquared(loc) < radius * radius) {
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) entity, damage1, DamageType.MAGIC);
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) entity, damage1, DamageType.SKILL, DamageType.PROJECTILE, DamageType.MAGICAL);
entity.setVelocity(entity.getLocation().toVector().subtract(loc.toVector()).multiply(.1 * knockback).setY(.4 * knockback));
}
cancel();

View File

@ -14,8 +14,8 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult;
import net.Indyuce.mmoitems.api.DamageInfo.DamageType;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.manager.DamageManager.DamageType;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.Indyuce.mmoitems.version.VersionSound;
@ -59,7 +59,7 @@ public class Firebolt extends Ability {
loc.getWorld().spawnParticle(Particle.LAVA, loc, 8, 0, 0, 0, 0);
loc.getWorld().spawnParticle(Particle.EXPLOSION_LARGE, loc, 0);
loc.getWorld().playSound(loc, Sound.ENTITY_GENERIC_EXPLODE, 3, 1);
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) target, data.getModifier("damage"), DamageType.MAGIC);
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) target, data.getModifier("damage"), DamageType.SKILL, DamageType.PROJECTILE, DamageType.MAGICAL);
target.setFireTicks((int) data.getModifier("ignite") * 20);
cancel();
return;

View File

@ -13,8 +13,8 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult;
import net.Indyuce.mmoitems.api.DamageInfo.DamageType;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.manager.DamageManager.DamageType;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.Indyuce.mmoitems.version.VersionSound;
@ -62,7 +62,7 @@ public class Firefly extends Ability {
stats.getPlayer().getWorld().spawnParticle(Particle.FLAME, stats.getPlayer().getLocation().add(0, 1, 0), 24, 0, 0, 0, .3);
entity.setVelocity(stats.getPlayer().getVelocity().setY(0.3).multiply(1.7 * knockback));
stats.getPlayer().setVelocity(stats.getPlayer().getEyeLocation().getDirection().multiply(-3).setY(.5));
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) entity, damage, DamageType.MAGIC);
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) entity, damage, DamageType.SKILL, DamageType.MAGICAL);
cancel();
return;
}

View File

@ -13,8 +13,8 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult;
import net.Indyuce.mmoitems.api.DamageInfo.DamageType;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.manager.DamageManager.DamageType;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.Indyuce.mmoitems.version.VersionSound;
@ -65,7 +65,7 @@ public class Freezing_Curse extends Ability {
double damage = data.getModifier("damage");
for (Entity entity : MMOUtils.getNearbyChunkEntities(loc))
if (entity.getLocation().distanceSquared(loc) < radius * radius && MMOUtils.canDamage(stats.getPlayer(), entity)) {
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) entity, damage, DamageType.MAGIC);
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) entity, damage, DamageType.SKILL, DamageType.MAGICAL);
((LivingEntity) entity).removePotionEffect(PotionEffectType.SLOW);
((LivingEntity) entity).addPotionEffect(new PotionEffect(PotionEffectType.SLOW, (int) (duration * 20), (int) amplifier));
}

View File

@ -11,8 +11,8 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult;
import net.Indyuce.mmoitems.api.DamageInfo.DamageType;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.manager.DamageManager.DamageType;
import net.Indyuce.mmoitems.stat.data.AbilityData;
public class Heavy_Charge extends Ability {
@ -50,7 +50,7 @@ public class Heavy_Charge extends Ability {
stats.getPlayer().getWorld().spawnParticle(Particle.EXPLOSION_LARGE, target.getLocation().add(0, 1, 0), 0);
target.setVelocity(stats.getPlayer().getVelocity().setY(0.3).multiply(1.7 * knockback));
stats.getPlayer().setVelocity(stats.getPlayer().getVelocity().setX(0).setY(0).setZ(0));
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) target, data.getModifier("damage"), DamageType.PHYSICAL);
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) target, data.getModifier("damage"), DamageType.SKILL, DamageType.PHYSICAL);
cancel();
break;
}

View File

@ -14,8 +14,8 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult;
import net.Indyuce.mmoitems.api.DamageInfo.DamageType;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.manager.DamageManager.DamageType;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.Indyuce.mmoitems.version.VersionSound;
@ -59,7 +59,7 @@ public class Holy_Missile extends Ability {
loc.getWorld().spawnParticle(Particle.EXPLOSION_LARGE, loc, 1);
loc.getWorld().spawnParticle(Particle.FIREWORKS_SPARK, loc, 32, 0, 0, 0, .2);
loc.getWorld().playSound(loc, Sound.ENTITY_GENERIC_EXPLODE, 2, 1);
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) entity, data.getModifier("damage"), DamageType.MAGIC);
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) entity, data.getModifier("damage"), DamageType.SKILL, DamageType.PROJECTILE, DamageType.MAGICAL);
cancel();
return;
}

View File

@ -17,8 +17,8 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult;
import net.Indyuce.mmoitems.api.DamageInfo.DamageType;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.manager.DamageManager.DamageType;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.Indyuce.mmoitems.version.VersionSound;
@ -72,7 +72,7 @@ public class Ice_Crystal extends Ability {
loc.getWorld().spawnParticle(Particle.EXPLOSION_LARGE, loc, 0);
loc.getWorld().spawnParticle(Particle.FIREWORKS_SPARK, loc, 48, 0, 0, 0, .2);
loc.getWorld().playSound(loc, Sound.ENTITY_GENERIC_EXPLODE, 2, 1);
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) entity, data.getModifier("damage"), DamageType.MAGIC);
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) entity, data.getModifier("damage"), DamageType.SKILL, DamageType.PROJECTILE, DamageType.MAGICAL);
((LivingEntity) entity).addPotionEffect(new PotionEffect(PotionEffectType.SLOW, (int) (data.getModifier("duration") * 20), (int) data.getModifier("amplifier")));
cancel();
return;

View File

@ -15,9 +15,9 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult;
import net.Indyuce.mmoitems.api.DamageInfo.DamageType;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.api.util.NoInteractItemEntity;
import net.Indyuce.mmoitems.manager.DamageManager.DamageType;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.Indyuce.mmoitems.version.VersionSound;
@ -59,7 +59,7 @@ public class Item_Bomb extends Ability implements Listener {
for (Entity entity : item.getEntity().getNearbyEntities(radius, radius, radius))
if (MMOUtils.canDamage(stats.getPlayer(), entity)) {
LivingEntity living = (LivingEntity) entity;
MMOItems.plugin.getDamage().damage(stats, living, damage, DamageType.MAGIC);
MMOItems.plugin.getDamage().damage(stats, living, damage, DamageType.SKILL, DamageType.PROJECTILE, DamageType.MAGICAL);
living.removePotionEffect(PotionEffectType.SLOW);
living.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, (int) (slowDuration * 20), (int) slowAmplifier));
}

View File

@ -13,9 +13,9 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult;
import net.Indyuce.mmoitems.api.DamageInfo.DamageType;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.api.util.NoInteractItemEntity;
import net.Indyuce.mmoitems.manager.DamageManager.DamageType;
import net.Indyuce.mmoitems.stat.data.AbilityData;
public class Item_Throw extends Ability implements Listener {
@ -53,7 +53,7 @@ public class Item_Throw extends Ability implements Listener {
item.getEntity().getWorld().spawnParticle(Particle.CRIT, item.getEntity().getLocation(), 0);
for (Entity target : item.getEntity().getNearbyEntities(1, 1, 1))
if (MMOUtils.canDamage(stats.getPlayer(), target)) {
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) target, data.getModifier("damage"), DamageType.PHYSICAL);
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) target, data.getModifier("damage"), DamageType.SKILL, DamageType.PROJECTILE, DamageType.PHYSICAL);
item.close();
cancel();
}

View File

@ -12,8 +12,8 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult;
import net.Indyuce.mmoitems.api.DamageInfo.DamageType;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.manager.DamageManager.DamageType;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.Indyuce.mmoitems.version.VersionSound;
@ -69,7 +69,7 @@ public class Life_Ender extends Ability {
for (Entity entity : MMOUtils.getNearbyChunkEntities(source))
if (entity.getLocation().distanceSquared(source) < radius * radius && MMOUtils.canDamage(stats.getPlayer(), entity)) {
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) entity, damage, DamageType.MAGIC);
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) entity, damage, DamageType.SKILL, DamageType.PROJECTILE, DamageType.MAGICAL);
entity.setVelocity(entity.getLocation().subtract(source).toVector().setY(.75).normalize().multiply(knockback));
}
cancel();

View File

@ -13,8 +13,8 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult;
import net.Indyuce.mmoitems.api.DamageInfo.DamageType;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.manager.DamageManager.DamageType;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.Indyuce.mmoitems.version.VersionSound;
@ -49,7 +49,7 @@ public class Light_Dash extends Ability {
for (Entity entity : stats.getPlayer().getNearbyEntities(1, 1, 1))
if (!hit.contains(entity.getEntityId()) && MMOUtils.canDamage(stats.getPlayer(), entity)) {
hit.add(entity.getEntityId());
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) entity, damage1, DamageType.PHYSICAL);
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) entity, damage1, DamageType.SKILL, DamageType.PHYSICAL);
}
}
}.runTaskTimer(MMOItems.plugin, 0, 2);

View File

@ -10,8 +10,8 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult;
import net.Indyuce.mmoitems.api.DamageInfo.DamageType;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.manager.DamageManager.DamageType;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.Indyuce.mmoitems.version.VersionSound;
@ -41,7 +41,7 @@ public class Lightning_Beam extends Ability {
for (Entity entity : MMOUtils.getNearbyChunkEntities(loc))
if (MMOUtils.canDamage(stats.getPlayer(), entity) && entity.getLocation().distanceSquared(loc) <= radius * radius)
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) entity, damage1, DamageType.MAGIC);
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) entity, damage1, DamageType.SKILL, DamageType.MAGICAL);
stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(), VersionSound.ENTITY_FIREWORK_ROCKET_BLAST.toSound(), 1, 0);
loc.getWorld().spawnParticle(Particle.FIREWORKS_SPARK, loc, 64, 0, 0, 0, .2);

View File

@ -10,8 +10,8 @@ import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult;
import net.Indyuce.mmoitems.api.DamageInfo.DamageType;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.manager.DamageManager.DamageType;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.Indyuce.mmoitems.version.VersionSound;
@ -56,7 +56,7 @@ public class Magma_Fissure extends Ability {
if (target.getLocation().distanceSquared(loc) < 1) {
loc.getWorld().playSound(loc, Sound.ENTITY_BLAZE_HURT, 2, 1);
target.setFireTicks((int) (target.getFireTicks() + data.getModifier("ignite") * 20));
MMOItems.plugin.getDamage().damage(stats, target, data.getModifier("damage"), DamageType.MAGIC);
MMOItems.plugin.getDamage().damage(stats, target, data.getModifier("damage"), DamageType.SKILL, DamageType.PROJECTILE, DamageType.MAGICAL);
cancel();
}
}

View File

@ -12,8 +12,8 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult;
import net.Indyuce.mmoitems.api.DamageInfo.DamageType;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.manager.DamageManager.DamageType;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.Indyuce.mmoitems.version.VersionSound;
@ -39,7 +39,7 @@ public class Overload extends Ability {
for (Entity entity : stats.getPlayer().getNearbyEntities(radius, radius, radius))
if (MMOUtils.canDamage(stats.getPlayer(), entity))
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) entity, damage1, DamageType.MAGIC);
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) entity, damage1, DamageType.SKILL, DamageType.MAGICAL);
double step = 12 + (radius * 2.5);
for (double j = 0; j < Math.PI * 2; j += Math.PI / step) {

View File

@ -20,9 +20,9 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult;
import net.Indyuce.mmoitems.api.DamageInfo.DamageType;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.api.util.NoInteractItemEntity;
import net.Indyuce.mmoitems.manager.DamageManager.DamageType;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.Indyuce.mmoitems.version.VersionMaterial;
import net.Indyuce.mmoitems.version.VersionSound;
@ -89,7 +89,7 @@ public class Present_Throw extends Ability {
item.getEntity().getWorld().playSound(item.getEntity().getLocation(), VersionSound.ENTITY_FIREWORK_ROCKET_TWINKLE.toSound(), 2, 1.5f);
for (Entity entity : MMOUtils.getNearbyChunkEntities(item.getEntity().getLocation()))
if (entity.getLocation().distanceSquared(item.getEntity().getLocation()) < radiusSquared && MMOUtils.canDamage(stats.getPlayer(), entity))
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) entity, damage1, DamageType.MAGIC);
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) entity, damage1, DamageType.SKILL, DamageType.PROJECTILE, DamageType.MAGICAL);
item.close();
cancel();
}

View File

@ -12,8 +12,8 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult;
import net.Indyuce.mmoitems.api.DamageInfo.DamageType;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.manager.DamageManager.DamageType;
import net.Indyuce.mmoitems.stat.data.AbilityData;
public class Sky_Smash extends Ability {
@ -40,7 +40,7 @@ public class Sky_Smash extends Ability {
for (Entity entity : MMOUtils.getNearbyChunkEntities(loc))
if (MMOUtils.canDamage(stats.getPlayer(), entity) && entity.getLocation().distanceSquared(loc) < 10) {
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) entity, damage1, DamageType.PHYSICAL);
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) entity, damage1, DamageType.SKILL, DamageType.PHYSICAL);
Location loc1 = stats.getPlayer().getEyeLocation().clone();
loc1.setPitch(-70);
((LivingEntity) entity).setVelocity(loc1.getDirection().multiply(1.2 * knockUp));

View File

@ -5,8 +5,8 @@ import org.bukkit.entity.LivingEntity;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult;
import net.Indyuce.mmoitems.api.DamageInfo.DamageType;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.manager.DamageManager.DamageType;
import net.Indyuce.mmoitems.stat.data.AbilityData;
public class Smite extends Ability {
@ -27,7 +27,7 @@ public class Smite extends Ability {
return;
}
MMOItems.plugin.getDamage().damage(stats, target, data.getModifier("damage"), DamageType.MAGIC);
MMOItems.plugin.getDamage().damage(stats, target, data.getModifier("damage"), DamageType.SKILL, DamageType.MAGICAL);
target.getWorld().strikeLightningEffect(target.getLocation());
}
}

View File

@ -10,8 +10,8 @@ import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult;
import net.Indyuce.mmoitems.api.DamageInfo.DamageType;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.manager.DamageManager.DamageType;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.Indyuce.mmoitems.version.VersionSound;
@ -39,7 +39,7 @@ public class Sparkle extends Ability {
double radius = data.getModifier("radius");
double limit = data.getModifier("limit");
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) target, damage1, DamageType.MAGIC);
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) target, damage1, DamageType.SKILL, DamageType.MAGICAL);
target.getWorld().spawnParticle(Particle.EXPLOSION_LARGE, target.getLocation().add(0, 1, 0), 0);
target.getWorld().playSound(target.getLocation(), VersionSound.ENTITY_FIREWORK_ROCKET_TWINKLE.toSound(), 2, 2);
int count = 0;
@ -49,7 +49,7 @@ public class Sparkle extends Ability {
if (ent instanceof LivingEntity && ent != stats.getPlayer() && !(ent instanceof ArmorStand)) {
count++;
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) ent, damage1, DamageType.MAGIC);
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) ent, damage1, DamageType.SKILL, DamageType.MAGICAL);
ent.getWorld().playSound(ent.getLocation(), VersionSound.ENTITY_FIREWORK_ROCKET_TWINKLE.toSound(), 2, 2);
Location loc_t = target.getLocation().add(0, .75, 0);
Location loc_ent = ent.getLocation().add(0, .75, 0);

View File

@ -15,8 +15,8 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult;
import net.Indyuce.mmoitems.api.DamageInfo.DamageType;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.manager.DamageManager.DamageType;
import net.Indyuce.mmoitems.stat.data.AbilityData;
public class Tactical_Grenade extends Ability {
@ -73,7 +73,7 @@ public class Tactical_Grenade extends Ability {
if (entity.equals(target))
cancel();
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) entity, data.getModifier("damage"), DamageType.MAGIC);
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) entity, data.getModifier("damage"), DamageType.SKILL, DamageType.PROJECTILE, DamageType.MAGICAL);
entity.setVelocity(entity.getVelocity().add(offsetVector(knockup)));
}
}

View File

@ -9,8 +9,8 @@ import org.bukkit.scheduler.BukkitRunnable;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult;
import net.Indyuce.mmoitems.api.DamageInfo.DamageType;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.manager.DamageManager.DamageType;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.Indyuce.mmoitems.version.VersionSound;
@ -55,7 +55,7 @@ public class Targeted_Fireball extends Ability {
loc.getWorld().spawnParticle(Particle.FLAME, loc, 32, 0, 0, 0, .1);
loc.getWorld().playSound(loc, Sound.ENTITY_BLAZE_HURT, 2, 1);
target.setFireTicks((int) (target.getFireTicks() + data.getModifier("ignite") * 20));
MMOItems.plugin.getDamage().damage(stats, target, data.getModifier("damage"), DamageType.MAGIC);
MMOItems.plugin.getDamage().damage(stats, target, data.getModifier("damage"), DamageType.SKILL, DamageType.PROJECTILE, DamageType.MAGICAL);
cancel();
}
}

View File

@ -15,9 +15,9 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult;
import net.Indyuce.mmoitems.api.DamageInfo.DamageType;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.api.util.NoInteractItemEntity;
import net.Indyuce.mmoitems.manager.DamageManager.DamageType;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.Indyuce.mmoitems.version.nms.ItemTag;
@ -54,7 +54,7 @@ public class Throw_Up extends Ability implements Listener {
if (ent.getLocation().distanceSquared(loc) < 40)
if (stats.getPlayer().getEyeLocation().getDirection().angle(ent.getLocation().toVector().subtract(stats.getPlayer().getLocation().toVector())) < Math.PI / 6)
if (MMOUtils.canDamage(stats.getPlayer(), ent))
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) ent, dps, DamageType.MAGIC);
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) ent, dps, DamageType.SKILL, DamageType.MAGICAL);
loc.getWorld().playSound(loc, Sound.ENTITY_ZOMBIE_HURT, 1, 1);

View File

@ -13,8 +13,8 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult;
import net.Indyuce.mmoitems.api.DamageInfo.DamageType;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.manager.DamageManager.DamageType;
import net.Indyuce.mmoitems.stat.data.AbilityData;
public class Thrust extends Ability {
@ -40,7 +40,7 @@ public class Thrust extends Ability {
loc.add(vec);
for (Entity entity : MMOUtils.getNearbyChunkEntities(loc))
if (MMOUtils.canDamage(stats.getPlayer(), loc, entity))
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) entity, damage1, DamageType.PHYSICAL);
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) entity, damage1, DamageType.SKILL, DamageType.PHYSICAL);
loc.getWorld().spawnParticle(Particle.SMOKE_LARGE, loc, 0);
}
}

View File

@ -11,8 +11,8 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult;
import net.Indyuce.mmoitems.api.DamageInfo.DamageType;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.manager.DamageManager.DamageType;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.Indyuce.mmoitems.version.VersionSound;
@ -54,7 +54,7 @@ public class Arcane_Hail extends Ability {
loc1.getWorld().playSound(loc1, VersionSound.ENTITY_ENDERMAN_HURT.toSound(), 1, 0);
for (Entity entity : MMOUtils.getNearbyChunkEntities(loc1))
if (MMOUtils.canDamage(stats.getPlayer(), entity) && entity.getLocation().distanceSquared(loc1) <= 4)
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) entity, damage1, DamageType.MAGIC);
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) entity, damage1, DamageType.SKILL, DamageType.MAGICAL);
loc1.getWorld().spawnParticle(Particle.SPELL_WITCH, loc1, 12, 0, 0, 0, .1);
loc1.getWorld().spawnParticle(Particle.SMOKE_NORMAL, loc1, 6, 0, 0, 0, .1);

View File

@ -16,8 +16,8 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult;
import net.Indyuce.mmoitems.api.DamageInfo.DamageType;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.manager.DamageManager.DamageType;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.Indyuce.mmoitems.version.VersionSound;
@ -62,7 +62,7 @@ public class Arcane_Rift extends Ability {
for (Entity entity : MMOUtils.getNearbyChunkEntities(loc))
if (MMOUtils.canDamage(stats.getPlayer(), entity) && loc.distanceSquared(entity.getLocation()) < 2 && !hit.contains(entity.getEntityId())) {
hit.add(entity.getEntityId());
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) entity, damage1, DamageType.MAGIC);
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) entity, damage1, DamageType.SKILL, DamageType.MAGICAL);
((LivingEntity) entity).addPotionEffect(new PotionEffect(PotionEffectType.SLOW, (int) (slowDuration * 20), (int) slowAmplifier));
}
}

View File

@ -10,8 +10,8 @@ import org.bukkit.scheduler.BukkitRunnable;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult;
import net.Indyuce.mmoitems.api.DamageInfo.DamageType;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.manager.DamageManager.DamageType;
import net.Indyuce.mmoitems.stat.data.AbilityData;
public class Death_Mark extends Ability {
@ -50,7 +50,7 @@ public class Death_Mark extends Ability {
target.getWorld().spawnParticle(Particle.SPELL_MOB, target.getLocation(), 4, .2, 0, .2, 0);
if (ti % 20 == 0)
MMOItems.plugin.getDamage().damage(stats, target, dps, DamageType.MAGIC, false);
MMOItems.plugin.getDamage().damage(stats, target, dps, false, DamageType.SKILL, DamageType.MAGICAL);
}
}.runTaskTimer(MMOItems.plugin, 0, 1);
target.getWorld().playSound(target.getLocation(), Sound.ENTITY_BLAZE_HURT, 1, 2);

View File

@ -11,8 +11,8 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult;
import net.Indyuce.mmoitems.api.DamageInfo.DamageType;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.manager.DamageManager.DamageType;
import net.Indyuce.mmoitems.stat.data.AbilityData;
public class Minor_Explosion extends Ability {
@ -45,7 +45,7 @@ public class Minor_Explosion extends Ability {
for (Entity entity : MMOUtils.getNearbyChunkEntities(loc))
if (entity.getLocation().distanceSquared(loc) < radiusSquared && MMOUtils.canDamage(stats.getPlayer(), entity)) {
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) entity, damage, DamageType.MAGIC);
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) entity, damage, DamageType.SKILL, DamageType.MAGICAL);
entity.setVelocity(normalizeIfNotNull(entity.getLocation().subtract(loc).toVector().setY(0)).setY(.2).multiply(2 * knockback));
}
}

View File

@ -9,11 +9,11 @@ import org.bukkit.entity.Player;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Ability.CastingMode;
import net.Indyuce.mmoitems.api.DamageInfo.DamageType;
import net.Indyuce.mmoitems.api.interaction.weapon.Weapon;
import net.Indyuce.mmoitems.api.interaction.weapon.untargeted.UntargetedWeapon;
import net.Indyuce.mmoitems.api.item.NBTItem;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.manager.DamageManager.DamageType;
import net.Indyuce.mmoitems.stat.type.ItemStat;
public class AttackResult {
@ -87,8 +87,8 @@ public class AttackResult {
// applyEffectsAndDamage(stats, item, target, DamageType.WEAPON);
// }
public void applyEffectsAndDamage(TemporaryStats stats, NBTItem item, LivingEntity target, DamageType type) {
MMOItems.plugin.getDamage().damage(stats, target, applyEffects(stats, item, target).damage, type);
public void applyEffectsAndDamage(TemporaryStats stats, NBTItem item, LivingEntity target, DamageType... types) {
MMOItems.plugin.getDamage().damage(stats, target, applyEffects(stats, item, target).damage, types);
}
public AttackResult applyElementalEffects(TemporaryStats stats, NBTItem item, LivingEntity target) {

View File

@ -0,0 +1,68 @@
package net.Indyuce.mmoitems.api;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import org.apache.commons.lang.Validate;
public class DamageInfo {
private final Set<DamageType> types;
private final double value;
public DamageInfo(DamageType... type) {
this(0, type);
}
public DamageInfo(double value, DamageType... types) {
Validate.notEmpty(types, "Damage must have at least one damage type!");
this.types = new HashSet<>(Arrays.asList(types));
this.value = value;
}
public DamageInfo merge(DamageInfo info) {
types.addAll(info.getTypes());
return this;
}
public Set<DamageType> getTypes() {
return types;
}
public boolean hasType(DamageType type) {
return types.contains(type);
}
public double getValue() {
return value;
}
public enum DamageType {
/*
* skills or abilities dealing magic damage
*/
MAGICAL,
/*
* skills or abilities dealing physical damage
*/
PHYSICAL,
/*
* weapons dealing damage
*/
WEAPON,
/*
* skill damage
*/
SKILL,
/*
* projectile based weapons or skills
*/
PROJECTILE;
}
}

View File

@ -18,9 +18,9 @@ import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.DamageInfo.DamageType;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.listener.ElementListener;
import net.Indyuce.mmoitems.manager.DamageManager.DamageType;
import net.Indyuce.mmoitems.version.VersionMaterial;
import net.Indyuce.mmoitems.version.VersionSound;

View File

@ -12,10 +12,10 @@ import org.bukkit.potion.PotionEffectType;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.DamageInfo.DamageType;
import net.Indyuce.mmoitems.api.interaction.weapon.Weapon;
import net.Indyuce.mmoitems.api.player.PlayerData.CooldownType;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.manager.DamageManager.DamageType;
import net.Indyuce.mmoitems.stat.type.ItemStat;
import net.Indyuce.mmoitems.version.VersionSound;

View File

@ -14,12 +14,12 @@ import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.AttackResult;
import net.Indyuce.mmoitems.api.DamageInfo.DamageType;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.item.NBTItem;
import net.Indyuce.mmoitems.api.player.PlayerData.CooldownType;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.api.util.SoundReader;
import net.Indyuce.mmoitems.manager.DamageManager.DamageType;
import net.Indyuce.mmoitems.stat.Lute_Attack_Effect.LuteAttackEffect;
import net.Indyuce.mmoitems.stat.type.ItemStat;
import net.Indyuce.mmoitems.version.VersionSound;
@ -69,7 +69,7 @@ public class Lute extends UntargetedWeapon {
for (Entity target : entities)
if (MMOUtils.canDamage(getPlayer(), loc, target)) {
new AttackResult(untargeted, attackDamage).applyEffectsAndDamage(stats, getNBTItem(), (LivingEntity) target, DamageType.PROJECTILE);
new AttackResult(untargeted, attackDamage).applyEffectsAndDamage(stats, getNBTItem(), (LivingEntity) target, DamageType.WEAPON, DamageType.PROJECTILE);
cancel();
return;
}

View File

@ -8,12 +8,12 @@ import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.AttackResult;
import net.Indyuce.mmoitems.api.DamageInfo.DamageType;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.item.NBTItem;
import net.Indyuce.mmoitems.api.player.PlayerData.CooldownType;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.api.util.MMORayTraceResult;
import net.Indyuce.mmoitems.manager.DamageManager.DamageType;
import net.Indyuce.mmoitems.stat.type.ItemStat;
public class Musket extends UntargetedWeapon {
@ -46,7 +46,7 @@ public class Musket extends UntargetedWeapon {
MMORayTraceResult trace = MMOItems.plugin.getVersion().getVersionWrapper().rayTrace(stats.getPlayer(), vec, range);
if (trace.hasHit())
new AttackResult(untargeted, attackDamage).applyEffectsAndDamage(stats, getNBTItem(), trace.getHit(), DamageType.PROJECTILE);
new AttackResult(untargeted, attackDamage).applyEffectsAndDamage(stats, getNBTItem(), trace.getHit(), DamageType.WEAPON, DamageType.PROJECTILE);
trace.draw(loc, vec, 2, Color.BLACK);
getPlayer().getWorld().playSound(getPlayer().getLocation(), Sound.ENTITY_ZOMBIE_ATTACK_IRON_DOOR, 2, 2);
}

View File

@ -10,12 +10,12 @@ import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.AttackResult;
import net.Indyuce.mmoitems.api.DamageInfo.DamageType;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.item.NBTItem;
import net.Indyuce.mmoitems.api.player.PlayerData.CooldownType;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.api.util.MMORayTraceResult;
import net.Indyuce.mmoitems.manager.DamageManager.DamageType;
import net.Indyuce.mmoitems.stat.Staff_Spirit.StaffSpirit;
import net.Indyuce.mmoitems.stat.type.ItemStat;
import net.Indyuce.mmoitems.version.VersionSound;
@ -46,7 +46,7 @@ public class Staff extends UntargetedWeapon {
MMORayTraceResult trace = MMOItems.plugin.getVersion().getVersionWrapper().rayTrace(stats.getPlayer(), range);
if (trace.hasHit())
new AttackResult(untargeted, attackDamage).applyEffectsAndDamage(stats, getNBTItem(), trace.getHit(), DamageType.PROJECTILE);
new AttackResult(untargeted, attackDamage).applyEffectsAndDamage(stats, getNBTItem(), trace.getHit(), DamageType.WEAPON, DamageType.PROJECTILE);
trace.draw(loc, getPlayer().getEyeLocation().getDirection(), 2, (tick) -> tick.getWorld().spawnParticle(Particle.EXPLOSION_NORMAL, tick, 0, .1, .1, .1, 0));
getPlayer().getWorld().playSound(getPlayer().getLocation(), VersionSound.ENTITY_FIREWORK_ROCKET_TWINKLE.toSound(), 2, 2);
}

View File

@ -7,12 +7,12 @@ import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.AttackResult;
import net.Indyuce.mmoitems.api.DamageInfo.DamageType;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.item.NBTItem;
import net.Indyuce.mmoitems.api.player.PlayerData.CooldownType;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.api.util.MMORayTraceResult;
import net.Indyuce.mmoitems.manager.DamageManager.DamageType;
import net.Indyuce.mmoitems.stat.type.ItemStat;
import net.Indyuce.mmoitems.version.VersionSound;
@ -36,7 +36,7 @@ public class Whip extends UntargetedWeapon {
MMORayTraceResult trace = MMOItems.plugin.getVersion().getVersionWrapper().rayTrace(stats.getPlayer(), range);
if (trace.hasHit())
new AttackResult(untargeted, attackDamage).applyEffectsAndDamage(stats, getNBTItem(), trace.getHit(), DamageType.PROJECTILE);
new AttackResult(untargeted, attackDamage).applyEffectsAndDamage(stats, getNBTItem(), trace.getHit(), DamageType.WEAPON, DamageType.PROJECTILE);
trace.draw(loc, getPlayer().getEyeLocation().getDirection(), 2, (tick) -> tick.getWorld().spawnParticle(Particle.CRIT, tick, 0, .1, .1, .1, 0));
getPlayer().getWorld().playSound(getPlayer().getLocation(), VersionSound.ENTITY_FIREWORK_ROCKET_BLAST.toSound(), 1, 2);
}

View File

@ -13,10 +13,10 @@ import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.AttackResult;
import net.Indyuce.mmoitems.api.DamageInfo.DamageType;
import net.Indyuce.mmoitems.api.interaction.weapon.untargeted.UntargetedWeapon;
import net.Indyuce.mmoitems.api.item.NBTItem;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.manager.DamageManager.DamageType;
public class BruteLuteAttack implements LuteAttackHandler {
@ -44,7 +44,7 @@ public class BruteLuteAttack implements LuteAttackHandler {
for (Entity target : entities)
if (MMOUtils.canDamage(stats.getPlayer(), loc, target)) {
new AttackResult(untargeted, attackDamage).applyEffectsAndDamage(stats, nbt, (LivingEntity) target, DamageType.PROJECTILE);
new AttackResult(untargeted, attackDamage).applyEffectsAndDamage(stats, nbt, (LivingEntity) target, DamageType.WEAPON, DamageType.PROJECTILE);
cancel();
return;
}

View File

@ -13,10 +13,10 @@ import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.AttackResult;
import net.Indyuce.mmoitems.api.DamageInfo.DamageType;
import net.Indyuce.mmoitems.api.interaction.weapon.untargeted.UntargetedWeapon;
import net.Indyuce.mmoitems.api.item.NBTItem;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.manager.DamageManager.DamageType;
public class CircularLuteAttack implements LuteAttackHandler {
@ -47,7 +47,7 @@ public class CircularLuteAttack implements LuteAttackHandler {
for (Entity target : entities)
if (MMOUtils.canDamage(stats.getPlayer(), loc, target)) {
new AttackResult(untargeted, attackDamage).applyEffectsAndDamage(stats, nbt, (LivingEntity) target, DamageType.PROJECTILE);
new AttackResult(untargeted, attackDamage).applyEffectsAndDamage(stats, nbt, (LivingEntity) target, DamageType.WEAPON, DamageType.PROJECTILE);
cancel();
return;
}

View File

@ -13,10 +13,10 @@ import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.AttackResult;
import net.Indyuce.mmoitems.api.DamageInfo.DamageType;
import net.Indyuce.mmoitems.api.interaction.weapon.untargeted.UntargetedWeapon;
import net.Indyuce.mmoitems.api.item.NBTItem;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.manager.DamageManager.DamageType;
public class SimpleLuteAttack implements LuteAttackHandler {
@ -44,7 +44,7 @@ public class SimpleLuteAttack implements LuteAttackHandler {
for (Entity target : entities)
if (MMOUtils.canDamage(stats.getPlayer(), loc, target)) {
new AttackResult(untargeted, attackDamage).applyEffectsAndDamage(stats, nbt, (LivingEntity) target, DamageType.PROJECTILE);
new AttackResult(untargeted, attackDamage).applyEffectsAndDamage(stats, nbt, (LivingEntity) target, DamageType.WEAPON, DamageType.PROJECTILE);
cancel();
return;
}

View File

@ -11,10 +11,10 @@ import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.AttackResult;
import net.Indyuce.mmoitems.api.DamageInfo.DamageType;
import net.Indyuce.mmoitems.api.interaction.weapon.untargeted.UntargetedWeapon;
import net.Indyuce.mmoitems.api.item.NBTItem;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.manager.DamageManager.DamageType;
public class SlashLuteAttack implements LuteAttackHandler {
@ -42,6 +42,6 @@ public class SlashLuteAttack implements LuteAttackHandler {
for (Entity entity : MMOUtils.getNearbyChunkEntities(stats.getPlayer().getLocation()))
if (entity.getLocation().distanceSquared(stats.getPlayer().getLocation()) < 40 && stats.getPlayer().getEyeLocation().getDirection().angle(entity.getLocation().toVector().subtract(stats.getPlayer().getLocation().toVector())) < Math.PI / 6 && MMOUtils.canDamage(stats.getPlayer(), entity))
new AttackResult(untargeted, attackDamage).applyEffectsAndDamage(stats, nbt, (LivingEntity) entity, DamageType.PROJECTILE);
new AttackResult(untargeted, attackDamage).applyEffectsAndDamage(stats, nbt, (LivingEntity) entity, DamageType.WEAPON, DamageType.PROJECTILE);
}
}

View File

@ -13,10 +13,10 @@ import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.AttackResult;
import net.Indyuce.mmoitems.api.DamageInfo.DamageType;
import net.Indyuce.mmoitems.api.interaction.weapon.untargeted.UntargetedWeapon;
import net.Indyuce.mmoitems.api.item.NBTItem;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.manager.DamageManager.DamageType;
public class WaveLuteAttack implements LuteAttackHandler {
@ -46,7 +46,7 @@ public class WaveLuteAttack implements LuteAttackHandler {
for (Entity target : entities)
if (MMOUtils.canDamage(stats.getPlayer(), loc, target)) {
new AttackResult(untargeted, attackDamage).applyEffectsAndDamage(stats, nbt, (LivingEntity) target, DamageType.PROJECTILE);
new AttackResult(untargeted, attackDamage).applyEffectsAndDamage(stats, nbt, (LivingEntity) target, DamageType.WEAPON, DamageType.PROJECTILE);
cancel();
return;
}

View File

@ -8,10 +8,10 @@ import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.AttackResult;
import net.Indyuce.mmoitems.api.DamageInfo.DamageType;
import net.Indyuce.mmoitems.api.interaction.weapon.untargeted.UntargetedWeapon;
import net.Indyuce.mmoitems.api.item.NBTItem;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.manager.DamageManager.DamageType;
import net.Indyuce.mmoitems.version.VersionSound;
public class LightningSpirit implements StaffAttackHandler {
@ -29,7 +29,7 @@ public class LightningSpirit implements StaffAttackHandler {
loc.getWorld().spawnParticle(Particle.FIREWORKS_SPARK, loc, 0);
for (Entity target : MMOUtils.getNearbyChunkEntities(loc))
if (MMOUtils.canDamage(stats.getPlayer(), loc, target)) {
new AttackResult(untargeted, attackDamage).applyEffectsAndDamage(stats, nbt, (LivingEntity) target, DamageType.PROJECTILE);
new AttackResult(untargeted, attackDamage).applyEffectsAndDamage(stats, nbt, (LivingEntity) target, DamageType.WEAPON, DamageType.PROJECTILE);
loc.getWorld().spawnParticle(Particle.EXPLOSION_NORMAL, loc, 16, 0, 0, 0, .1);
return;
}

View File

@ -14,10 +14,10 @@ import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.AttackResult;
import net.Indyuce.mmoitems.api.DamageInfo.DamageType;
import net.Indyuce.mmoitems.api.interaction.weapon.untargeted.UntargetedWeapon;
import net.Indyuce.mmoitems.api.item.NBTItem;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.manager.DamageManager.DamageType;
public class ManaSpirit implements StaffAttackHandler {
@ -51,7 +51,7 @@ public class ManaSpirit implements StaffAttackHandler {
}
for (Entity target : targets)
if (MMOUtils.canDamage(stats.getPlayer(), loc, target)) {
new AttackResult(untargeted, attackDamage).applyEffectsAndDamage(stats, nbt, (LivingEntity) target, DamageType.PROJECTILE);
new AttackResult(untargeted, attackDamage).applyEffectsAndDamage(stats, nbt, (LivingEntity) target, DamageType.WEAPON, DamageType.PROJECTILE);
loc.getWorld().spawnParticle(Particle.EXPLOSION_LARGE, loc, 0);
cancel();
return;

View File

@ -13,10 +13,10 @@ import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.AttackResult;
import net.Indyuce.mmoitems.api.DamageInfo.DamageType;
import net.Indyuce.mmoitems.api.interaction.weapon.untargeted.UntargetedWeapon;
import net.Indyuce.mmoitems.api.item.NBTItem;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.manager.DamageManager.DamageType;
public class NetherSpirit implements StaffAttackHandler {
@ -43,7 +43,7 @@ public class NetherSpirit implements StaffAttackHandler {
loc.getWorld().spawnParticle(Particle.SMOKE_NORMAL, loc, 0);
for (Entity target : targets)
if (MMOUtils.canDamage(stats.getPlayer(), loc, target)) {
new AttackResult(untargeted, attackDamage).applyEffectsAndDamage(stats, nbt, (LivingEntity) target, DamageType.PROJECTILE);
new AttackResult(untargeted, attackDamage).applyEffectsAndDamage(stats, nbt, (LivingEntity) target, DamageType.WEAPON, DamageType.PROJECTILE);
loc.getWorld().spawnParticle(Particle.EXPLOSION_LARGE, loc, 0);
cancel();
return;

View File

@ -14,10 +14,10 @@ import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.AttackResult;
import net.Indyuce.mmoitems.api.DamageInfo.DamageType;
import net.Indyuce.mmoitems.api.interaction.weapon.untargeted.UntargetedWeapon;
import net.Indyuce.mmoitems.api.item.NBTItem;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.manager.DamageManager.DamageType;
import net.Indyuce.mmoitems.version.VersionSound;
public class SunfireSpirit implements StaffAttackHandler {
@ -45,7 +45,7 @@ public class SunfireSpirit implements StaffAttackHandler {
loc.getWorld().playSound(loc, VersionSound.ENTITY_FIREWORK_ROCKET_BLAST.toSound(), 2, 2);
for (Entity target : MMOUtils.getNearbyChunkEntities(loc))
if (MMOUtils.canDamage(stats.getPlayer(), target) && target.getLocation().distanceSquared(loc) <= 9)
new AttackResult(untargeted, attackDamage).applyEffectsAndDamage(stats, nbt, (LivingEntity) target, DamageType.PROJECTILE);
new AttackResult(untargeted, attackDamage).applyEffectsAndDamage(stats, nbt, (LivingEntity) target, DamageType.WEAPON, DamageType.PROJECTILE);
cancel();
break;
}

View File

@ -14,10 +14,10 @@ import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.AttackResult;
import net.Indyuce.mmoitems.api.DamageInfo.DamageType;
import net.Indyuce.mmoitems.api.interaction.weapon.untargeted.UntargetedWeapon;
import net.Indyuce.mmoitems.api.item.NBTItem;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.manager.DamageManager.DamageType;
import net.Indyuce.mmoitems.version.VersionSound;
public class ThunderSpirit implements StaffAttackHandler {
@ -43,7 +43,7 @@ public class ThunderSpirit implements StaffAttackHandler {
loc.getWorld().playSound(loc, VersionSound.ENTITY_FIREWORK_ROCKET_BLAST.toSound(), 2, 2);
for (Entity target : MMOUtils.getNearbyChunkEntities(loc))
if (MMOUtils.canDamage(stats.getPlayer(), target) && target.getLocation().distanceSquared(loc) <= 9)
new AttackResult(untargeted, attackDamage).applyEffectsAndDamage(stats, nbt, (LivingEntity) target, DamageType.PROJECTILE);
new AttackResult(untargeted, attackDamage).applyEffectsAndDamage(stats, nbt, (LivingEntity) target, DamageType.WEAPON, DamageType.PROJECTILE);
cancel();
}
}

View File

@ -7,11 +7,11 @@ import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.AttackResult;
import net.Indyuce.mmoitems.api.DamageInfo.DamageType;
import net.Indyuce.mmoitems.api.interaction.weapon.untargeted.UntargetedWeapon;
import net.Indyuce.mmoitems.api.item.NBTItem;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.api.util.MMORayTraceResult;
import net.Indyuce.mmoitems.manager.DamageManager.DamageType;
public class XRaySpirit implements StaffAttackHandler {
@ -24,7 +24,7 @@ public class XRaySpirit implements StaffAttackHandler {
MMORayTraceResult trace = MMOItems.plugin.getVersion().getVersionWrapper().rayTrace(stats.getPlayer(), range);
if (trace.hasHit())
new AttackResult(untargeted, attackDamage).applyEffectsAndDamage(stats, nbt, trace.getHit(), DamageType.PROJECTILE);
new AttackResult(untargeted, attackDamage).applyEffectsAndDamage(stats, nbt, trace.getHit(), DamageType.WEAPON, DamageType.PROJECTILE);
trace.draw(loc, stats.getPlayer().getEyeLocation().getDirection(), 2, Color.BLACK);
stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(), Sound.ENTITY_ZOMBIE_ATTACK_IRON_DOOR, 2, 2);
}

View File

@ -1,5 +1,7 @@
package net.Indyuce.mmoitems.comp.mmocore;
import java.util.stream.Collectors;
import org.bukkit.entity.Entity;
import net.Indyuce.mmocore.comp.rpg.damage.DamageHandler;
@ -11,8 +13,8 @@ public class MMOCoreDamageHandler implements DamageHandler {
@Override
public DamageInfo getDamage(Entity entity) {
net.Indyuce.mmoitems.manager.DamageManager.DamageInfo miInfo = MMOItems.plugin.getDamage().getDamage(entity);
return new DamageInfo(DamageType.valueOf(miInfo.getType().name()), miInfo.getValue());
net.Indyuce.mmoitems.api.DamageInfo mmoitemsInfo = MMOItems.plugin.getDamage().getDamage(entity);
return new DamageInfo(mmoitemsInfo.getValue(), mmoitemsInfo.getTypes().stream().map((type) -> DamageType.valueOf(type.name())).collect(Collectors.toSet()));
}
@Override

View File

@ -1,17 +1,22 @@
package net.Indyuce.mmoitems.comp.mmocore;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.event.PlayerLevelUpEvent;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.player.stats.StatType;
import net.Indyuce.mmocore.comp.rpg.damage.DamageInfo.DamageType;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.player.RPGPlayer;
import net.Indyuce.mmoitems.comp.rpg.RPGHandler;
import net.Indyuce.mmoitems.stat.type.DoubleStat;
import net.Indyuce.mmoitems.stat.type.ItemStat;
public class MMOCoreHook implements RPGHandler, Listener {
@ -27,6 +32,11 @@ public class MMOCoreHook implements RPGHandler, Listener {
* register custom damage
*/
MMOCore.plugin.damage.registerHandler(new MMOCoreDamageHandler());
MMOItems.plugin.getStats().register(StatType.COOLDOWN_REDUCTION.name(), new DoubleStat(new ItemStack(Material.BOOK), "Skill Cooldown Reduction", new String[] { "(%) Reduces cooldowns of MMOCore skills." }, "skill-cooldown-reduction"));
MMOItems.plugin.getStats().register(StatType.ADDITIONAL_EXPERIENCE.name(), new DoubleStat(new ItemStack(Material.EXPERIENCE_BOTTLE), "Additional Experience", new String[] { "Additional % MMOCore main class experience." }, "additional-experience"));
for (DamageType type : DamageType.values())
MMOItems.plugin.getStats().register(type.name() + "_DAMAGE", new DoubleStat(new ItemStack(Material.GRAY_DYE), MMOUtils.caseOnWords(type.name().toLowerCase().replace("_", " ")) + " Damage (MMOCore)", new String[] { "Additional % MMOCore main class experience." }, "additional-experience"));
}
@Override

View File

@ -13,7 +13,6 @@ import com.sucy.skill.api.player.PlayerData;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.player.RPGPlayer;
import net.Indyuce.mmoitems.manager.DamageManager.DamageType;
import net.Indyuce.mmoitems.stat.type.ItemStat;
public class SkillAPIHook implements RPGHandler, Listener {
@ -29,12 +28,6 @@ public class SkillAPIHook implements RPGHandler, Listener {
@EventHandler
public void a(SkillDamageEvent event) {
/*
* registers the target as a custom damaged entity, this way MMOItems
* weapons effects do not apply when the entity is hit
*/
MMOItems.plugin.getDamage().setDamaged(event.getTarget(), event.getDamage(), DamageType.MAGIC);
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));

View File

@ -15,6 +15,8 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import net.Indyuce.mmoitems.api.DamageInfo;
import net.Indyuce.mmoitems.api.DamageInfo.DamageType;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.stat.type.ItemStat;
@ -25,24 +27,15 @@ public class DamageManager implements Listener {
return customDamage.containsKey(entity.getEntityId());
}
public void setDamaged(Entity entity, double value, DamageType type) {
if (!customDamage.containsKey(entity.getEntityId()))
customDamage.put(entity.getEntityId(), new DamageInfo(value, type));
}
public DamageInfo getDamage(Entity entity) {
return customDamage.get(entity.getEntityId());
}
public void removeDamaged(Entity entity) {
customDamage.remove(Integer.valueOf(entity.getEntityId()));
public void damage(TemporaryStats playerStats, LivingEntity target, double value, DamageType... types) {
damage(playerStats, target, value, true, types);
}
public void damage(TemporaryStats playerStats, LivingEntity target, double value, DamageType damageType) {
damage(playerStats, target, value, damageType, true);
}
public void damage(TemporaryStats playerStats, LivingEntity target, double value, DamageType damageType, boolean knockback) {
public void damage(TemporaryStats playerStats, LivingEntity target, double value, boolean knockback, DamageType... types) {
if (target.hasMetadata("NPC") || playerStats.getPlayer().hasMetadata("NPC"))
return;
@ -50,13 +43,16 @@ public class DamageManager implements Listener {
* calculate extra damage depending on the type of attack and the entity
* that is being damaged
*/
if (damageType.isSpell()) {
value *= 1 + (damageType == DamageType.MAGIC ? playerStats.getStat(ItemStat.MAGIC_DAMAGE) / 100 : 0);
value *= 1 + (isUndead(target) ? playerStats.getStat(ItemStat.UNDEAD_DAMAGE) / 100 : 0);
DamageInfo info = new DamageInfo(value, types);
if (info.hasType(DamageType.SKILL)) {
if (info.hasType(DamageType.MAGICAL))
value *= 1 + playerStats.getStat(ItemStat.MAGIC_DAMAGE) / 100;
if (isUndead(target))
value *= 1 + playerStats.getStat(ItemStat.UNDEAD_DAMAGE) / 100;
value *= 1 + (playerStats.getStat(target instanceof Player ? ItemStat.PVP_DAMAGE : ItemStat.PVE_DAMAGE) / 100);
}
setDamaged(target, value, damageType);
customDamage.put(target.getEntityId(), info);
if (!knockback) {
final double baseKnockbackValue = target.getAttribute(Attribute.GENERIC_KNOCKBACK_RESISTANCE).getBaseValue();
@ -77,45 +73,8 @@ public class DamageManager implements Listener {
return entity instanceof Zombie || entity instanceof Skeleton || entity instanceof Wither;
}
public enum DamageType {
// damage dealt by weapons & weapon passives
WEAPON,
// damage dealt by physical skills
PHYSICAL,
// damage dealt by magical abilities
MAGIC,
// damage dealt by projectile based weapons
PROJECTILE;
public boolean isSpell() {
return this == MAGIC || this == PHYSICAL;
}
}
public class DamageInfo {
private final double value;
private final DamageType type;
private DamageInfo(double value, DamageType type) {
this.value = value;
this.type = type;
}
public double getValue() {
return value;
}
public DamageType getType() {
return type;
}
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = false)
public void a(EntityDamageByEntityEvent event) {
removeDamaged(event.getEntity());
customDamage.remove(Integer.valueOf(event.getEntity().getEntityId()));
}
}