mirror of
https://gitlab.com/phoenix-dvpmt/mmoitems.git
synced 2024-12-22 04:37:42 +01:00
refactor attack result, new damage types
added projectile and physical damage to lore format and stat list
This commit is contained in:
parent
65edcfae44
commit
e9a2721368
@ -12,7 +12,7 @@ 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.AttackResult.DamageType;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
|
||||
@ -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.SKILL, DamageType.PROJECTILE, DamageType.MAGICAL);
|
||||
new AttackResult(damage, DamageType.SKILL, DamageType.MAGICAL, DamageType.PROJECTILE).applyEffectsAndDamage(stats, null, (LivingEntity) entity);
|
||||
((LivingEntity) entity).setFireTicks((int) (ignite * 20));
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ 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.AttackResult.DamageType;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
|
||||
@ -31,7 +31,7 @@ public class Burning_Hands extends Ability implements Listener {
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, AttackResult result) {
|
||||
double duration = data.getModifier("duration") * 10;
|
||||
double damage1 = data.getModifier("damage") / 2;
|
||||
double damage = data.getModifier("damage") / 2;
|
||||
|
||||
new BukkitRunnable() {
|
||||
int j = 0;
|
||||
@ -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.SKILL, DamageType.MAGICAL);
|
||||
new AttackResult(damage, DamageType.SKILL, DamageType.MAGICAL).applyEffectsAndDamage(stats, null, (LivingEntity) entity);
|
||||
|
||||
}
|
||||
}.runTaskTimer(MMOItems.plugin, 0, 2);
|
||||
|
@ -9,11 +9,10 @@ import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
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.AttackResult.DamageType;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
|
||||
@ -31,7 +30,7 @@ public class Circular_Slash extends Ability {
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, AttackResult result) {
|
||||
double damage1 = data.getModifier("damage");
|
||||
double damage = data.getModifier("damage");
|
||||
double radius = data.getModifier("radius");
|
||||
double knockback = data.getModifier("knockback");
|
||||
|
||||
@ -39,7 +38,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.SKILL, DamageType.PHYSICAL);
|
||||
new AttackResult(damage, DamageType.SKILL, DamageType.PHYSICAL).applyEffectsAndDamage(stats, null, (LivingEntity) entity);
|
||||
Vector v1 = entity.getLocation().toVector();
|
||||
Vector v2 = stats.getPlayer().getLocation().toVector();
|
||||
double y = .5;
|
||||
|
@ -11,7 +11,7 @@ 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.AttackResult.DamageType;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
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, false, DamageType.SKILL, DamageType.MAGICAL);
|
||||
MMOItems.plugin.getDamage().damage(stats.getPlayer(), (LivingEntity) entity, new AttackResult(dps, DamageType.SKILL, DamageType.MAGICAL).applySkillEffects(stats, (LivingEntity) entity), false);
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(MMOItems.plugin, 0, 1);
|
||||
|
@ -12,7 +12,7 @@ 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.AttackResult.DamageType;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.Indyuce.mmoitems.version.VersionSound;
|
||||
@ -37,7 +37,7 @@ public class Corrupt extends Ability {
|
||||
return;
|
||||
}
|
||||
|
||||
double damage1 = data.getModifier("damage");
|
||||
double damage = data.getModifier("damage");
|
||||
double duration = data.getModifier("duration");
|
||||
double amplifier = data.getModifier("amplifier");
|
||||
double radius = 2.7;
|
||||
@ -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.SKILL, DamageType.MAGICAL);
|
||||
new AttackResult(damage, DamageType.SKILL, DamageType.MAGICAL).applyEffectsAndDamage(stats, null, (LivingEntity) entity);
|
||||
((LivingEntity) entity).removePotionEffect(PotionEffectType.WITHER);
|
||||
((LivingEntity) entity).addPotionEffect(new PotionEffect(PotionEffectType.WITHER, (int) (duration * 20), (int) amplifier));
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ 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.AttackResult.DamageType;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
|
||||
@ -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.SKILL, DamageType.MAGICAL);
|
||||
new AttackResult((double) data[1], DamageType.SKILL, DamageType.MAGICAL).applyEffectsAndDamage(stats, null, (LivingEntity) event.getEntity());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ 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.AttackResult.DamageType;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.Indyuce.mmoitems.version.VersionSound;
|
||||
@ -64,10 +64,10 @@ public class Cursed_Beam extends Ability {
|
||||
double damage = data.getModifier("damage");
|
||||
loc.getWorld().playSound(loc, VersionSound.ENTITY_ENDERMAN_TELEPORT.toSound(), 2, .7f);
|
||||
|
||||
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.SKILL, DamageType.PROJECTILE, DamageType.MAGICAL);
|
||||
((LivingEntity) aoeTarget).addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, (int) (duration * 20), 0));
|
||||
for (Entity entity : entities)
|
||||
if (MMOUtils.canDamage(stats.getPlayer(), entity) && loc.distanceSquared(entity.getLocation().add(0, 1, 0)) < 9) {
|
||||
new AttackResult(damage, DamageType.SKILL, DamageType.MAGICAL, DamageType.PROJECTILE).applyEffectsAndDamage(stats, null, (LivingEntity) entity);
|
||||
((LivingEntity) entity).addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, (int) (duration * 20), 0));
|
||||
}
|
||||
cancel();
|
||||
return;
|
||||
|
@ -17,7 +17,7 @@ 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.AttackResult.DamageType;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
|
||||
@ -40,7 +40,7 @@ public class Earthquake extends Ability {
|
||||
return;
|
||||
}
|
||||
|
||||
double damage1 = data.getModifier("damage");
|
||||
double damage = data.getModifier("damage");
|
||||
double slowDuration = data.getModifier("duration");
|
||||
double slowAmplifier = data.getModifier("amplifier");
|
||||
|
||||
@ -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.SKILL, DamageType.MAGICAL);
|
||||
new AttackResult(damage, DamageType.SKILL, DamageType.MAGICAL).applyEffectsAndDamage(stats, null, (LivingEntity) entity);
|
||||
((LivingEntity) entity).addPotionEffect(new PotionEffect(PotionEffectType.SLOW, (int) (slowDuration * 20), (int) slowAmplifier));
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ 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.AttackResult.DamageType;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
|
||||
@ -31,7 +31,7 @@ public class Explosive_Turkey extends Ability {
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, AttackResult result) {
|
||||
double damage1 = data.getModifier("damage");
|
||||
double damage = data.getModifier("damage");
|
||||
double radiusSquared = Math.pow(data.getModifier("radius"), 2);
|
||||
double knockback = data.getModifier("knockback");
|
||||
|
||||
@ -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.SKILL, DamageType.PROJECTILE, DamageType.MAGICAL);
|
||||
new AttackResult(damage, DamageType.SKILL, DamageType.MAGICAL, DamageType.PROJECTILE).applyEffectsAndDamage(stats, null, (LivingEntity) entity);
|
||||
entity.setVelocity(entity.getLocation().toVector().subtract(chicken.getLocation().toVector()).multiply(.1 * knockback).setY(.4 * knockback));
|
||||
}
|
||||
cancel();
|
||||
|
@ -13,7 +13,7 @@ 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.AttackResult.DamageType;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.Indyuce.mmoitems.version.VersionSound;
|
||||
@ -52,12 +52,12 @@ public class Fire_Meteor extends Ability {
|
||||
loc.getWorld().spawnParticle(Particle.EXPLOSION_NORMAL, loc, 32, 0, 0, 0, .3);
|
||||
loc.getWorld().spawnParticle(Particle.FLAME, loc, 32, 0, 0, 0, .3);
|
||||
|
||||
double damage1 = data.getModifier("damage");
|
||||
double damage = data.getModifier("damage");
|
||||
double knockback = data.getModifier("knockback");
|
||||
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.SKILL, DamageType.PROJECTILE, DamageType.MAGICAL);
|
||||
new AttackResult(damage, DamageType.SKILL, DamageType.MAGICAL, DamageType.PROJECTILE).applyEffectsAndDamage(stats, null, (LivingEntity) entity);
|
||||
entity.setVelocity(entity.getLocation().toVector().subtract(loc.toVector()).multiply(.1 * knockback).setY(.4 * knockback));
|
||||
}
|
||||
cancel();
|
||||
|
@ -14,7 +14,7 @@ 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.AttackResult.DamageType;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
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.SKILL, DamageType.PROJECTILE, DamageType.MAGICAL);
|
||||
new AttackResult(data.getModifier("damage"), DamageType.SKILL, DamageType.MAGICAL, DamageType.PROJECTILE).applyEffectsAndDamage(stats, null, (LivingEntity) target);
|
||||
target.setFireTicks((int) data.getModifier("ignite") * 20);
|
||||
cancel();
|
||||
return;
|
||||
|
@ -13,7 +13,7 @@ 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.AttackResult.DamageType;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
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.SKILL, DamageType.MAGICAL);
|
||||
new AttackResult(damage, DamageType.SKILL, DamageType.MAGICAL).applyEffectsAndDamage(stats, null, (LivingEntity) entity);
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ 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.AttackResult.DamageType;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
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.SKILL, DamageType.MAGICAL);
|
||||
new AttackResult(damage, DamageType.SKILL, DamageType.MAGICAL).applyEffectsAndDamage(stats, null, (LivingEntity) entity);
|
||||
((LivingEntity) entity).removePotionEffect(PotionEffectType.SLOW);
|
||||
((LivingEntity) entity).addPotionEffect(new PotionEffect(PotionEffectType.SLOW, (int) (duration * 20), (int) amplifier));
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ 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.AttackResult.DamageType;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
|
||||
@ -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.SKILL, DamageType.PHYSICAL);
|
||||
new AttackResult(data.getModifier("damage"), DamageType.SKILL, DamageType.PHYSICAL).applyEffectsAndDamage(stats, null, (LivingEntity) target);
|
||||
cancel();
|
||||
break;
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ 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.AttackResult.DamageType;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
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.SKILL, DamageType.PROJECTILE, DamageType.MAGICAL);
|
||||
new AttackResult(data.getModifier("damage"), DamageType.SKILL, DamageType.MAGICAL, DamageType.PROJECTILE).applyEffectsAndDamage(stats, null, (LivingEntity) entity);
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ 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.AttackResult.DamageType;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
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.SKILL, DamageType.PROJECTILE, DamageType.MAGICAL);
|
||||
new AttackResult(data.getModifier("damage"), DamageType.SKILL, DamageType.MAGICAL, DamageType.PROJECTILE).applyEffectsAndDamage(stats, null, (LivingEntity) entity);
|
||||
((LivingEntity) entity).addPotionEffect(new PotionEffect(PotionEffectType.SLOW, (int) (data.getModifier("duration") * 20), (int) data.getModifier("amplifier")));
|
||||
cancel();
|
||||
return;
|
||||
|
@ -15,7 +15,7 @@ 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.AttackResult.DamageType;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.util.NoInteractItemEntity;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
@ -58,10 +58,9 @@ 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.SKILL, DamageType.PROJECTILE, DamageType.MAGICAL);
|
||||
living.removePotionEffect(PotionEffectType.SLOW);
|
||||
living.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, (int) (slowDuration * 20), (int) slowAmplifier));
|
||||
new AttackResult(damage, DamageType.SKILL, DamageType.PHYSICAL, DamageType.PROJECTILE).applyEffectsAndDamage(stats, null, (LivingEntity) entity);
|
||||
((LivingEntity) entity).removePotionEffect(PotionEffectType.SLOW);
|
||||
((LivingEntity) entity).addPotionEffect(new PotionEffect(PotionEffectType.SLOW, (int) (slowDuration * 20), (int) slowAmplifier));
|
||||
}
|
||||
|
||||
item.getEntity().getWorld().spawnParticle(Particle.EXPLOSION_LARGE, item.getEntity().getLocation(), 24, 2, 2, 2, 0);
|
||||
|
@ -13,7 +13,7 @@ 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.AttackResult.DamageType;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.util.NoInteractItemEntity;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
@ -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.SKILL, DamageType.PROJECTILE, DamageType.PHYSICAL);
|
||||
new AttackResult(data.getModifier("damage"), DamageType.SKILL, DamageType.PHYSICAL, DamageType.PROJECTILE).applyEffectsAndDamage(stats, null, (LivingEntity) target);
|
||||
item.close();
|
||||
cancel();
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ 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.AttackResult.DamageType;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
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.SKILL, DamageType.PROJECTILE, DamageType.MAGICAL);
|
||||
new AttackResult(damage, DamageType.SKILL, DamageType.MAGICAL).applyEffectsAndDamage(stats, null, (LivingEntity) entity);
|
||||
entity.setVelocity(entity.getLocation().subtract(source).toVector().setY(.75).normalize().multiply(knockback));
|
||||
}
|
||||
cancel();
|
||||
|
@ -13,7 +13,7 @@ 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.AttackResult.DamageType;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.Indyuce.mmoitems.version.VersionSound;
|
||||
@ -31,7 +31,7 @@ public class Light_Dash extends Ability {
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, AttackResult result) {
|
||||
double damage1 = data.getModifier("damage");
|
||||
double damage = data.getModifier("damage");
|
||||
double length = data.getModifier("length");
|
||||
|
||||
new BukkitRunnable() {
|
||||
@ -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.SKILL, DamageType.PHYSICAL);
|
||||
new AttackResult(damage, DamageType.SKILL, DamageType.PHYSICAL).applyEffectsAndDamage(stats, null, (LivingEntity) entity);
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(MMOItems.plugin, 0, 2);
|
||||
|
@ -6,11 +6,10 @@ import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
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.AttackResult.DamageType;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.Indyuce.mmoitems.version.VersionSound;
|
||||
@ -36,12 +35,12 @@ public class Lightning_Beam extends Ability {
|
||||
|
||||
loc = getFirstNonSolidBlock(loc);
|
||||
|
||||
double damage1 = data.getModifier("damage");
|
||||
double damage = data.getModifier("damage");
|
||||
double radius = data.getModifier("radius");
|
||||
|
||||
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.SKILL, DamageType.MAGICAL);
|
||||
new AttackResult(damage, DamageType.SKILL, DamageType.MAGICAL).applyEffectsAndDamage(stats, null, (LivingEntity) entity);
|
||||
|
||||
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);
|
||||
|
@ -10,7 +10,7 @@ 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.AttackResult.DamageType;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
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.SKILL, DamageType.PROJECTILE, DamageType.MAGICAL);
|
||||
new AttackResult(data.getModifier("damage"), DamageType.SKILL, DamageType.MAGICAL).applyEffectsAndDamage(stats, null, target);
|
||||
cancel();
|
||||
}
|
||||
}
|
||||
|
@ -8,11 +8,10 @@ import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
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.AttackResult.DamageType;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.Indyuce.mmoitems.version.VersionSound;
|
||||
@ -30,7 +29,7 @@ public class Overload extends Ability {
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, AttackResult result) {
|
||||
double damage1 = data.getModifier("damage");
|
||||
double damage = data.getModifier("damage");
|
||||
double radius = data.getModifier("radius");
|
||||
|
||||
stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 2, 0);
|
||||
@ -39,7 +38,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.SKILL, DamageType.MAGICAL);
|
||||
new AttackResult(damage, DamageType.SKILL, DamageType.MAGICAL).applyEffectsAndDamage(stats, null, (LivingEntity) entity);
|
||||
|
||||
double step = 12 + (radius * 2.5);
|
||||
for (double j = 0; j < Math.PI * 2; j += Math.PI / step) {
|
||||
|
@ -20,7 +20,7 @@ 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.AttackResult.DamageType;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.util.NoInteractItemEntity;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
@ -58,7 +58,7 @@ public class Present_Throw extends Ability {
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, AttackResult result) {
|
||||
double damage1 = data.getModifier("damage");
|
||||
double damage = data.getModifier("damage");
|
||||
double radiusSquared = Math.pow(data.getModifier("radius"), 2);
|
||||
|
||||
final NoInteractItemEntity item = new NoInteractItemEntity(stats.getPlayer().getLocation().add(0, 1.2, 0), present);
|
||||
@ -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.SKILL, DamageType.PROJECTILE, DamageType.MAGICAL);
|
||||
new AttackResult(damage, DamageType.SKILL, DamageType.MAGICAL, DamageType.PROJECTILE).applyEffectsAndDamage(stats, null, (LivingEntity) entity);
|
||||
item.close();
|
||||
cancel();
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ 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.AttackResult.DamageType;
|
||||
import net.Indyuce.mmoitems.api.item.NBTItem;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
@ -52,7 +53,7 @@ public class Shulker_Missile extends Ability implements Listener {
|
||||
stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(), Sound.ENTITY_WITHER_SHOOT, 2, 2);
|
||||
ShulkerBullet shulkerBullet = (ShulkerBullet) stats.getPlayer().getWorld().spawnEntity(stats.getPlayer().getLocation().add(0, 1, 0), EntityType.SHULKER_BULLET);
|
||||
shulkerBullet.setShooter(stats.getPlayer());
|
||||
MMOItems.plugin.getEntities().registerCustomEntity(shulkerBullet, data.getModifier("damage"), data.getModifier("effect-duration"));
|
||||
MMOItems.plugin.getEntities().registerCustomEntity(shulkerBullet, new AttackResult(data.getModifier("damage"), DamageType.SKILL, DamageType.MAGICAL, DamageType.PROJECTILE), data.getModifier("effect-duration"));
|
||||
new BukkitRunnable() {
|
||||
double ti = 0;
|
||||
|
||||
@ -82,12 +83,12 @@ public class Shulker_Missile extends Ability implements Listener {
|
||||
}
|
||||
|
||||
Object[] data = MMOItems.plugin.getEntities().getEntityData(damager);
|
||||
AttackResult result = new AttackResult(true, (double) data[0]);
|
||||
AttackResult result = (AttackResult) data[0];
|
||||
double duration = (double) data[1] * 20;
|
||||
|
||||
// void spirit
|
||||
if (data.length > 2)
|
||||
result.applyEffects((TemporaryStats) data[4], (NBTItem) data[3], entity);
|
||||
result.applyEffects((TemporaryStats) data[2], (NBTItem) data[3], entity);
|
||||
|
||||
event.setDamage(result.getDamage());
|
||||
|
||||
|
@ -8,11 +8,10 @@ import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
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.AttackResult.DamageType;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
|
||||
@ -29,7 +28,7 @@ public class Sky_Smash extends Ability {
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, AttackResult result) {
|
||||
double damage1 = data.getModifier("damage");
|
||||
double damage = data.getModifier("damage");
|
||||
double knockUp = data.getModifier("knock-up");
|
||||
|
||||
stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(), Sound.ENTITY_ZOMBIE_ATTACK_IRON_DOOR, 2, .5f);
|
||||
@ -40,7 +39,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.SKILL, DamageType.PHYSICAL);
|
||||
new AttackResult(damage, DamageType.SKILL, DamageType.PHYSICAL).applyEffectsAndDamage(stats, null, (LivingEntity) entity);
|
||||
Location loc1 = stats.getPlayer().getEyeLocation().clone();
|
||||
loc1.setPitch(-70);
|
||||
((LivingEntity) entity).setVelocity(loc1.getDirection().multiply(1.2 * knockUp));
|
||||
|
@ -5,7 +5,7 @@ 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.AttackResult.DamageType;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
|
||||
@ -27,7 +27,7 @@ public class Smite extends Ability {
|
||||
return;
|
||||
}
|
||||
|
||||
MMOItems.plugin.getDamage().damage(stats, target, data.getModifier("damage"), DamageType.SKILL, DamageType.MAGICAL);
|
||||
new AttackResult(data.getModifier("damage"), DamageType.SKILL, DamageType.MAGICAL).applyEffectsAndDamage(stats, null, target);
|
||||
target.getWorld().strikeLightningEffect(target.getLocation());
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ 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.AttackResult.DamageType;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.Indyuce.mmoitems.version.VersionSound;
|
||||
@ -30,34 +30,31 @@ public class Sparkle extends Ability {
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, AttackResult result) {
|
||||
target = target == null ? MMOItems.plugin.getVersion().getVersionWrapper().rayTrace(stats.getPlayer(), 50).getHit() : target;
|
||||
if (target == null){
|
||||
if (target == null) {
|
||||
result.setSuccessful(false);
|
||||
return;
|
||||
}
|
||||
|
||||
double damage1 = data.getModifier("damage");
|
||||
double damage = data.getModifier("damage");
|
||||
double radius = data.getModifier("radius");
|
||||
double limit = data.getModifier("limit");
|
||||
|
||||
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) target, damage1, DamageType.SKILL, DamageType.MAGICAL);
|
||||
new AttackResult(damage, DamageType.SKILL, DamageType.MAGICAL).applyEffectsAndDamage(stats, null, target);
|
||||
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;
|
||||
for (Entity ent : target.getNearbyEntities(radius, radius, radius)) {
|
||||
if (count >= limit)
|
||||
break;
|
||||
|
||||
if (ent instanceof LivingEntity && ent != stats.getPlayer() && !(ent instanceof ArmorStand)) {
|
||||
int count = 0;
|
||||
for (Entity entity : target.getNearbyEntities(radius, radius, radius))
|
||||
if (count < limit && entity instanceof LivingEntity && entity != stats.getPlayer() && !(entity instanceof ArmorStand)) {
|
||||
count++;
|
||||
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);
|
||||
new AttackResult(damage, DamageType.SKILL, DamageType.MAGICAL).applyEffectsAndDamage(stats, null, (LivingEntity) entity);
|
||||
entity.getWorld().playSound(entity.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);
|
||||
Location loc_ent = entity.getLocation().add(0, .75, 0);
|
||||
for (double j1 = 0; j1 < 1; j1 += .04) {
|
||||
Vector d = loc_ent.toVector().subtract(loc_t.toVector());
|
||||
target.getWorld().spawnParticle(Particle.FIREWORKS_SPARK, loc_t.clone().add(d.multiply(j1)), 3, .1, .1, .1, .008);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ 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.AttackResult.DamageType;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
|
||||
@ -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.SKILL, DamageType.PROJECTILE, DamageType.MAGICAL);
|
||||
new AttackResult(data.getModifier("damage"), DamageType.SKILL, DamageType.MAGICAL).applyEffectsAndDamage(stats, null, (LivingEntity) entity);
|
||||
entity.setVelocity(entity.getVelocity().add(offsetVector(knockup)));
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ 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.AttackResult.DamageType;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
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.SKILL, DamageType.PROJECTILE, DamageType.MAGICAL);
|
||||
new AttackResult(data.getModifier("damage"), DamageType.SKILL, DamageType.MAGICAL, DamageType.PROJECTILE).applyEffectsAndDamage(stats, null, target);
|
||||
cancel();
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ 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.AttackResult.DamageType;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.util.NoInteractItemEntity;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
@ -50,11 +50,9 @@ public class Throw_Up extends Ability implements Listener {
|
||||
loc.setYaw((float) (loc.getYaw() + (random.nextDouble() - .5) * 30));
|
||||
|
||||
if (j % 5 == 0)
|
||||
for (Entity ent : MMOUtils.getNearbyChunkEntities(loc))
|
||||
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.SKILL, DamageType.MAGICAL);
|
||||
for (Entity entity : MMOUtils.getNearbyChunkEntities(loc))
|
||||
if (entity.getLocation().distanceSquared(loc) < 40 && stats.getPlayer().getEyeLocation().getDirection().angle(entity.getLocation().toVector().subtract(stats.getPlayer().getLocation().toVector())) < Math.PI / 6 && MMOUtils.canDamage(stats.getPlayer(), entity))
|
||||
new AttackResult(dps, DamageType.SKILL, DamageType.MAGICAL, DamageType.PROJECTILE).applyEffectsAndDamage(stats, null, (LivingEntity) entity);
|
||||
|
||||
loc.getWorld().playSound(loc, Sound.ENTITY_ZOMBIE_HURT, 1, 1);
|
||||
|
||||
|
@ -9,11 +9,10 @@ import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
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.AttackResult.DamageType;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
|
||||
@ -29,7 +28,7 @@ public class Thrust extends Ability {
|
||||
|
||||
@Override
|
||||
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, AttackResult result) {
|
||||
double damage1 = data.getModifier("damage");
|
||||
double damage = data.getModifier("damage");
|
||||
|
||||
stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(), Sound.ENTITY_ZOMBIE_ATTACK_IRON_DOOR, 1, 0);
|
||||
stats.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 2, 3));
|
||||
@ -40,7 +39,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.SKILL, DamageType.PHYSICAL);
|
||||
new AttackResult(damage, DamageType.SKILL, DamageType.PHYSICAL).applyEffectsAndDamage(stats, null, (LivingEntity) entity);
|
||||
loc.getWorld().spawnParticle(Particle.SMOKE_LARGE, loc, 0);
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ 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.AttackResult.DamageType;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.Indyuce.mmoitems.version.VersionSound;
|
||||
@ -36,7 +36,7 @@ public class Arcane_Hail extends Ability {
|
||||
return;
|
||||
}
|
||||
|
||||
double damage1 = data.getModifier("damage");
|
||||
double damage = data.getModifier("damage");
|
||||
double duration = data.getModifier("duration");
|
||||
double radius = data.getModifier("radius");
|
||||
|
||||
@ -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.SKILL, DamageType.MAGICAL);
|
||||
new AttackResult(damage, DamageType.SKILL, DamageType.MAGICAL).applyEffectsAndDamage(stats, null, target);
|
||||
loc1.getWorld().spawnParticle(Particle.SPELL_WITCH, loc1, 12, 0, 0, 0, .1);
|
||||
loc1.getWorld().spawnParticle(Particle.SMOKE_NORMAL, loc1, 6, 0, 0, 0, .1);
|
||||
|
||||
|
@ -16,7 +16,7 @@ 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.AttackResult.DamageType;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import net.Indyuce.mmoitems.version.VersionSound;
|
||||
@ -41,7 +41,7 @@ public class Arcane_Rift extends Ability {
|
||||
return;
|
||||
}
|
||||
|
||||
double damage1 = data.getModifier("damage");
|
||||
double damage = data.getModifier("damage");
|
||||
double slowDuration = data.getModifier("duration");
|
||||
double slowAmplifier = data.getModifier("amplifier");
|
||||
|
||||
@ -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.SKILL, DamageType.MAGICAL);
|
||||
new AttackResult(damage, DamageType.SKILL, DamageType.MAGICAL).applyEffectsAndDamage(stats, null, (LivingEntity) entity);
|
||||
((LivingEntity) entity).addPotionEffect(new PotionEffect(PotionEffectType.SLOW, (int) (slowDuration * 20), (int) slowAmplifier));
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ 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.AttackResult.DamageType;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
|
||||
@ -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, false, DamageType.SKILL, DamageType.MAGICAL);
|
||||
MMOItems.plugin.getDamage().damage(stats.getPlayer(), target, new AttackResult(dps, DamageType.SKILL, DamageType.MAGICAL).applySkillEffects(stats, target), false);
|
||||
}
|
||||
}.runTaskTimer(MMOItems.plugin, 0, 1);
|
||||
target.getWorld().playSound(target.getLocation(), Sound.ENTITY_BLAZE_HURT, 1, 2);
|
||||
|
@ -7,11 +7,10 @@ import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
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.AttackResult.DamageType;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
|
||||
@ -45,7 +44,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.SKILL, DamageType.MAGICAL);
|
||||
new AttackResult(damage, DamageType.SKILL, DamageType.MAGICAL).applyEffectsAndDamage(stats, null, (LivingEntity) entity);
|
||||
entity.setVelocity(normalizeIfNotNull(entity.getLocation().subtract(loc).toVector().setY(0)).setY(.2).multiply(2 * knockback));
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,11 @@
|
||||
package net.Indyuce.mmoitems.api;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@ -9,9 +13,6 @@ 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.stat.type.ItemStat;
|
||||
@ -20,31 +21,43 @@ public class AttackResult {
|
||||
private final double initial;
|
||||
|
||||
private double damage;
|
||||
private boolean successful, untargetedWeapon;
|
||||
private boolean successful;
|
||||
|
||||
private final List<DamageType> damageTypes;
|
||||
|
||||
private static final Random random = new Random();
|
||||
|
||||
public AttackResult(boolean successful) {
|
||||
this(successful, 0);
|
||||
public AttackResult(boolean successful, DamageType... types) {
|
||||
this(successful, 0, types);
|
||||
}
|
||||
|
||||
public AttackResult(Weapon weapon, double damage) {
|
||||
this(true, damage);
|
||||
|
||||
this.untargetedWeapon = weapon != null && weapon instanceof UntargetedWeapon;
|
||||
public AttackResult(double damage, DamageType... types) {
|
||||
this(true, damage, types);
|
||||
}
|
||||
|
||||
public AttackResult(boolean successful, double damage) {
|
||||
public AttackResult(boolean successful, double damage, DamageType... types) {
|
||||
Validate.isTrue(types.length > 0, "Attack must have at least one damage type!");
|
||||
|
||||
this.successful = successful;
|
||||
this.damage = damage;
|
||||
this.initial = damage;
|
||||
this.damage = damage;
|
||||
|
||||
this.damageTypes = Arrays.asList(types);
|
||||
}
|
||||
|
||||
public AttackResult(AttackResult result) {
|
||||
initial = result.initial;
|
||||
damage = result.damage;
|
||||
successful = result.successful;
|
||||
untargetedWeapon = result.untargetedWeapon;
|
||||
damageTypes = new ArrayList<>(result.damageTypes);
|
||||
}
|
||||
|
||||
public List<DamageType> getTypes() {
|
||||
return damageTypes;
|
||||
}
|
||||
|
||||
public boolean hasType(DamageType type) {
|
||||
return damageTypes.contains(type);
|
||||
}
|
||||
|
||||
public boolean isSuccessful() {
|
||||
@ -81,8 +94,38 @@ public class AttackResult {
|
||||
return new AttackResult(this);
|
||||
}
|
||||
|
||||
public void applyEffectsAndDamage(TemporaryStats stats, NBTItem item, LivingEntity target, DamageType... types) {
|
||||
MMOItems.plugin.getDamage().damage(stats, target, applyEffects(stats, item, target).damage, types);
|
||||
public void damage(TemporaryStats stats, LivingEntity target) {
|
||||
MMOItems.plugin.getDamage().damage(stats.getPlayer(), target, this);
|
||||
}
|
||||
|
||||
public void applyEffectsAndDamage(TemporaryStats stats, NBTItem item, LivingEntity target) {
|
||||
MMOItems.plugin.getDamage().damage(stats.getPlayer(), target, applyEffects(stats, item, target));
|
||||
}
|
||||
|
||||
/*
|
||||
* this methods makes applying ALL effects including elemental damage easier
|
||||
* for untargeted weapons like staffs.
|
||||
*/
|
||||
public AttackResult applyEffects(TemporaryStats stats, NBTItem item, LivingEntity target) {
|
||||
if (hasType(DamageType.WEAPON)) {
|
||||
applyElementalEffects(stats, item, target);
|
||||
applyOnHitEffects(stats, target);
|
||||
} else if (hasType(DamageType.SKILL))
|
||||
applySkillEffects(stats, target);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AttackResult applySkillEffects(TemporaryStats stats, LivingEntity target) {
|
||||
|
||||
for (DamageType type : DamageType.values())
|
||||
if (hasType(type))
|
||||
addRelativeDamage(stats.getStat(type.getStat()) / 100);
|
||||
|
||||
addRelativeDamage(stats.getStat(target instanceof Player ? ItemStat.PVP_DAMAGE : ItemStat.PVE_DAMAGE) / 100);
|
||||
if (MMOItems.plugin.getDamage().isUndead(target))
|
||||
addRelativeDamage(stats.getStat(ItemStat.UNDEAD_DAMAGE) / 100);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public AttackResult applyElementalEffects(TemporaryStats stats, NBTItem item, LivingEntity target) {
|
||||
@ -90,29 +133,21 @@ public class AttackResult {
|
||||
return this;
|
||||
}
|
||||
|
||||
/*
|
||||
* this methods makes applying ALL effects including elemental damage easier
|
||||
* for untargeted weapons like staffs.
|
||||
*/
|
||||
public AttackResult applyEffects(TemporaryStats stats, NBTItem item, LivingEntity target) {
|
||||
applyElementalEffects(stats, item, target);
|
||||
applyEffects(stats, target);
|
||||
return this;
|
||||
}
|
||||
|
||||
/*
|
||||
* vanilla melee weapons have no NBTTitems so this method only provides for
|
||||
* non-weapon specific effects like critical strikes and extra stat damage
|
||||
*/
|
||||
public AttackResult applyEffects(TemporaryStats stats, LivingEntity target) {
|
||||
public AttackResult applyOnHitEffects(TemporaryStats stats, LivingEntity target) {
|
||||
|
||||
// abilities only if the weapon attacking is an untargeted weapon
|
||||
if (untargetedWeapon)
|
||||
// abilities
|
||||
stats.getPlayerData().castAbilities(stats, target, this, CastingMode.ON_HIT);
|
||||
|
||||
// extra damage
|
||||
for (DamageType type : DamageType.values())
|
||||
if (hasType(type))
|
||||
addRelativeDamage(stats.getStat(type.getStat()) / 100);
|
||||
|
||||
addRelativeDamage(stats.getStat(target instanceof Player ? ItemStat.PVP_DAMAGE : ItemStat.PVE_DAMAGE) / 100);
|
||||
addRelativeDamage(stats.getStat(ItemStat.WEAPON_DAMAGE) / 100);
|
||||
if (MMOItems.plugin.getDamage().isUndead(target))
|
||||
addRelativeDamage(stats.getStat(ItemStat.UNDEAD_DAMAGE) / 100);
|
||||
|
||||
@ -125,4 +160,42 @@ public class AttackResult {
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public enum DamageType {
|
||||
|
||||
/*
|
||||
* skills or abilities dealing magic damage
|
||||
*/
|
||||
MAGICAL(ItemStat.MAGIC_DAMAGE),
|
||||
|
||||
/*
|
||||
* skills or abilities dealing physical damage
|
||||
*/
|
||||
PHYSICAL(ItemStat.PHYSICAL_DAMAGE),
|
||||
|
||||
/*
|
||||
* weapons dealing damage
|
||||
*/
|
||||
WEAPON(ItemStat.WEAPON_DAMAGE),
|
||||
|
||||
/*
|
||||
* skill damage
|
||||
*/
|
||||
SKILL(ItemStat.SKILL_DAMAGE),
|
||||
|
||||
/*
|
||||
* projectile based weapons or skills
|
||||
*/
|
||||
PROJECTILE(ItemStat.PROJECTILE_DAMAGE);
|
||||
|
||||
private final ItemStat stat;
|
||||
|
||||
private DamageType(ItemStat stat) {
|
||||
this.stat = stat;
|
||||
}
|
||||
|
||||
public ItemStat getStat() {
|
||||
return stat;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,68 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
@ -18,7 +18,7 @@ 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.AttackResult.DamageType;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.listener.ElementListener;
|
||||
import net.Indyuce.mmoitems.version.VersionMaterial;
|
||||
@ -89,7 +89,7 @@ public enum Element {
|
||||
target.getWorld().playSound(target.getLocation(), VersionSound.ENTITY_FIREWORK_ROCKET_LARGE_BLAST.toSound(), 2, 0);
|
||||
for (Entity entity : target.getNearbyEntities(3, 2, 3))
|
||||
if (MMOUtils.canDamage(stats.getPlayer(), entity))
|
||||
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) entity, result.getDamage() * attack / 100, DamageType.WEAPON);
|
||||
new AttackResult(result.getDamage() * attack / 100, DamageType.WEAPON).damage(stats, (LivingEntity) entity);
|
||||
|
||||
result.addDamage(absolute);
|
||||
for (double k = 0; k < Math.PI * 2; k += Math.PI / 16)
|
||||
|
@ -12,7 +12,6 @@ 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;
|
||||
@ -39,7 +38,7 @@ public enum TypeSet {
|
||||
|
||||
for (Entity entity : MMOUtils.getNearbyChunkEntities(loc))
|
||||
if (entity.getLocation().distanceSquared(loc) < 40 && stats.getPlayer().getEyeLocation().getDirection().angle(entity.getLocation().subtract(stats.getPlayer().getLocation()).toVector()) < Math.PI / 3 && MMOUtils.canDamage(stats.getPlayer(), entity) && !entity.equals(target))
|
||||
result.clone().multiplyDamage(.4).applyEffectsAndDamage(stats, weapon.getNBTItem(), (LivingEntity) entity, DamageType.WEAPON);
|
||||
result.clone().multiplyDamage(.4).applyEffectsAndDamage(stats, weapon.getNBTItem(), (LivingEntity) entity);
|
||||
}),
|
||||
|
||||
/*
|
||||
@ -62,7 +61,7 @@ public enum TypeSet {
|
||||
|
||||
for (Entity entity : MMOUtils.getNearbyChunkEntities(loc))
|
||||
if (entity.getLocation().distanceSquared(stats.getPlayer().getLocation()) < 40 && stats.getPlayer().getEyeLocation().getDirection().angle(entity.getLocation().toVector().subtract(stats.getPlayer().getLocation().toVector())) < Math.PI / 18 && MMOUtils.canDamage(stats.getPlayer(), entity) && !entity.equals(target))
|
||||
result.clone().multiplyDamage(.4).applyEffectsAndDamage(stats, weapon.getNBTItem(), (LivingEntity) entity, DamageType.WEAPON);
|
||||
result.clone().multiplyDamage(.4).applyEffectsAndDamage(stats, weapon.getNBTItem(), (LivingEntity) entity);
|
||||
}),
|
||||
|
||||
/*
|
||||
@ -81,7 +80,7 @@ public enum TypeSet {
|
||||
double bluntRating = weapon.getValue(stats.getStat(ItemStat.BLUNT_RATING), MMOItems.plugin.getConfig().getDouble("default.blunt-rating")) / 100;
|
||||
for (Entity entity : target.getNearbyEntities(bluntPower, bluntPower, bluntPower))
|
||||
if (MMOUtils.canDamage(stats.getPlayer(), entity) && !entity.equals(target))
|
||||
result.clone().multiplyDamage(bluntRating).applyEffectsAndDamage(stats, weapon.getNBTItem(), (LivingEntity) entity, DamageType.WEAPON);
|
||||
result.clone().multiplyDamage(bluntRating).applyEffectsAndDamage(stats, weapon.getNBTItem(), (LivingEntity) entity);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@ 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.AttackResult.DamageType;
|
||||
import net.Indyuce.mmoitems.api.Type;
|
||||
import net.Indyuce.mmoitems.api.item.NBTItem;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerData.CooldownType;
|
||||
@ -44,7 +44,7 @@ public class Lute extends UntargetedWeapon {
|
||||
LuteAttackEffect effect = LuteAttackEffect.get(getNBTItem());
|
||||
Sound sound = new SoundReader(getNBTItem().getString("MMOITEMS_LUTE_ATTACK_SOUND"), VersionSound.BLOCK_NOTE_BLOCK_BELL.toSound()).getSound();
|
||||
if (effect != null) {
|
||||
effect.getAttack().handle( stats, getNBTItem(), attackDamage, range, untargeted, weight, sound);
|
||||
effect.getAttack().handle(stats, getNBTItem(), attackDamage, range, weight, sound);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -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.WEAPON, DamageType.PROJECTILE);
|
||||
new AttackResult(attackDamage, DamageType.WEAPON, DamageType.PROJECTILE, DamageType.PHYSICAL).applyEffectsAndDamage(stats, getNBTItem(), (LivingEntity) target);
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ 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.AttackResult.DamageType;
|
||||
import net.Indyuce.mmoitems.api.Type;
|
||||
import net.Indyuce.mmoitems.api.item.NBTItem;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerData.CooldownType;
|
||||
@ -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.WEAPON, DamageType.PROJECTILE);
|
||||
new AttackResult(attackDamage, DamageType.WEAPON, DamageType.PROJECTILE, DamageType.PHYSICAL).applyEffectsAndDamage(stats, getNBTItem(), trace.getHit());
|
||||
trace.draw(loc, vec, 2, Color.BLACK);
|
||||
getPlayer().getWorld().playSound(getPlayer().getLocation(), Sound.ENTITY_ZOMBIE_ATTACK_IRON_DOOR, 2, 2);
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ 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.AttackResult.DamageType;
|
||||
import net.Indyuce.mmoitems.api.Type;
|
||||
import net.Indyuce.mmoitems.api.item.NBTItem;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerData.CooldownType;
|
||||
@ -37,7 +37,7 @@ public class Staff extends UntargetedWeapon {
|
||||
|
||||
StaffSpirit spirit = StaffSpirit.get(getNBTItem());
|
||||
if (spirit != null) {
|
||||
spirit.getAttack().handle(stats, getNBTItem(), attackDamage, range, untargeted);
|
||||
spirit.getAttack().handle(stats, getNBTItem(), attackDamage, range);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -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.WEAPON, DamageType.PROJECTILE);
|
||||
new AttackResult(attackDamage, DamageType.WEAPON, DamageType.PROJECTILE, DamageType.PHYSICAL).applyEffectsAndDamage(stats, getNBTItem(), trace.getHit());
|
||||
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);
|
||||
}
|
||||
|
@ -12,11 +12,6 @@ import net.Indyuce.mmoitems.api.item.NBTItem;
|
||||
|
||||
public abstract class UntargetedWeapon extends Weapon {
|
||||
|
||||
/*
|
||||
* this final field is used in the AttackResult constructor to be able to
|
||||
* cast on-hit abilities since the weapon is untargeted.
|
||||
*/
|
||||
protected final UntargetedWeapon untargeted = this;
|
||||
protected final WeaponType weaponType;
|
||||
|
||||
public UntargetedWeapon(Player player, NBTItem item, Type type, WeaponType weaponType) {
|
||||
|
@ -7,7 +7,7 @@ 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.AttackResult.DamageType;
|
||||
import net.Indyuce.mmoitems.api.Type;
|
||||
import net.Indyuce.mmoitems.api.item.NBTItem;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerData.CooldownType;
|
||||
@ -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.WEAPON, DamageType.PROJECTILE);
|
||||
new AttackResult(attackDamage, DamageType.WEAPON, DamageType.PROJECTILE, DamageType.PHYSICAL).applyEffectsAndDamage(stats, getNBTItem(), trace.getHit());
|
||||
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);
|
||||
}
|
||||
|
@ -13,15 +13,14 @@ 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.AttackResult.DamageType;
|
||||
import net.Indyuce.mmoitems.api.item.NBTItem;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
|
||||
public class BruteLuteAttack implements LuteAttackHandler {
|
||||
|
||||
@Override
|
||||
public void handle(TemporaryStats stats, NBTItem nbt, double attackDamage, double range, UntargetedWeapon untargeted, Vector weight, Sound sound) {
|
||||
public void handle(TemporaryStats stats, NBTItem nbt, double attackDamage, double range, Vector weight, Sound sound) {
|
||||
new BukkitRunnable() {
|
||||
Vector vec = stats.getPlayer().getEyeLocation().getDirection().multiply(.4);
|
||||
Location loc = stats.getPlayer().getEyeLocation();
|
||||
@ -44,7 +43,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.WEAPON, DamageType.PROJECTILE);
|
||||
new AttackResult(attackDamage, DamageType.WEAPON, DamageType.PROJECTILE).applyEffectsAndDamage(stats, nbt, (LivingEntity) target);
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
|
@ -13,15 +13,14 @@ 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.AttackResult.DamageType;
|
||||
import net.Indyuce.mmoitems.api.item.NBTItem;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
|
||||
public class CircularLuteAttack implements LuteAttackHandler {
|
||||
|
||||
@Override
|
||||
public void handle(TemporaryStats stats, NBTItem nbt, double attackDamage, double range, UntargetedWeapon untargeted, Vector weight, Sound sound) {
|
||||
public void handle(TemporaryStats stats, NBTItem nbt, double attackDamage, double range, Vector weight, Sound sound) {
|
||||
new BukkitRunnable() {
|
||||
Vector vec = stats.getPlayer().getEyeLocation().getDirection().multiply(.4);
|
||||
Location loc = stats.getPlayer().getEyeLocation();
|
||||
@ -47,7 +46,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.WEAPON, DamageType.PROJECTILE);
|
||||
new AttackResult(attackDamage, DamageType.WEAPON, DamageType.PROJECTILE).applyEffectsAndDamage(stats, nbt, (LivingEntity) target);
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
|
@ -5,12 +5,11 @@ import java.util.Random;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.Indyuce.mmoitems.api.interaction.weapon.untargeted.UntargetedWeapon;
|
||||
import net.Indyuce.mmoitems.api.item.NBTItem;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
|
||||
public interface LuteAttackHandler {
|
||||
public void handle(TemporaryStats stats, NBTItem nbt, double attackDamage, double range, UntargetedWeapon untargeted, Vector weight, Sound sound);
|
||||
public void handle(TemporaryStats stats, NBTItem nbt, double attackDamage, double range, Vector weight, Sound sound);
|
||||
|
||||
static final Random random = new Random();
|
||||
}
|
||||
|
@ -13,15 +13,14 @@ 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.AttackResult.DamageType;
|
||||
import net.Indyuce.mmoitems.api.item.NBTItem;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
|
||||
public class SimpleLuteAttack implements LuteAttackHandler {
|
||||
|
||||
@Override
|
||||
public void handle(TemporaryStats stats, NBTItem nbt, double attackDamage, double range, UntargetedWeapon untargeted, Vector weight, Sound sound) {
|
||||
public void handle(TemporaryStats stats, NBTItem nbt, double attackDamage, double range, Vector weight, Sound sound) {
|
||||
new BukkitRunnable() {
|
||||
Vector vec = stats.getPlayer().getEyeLocation().getDirection().multiply(.4);
|
||||
Location loc = stats.getPlayer().getEyeLocation();
|
||||
@ -44,7 +43,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.WEAPON, DamageType.PROJECTILE);
|
||||
new AttackResult(attackDamage, DamageType.WEAPON, DamageType.PROJECTILE).applyEffectsAndDamage(stats, nbt, (LivingEntity) target);
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
|
@ -11,15 +11,14 @@ 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.AttackResult.DamageType;
|
||||
import net.Indyuce.mmoitems.api.item.NBTItem;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
|
||||
public class SlashLuteAttack implements LuteAttackHandler {
|
||||
|
||||
@Override
|
||||
public void handle(TemporaryStats stats, NBTItem nbt, double attackDamage, double range, UntargetedWeapon untargeted, Vector weight, Sound sound) {
|
||||
public void handle(TemporaryStats stats, NBTItem nbt, double attackDamage, double range, Vector weight, Sound sound) {
|
||||
new BukkitRunnable() {
|
||||
final Vector vec = stats.getPlayer().getEyeLocation().getDirection();
|
||||
Location loc = stats.getPlayer().getLocation().add(0, 1.3, 0);
|
||||
@ -42,6 +41,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.WEAPON, DamageType.PROJECTILE);
|
||||
new AttackResult(attackDamage, DamageType.WEAPON, DamageType.PROJECTILE).applyEffectsAndDamage(stats, nbt, (LivingEntity) entity);
|
||||
}
|
||||
}
|
||||
|
@ -13,15 +13,14 @@ 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.AttackResult.DamageType;
|
||||
import net.Indyuce.mmoitems.api.item.NBTItem;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
|
||||
public class WaveLuteAttack implements LuteAttackHandler {
|
||||
|
||||
@Override
|
||||
public void handle(TemporaryStats stats, NBTItem nbt, double attackDamage, double range, UntargetedWeapon untargeted, Vector weight, Sound sound) {
|
||||
public void handle(TemporaryStats stats, NBTItem nbt, double attackDamage, double range, Vector weight, Sound sound) {
|
||||
new BukkitRunnable() {
|
||||
Vector vec = stats.getPlayer().getEyeLocation().getDirection().multiply(.4);
|
||||
Location loc = stats.getPlayer().getEyeLocation();
|
||||
@ -46,7 +45,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.WEAPON, DamageType.PROJECTILE);
|
||||
new AttackResult(attackDamage, DamageType.WEAPON, DamageType.PROJECTILE).applyEffectsAndDamage(stats, nbt, (LivingEntity) target);
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
|
@ -8,8 +8,7 @@ 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.AttackResult.DamageType;
|
||||
import net.Indyuce.mmoitems.api.item.NBTItem;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.version.VersionSound;
|
||||
@ -17,7 +16,7 @@ import net.Indyuce.mmoitems.version.VersionSound;
|
||||
public class LightningSpirit implements StaffAttackHandler {
|
||||
|
||||
@Override
|
||||
public void handle(TemporaryStats stats, NBTItem nbt, double attackDamage, double range, UntargetedWeapon untargeted) {
|
||||
public void handle(TemporaryStats stats, NBTItem nbt, double attackDamage, double range) {
|
||||
stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(), VersionSound.ENTITY_FIREWORK_ROCKET_BLAST.toSound(), 2, 2);
|
||||
Location loc = stats.getPlayer().getEyeLocation();
|
||||
Vector vec = stats.getPlayer().getEyeLocation().getDirection().multiply(.75);
|
||||
@ -29,7 +28,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.WEAPON, DamageType.PROJECTILE);
|
||||
new AttackResult(attackDamage, DamageType.WEAPON, DamageType.PROJECTILE, DamageType.PHYSICAL).applyEffectsAndDamage(stats, nbt, (LivingEntity) target);
|
||||
loc.getWorld().spawnParticle(Particle.EXPLOSION_NORMAL, loc, 16, 0, 0, 0, .1);
|
||||
return;
|
||||
}
|
||||
|
@ -14,15 +14,14 @@ 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.AttackResult.DamageType;
|
||||
import net.Indyuce.mmoitems.api.item.NBTItem;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
|
||||
public class ManaSpirit implements StaffAttackHandler {
|
||||
|
||||
@Override
|
||||
public void handle(TemporaryStats stats, NBTItem nbt, double attackDamage, double range, UntargetedWeapon untargeted) {
|
||||
public void handle(TemporaryStats stats, NBTItem nbt, double attackDamage, double range) {
|
||||
new BukkitRunnable() {
|
||||
Vector vec = stats.getPlayer().getEyeLocation().getDirection().multiply(.4);
|
||||
Location loc = stats.getPlayer().getEyeLocation();
|
||||
@ -51,7 +50,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.WEAPON, DamageType.PROJECTILE);
|
||||
new AttackResult(attackDamage, DamageType.WEAPON, DamageType.PROJECTILE, DamageType.PHYSICAL).applyEffectsAndDamage(stats, nbt, (LivingEntity) target);
|
||||
loc.getWorld().spawnParticle(Particle.EXPLOSION_LARGE, loc, 0);
|
||||
cancel();
|
||||
return;
|
||||
|
@ -13,15 +13,14 @@ 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.AttackResult.DamageType;
|
||||
import net.Indyuce.mmoitems.api.item.NBTItem;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
|
||||
public class NetherSpirit implements StaffAttackHandler {
|
||||
|
||||
@Override
|
||||
public void handle(TemporaryStats stats, NBTItem nbt, double attackDamage, double range, UntargetedWeapon untargeted) {
|
||||
public void handle(TemporaryStats stats, NBTItem nbt, double attackDamage, double range) {
|
||||
new BukkitRunnable() {
|
||||
Vector vec = stats.getPlayer().getEyeLocation().getDirection().multiply(.3);
|
||||
Location loc = stats.getPlayer().getEyeLocation();
|
||||
@ -43,7 +42,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.WEAPON, DamageType.PROJECTILE);
|
||||
new AttackResult(attackDamage, DamageType.WEAPON, DamageType.PROJECTILE, DamageType.PHYSICAL).applyEffectsAndDamage(stats, nbt, (LivingEntity) target);
|
||||
loc.getWorld().spawnParticle(Particle.EXPLOSION_LARGE, loc, 0);
|
||||
cancel();
|
||||
return;
|
||||
|
@ -4,12 +4,11 @@ import java.util.Random;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
import net.Indyuce.mmoitems.api.interaction.weapon.untargeted.UntargetedWeapon;
|
||||
import net.Indyuce.mmoitems.api.item.NBTItem;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
|
||||
public interface StaffAttackHandler {
|
||||
public void handle(TemporaryStats stats, NBTItem nbt, double attackDamage, double range, UntargetedWeapon untargeted);
|
||||
public void handle(TemporaryStats stats, NBTItem nbt, double attackDamage, double range);
|
||||
|
||||
static final Random random = new Random();
|
||||
|
||||
|
@ -14,8 +14,7 @@ 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.AttackResult.DamageType;
|
||||
import net.Indyuce.mmoitems.api.item.NBTItem;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.version.VersionSound;
|
||||
@ -23,7 +22,7 @@ import net.Indyuce.mmoitems.version.VersionSound;
|
||||
public class SunfireSpirit implements StaffAttackHandler {
|
||||
|
||||
@Override
|
||||
public void handle(TemporaryStats stats, NBTItem nbt, double attackDamage, double range, UntargetedWeapon untargeted) {
|
||||
public void handle(TemporaryStats stats, NBTItem nbt, double attackDamage, double range) {
|
||||
stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(), Sound.ENTITY_WITHER_SHOOT, 2, 2);
|
||||
new BukkitRunnable() {
|
||||
Location target = getGround(stats.getPlayer().getTargetBlock((Set<Material>) null, (int) range * 2).getLocation()).add(0, 1.2, 0);
|
||||
@ -45,7 +44,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.WEAPON, DamageType.PROJECTILE);
|
||||
new AttackResult(attackDamage, DamageType.WEAPON, DamageType.PROJECTILE, DamageType.PHYSICAL).applyEffectsAndDamage(stats, nbt, (LivingEntity) target);
|
||||
cancel();
|
||||
break;
|
||||
}
|
||||
|
@ -14,8 +14,7 @@ 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.AttackResult.DamageType;
|
||||
import net.Indyuce.mmoitems.api.item.NBTItem;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.version.VersionSound;
|
||||
@ -23,7 +22,7 @@ import net.Indyuce.mmoitems.version.VersionSound;
|
||||
public class ThunderSpirit implements StaffAttackHandler {
|
||||
|
||||
@Override
|
||||
public void handle(TemporaryStats stats, NBTItem nbt, double attackDamage, double range, UntargetedWeapon untargeted) {
|
||||
public void handle(TemporaryStats stats, NBTItem nbt, double attackDamage, double range) {
|
||||
stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(), Sound.ENTITY_WITHER_SHOOT, 2, 2);
|
||||
new BukkitRunnable() {
|
||||
Location target = getGround(stats.getPlayer().getTargetBlock((Set<Material>) null, (int) range * 2).getLocation()).add(0, 1.2, 0);
|
||||
@ -43,7 +42,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.WEAPON, DamageType.PROJECTILE);
|
||||
new AttackResult(attackDamage, DamageType.WEAPON, DamageType.PROJECTILE, DamageType.PHYSICAL).applyEffectsAndDamage(stats, nbt, (LivingEntity) target);
|
||||
cancel();
|
||||
}
|
||||
}
|
||||
|
@ -7,14 +7,15 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.interaction.weapon.untargeted.UntargetedWeapon;
|
||||
import net.Indyuce.mmoitems.api.AttackResult;
|
||||
import net.Indyuce.mmoitems.api.AttackResult.DamageType;
|
||||
import net.Indyuce.mmoitems.api.item.NBTItem;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
|
||||
public class VoidSpirit implements StaffAttackHandler {
|
||||
|
||||
@Override
|
||||
public void handle(TemporaryStats stats, NBTItem nbt, double attackDamage, double range, UntargetedWeapon untargeted) {
|
||||
public void handle(TemporaryStats stats, NBTItem nbt, double attackDamage, double range) {
|
||||
Vector vec = stats.getPlayer().getEyeLocation().getDirection();
|
||||
stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(), Sound.ENTITY_WITHER_SHOOT, 2, 2);
|
||||
ShulkerBullet shulkerBullet = (ShulkerBullet) stats.getPlayer().getWorld().spawnEntity(stats.getPlayer().getLocation().add(0, 1, 0), EntityType.valueOf("SHULKER_BULLET"));
|
||||
@ -31,6 +32,6 @@ public class VoidSpirit implements StaffAttackHandler {
|
||||
shulkerBullet.setVelocity(vec);
|
||||
}
|
||||
}.runTaskTimer(MMOItems.plugin, 0, 1);
|
||||
MMOItems.plugin.getEntities().registerCustomEntity(shulkerBullet, attackDamage, 0., stats.getPlayer(), nbt, stats);
|
||||
MMOItems.plugin.getEntities().registerCustomEntity(shulkerBullet, new AttackResult(attackDamage, DamageType.WEAPON, DamageType.PHYSICAL, DamageType.PROJECTILE), 0., stats, nbt);
|
||||
}
|
||||
}
|
||||
|
@ -7,8 +7,7 @@ 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.AttackResult.DamageType;
|
||||
import net.Indyuce.mmoitems.api.item.NBTItem;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
import net.Indyuce.mmoitems.api.util.MMORayTraceResult;
|
||||
@ -16,7 +15,7 @@ import net.Indyuce.mmoitems.api.util.MMORayTraceResult;
|
||||
public class XRaySpirit implements StaffAttackHandler {
|
||||
|
||||
@Override
|
||||
public void handle(TemporaryStats stats, NBTItem nbt, double attackDamage, double range, UntargetedWeapon untargeted) {
|
||||
public void handle(TemporaryStats stats, NBTItem nbt, double attackDamage, double range) {
|
||||
stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(), Sound.BLOCK_FIRE_EXTINGUISH, 2, 2);
|
||||
|
||||
double a = Math.toRadians(stats.getPlayer().getEyeLocation().getYaw() + 160);
|
||||
@ -24,7 +23,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.WEAPON, DamageType.PROJECTILE);
|
||||
new AttackResult(attackDamage, DamageType.WEAPON, DamageType.PROJECTILE, DamageType.PHYSICAL).applyEffectsAndDamage(stats, nbt, trace.getHit());
|
||||
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);
|
||||
}
|
||||
|
@ -8,13 +8,14 @@ import net.Indyuce.mmocore.comp.rpg.damage.DamageHandler;
|
||||
import net.Indyuce.mmocore.comp.rpg.damage.DamageInfo;
|
||||
import net.Indyuce.mmocore.comp.rpg.damage.DamageInfo.DamageType;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.AttackResult;
|
||||
|
||||
public class MMOCoreDamageHandler implements DamageHandler {
|
||||
|
||||
@Override
|
||||
public DamageInfo getDamage(Entity entity) {
|
||||
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()));
|
||||
AttackResult result = MMOItems.plugin.getDamage().getDamage(entity);
|
||||
return new DamageInfo(result.getDamage(), result.getTypes().stream().map((type) -> DamageType.valueOf(type.name())).collect(Collectors.toSet()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -25,7 +25,6 @@ import org.bukkit.inventory.EquipmentSlot;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.Ability.CastingMode;
|
||||
import net.Indyuce.mmoitems.api.AttackResult;
|
||||
import net.Indyuce.mmoitems.api.Message;
|
||||
import net.Indyuce.mmoitems.api.Type;
|
||||
@ -142,8 +141,7 @@ public class ItemUse implements Listener {
|
||||
/*
|
||||
* cast on-hit abilities and add the extra damage to the damage event
|
||||
*/
|
||||
result.applyEffects(stats == null ? stats = playerData.getStats().newTemporary() : stats, target);
|
||||
playerData.castAbilities(stats, target, result, CastingMode.ON_HIT);
|
||||
result.applyOnHitEffects(stats == null ? stats = playerData.getStats().newTemporary() : stats, target);
|
||||
|
||||
event.setDamage(result.getDamage());
|
||||
}
|
||||
|
@ -15,58 +15,45 @@ 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;
|
||||
import net.Indyuce.mmoitems.api.AttackResult;
|
||||
|
||||
public class DamageManager implements Listener {
|
||||
private final Map<Integer, DamageInfo> customDamage = new HashMap<>();
|
||||
private final Map<Integer, AttackResult> customDamage = new HashMap<>();
|
||||
|
||||
public boolean isDamaged(Entity entity) {
|
||||
return customDamage.containsKey(entity.getEntityId());
|
||||
}
|
||||
|
||||
public DamageInfo getDamage(Entity entity) {
|
||||
public AttackResult getDamage(Entity entity) {
|
||||
return customDamage.get(entity.getEntityId());
|
||||
}
|
||||
|
||||
public void damage(TemporaryStats playerStats, LivingEntity target, double value, DamageType... types) {
|
||||
damage(playerStats, target, value, true, types);
|
||||
public void damage(Player player, LivingEntity target, AttackResult result) {
|
||||
damage(player, target, result, true);
|
||||
}
|
||||
|
||||
public void damage(TemporaryStats playerStats, LivingEntity target, double value, boolean knockback, DamageType... types) {
|
||||
if (target.hasMetadata("NPC") || playerStats.getPlayer().hasMetadata("NPC"))
|
||||
public void damage(Player player, LivingEntity target, AttackResult result, boolean knockback) {
|
||||
if (target.hasMetadata("NPC") || player.hasMetadata("NPC"))
|
||||
return;
|
||||
|
||||
/*
|
||||
* calculate extra damage depending on the type of attack and the entity
|
||||
* that is being damaged
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
customDamage.put(target.getEntityId(), info);
|
||||
customDamage.put(target.getEntityId(), result);
|
||||
|
||||
if (!knockback) {
|
||||
final double baseKnockbackValue = target.getAttribute(Attribute.GENERIC_KNOCKBACK_RESISTANCE).getBaseValue();
|
||||
target.getAttribute(Attribute.GENERIC_KNOCKBACK_RESISTANCE).setBaseValue(63);
|
||||
try {
|
||||
target.damage(value, playerStats.getPlayer());
|
||||
target.damage(result.getDamage(), player);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
target.getAttribute(Attribute.GENERIC_KNOCKBACK_RESISTANCE).setBaseValue(baseKnockbackValue);
|
||||
return;
|
||||
}
|
||||
|
||||
target.damage(value, playerStats.getPlayer());
|
||||
} else
|
||||
target.damage(result.getDamage(), player);
|
||||
}
|
||||
|
||||
public boolean isUndead(Entity entity) {
|
||||
|
@ -16,9 +16,9 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.Ability.CastingMode;
|
||||
import net.Indyuce.mmoitems.api.ArrowParticles;
|
||||
import net.Indyuce.mmoitems.api.AttackResult;
|
||||
import net.Indyuce.mmoitems.api.AttackResult.DamageType;
|
||||
import net.Indyuce.mmoitems.api.ProjectileData;
|
||||
import net.Indyuce.mmoitems.api.item.NBTItem;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
|
||||
@ -109,12 +109,10 @@ public class EntityManager implements Listener {
|
||||
LivingEntity target = (LivingEntity) event.getEntity();
|
||||
TemporaryStats stats = data.getPlayerStats();
|
||||
|
||||
AttackResult result = new AttackResult(true, stats.getStat(ItemStat.ATTACK_DAMAGE)).applyEffects(stats, target);
|
||||
AttackResult result = new AttackResult(stats.getStat(ItemStat.ATTACK_DAMAGE), DamageType.WEAPON, DamageType.PROJECTILE, DamageType.PHYSICAL).applyOnHitEffects(stats, target);
|
||||
if (data.isCustomWeapon())
|
||||
result.applyElementalEffects(stats, data.getSourceItem(), target);
|
||||
|
||||
stats.getPlayerData().castAbilities(target, result, CastingMode.ON_HIT);
|
||||
|
||||
if (data.getSourceItem().getItem().hasItemMeta())
|
||||
if (data.getSourceItem().getItem().getItemMeta().getEnchants().containsKey(Enchantment.ARROW_DAMAGE))
|
||||
result.addRelativeDamage(.25 + (.25 * data.getSourceItem().getItem().getItemMeta().getEnchantLevel(Enchantment.ARROW_DAMAGE)));
|
||||
|
@ -104,17 +104,20 @@ public abstract class ItemStat {
|
||||
public static final ItemStat PVP_DAMAGE = new DoubleStat(new ItemStack(VersionMaterial.SKELETON_SKULL.toMaterial()), "PvP Damage", new String[] { "Additional damage", "against players in %." }, "pvp-damage", new String[] { "piercing", "slashing", "blunt", "offhand", "range", "tool", "armor", "gem_stone" });
|
||||
public static final ItemStat BLUNT_POWER = new DoubleStat(new ItemStack(Material.IRON_AXE), "Blunt Power", new String[] { "The radius of the AoE attack.", "If set to 2.0, enemies within 2 blocks", "around your target will take damage." }, "blunt-power", new String[] { "blunt", "gem_stone" });
|
||||
public static final ItemStat BLUNT_RATING = new DoubleStat(new ItemStack(Material.BRICK), "Blunt Rating", new String[] { "The force of the blunt attack.", "If set to 50%, enemies hit by the attack", "will take 50% of the initial damage." }, "blunt-rating", new String[] { "blunt", "gem_stone" });
|
||||
public static final ItemStat WEAPON_DAMAGE = new DoubleStat(new ItemStack(Material.IRON_SWORD), "Weapon Damage", new String[] { "Additional on-hit weapon damage." }, "weapon-damage", new String[] { "!miscellaneous", "all" });
|
||||
public static final ItemStat MAGIC_DAMAGE = new DoubleStat(new ItemStack(Material.BOOK), "Magic Damage", new String[] { "The additional damage spells deal.", "In %." }, "magic-damage", new String[] { "!miscellaneous", "all" });
|
||||
public static final ItemStat DAMAGE_REDUCTION = new DoubleStat(new ItemStack(Material.IRON_CHESTPLATE), "Damage Reduction", new String[] { "Reduces damage from any source.", "In %." }, "damage-reduction", new String[] { "!miscellaneous", "all" });
|
||||
public static final ItemStat FALL_DAMAGE_REDUCTION = new DoubleStat(new ItemStack(Material.FEATHER), "Fall Damage Reduction", new String[] { "Reduces fall damage.", "In %." }, "fall-damage-reduction", new String[] { "!miscellaneous", "all" });
|
||||
public static final ItemStat PHYSICAL_DAMAGE_REDUCTION = new DoubleStat(new ItemStack(Material.LEATHER_CHESTPLATE), "Physical Damage Reduction", new String[] { "Reduces physical damage.", "In %." }, "physical-damage-reduction", new String[] { "!miscellaneous", "all" });
|
||||
public static final ItemStat FIRE_DAMAGE_REDUCTION = new DoubleStat(new ItemStack(Material.BLAZE_POWDER), "Fire Damage Reduction", new String[] { "Reduces fire damage.", "In %." }, "fire-damage-reduction", new String[] { "!miscellaneous", "all" });
|
||||
public static final ItemStat MAGIC_DAMAGE_REDUCTION = new DoubleStat(new ItemStack(Material.POTION), "Magic Damage Reduction", new String[] { "Reduce magic damage dealt by potions.", "In %." }, "magic-damage-reduction", new String[] { "!miscellaneous", "all" });
|
||||
public static final ItemStat UNDEAD_DAMAGE = new DoubleStat(new ItemStack(VersionMaterial.SKELETON_SKULL.toMaterial()), "Undead Damage", new String[] { "Deals additional damage to undead.", "In %." }, "undead-damage", new String[] { "!miscellaneous", "all" });
|
||||
public static final ItemStat REGENERATION = new DoubleStat(new ItemStack(Material.BREAD), "Regeneration", new String[] { "Increases natural/magic health regen.", "In %." }, "regeneration", new String[] { "!miscellaneous", "all" });
|
||||
public static final ItemStat WEAPON_DAMAGE = new DoubleStat(new ItemStack(Material.IRON_SWORD), "Weapon Damage", new String[] { "Additional on-hit weapon damage in %." }, "weapon-damage");
|
||||
public static final ItemStat SKILL_DAMAGE = new DoubleStat(new ItemStack(Material.BOOK), "Skill Damage", new String[] { "Additional ability damage in %." }, "skill-damage");
|
||||
public static final ItemStat PROJECTILE_DAMAGE = new DoubleStat(new ItemStack(Material.ARROW), "Projectile Damage", new String[] { "Additional skill/weapon projectile damage." }, "projectile-damage");
|
||||
public static final ItemStat MAGIC_DAMAGE = new DoubleStat(new ItemStack(Material.BOOK), "Magic Damage", new String[] { "Additional magical skill damage in %." }, "magic-damage");
|
||||
public static final ItemStat PHYSICAL_DAMAGE = new DoubleStat(new ItemStack(Material.IRON_AXE), "Physical Damage", new String[] { "Additional skill/weapon physical damage." }, "physical-damage");
|
||||
public static final ItemStat DAMAGE_REDUCTION = new DoubleStat(new ItemStack(Material.IRON_CHESTPLATE), "Damage Reduction", new String[] { "Reduces damage from any source.", "In %." }, "damage-reduction");
|
||||
public static final ItemStat FALL_DAMAGE_REDUCTION = new DoubleStat(new ItemStack(Material.FEATHER), "Fall Damage Reduction", new String[] { "Reduces fall damage.", "In %." }, "fall-damage-reduction");
|
||||
public static final ItemStat PHYSICAL_DAMAGE_REDUCTION = new DoubleStat(new ItemStack(Material.LEATHER_CHESTPLATE), "Physical Damage Reduction", new String[] { "Reduces physical damage.", "In %." }, "physical-damage-reduction");
|
||||
public static final ItemStat FIRE_DAMAGE_REDUCTION = new DoubleStat(new ItemStack(Material.BLAZE_POWDER), "Fire Damage Reduction", new String[] { "Reduces fire damage.", "In %." }, "fire-damage-reduction");
|
||||
public static final ItemStat MAGIC_DAMAGE_REDUCTION = new DoubleStat(new ItemStack(Material.POTION), "Magic Damage Reduction", new String[] { "Reduce magic damage dealt by potions.", "In %." }, "magic-damage-reduction");
|
||||
public static final ItemStat UNDEAD_DAMAGE = new DoubleStat(new ItemStack(VersionMaterial.SKELETON_SKULL.toMaterial()), "Undead Damage", new String[] { "Deals additional damage to undead.", "In %." }, "undead-damage");
|
||||
public static final ItemStat REGENERATION = new DoubleStat(new ItemStack(Material.BREAD), "Regeneration", new String[] { "Increases natural/magic health regen.", "In %." }, "regeneration");
|
||||
public static final ItemStat UNBREAKABLE = new Unbreakable(), TIER = new Item_Tier(), SET = new Item_Set(), ARMOR = new Armor(), ARMOR_TOUGHNESS = new Armor_Toughness(), MAX_HEALTH = new Max_Health();
|
||||
public static final ItemStat MAX_MANA = new DoubleStat(VersionMaterial.LAPIS_LAZULI.toItem(), "Max Mana", new String[] { "Adds mana to your max mana bar." }, "max-mana", new String[] { "!miscellaneous", "all" });
|
||||
public static final ItemStat MAX_MANA = new DoubleStat(VersionMaterial.LAPIS_LAZULI.toItem(), "Max Mana", new String[] { "Adds mana to your max mana bar." }, "max-mana");
|
||||
public static final ItemStat KNOCKBACK_RESISTANCE = new Knockback_Resistance(), MOVEMENT_SPEED = new Movement_Speed();
|
||||
|
||||
public static final ItemStat TWO_HANDED = new BooleanStat(new ItemStack(Material.IRON_INGOT), "Two Handed", new String[] { "If set to true, a player will be", "significantly slower if holding two", "items, one being Two Handed." }, "two-handed", new String[] { "piercing", "slashing", "blunt", "offhand", "range", "tool" });
|
||||
|
@ -34,6 +34,8 @@ lore-format:
|
||||
- '#blunt-rating#'
|
||||
- '#weapon-damage#'
|
||||
- '#magic-damage#'
|
||||
- '#physical-damage#'
|
||||
- '#projectile-damage#'
|
||||
- '#damage-reduction#'
|
||||
- '#fall-damage-reduction#'
|
||||
- '#fire-damage-reduction#'
|
||||
|
@ -34,6 +34,8 @@ lore-format:
|
||||
- '#blunt-rating#'
|
||||
- '#weapon-damage#'
|
||||
- '#magic-damage#'
|
||||
- '#physical-damage#'
|
||||
- '#projectile-damage#'
|
||||
- '#damage-reduction#'
|
||||
- '#fall-damage-reduction#'
|
||||
- '#fire-damage-reduction#'
|
||||
|
@ -34,6 +34,8 @@ lore-format:
|
||||
- '#blunt-rating#'
|
||||
- '#weapon-damage#'
|
||||
- '#magic-damage#'
|
||||
- '#physical-damage#'
|
||||
- '#projectile-damage#'
|
||||
- '#damage-reduction#'
|
||||
- '#fall-damage-reduction#'
|
||||
- '#fire-damage-reduction#'
|
||||
|
@ -34,6 +34,8 @@ lore-format:
|
||||
- '#blunt-rating#'
|
||||
- '#weapon-damage#'
|
||||
- '#magic-damage#'
|
||||
- '#physical-damage#'
|
||||
- '#projectile-damage#'
|
||||
- '#damage-reduction#'
|
||||
- '#fall-damage-reduction#'
|
||||
- '#fire-damage-reduction#'
|
||||
|
@ -33,6 +33,8 @@ lore-format:
|
||||
- '#blunt-rating#'
|
||||
- '#weapon-damage#'
|
||||
- '#magic-damage#'
|
||||
- '#physical-damage#'
|
||||
- '#projectile-damage#'
|
||||
- '#damage-reduction#'
|
||||
- '#fall-damage-reduction#'
|
||||
- '#fire-damage-reduction#'
|
||||
|
@ -34,6 +34,8 @@ lore-format:
|
||||
- '#blunt-rating#'
|
||||
- '#weapon-damage#'
|
||||
- '#magic-damage#'
|
||||
- '#physical-damage#'
|
||||
- '#projectile-damage#'
|
||||
- '#damage-reduction#'
|
||||
- '#fall-damage-reduction#'
|
||||
- '#fire-damage-reduction#'
|
||||
|
Loading…
Reference in New Issue
Block a user