refactor attack result, new damage types

added projectile and physical damage to lore format and stat list
This commit is contained in:
Indyuce 2019-08-30 00:15:22 +02:00
parent 65edcfae44
commit e9a2721368
70 changed files with 304 additions and 329 deletions

View File

@ -12,7 +12,7 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability; import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult; 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.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.stat.data.AbilityData; import net.Indyuce.mmoitems.stat.data.AbilityData;
@ -74,7 +74,7 @@ public class Bouncy_Fireball extends Ability {
for (Entity entity : MMOUtils.getNearbyChunkEntities(loc)) for (Entity entity : MMOUtils.getNearbyChunkEntities(loc))
if (entity.getLocation().distanceSquared(loc) < radius * radius) if (entity.getLocation().distanceSquared(loc) < radius * radius)
if (MMOUtils.canDamage(stats.getPlayer(), entity)) { 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)); ((LivingEntity) entity).setFireTicks((int) (ignite * 20));
} }

View File

@ -13,7 +13,7 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability; import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult; 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.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.stat.data.AbilityData; import net.Indyuce.mmoitems.stat.data.AbilityData;
@ -31,7 +31,7 @@ public class Burning_Hands extends Ability implements Listener {
@Override @Override
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, AttackResult result) { public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, AttackResult result) {
double duration = data.getModifier("duration") * 10; double duration = data.getModifier("duration") * 10;
double damage1 = data.getModifier("damage") / 2; double damage = data.getModifier("damage") / 2;
new BukkitRunnable() { new BukkitRunnable() {
int j = 0; int j = 0;
@ -58,7 +58,7 @@ public class Burning_Hands extends Ability implements Listener {
if (entity.getLocation().distanceSquared(loc) < 60) if (entity.getLocation().distanceSquared(loc) < 60)
if (stats.getPlayer().getEyeLocation().getDirection().angle(entity.getLocation().toVector().subtract(stats.getPlayer().getLocation().toVector())) < Math.PI / 6) if (stats.getPlayer().getEyeLocation().getDirection().angle(entity.getLocation().toVector().subtract(stats.getPlayer().getLocation().toVector())) < Math.PI / 6)
if (MMOUtils.canDamage(stats.getPlayer(), entity)) 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); }.runTaskTimer(MMOItems.plugin, 0, 2);

View File

@ -9,11 +9,10 @@ import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability; import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult; 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.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.stat.data.AbilityData; import net.Indyuce.mmoitems.stat.data.AbilityData;
@ -31,7 +30,7 @@ public class Circular_Slash extends Ability {
@Override @Override
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, AttackResult result) { 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 radius = data.getModifier("radius");
double knockback = data.getModifier("knockback"); double knockback = data.getModifier("knockback");
@ -39,7 +38,7 @@ public class Circular_Slash extends Ability {
stats.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 2, 254)); stats.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 2, 254));
for (Entity entity : stats.getPlayer().getNearbyEntities(radius, radius, radius)) { for (Entity entity : stats.getPlayer().getNearbyEntities(radius, radius, radius)) {
if (MMOUtils.canDamage(stats.getPlayer(), entity)) { 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 v1 = entity.getLocation().toVector();
Vector v2 = stats.getPlayer().getLocation().toVector(); Vector v2 = stats.getPlayer().getLocation().toVector();
double y = .5; double y = .5;

View File

@ -11,7 +11,7 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability; import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult; 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.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.stat.data.AbilityData; import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.Indyuce.mmoitems.version.VersionSound; 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); loc.getWorld().playSound(loc, VersionSound.ENTITY_ENDERMAN_HURT.toSound(), 2, 1);
for (Entity entity : MMOUtils.getNearbyChunkEntities(loc)) for (Entity entity : MMOUtils.getNearbyChunkEntities(loc))
if (MMOUtils.canDamage(stats.getPlayer(), entity) && entity.getLocation().distanceSquared(loc) <= 25) 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); }.runTaskTimer(MMOItems.plugin, 0, 1);

View File

@ -12,7 +12,7 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability; import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult; 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.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.stat.data.AbilityData; import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.Indyuce.mmoitems.version.VersionSound; import net.Indyuce.mmoitems.version.VersionSound;
@ -37,7 +37,7 @@ public class Corrupt extends Ability {
return; return;
} }
double damage1 = data.getModifier("damage"); double damage = data.getModifier("damage");
double duration = data.getModifier("duration"); double duration = data.getModifier("duration");
double amplifier = data.getModifier("amplifier"); double amplifier = data.getModifier("amplifier");
double radius = 2.7; double radius = 2.7;
@ -53,7 +53,7 @@ public class Corrupt extends Ability {
for (Entity entity : MMOUtils.getNearbyChunkEntities(loc)) for (Entity entity : MMOUtils.getNearbyChunkEntities(loc))
if (MMOUtils.canDamage(stats.getPlayer(), entity) && entity.getLocation().distanceSquared(loc) <= radius * radius) { 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).removePotionEffect(PotionEffectType.WITHER);
((LivingEntity) entity).addPotionEffect(new PotionEffect(PotionEffectType.WITHER, (int) (duration * 20), (int) amplifier)); ((LivingEntity) entity).addPotionEffect(new PotionEffect(PotionEffectType.WITHER, (int) (duration * 20), (int) amplifier));
} }

View File

@ -15,7 +15,7 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability; import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult; 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.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.stat.data.AbilityData; 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); Object[] data = MMOItems.plugin.getEntities().getEntityData(damager);
TemporaryStats stats = (TemporaryStats) data[0]; TemporaryStats stats = (TemporaryStats) data[0];
if (MMOUtils.canDamage(stats.getPlayer(), event.getEntity())) 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());
} }
} }
} }

View File

@ -16,7 +16,7 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability; import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult; 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.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.stat.data.AbilityData; import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.Indyuce.mmoitems.version.VersionSound; import net.Indyuce.mmoitems.version.VersionSound;
@ -64,10 +64,10 @@ public class Cursed_Beam extends Ability {
double damage = data.getModifier("damage"); double damage = data.getModifier("damage");
loc.getWorld().playSound(loc, VersionSound.ENTITY_ENDERMAN_TELEPORT.toSound(), 2, .7f); loc.getWorld().playSound(loc, VersionSound.ENTITY_ENDERMAN_TELEPORT.toSound(), 2, .7f);
for (Entity aoeTarget : entities) for (Entity entity : entities)
if (MMOUtils.canDamage(stats.getPlayer(), aoeTarget) && loc.distanceSquared(aoeTarget.getLocation().add(0, 1, 0)) < 9) { if (MMOUtils.canDamage(stats.getPlayer(), entity) && loc.distanceSquared(entity.getLocation().add(0, 1, 0)) < 9) {
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) aoeTarget, damage, DamageType.SKILL, DamageType.PROJECTILE, DamageType.MAGICAL); new AttackResult(damage, DamageType.SKILL, DamageType.MAGICAL, DamageType.PROJECTILE).applyEffectsAndDamage(stats, null, (LivingEntity) entity);
((LivingEntity) aoeTarget).addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, (int) (duration * 20), 0)); ((LivingEntity) entity).addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, (int) (duration * 20), 0));
} }
cancel(); cancel();
return; return;

View File

@ -17,7 +17,7 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability; import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult; 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.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.stat.data.AbilityData; import net.Indyuce.mmoitems.stat.data.AbilityData;
@ -40,7 +40,7 @@ public class Earthquake extends Ability {
return; return;
} }
double damage1 = data.getModifier("damage"); double damage = data.getModifier("damage");
double slowDuration = data.getModifier("duration"); double slowDuration = data.getModifier("duration");
double slowAmplifier = data.getModifier("amplifier"); double slowAmplifier = data.getModifier("amplifier");
@ -62,7 +62,7 @@ public class Earthquake extends Ability {
for (Entity entity : MMOUtils.getNearbyChunkEntities(loc)) for (Entity entity : MMOUtils.getNearbyChunkEntities(loc))
if (MMOUtils.canDamage(stats.getPlayer(), entity) && loc.distanceSquared(entity.getLocation()) < 2 && !hit.contains(entity.getEntityId())) { if (MMOUtils.canDamage(stats.getPlayer(), entity) && loc.distanceSquared(entity.getLocation()) < 2 && !hit.contains(entity.getEntityId())) {
hit.add(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)); ((LivingEntity) entity).addPotionEffect(new PotionEffect(PotionEffectType.SLOW, (int) (slowDuration * 20), (int) slowAmplifier));
} }
} }

View File

@ -13,7 +13,7 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability; import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult; 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.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.stat.data.AbilityData; import net.Indyuce.mmoitems.stat.data.AbilityData;
@ -31,7 +31,7 @@ public class Explosive_Turkey extends Ability {
@Override @Override
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, AttackResult result) { 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 radiusSquared = Math.pow(data.getModifier("radius"), 2);
double knockback = data.getModifier("knockback"); 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); chicken.getWorld().playSound(chicken.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 2, 1.5f);
for (Entity entity : MMOUtils.getNearbyChunkEntities(chicken.getLocation())) for (Entity entity : MMOUtils.getNearbyChunkEntities(chicken.getLocation()))
if (!entity.isDead() && entity.getLocation().distanceSquared(chicken.getLocation()) < radiusSquared && MMOUtils.canDamage(stats.getPlayer(), entity)) { 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)); entity.setVelocity(entity.getLocation().toVector().subtract(chicken.getLocation().toVector()).multiply(.1 * knockback).setY(.4 * knockback));
} }
cancel(); cancel();

View File

@ -13,7 +13,7 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability; import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult; 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.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.stat.data.AbilityData; import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.Indyuce.mmoitems.version.VersionSound; 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.EXPLOSION_NORMAL, loc, 32, 0, 0, 0, .3);
loc.getWorld().spawnParticle(Particle.FLAME, 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 knockback = data.getModifier("knockback");
double radius = data.getModifier("radius"); double radius = data.getModifier("radius");
for (Entity entity : loc.getWorld().getEntitiesByClass(LivingEntity.class)) for (Entity entity : loc.getWorld().getEntitiesByClass(LivingEntity.class))
if (MMOUtils.canDamage(stats.getPlayer(), entity) && entity.getLocation().distanceSquared(loc) < radius * radius) { 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)); entity.setVelocity(entity.getLocation().toVector().subtract(loc.toVector()).multiply(.1 * knockback).setY(.4 * knockback));
} }
cancel(); cancel();

View File

@ -14,7 +14,7 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability; import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult; 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.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.stat.data.AbilityData; import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.Indyuce.mmoitems.version.VersionSound; 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.LAVA, loc, 8, 0, 0, 0, 0);
loc.getWorld().spawnParticle(Particle.EXPLOSION_LARGE, loc, 0); loc.getWorld().spawnParticle(Particle.EXPLOSION_LARGE, loc, 0);
loc.getWorld().playSound(loc, Sound.ENTITY_GENERIC_EXPLODE, 3, 1); 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); target.setFireTicks((int) data.getModifier("ignite") * 20);
cancel(); cancel();
return; return;

View File

@ -13,7 +13,7 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability; import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult; 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.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.stat.data.AbilityData; import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.Indyuce.mmoitems.version.VersionSound; 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); 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)); entity.setVelocity(stats.getPlayer().getVelocity().setY(0.3).multiply(1.7 * knockback));
stats.getPlayer().setVelocity(stats.getPlayer().getEyeLocation().getDirection().multiply(-3).setY(.5)); 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(); cancel();
return; return;
} }

View File

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

View File

@ -11,7 +11,7 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability; import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult; 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.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.stat.data.AbilityData; 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); 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)); target.setVelocity(stats.getPlayer().getVelocity().setY(0.3).multiply(1.7 * knockback));
stats.getPlayer().setVelocity(stats.getPlayer().getVelocity().setX(0).setY(0).setZ(0)); 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(); cancel();
break; break;
} }

View File

@ -14,7 +14,7 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability; import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult; 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.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.stat.data.AbilityData; import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.Indyuce.mmoitems.version.VersionSound; 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.EXPLOSION_LARGE, loc, 1);
loc.getWorld().spawnParticle(Particle.FIREWORKS_SPARK, loc, 32, 0, 0, 0, .2); loc.getWorld().spawnParticle(Particle.FIREWORKS_SPARK, loc, 32, 0, 0, 0, .2);
loc.getWorld().playSound(loc, Sound.ENTITY_GENERIC_EXPLODE, 2, 1); 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(); cancel();
return; return;
} }

View File

@ -17,7 +17,7 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability; import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult; 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.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.stat.data.AbilityData; import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.Indyuce.mmoitems.version.VersionSound; 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.EXPLOSION_LARGE, loc, 0);
loc.getWorld().spawnParticle(Particle.FIREWORKS_SPARK, loc, 48, 0, 0, 0, .2); loc.getWorld().spawnParticle(Particle.FIREWORKS_SPARK, loc, 48, 0, 0, 0, .2);
loc.getWorld().playSound(loc, Sound.ENTITY_GENERIC_EXPLODE, 2, 1); 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"))); ((LivingEntity) entity).addPotionEffect(new PotionEffect(PotionEffectType.SLOW, (int) (data.getModifier("duration") * 20), (int) data.getModifier("amplifier")));
cancel(); cancel();
return; return;

View File

@ -15,7 +15,7 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability; import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult; 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.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.api.util.NoInteractItemEntity; import net.Indyuce.mmoitems.api.util.NoInteractItemEntity;
import net.Indyuce.mmoitems.stat.data.AbilityData; 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)) for (Entity entity : item.getEntity().getNearbyEntities(radius, radius, radius))
if (MMOUtils.canDamage(stats.getPlayer(), entity)) { if (MMOUtils.canDamage(stats.getPlayer(), entity)) {
LivingEntity living = (LivingEntity) entity; new AttackResult(damage, DamageType.SKILL, DamageType.PHYSICAL, DamageType.PROJECTILE).applyEffectsAndDamage(stats, null, (LivingEntity) entity);
MMOItems.plugin.getDamage().damage(stats, living, damage, DamageType.SKILL, DamageType.PROJECTILE, DamageType.MAGICAL); ((LivingEntity) entity).removePotionEffect(PotionEffectType.SLOW);
living.removePotionEffect(PotionEffectType.SLOW); ((LivingEntity) entity).addPotionEffect(new PotionEffect(PotionEffectType.SLOW, (int) (slowDuration * 20), (int) slowAmplifier));
living.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); item.getEntity().getWorld().spawnParticle(Particle.EXPLOSION_LARGE, item.getEntity().getLocation(), 24, 2, 2, 2, 0);

View File

@ -13,7 +13,7 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability; import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult; 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.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.api.util.NoInteractItemEntity; import net.Indyuce.mmoitems.api.util.NoInteractItemEntity;
import net.Indyuce.mmoitems.stat.data.AbilityData; 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); item.getEntity().getWorld().spawnParticle(Particle.CRIT, item.getEntity().getLocation(), 0);
for (Entity target : item.getEntity().getNearbyEntities(1, 1, 1)) for (Entity target : item.getEntity().getNearbyEntities(1, 1, 1))
if (MMOUtils.canDamage(stats.getPlayer(), target)) { 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(); item.close();
cancel(); cancel();
} }

View File

@ -12,7 +12,7 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability; import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult; 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.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.stat.data.AbilityData; import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.Indyuce.mmoitems.version.VersionSound; import net.Indyuce.mmoitems.version.VersionSound;
@ -69,7 +69,7 @@ public class Life_Ender extends Ability {
for (Entity entity : MMOUtils.getNearbyChunkEntities(source)) for (Entity entity : MMOUtils.getNearbyChunkEntities(source))
if (entity.getLocation().distanceSquared(source) < radius * radius && MMOUtils.canDamage(stats.getPlayer(), entity)) { 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)); entity.setVelocity(entity.getLocation().subtract(source).toVector().setY(.75).normalize().multiply(knockback));
} }
cancel(); cancel();

View File

@ -13,7 +13,7 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability; import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult; 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.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.stat.data.AbilityData; import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.Indyuce.mmoitems.version.VersionSound; import net.Indyuce.mmoitems.version.VersionSound;
@ -31,7 +31,7 @@ public class Light_Dash extends Ability {
@Override @Override
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, AttackResult result) { 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"); double length = data.getModifier("length");
new BukkitRunnable() { new BukkitRunnable() {
@ -49,7 +49,7 @@ public class Light_Dash extends Ability {
for (Entity entity : stats.getPlayer().getNearbyEntities(1, 1, 1)) for (Entity entity : stats.getPlayer().getNearbyEntities(1, 1, 1))
if (!hit.contains(entity.getEntityId()) && MMOUtils.canDamage(stats.getPlayer(), entity)) { if (!hit.contains(entity.getEntityId()) && MMOUtils.canDamage(stats.getPlayer(), entity)) {
hit.add(entity.getEntityId()); 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); }.runTaskTimer(MMOItems.plugin, 0, 2);

View File

@ -6,11 +6,10 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability; import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult; 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.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.stat.data.AbilityData; import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.Indyuce.mmoitems.version.VersionSound; import net.Indyuce.mmoitems.version.VersionSound;
@ -36,12 +35,12 @@ public class Lightning_Beam extends Ability {
loc = getFirstNonSolidBlock(loc); loc = getFirstNonSolidBlock(loc);
double damage1 = data.getModifier("damage"); double damage = data.getModifier("damage");
double radius = data.getModifier("radius"); double radius = data.getModifier("radius");
for (Entity entity : MMOUtils.getNearbyChunkEntities(loc)) for (Entity entity : MMOUtils.getNearbyChunkEntities(loc))
if (MMOUtils.canDamage(stats.getPlayer(), entity) && entity.getLocation().distanceSquared(loc) <= radius * radius) 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); 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); loc.getWorld().spawnParticle(Particle.FIREWORKS_SPARK, loc, 64, 0, 0, 0, .2);

View File

@ -10,7 +10,7 @@ import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Ability; import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult; 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.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.stat.data.AbilityData; import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.Indyuce.mmoitems.version.VersionSound; import net.Indyuce.mmoitems.version.VersionSound;
@ -56,7 +56,7 @@ public class Magma_Fissure extends Ability {
if (target.getLocation().distanceSquared(loc) < 1) { if (target.getLocation().distanceSquared(loc) < 1) {
loc.getWorld().playSound(loc, Sound.ENTITY_BLAZE_HURT, 2, 1); loc.getWorld().playSound(loc, Sound.ENTITY_BLAZE_HURT, 2, 1);
target.setFireTicks((int) (target.getFireTicks() + data.getModifier("ignite") * 20)); 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(); cancel();
} }
} }

View File

@ -8,11 +8,10 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability; import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult; 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.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.stat.data.AbilityData; import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.Indyuce.mmoitems.version.VersionSound; import net.Indyuce.mmoitems.version.VersionSound;
@ -30,7 +29,7 @@ public class Overload extends Ability {
@Override @Override
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, AttackResult result) { 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 radius = data.getModifier("radius");
stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 2, 0); 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)) for (Entity entity : stats.getPlayer().getNearbyEntities(radius, radius, radius))
if (MMOUtils.canDamage(stats.getPlayer(), entity)) 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); double step = 12 + (radius * 2.5);
for (double j = 0; j < Math.PI * 2; j += Math.PI / step) { for (double j = 0; j < Math.PI * 2; j += Math.PI / step) {

View File

@ -20,7 +20,7 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability; import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult; 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.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.api.util.NoInteractItemEntity; import net.Indyuce.mmoitems.api.util.NoInteractItemEntity;
import net.Indyuce.mmoitems.stat.data.AbilityData; import net.Indyuce.mmoitems.stat.data.AbilityData;
@ -58,7 +58,7 @@ public class Present_Throw extends Ability {
@Override @Override
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, AttackResult result) { 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 radiusSquared = Math.pow(data.getModifier("radius"), 2);
final NoInteractItemEntity item = new NoInteractItemEntity(stats.getPlayer().getLocation().add(0, 1.2, 0), present); 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); item.getEntity().getWorld().playSound(item.getEntity().getLocation(), VersionSound.ENTITY_FIREWORK_ROCKET_TWINKLE.toSound(), 2, 1.5f);
for (Entity entity : MMOUtils.getNearbyChunkEntities(item.getEntity().getLocation())) for (Entity entity : MMOUtils.getNearbyChunkEntities(item.getEntity().getLocation()))
if (entity.getLocation().distanceSquared(item.getEntity().getLocation()) < radiusSquared && MMOUtils.canDamage(stats.getPlayer(), entity)) 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(); item.close();
cancel(); cancel();
} }

View File

@ -19,6 +19,7 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability; import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult; 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.item.NBTItem;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats; import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.stat.data.AbilityData; 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); 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 shulkerBullet = (ShulkerBullet) stats.getPlayer().getWorld().spawnEntity(stats.getPlayer().getLocation().add(0, 1, 0), EntityType.SHULKER_BULLET);
shulkerBullet.setShooter(stats.getPlayer()); 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() { new BukkitRunnable() {
double ti = 0; double ti = 0;
@ -82,12 +83,12 @@ public class Shulker_Missile extends Ability implements Listener {
} }
Object[] data = MMOItems.plugin.getEntities().getEntityData(damager); 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; double duration = (double) data[1] * 20;
// void spirit // void spirit
if (data.length > 2) 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()); event.setDamage(result.getDamage());

View File

@ -8,11 +8,10 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability; import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult; 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.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.stat.data.AbilityData; import net.Indyuce.mmoitems.stat.data.AbilityData;
@ -29,7 +28,7 @@ public class Sky_Smash extends Ability {
@Override @Override
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, AttackResult result) { 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"); double knockUp = data.getModifier("knock-up");
stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(), Sound.ENTITY_ZOMBIE_ATTACK_IRON_DOOR, 2, .5f); 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)) for (Entity entity : MMOUtils.getNearbyChunkEntities(loc))
if (MMOUtils.canDamage(stats.getPlayer(), entity) && entity.getLocation().distanceSquared(loc) < 10) { 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(); Location loc1 = stats.getPlayer().getEyeLocation().clone();
loc1.setPitch(-70); loc1.setPitch(-70);
((LivingEntity) entity).setVelocity(loc1.getDirection().multiply(1.2 * knockUp)); ((LivingEntity) entity).setVelocity(loc1.getDirection().multiply(1.2 * knockUp));

View File

@ -5,7 +5,7 @@ import org.bukkit.entity.LivingEntity;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Ability; import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult; 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.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.stat.data.AbilityData; import net.Indyuce.mmoitems.stat.data.AbilityData;
@ -27,7 +27,7 @@ public class Smite extends Ability {
return; 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()); target.getWorld().strikeLightningEffect(target.getLocation());
} }
} }

View File

@ -10,7 +10,7 @@ import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Ability; import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult; 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.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.stat.data.AbilityData; import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.Indyuce.mmoitems.version.VersionSound; import net.Indyuce.mmoitems.version.VersionSound;
@ -30,34 +30,31 @@ public class Sparkle extends Ability {
@Override @Override
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, AttackResult result) { public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, AttackResult result) {
target = target == null ? MMOItems.plugin.getVersion().getVersionWrapper().rayTrace(stats.getPlayer(), 50).getHit() : target; target = target == null ? MMOItems.plugin.getVersion().getVersionWrapper().rayTrace(stats.getPlayer(), 50).getHit() : target;
if (target == null){ if (target == null) {
result.setSuccessful(false); result.setSuccessful(false);
return; return;
} }
double damage1 = data.getModifier("damage"); double damage = data.getModifier("damage");
double radius = data.getModifier("radius"); double radius = data.getModifier("radius");
double limit = data.getModifier("limit"); 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().spawnParticle(Particle.EXPLOSION_LARGE, target.getLocation().add(0, 1, 0), 0);
target.getWorld().playSound(target.getLocation(), VersionSound.ENTITY_FIREWORK_ROCKET_TWINKLE.toSound(), 2, 2); 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++; count++;
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) ent, damage1, DamageType.SKILL, DamageType.MAGICAL); new AttackResult(damage, DamageType.SKILL, DamageType.MAGICAL).applyEffectsAndDamage(stats, null, (LivingEntity) entity);
ent.getWorld().playSound(ent.getLocation(), VersionSound.ENTITY_FIREWORK_ROCKET_TWINKLE.toSound(), 2, 2); entity.getWorld().playSound(entity.getLocation(), VersionSound.ENTITY_FIREWORK_ROCKET_TWINKLE.toSound(), 2, 2);
Location loc_t = target.getLocation().add(0, .75, 0); 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) { for (double j1 = 0; j1 < 1; j1 += .04) {
Vector d = loc_ent.toVector().subtract(loc_t.toVector()); 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); target.getWorld().spawnParticle(Particle.FIREWORKS_SPARK, loc_t.clone().add(d.multiply(j1)), 3, .1, .1, .1, .008);
} }
} }
} }
}
} }

View File

@ -15,7 +15,7 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability; import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult; 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.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.stat.data.AbilityData; import net.Indyuce.mmoitems.stat.data.AbilityData;
@ -73,7 +73,7 @@ public class Tactical_Grenade extends Ability {
if (entity.equals(target)) if (entity.equals(target))
cancel(); 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))); entity.setVelocity(entity.getVelocity().add(offsetVector(knockup)));
} }
} }

View File

@ -9,7 +9,7 @@ import org.bukkit.scheduler.BukkitRunnable;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Ability; import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult; 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.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.stat.data.AbilityData; import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.Indyuce.mmoitems.version.VersionSound; 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().spawnParticle(Particle.FLAME, loc, 32, 0, 0, 0, .1);
loc.getWorld().playSound(loc, Sound.ENTITY_BLAZE_HURT, 2, 1); loc.getWorld().playSound(loc, Sound.ENTITY_BLAZE_HURT, 2, 1);
target.setFireTicks((int) (target.getFireTicks() + data.getModifier("ignite") * 20)); 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(); cancel();
} }
} }

View File

@ -15,7 +15,7 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability; import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult; 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.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.api.util.NoInteractItemEntity; import net.Indyuce.mmoitems.api.util.NoInteractItemEntity;
import net.Indyuce.mmoitems.stat.data.AbilityData; 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)); loc.setYaw((float) (loc.getYaw() + (random.nextDouble() - .5) * 30));
if (j % 5 == 0) if (j % 5 == 0)
for (Entity ent : MMOUtils.getNearbyChunkEntities(loc)) for (Entity entity : MMOUtils.getNearbyChunkEntities(loc))
if (ent.getLocation().distanceSquared(loc) < 40) 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))
if (stats.getPlayer().getEyeLocation().getDirection().angle(ent.getLocation().toVector().subtract(stats.getPlayer().getLocation().toVector())) < Math.PI / 6) new AttackResult(dps, DamageType.SKILL, DamageType.MAGICAL, DamageType.PROJECTILE).applyEffectsAndDamage(stats, null, (LivingEntity) entity);
if (MMOUtils.canDamage(stats.getPlayer(), ent))
MMOItems.plugin.getDamage().damage(stats, (LivingEntity) ent, dps, DamageType.SKILL, DamageType.MAGICAL);
loc.getWorld().playSound(loc, Sound.ENTITY_ZOMBIE_HURT, 1, 1); loc.getWorld().playSound(loc, Sound.ENTITY_ZOMBIE_HURT, 1, 1);

View File

@ -9,11 +9,10 @@ import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability; import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult; 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.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.stat.data.AbilityData; import net.Indyuce.mmoitems.stat.data.AbilityData;
@ -29,7 +28,7 @@ public class Thrust extends Ability {
@Override @Override
public void whenCast(TemporaryStats stats, LivingEntity target, AbilityData data, AttackResult result) { 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().getWorld().playSound(stats.getPlayer().getLocation(), Sound.ENTITY_ZOMBIE_ATTACK_IRON_DOOR, 1, 0);
stats.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 2, 3)); stats.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 2, 3));
@ -40,7 +39,7 @@ public class Thrust extends Ability {
loc.add(vec); loc.add(vec);
for (Entity entity : MMOUtils.getNearbyChunkEntities(loc)) for (Entity entity : MMOUtils.getNearbyChunkEntities(loc))
if (MMOUtils.canDamage(stats.getPlayer(), loc, entity)) 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); loc.getWorld().spawnParticle(Particle.SMOKE_LARGE, loc, 0);
} }
} }

View File

@ -11,7 +11,7 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability; import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult; 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.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.stat.data.AbilityData; import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.Indyuce.mmoitems.version.VersionSound; import net.Indyuce.mmoitems.version.VersionSound;
@ -36,7 +36,7 @@ public class Arcane_Hail extends Ability {
return; return;
} }
double damage1 = data.getModifier("damage"); double damage = data.getModifier("damage");
double duration = data.getModifier("duration"); double duration = data.getModifier("duration");
double radius = data.getModifier("radius"); 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); loc1.getWorld().playSound(loc1, VersionSound.ENTITY_ENDERMAN_HURT.toSound(), 1, 0);
for (Entity entity : MMOUtils.getNearbyChunkEntities(loc1)) for (Entity entity : MMOUtils.getNearbyChunkEntities(loc1))
if (MMOUtils.canDamage(stats.getPlayer(), entity) && entity.getLocation().distanceSquared(loc1) <= 4) 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.SPELL_WITCH, loc1, 12, 0, 0, 0, .1);
loc1.getWorld().spawnParticle(Particle.SMOKE_NORMAL, loc1, 6, 0, 0, 0, .1); loc1.getWorld().spawnParticle(Particle.SMOKE_NORMAL, loc1, 6, 0, 0, 0, .1);

View File

@ -16,7 +16,7 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability; import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult; 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.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.stat.data.AbilityData; import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.Indyuce.mmoitems.version.VersionSound; import net.Indyuce.mmoitems.version.VersionSound;
@ -41,7 +41,7 @@ public class Arcane_Rift extends Ability {
return; return;
} }
double damage1 = data.getModifier("damage"); double damage = data.getModifier("damage");
double slowDuration = data.getModifier("duration"); double slowDuration = data.getModifier("duration");
double slowAmplifier = data.getModifier("amplifier"); double slowAmplifier = data.getModifier("amplifier");
@ -62,7 +62,7 @@ public class Arcane_Rift extends Ability {
for (Entity entity : MMOUtils.getNearbyChunkEntities(loc)) for (Entity entity : MMOUtils.getNearbyChunkEntities(loc))
if (MMOUtils.canDamage(stats.getPlayer(), entity) && loc.distanceSquared(entity.getLocation()) < 2 && !hit.contains(entity.getEntityId())) { if (MMOUtils.canDamage(stats.getPlayer(), entity) && loc.distanceSquared(entity.getLocation()) < 2 && !hit.contains(entity.getEntityId())) {
hit.add(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)); ((LivingEntity) entity).addPotionEffect(new PotionEffect(PotionEffectType.SLOW, (int) (slowDuration * 20), (int) slowAmplifier));
} }
} }

View File

@ -10,7 +10,7 @@ import org.bukkit.scheduler.BukkitRunnable;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Ability; import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult; 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.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.stat.data.AbilityData; 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); target.getWorld().spawnParticle(Particle.SPELL_MOB, target.getLocation(), 4, .2, 0, .2, 0);
if (ti % 20 == 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); }.runTaskTimer(MMOItems.plugin, 0, 1);
target.getWorld().playSound(target.getLocation(), Sound.ENTITY_BLAZE_HURT, 1, 2); target.getWorld().playSound(target.getLocation(), Sound.ENTITY_BLAZE_HURT, 1, 2);

View File

@ -7,11 +7,10 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability; import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.AttackResult; 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.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.stat.data.AbilityData; import net.Indyuce.mmoitems.stat.data.AbilityData;
@ -45,7 +44,7 @@ public class Minor_Explosion extends Ability {
for (Entity entity : MMOUtils.getNearbyChunkEntities(loc)) for (Entity entity : MMOUtils.getNearbyChunkEntities(loc))
if (entity.getLocation().distanceSquared(loc) < radiusSquared && MMOUtils.canDamage(stats.getPlayer(), entity)) { 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)); entity.setVelocity(normalizeIfNotNull(entity.getLocation().subtract(loc).toVector().setY(0)).setY(.2).multiply(2 * knockback));
} }
} }

View File

@ -1,7 +1,11 @@
package net.Indyuce.mmoitems.api; package net.Indyuce.mmoitems.api;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random; import java.util.Random;
import org.apache.commons.lang.Validate;
import org.bukkit.Particle; import org.bukkit.Particle;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
@ -9,9 +13,6 @@ import org.bukkit.entity.Player;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Ability.CastingMode; 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.item.NBTItem;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats; import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.stat.type.ItemStat; import net.Indyuce.mmoitems.stat.type.ItemStat;
@ -20,31 +21,43 @@ public class AttackResult {
private final double initial; private final double initial;
private double damage; private double damage;
private boolean successful, untargetedWeapon; private boolean successful;
private final List<DamageType> damageTypes;
private static final Random random = new Random(); private static final Random random = new Random();
public AttackResult(boolean successful) { public AttackResult(boolean successful, DamageType... types) {
this(successful, 0); this(successful, 0, types);
} }
public AttackResult(Weapon weapon, double damage) { public AttackResult(double damage, DamageType... types) {
this(true, damage); this(true, damage, types);
this.untargetedWeapon = weapon != null && weapon instanceof UntargetedWeapon;
} }
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.successful = successful;
this.damage = damage;
this.initial = damage; this.initial = damage;
this.damage = damage;
this.damageTypes = Arrays.asList(types);
} }
public AttackResult(AttackResult result) { public AttackResult(AttackResult result) {
initial = result.initial; initial = result.initial;
damage = result.damage; damage = result.damage;
successful = result.successful; 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() { public boolean isSuccessful() {
@ -81,8 +94,38 @@ public class AttackResult {
return new AttackResult(this); return new AttackResult(this);
} }
public void applyEffectsAndDamage(TemporaryStats stats, NBTItem item, LivingEntity target, DamageType... types) { public void damage(TemporaryStats stats, LivingEntity target) {
MMOItems.plugin.getDamage().damage(stats, target, applyEffects(stats, item, target).damage, types); 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) { public AttackResult applyElementalEffects(TemporaryStats stats, NBTItem item, LivingEntity target) {
@ -90,29 +133,21 @@ public class AttackResult {
return this; 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 * vanilla melee weapons have no NBTTitems so this method only provides for
* non-weapon specific effects like critical strikes and extra stat damage * 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 // abilities
if (untargetedWeapon)
stats.getPlayerData().castAbilities(stats, target, this, CastingMode.ON_HIT); stats.getPlayerData().castAbilities(stats, target, this, CastingMode.ON_HIT);
// extra damage // 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(target instanceof Player ? ItemStat.PVP_DAMAGE : ItemStat.PVE_DAMAGE) / 100);
addRelativeDamage(stats.getStat(ItemStat.WEAPON_DAMAGE) / 100);
if (MMOItems.plugin.getDamage().isUndead(target)) if (MMOItems.plugin.getDamage().isUndead(target))
addRelativeDamage(stats.getStat(ItemStat.UNDEAD_DAMAGE) / 100); addRelativeDamage(stats.getStat(ItemStat.UNDEAD_DAMAGE) / 100);
@ -125,4 +160,42 @@ public class AttackResult {
return this; 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;
}
}
} }

View File

@ -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;
}
}

View File

@ -18,7 +18,7 @@ import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; 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.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.listener.ElementListener; import net.Indyuce.mmoitems.listener.ElementListener;
import net.Indyuce.mmoitems.version.VersionMaterial; 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); target.getWorld().playSound(target.getLocation(), VersionSound.ENTITY_FIREWORK_ROCKET_LARGE_BLAST.toSound(), 2, 0);
for (Entity entity : target.getNearbyEntities(3, 2, 3)) for (Entity entity : target.getNearbyEntities(3, 2, 3))
if (MMOUtils.canDamage(stats.getPlayer(), entity)) 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); result.addDamage(absolute);
for (double k = 0; k < Math.PI * 2; k += Math.PI / 16) for (double k = 0; k < Math.PI * 2; k += Math.PI / 16)

View File

@ -12,7 +12,6 @@ import org.bukkit.potion.PotionEffectType;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; 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.interaction.weapon.Weapon;
import net.Indyuce.mmoitems.api.player.PlayerData.CooldownType; import net.Indyuce.mmoitems.api.player.PlayerData.CooldownType;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats; import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
@ -39,7 +38,7 @@ public enum TypeSet {
for (Entity entity : MMOUtils.getNearbyChunkEntities(loc)) 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)) 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)) 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)) 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; 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)) for (Entity entity : target.getNearbyEntities(bluntPower, bluntPower, bluntPower))
if (MMOUtils.canDamage(stats.getPlayer(), entity) && !entity.equals(target)) 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);
} }
} }

View File

@ -14,7 +14,7 @@ import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.AttackResult; 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.Type;
import net.Indyuce.mmoitems.api.item.NBTItem; import net.Indyuce.mmoitems.api.item.NBTItem;
import net.Indyuce.mmoitems.api.player.PlayerData.CooldownType; import net.Indyuce.mmoitems.api.player.PlayerData.CooldownType;
@ -44,7 +44,7 @@ public class Lute extends UntargetedWeapon {
LuteAttackEffect effect = LuteAttackEffect.get(getNBTItem()); LuteAttackEffect effect = LuteAttackEffect.get(getNBTItem());
Sound sound = new SoundReader(getNBTItem().getString("MMOITEMS_LUTE_ATTACK_SOUND"), VersionSound.BLOCK_NOTE_BLOCK_BELL.toSound()).getSound(); Sound sound = new SoundReader(getNBTItem().getString("MMOITEMS_LUTE_ATTACK_SOUND"), VersionSound.BLOCK_NOTE_BLOCK_BELL.toSound()).getSound();
if (effect != null) { if (effect != null) {
effect.getAttack().handle( stats, getNBTItem(), attackDamage, range, untargeted, weight, sound); effect.getAttack().handle(stats, getNBTItem(), attackDamage, range, weight, sound);
return; return;
} }
@ -69,7 +69,7 @@ public class Lute extends UntargetedWeapon {
for (Entity target : entities) for (Entity target : entities)
if (MMOUtils.canDamage(getPlayer(), loc, target)) { 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(); cancel();
return; return;
} }

View File

@ -8,7 +8,7 @@ import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.AttackResult; 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.Type;
import net.Indyuce.mmoitems.api.item.NBTItem; import net.Indyuce.mmoitems.api.item.NBTItem;
import net.Indyuce.mmoitems.api.player.PlayerData.CooldownType; 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); MMORayTraceResult trace = MMOItems.plugin.getVersion().getVersionWrapper().rayTrace(stats.getPlayer(), vec, range);
if (trace.hasHit()) 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); trace.draw(loc, vec, 2, Color.BLACK);
getPlayer().getWorld().playSound(getPlayer().getLocation(), Sound.ENTITY_ZOMBIE_ATTACK_IRON_DOOR, 2, 2); getPlayer().getWorld().playSound(getPlayer().getLocation(), Sound.ENTITY_ZOMBIE_ATTACK_IRON_DOOR, 2, 2);
} }

View File

@ -10,7 +10,7 @@ import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.AttackResult; 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.Type;
import net.Indyuce.mmoitems.api.item.NBTItem; import net.Indyuce.mmoitems.api.item.NBTItem;
import net.Indyuce.mmoitems.api.player.PlayerData.CooldownType; import net.Indyuce.mmoitems.api.player.PlayerData.CooldownType;
@ -37,7 +37,7 @@ public class Staff extends UntargetedWeapon {
StaffSpirit spirit = StaffSpirit.get(getNBTItem()); StaffSpirit spirit = StaffSpirit.get(getNBTItem());
if (spirit != null) { if (spirit != null) {
spirit.getAttack().handle(stats, getNBTItem(), attackDamage, range, untargeted); spirit.getAttack().handle(stats, getNBTItem(), attackDamage, range);
return; return;
} }
@ -46,7 +46,7 @@ public class Staff extends UntargetedWeapon {
MMORayTraceResult trace = MMOItems.plugin.getVersion().getVersionWrapper().rayTrace(stats.getPlayer(), range); MMORayTraceResult trace = MMOItems.plugin.getVersion().getVersionWrapper().rayTrace(stats.getPlayer(), range);
if (trace.hasHit()) 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)); 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); getPlayer().getWorld().playSound(getPlayer().getLocation(), VersionSound.ENTITY_FIREWORK_ROCKET_TWINKLE.toSound(), 2, 2);
} }

View File

@ -12,11 +12,6 @@ import net.Indyuce.mmoitems.api.item.NBTItem;
public abstract class UntargetedWeapon extends Weapon { 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; protected final WeaponType weaponType;
public UntargetedWeapon(Player player, NBTItem item, Type type, WeaponType weaponType) { public UntargetedWeapon(Player player, NBTItem item, Type type, WeaponType weaponType) {

View File

@ -7,7 +7,7 @@ import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.AttackResult; 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.Type;
import net.Indyuce.mmoitems.api.item.NBTItem; import net.Indyuce.mmoitems.api.item.NBTItem;
import net.Indyuce.mmoitems.api.player.PlayerData.CooldownType; 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); MMORayTraceResult trace = MMOItems.plugin.getVersion().getVersionWrapper().rayTrace(stats.getPlayer(), range);
if (trace.hasHit()) 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)); 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); getPlayer().getWorld().playSound(getPlayer().getLocation(), VersionSound.ENTITY_FIREWORK_ROCKET_BLAST.toSound(), 1, 2);
} }

View File

@ -13,15 +13,14 @@ import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.AttackResult; 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.interaction.weapon.untargeted.UntargetedWeapon;
import net.Indyuce.mmoitems.api.item.NBTItem; import net.Indyuce.mmoitems.api.item.NBTItem;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats; import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
public class BruteLuteAttack implements LuteAttackHandler { public class BruteLuteAttack implements LuteAttackHandler {
@Override @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() { new BukkitRunnable() {
Vector vec = stats.getPlayer().getEyeLocation().getDirection().multiply(.4); Vector vec = stats.getPlayer().getEyeLocation().getDirection().multiply(.4);
Location loc = stats.getPlayer().getEyeLocation(); Location loc = stats.getPlayer().getEyeLocation();
@ -44,7 +43,7 @@ public class BruteLuteAttack implements LuteAttackHandler {
for (Entity target : entities) for (Entity target : entities)
if (MMOUtils.canDamage(stats.getPlayer(), loc, target)) { 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(); cancel();
return; return;
} }

View File

@ -13,15 +13,14 @@ import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.AttackResult; 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.interaction.weapon.untargeted.UntargetedWeapon;
import net.Indyuce.mmoitems.api.item.NBTItem; import net.Indyuce.mmoitems.api.item.NBTItem;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats; import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
public class CircularLuteAttack implements LuteAttackHandler { public class CircularLuteAttack implements LuteAttackHandler {
@Override @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() { new BukkitRunnable() {
Vector vec = stats.getPlayer().getEyeLocation().getDirection().multiply(.4); Vector vec = stats.getPlayer().getEyeLocation().getDirection().multiply(.4);
Location loc = stats.getPlayer().getEyeLocation(); Location loc = stats.getPlayer().getEyeLocation();
@ -47,7 +46,7 @@ public class CircularLuteAttack implements LuteAttackHandler {
for (Entity target : entities) for (Entity target : entities)
if (MMOUtils.canDamage(stats.getPlayer(), loc, target)) { 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(); cancel();
return; return;
} }

View File

@ -5,12 +5,11 @@ import java.util.Random;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.util.Vector; 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.item.NBTItem;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats; import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
public interface LuteAttackHandler { 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(); static final Random random = new Random();
} }

View File

@ -13,15 +13,14 @@ import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.AttackResult; 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.interaction.weapon.untargeted.UntargetedWeapon;
import net.Indyuce.mmoitems.api.item.NBTItem; import net.Indyuce.mmoitems.api.item.NBTItem;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats; import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
public class SimpleLuteAttack implements LuteAttackHandler { public class SimpleLuteAttack implements LuteAttackHandler {
@Override @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() { new BukkitRunnable() {
Vector vec = stats.getPlayer().getEyeLocation().getDirection().multiply(.4); Vector vec = stats.getPlayer().getEyeLocation().getDirection().multiply(.4);
Location loc = stats.getPlayer().getEyeLocation(); Location loc = stats.getPlayer().getEyeLocation();
@ -44,7 +43,7 @@ public class SimpleLuteAttack implements LuteAttackHandler {
for (Entity target : entities) for (Entity target : entities)
if (MMOUtils.canDamage(stats.getPlayer(), loc, target)) { 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(); cancel();
return; return;
} }

View File

@ -11,15 +11,14 @@ import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.AttackResult; 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.interaction.weapon.untargeted.UntargetedWeapon;
import net.Indyuce.mmoitems.api.item.NBTItem; import net.Indyuce.mmoitems.api.item.NBTItem;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats; import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
public class SlashLuteAttack implements LuteAttackHandler { public class SlashLuteAttack implements LuteAttackHandler {
@Override @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() { new BukkitRunnable() {
final Vector vec = stats.getPlayer().getEyeLocation().getDirection(); final Vector vec = stats.getPlayer().getEyeLocation().getDirection();
Location loc = stats.getPlayer().getLocation().add(0, 1.3, 0); 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())) 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)) 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);
} }
} }

View File

@ -13,15 +13,14 @@ import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.AttackResult; 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.interaction.weapon.untargeted.UntargetedWeapon;
import net.Indyuce.mmoitems.api.item.NBTItem; import net.Indyuce.mmoitems.api.item.NBTItem;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats; import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
public class WaveLuteAttack implements LuteAttackHandler { public class WaveLuteAttack implements LuteAttackHandler {
@Override @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() { new BukkitRunnable() {
Vector vec = stats.getPlayer().getEyeLocation().getDirection().multiply(.4); Vector vec = stats.getPlayer().getEyeLocation().getDirection().multiply(.4);
Location loc = stats.getPlayer().getEyeLocation(); Location loc = stats.getPlayer().getEyeLocation();
@ -46,7 +45,7 @@ public class WaveLuteAttack implements LuteAttackHandler {
for (Entity target : entities) for (Entity target : entities)
if (MMOUtils.canDamage(stats.getPlayer(), loc, target)) { 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(); cancel();
return; return;
} }

View File

@ -8,8 +8,7 @@ import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.AttackResult; 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.interaction.weapon.untargeted.UntargetedWeapon;
import net.Indyuce.mmoitems.api.item.NBTItem; import net.Indyuce.mmoitems.api.item.NBTItem;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats; import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.version.VersionSound; import net.Indyuce.mmoitems.version.VersionSound;
@ -17,7 +16,7 @@ import net.Indyuce.mmoitems.version.VersionSound;
public class LightningSpirit implements StaffAttackHandler { public class LightningSpirit implements StaffAttackHandler {
@Override @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); stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(), VersionSound.ENTITY_FIREWORK_ROCKET_BLAST.toSound(), 2, 2);
Location loc = stats.getPlayer().getEyeLocation(); Location loc = stats.getPlayer().getEyeLocation();
Vector vec = stats.getPlayer().getEyeLocation().getDirection().multiply(.75); 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); loc.getWorld().spawnParticle(Particle.FIREWORKS_SPARK, loc, 0);
for (Entity target : MMOUtils.getNearbyChunkEntities(loc)) for (Entity target : MMOUtils.getNearbyChunkEntities(loc))
if (MMOUtils.canDamage(stats.getPlayer(), loc, target)) { 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); loc.getWorld().spawnParticle(Particle.EXPLOSION_NORMAL, loc, 16, 0, 0, 0, .1);
return; return;
} }

View File

@ -14,15 +14,14 @@ import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.AttackResult; 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.interaction.weapon.untargeted.UntargetedWeapon;
import net.Indyuce.mmoitems.api.item.NBTItem; import net.Indyuce.mmoitems.api.item.NBTItem;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats; import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
public class ManaSpirit implements StaffAttackHandler { public class ManaSpirit implements StaffAttackHandler {
@Override @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() { new BukkitRunnable() {
Vector vec = stats.getPlayer().getEyeLocation().getDirection().multiply(.4); Vector vec = stats.getPlayer().getEyeLocation().getDirection().multiply(.4);
Location loc = stats.getPlayer().getEyeLocation(); Location loc = stats.getPlayer().getEyeLocation();
@ -51,7 +50,7 @@ public class ManaSpirit implements StaffAttackHandler {
} }
for (Entity target : targets) for (Entity target : targets)
if (MMOUtils.canDamage(stats.getPlayer(), loc, target)) { 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); loc.getWorld().spawnParticle(Particle.EXPLOSION_LARGE, loc, 0);
cancel(); cancel();
return; return;

View File

@ -13,15 +13,14 @@ import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.AttackResult; 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.interaction.weapon.untargeted.UntargetedWeapon;
import net.Indyuce.mmoitems.api.item.NBTItem; import net.Indyuce.mmoitems.api.item.NBTItem;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats; import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
public class NetherSpirit implements StaffAttackHandler { public class NetherSpirit implements StaffAttackHandler {
@Override @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() { new BukkitRunnable() {
Vector vec = stats.getPlayer().getEyeLocation().getDirection().multiply(.3); Vector vec = stats.getPlayer().getEyeLocation().getDirection().multiply(.3);
Location loc = stats.getPlayer().getEyeLocation(); Location loc = stats.getPlayer().getEyeLocation();
@ -43,7 +42,7 @@ public class NetherSpirit implements StaffAttackHandler {
loc.getWorld().spawnParticle(Particle.SMOKE_NORMAL, loc, 0); loc.getWorld().spawnParticle(Particle.SMOKE_NORMAL, loc, 0);
for (Entity target : targets) for (Entity target : targets)
if (MMOUtils.canDamage(stats.getPlayer(), loc, target)) { 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); loc.getWorld().spawnParticle(Particle.EXPLOSION_LARGE, loc, 0);
cancel(); cancel();
return; return;

View File

@ -4,12 +4,11 @@ import java.util.Random;
import org.bukkit.Location; 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.item.NBTItem;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats; import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
public interface StaffAttackHandler { 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(); static final Random random = new Random();

View File

@ -14,8 +14,7 @@ import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.AttackResult; 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.interaction.weapon.untargeted.UntargetedWeapon;
import net.Indyuce.mmoitems.api.item.NBTItem; import net.Indyuce.mmoitems.api.item.NBTItem;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats; import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.version.VersionSound; import net.Indyuce.mmoitems.version.VersionSound;
@ -23,7 +22,7 @@ import net.Indyuce.mmoitems.version.VersionSound;
public class SunfireSpirit implements StaffAttackHandler { public class SunfireSpirit implements StaffAttackHandler {
@Override @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); stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(), Sound.ENTITY_WITHER_SHOOT, 2, 2);
new BukkitRunnable() { new BukkitRunnable() {
Location target = getGround(stats.getPlayer().getTargetBlock((Set<Material>) null, (int) range * 2).getLocation()).add(0, 1.2, 0); 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); loc.getWorld().playSound(loc, VersionSound.ENTITY_FIREWORK_ROCKET_BLAST.toSound(), 2, 2);
for (Entity target : MMOUtils.getNearbyChunkEntities(loc)) for (Entity target : MMOUtils.getNearbyChunkEntities(loc))
if (MMOUtils.canDamage(stats.getPlayer(), target) && target.getLocation().distanceSquared(loc) <= 9) 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(); cancel();
break; break;
} }

View File

@ -14,8 +14,7 @@ import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.AttackResult; 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.interaction.weapon.untargeted.UntargetedWeapon;
import net.Indyuce.mmoitems.api.item.NBTItem; import net.Indyuce.mmoitems.api.item.NBTItem;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats; import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.version.VersionSound; import net.Indyuce.mmoitems.version.VersionSound;
@ -23,7 +22,7 @@ import net.Indyuce.mmoitems.version.VersionSound;
public class ThunderSpirit implements StaffAttackHandler { public class ThunderSpirit implements StaffAttackHandler {
@Override @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); stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(), Sound.ENTITY_WITHER_SHOOT, 2, 2);
new BukkitRunnable() { new BukkitRunnable() {
Location target = getGround(stats.getPlayer().getTargetBlock((Set<Material>) null, (int) range * 2).getLocation()).add(0, 1.2, 0); 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); loc.getWorld().playSound(loc, VersionSound.ENTITY_FIREWORK_ROCKET_BLAST.toSound(), 2, 2);
for (Entity target : MMOUtils.getNearbyChunkEntities(loc)) for (Entity target : MMOUtils.getNearbyChunkEntities(loc))
if (MMOUtils.canDamage(stats.getPlayer(), target) && target.getLocation().distanceSquared(loc) <= 9) 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(); cancel();
} }
} }

View File

@ -7,14 +7,15 @@ import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems; 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.item.NBTItem;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats; import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
public class VoidSpirit implements StaffAttackHandler { public class VoidSpirit implements StaffAttackHandler {
@Override @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(); Vector vec = stats.getPlayer().getEyeLocation().getDirection();
stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(), Sound.ENTITY_WITHER_SHOOT, 2, 2); 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")); 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); shulkerBullet.setVelocity(vec);
} }
}.runTaskTimer(MMOItems.plugin, 0, 1); }.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);
} }
} }

View File

@ -7,8 +7,7 @@ import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.AttackResult; 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.interaction.weapon.untargeted.UntargetedWeapon;
import net.Indyuce.mmoitems.api.item.NBTItem; import net.Indyuce.mmoitems.api.item.NBTItem;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats; import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.api.util.MMORayTraceResult; import net.Indyuce.mmoitems.api.util.MMORayTraceResult;
@ -16,7 +15,7 @@ import net.Indyuce.mmoitems.api.util.MMORayTraceResult;
public class XRaySpirit implements StaffAttackHandler { public class XRaySpirit implements StaffAttackHandler {
@Override @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); stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(), Sound.BLOCK_FIRE_EXTINGUISH, 2, 2);
double a = Math.toRadians(stats.getPlayer().getEyeLocation().getYaw() + 160); 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); MMORayTraceResult trace = MMOItems.plugin.getVersion().getVersionWrapper().rayTrace(stats.getPlayer(), range);
if (trace.hasHit()) 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); 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); stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(), Sound.ENTITY_ZOMBIE_ATTACK_IRON_DOOR, 2, 2);
} }

View File

@ -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;
import net.Indyuce.mmocore.comp.rpg.damage.DamageInfo.DamageType; import net.Indyuce.mmocore.comp.rpg.damage.DamageInfo.DamageType;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.AttackResult;
public class MMOCoreDamageHandler implements DamageHandler { public class MMOCoreDamageHandler implements DamageHandler {
@Override @Override
public DamageInfo getDamage(Entity entity) { public DamageInfo getDamage(Entity entity) {
net.Indyuce.mmoitems.api.DamageInfo mmoitemsInfo = MMOItems.plugin.getDamage().getDamage(entity); AttackResult result = MMOItems.plugin.getDamage().getDamage(entity);
return new DamageInfo(mmoitemsInfo.getValue(), mmoitemsInfo.getTypes().stream().map((type) -> DamageType.valueOf(type.name())).collect(Collectors.toSet())); return new DamageInfo(result.getDamage(), result.getTypes().stream().map((type) -> DamageType.valueOf(type.name())).collect(Collectors.toSet()));
} }
@Override @Override

View File

@ -25,7 +25,6 @@ import org.bukkit.inventory.EquipmentSlot;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability.CastingMode;
import net.Indyuce.mmoitems.api.AttackResult; import net.Indyuce.mmoitems.api.AttackResult;
import net.Indyuce.mmoitems.api.Message; import net.Indyuce.mmoitems.api.Message;
import net.Indyuce.mmoitems.api.Type; 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 * cast on-hit abilities and add the extra damage to the damage event
*/ */
result.applyEffects(stats == null ? stats = playerData.getStats().newTemporary() : stats, target); result.applyOnHitEffects(stats == null ? stats = playerData.getStats().newTemporary() : stats, target);
playerData.castAbilities(stats, target, result, CastingMode.ON_HIT);
event.setDamage(result.getDamage()); event.setDamage(result.getDamage());
} }

View File

@ -15,58 +15,45 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import net.Indyuce.mmoitems.api.DamageInfo; import net.Indyuce.mmoitems.api.AttackResult;
import net.Indyuce.mmoitems.api.DamageInfo.DamageType;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
import net.Indyuce.mmoitems.stat.type.ItemStat;
public class DamageManager implements Listener { 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) { public boolean isDamaged(Entity entity) {
return customDamage.containsKey(entity.getEntityId()); return customDamage.containsKey(entity.getEntityId());
} }
public DamageInfo getDamage(Entity entity) { public AttackResult getDamage(Entity entity) {
return customDamage.get(entity.getEntityId()); return customDamage.get(entity.getEntityId());
} }
public void damage(TemporaryStats playerStats, LivingEntity target, double value, DamageType... types) { public void damage(Player player, LivingEntity target, AttackResult result) {
damage(playerStats, target, value, true, types); damage(player, target, result, true);
} }
public void damage(TemporaryStats playerStats, LivingEntity target, double value, boolean knockback, DamageType... types) { public void damage(Player player, LivingEntity target, AttackResult result, boolean knockback) {
if (target.hasMetadata("NPC") || playerStats.getPlayer().hasMetadata("NPC")) if (target.hasMetadata("NPC") || player.hasMetadata("NPC"))
return; return;
/* /*
* calculate extra damage depending on the type of attack and the entity * calculate extra damage depending on the type of attack and the entity
* that is being damaged * that is being damaged
*/ */
DamageInfo info = new DamageInfo(value, types); customDamage.put(target.getEntityId(), result);
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);
if (!knockback) { if (!knockback) {
final double baseKnockbackValue = target.getAttribute(Attribute.GENERIC_KNOCKBACK_RESISTANCE).getBaseValue(); final double baseKnockbackValue = target.getAttribute(Attribute.GENERIC_KNOCKBACK_RESISTANCE).getBaseValue();
target.getAttribute(Attribute.GENERIC_KNOCKBACK_RESISTANCE).setBaseValue(63); target.getAttribute(Attribute.GENERIC_KNOCKBACK_RESISTANCE).setBaseValue(63);
try { try {
target.damage(value, playerStats.getPlayer()); target.damage(result.getDamage(), player);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
target.getAttribute(Attribute.GENERIC_KNOCKBACK_RESISTANCE).setBaseValue(baseKnockbackValue); 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) { public boolean isUndead(Entity entity) {

View File

@ -16,9 +16,9 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityDeathEvent;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Ability.CastingMode;
import net.Indyuce.mmoitems.api.ArrowParticles; import net.Indyuce.mmoitems.api.ArrowParticles;
import net.Indyuce.mmoitems.api.AttackResult; import net.Indyuce.mmoitems.api.AttackResult;
import net.Indyuce.mmoitems.api.AttackResult.DamageType;
import net.Indyuce.mmoitems.api.ProjectileData; import net.Indyuce.mmoitems.api.ProjectileData;
import net.Indyuce.mmoitems.api.item.NBTItem; import net.Indyuce.mmoitems.api.item.NBTItem;
import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats; import net.Indyuce.mmoitems.api.player.PlayerStats.TemporaryStats;
@ -109,12 +109,10 @@ public class EntityManager implements Listener {
LivingEntity target = (LivingEntity) event.getEntity(); LivingEntity target = (LivingEntity) event.getEntity();
TemporaryStats stats = data.getPlayerStats(); 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()) if (data.isCustomWeapon())
result.applyElementalEffects(stats, data.getSourceItem(), target); result.applyElementalEffects(stats, data.getSourceItem(), target);
stats.getPlayerData().castAbilities(target, result, CastingMode.ON_HIT);
if (data.getSourceItem().getItem().hasItemMeta()) if (data.getSourceItem().getItem().hasItemMeta())
if (data.getSourceItem().getItem().getItemMeta().getEnchants().containsKey(Enchantment.ARROW_DAMAGE)) if (data.getSourceItem().getItem().getItemMeta().getEnchants().containsKey(Enchantment.ARROW_DAMAGE))
result.addRelativeDamage(.25 + (.25 * data.getSourceItem().getItem().getItemMeta().getEnchantLevel(Enchantment.ARROW_DAMAGE))); result.addRelativeDamage(.25 + (.25 * data.getSourceItem().getItem().getItemMeta().getEnchantLevel(Enchantment.ARROW_DAMAGE)));

View File

@ -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 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_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 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 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 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 SKILL_DAMAGE = new DoubleStat(new ItemStack(Material.BOOK), "Skill Damage", new String[] { "Additional ability damage in %." }, "skill-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", new String[] { "!miscellaneous", "all" }); 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 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 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_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 PHYSICAL_DAMAGE = new DoubleStat(new ItemStack(Material.IRON_AXE), "Physical Damage", new String[] { "Additional skill/weapon physical damage." }, "physical-damage");
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 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 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 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 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 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 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 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 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 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" }); 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" });

View File

@ -34,6 +34,8 @@ lore-format:
- '#blunt-rating#' - '#blunt-rating#'
- '#weapon-damage#' - '#weapon-damage#'
- '#magic-damage#' - '#magic-damage#'
- '#physical-damage#'
- '#projectile-damage#'
- '#damage-reduction#' - '#damage-reduction#'
- '#fall-damage-reduction#' - '#fall-damage-reduction#'
- '#fire-damage-reduction#' - '#fire-damage-reduction#'

View File

@ -34,6 +34,8 @@ lore-format:
- '#blunt-rating#' - '#blunt-rating#'
- '#weapon-damage#' - '#weapon-damage#'
- '#magic-damage#' - '#magic-damage#'
- '#physical-damage#'
- '#projectile-damage#'
- '#damage-reduction#' - '#damage-reduction#'
- '#fall-damage-reduction#' - '#fall-damage-reduction#'
- '#fire-damage-reduction#' - '#fire-damage-reduction#'

View File

@ -34,6 +34,8 @@ lore-format:
- '#blunt-rating#' - '#blunt-rating#'
- '#weapon-damage#' - '#weapon-damage#'
- '#magic-damage#' - '#magic-damage#'
- '#physical-damage#'
- '#projectile-damage#'
- '#damage-reduction#' - '#damage-reduction#'
- '#fall-damage-reduction#' - '#fall-damage-reduction#'
- '#fire-damage-reduction#' - '#fire-damage-reduction#'

View File

@ -34,6 +34,8 @@ lore-format:
- '#blunt-rating#' - '#blunt-rating#'
- '#weapon-damage#' - '#weapon-damage#'
- '#magic-damage#' - '#magic-damage#'
- '#physical-damage#'
- '#projectile-damage#'
- '#damage-reduction#' - '#damage-reduction#'
- '#fall-damage-reduction#' - '#fall-damage-reduction#'
- '#fire-damage-reduction#' - '#fire-damage-reduction#'

View File

@ -33,6 +33,8 @@ lore-format:
- '#blunt-rating#' - '#blunt-rating#'
- '#weapon-damage#' - '#weapon-damage#'
- '#magic-damage#' - '#magic-damage#'
- '#physical-damage#'
- '#projectile-damage#'
- '#damage-reduction#' - '#damage-reduction#'
- '#fall-damage-reduction#' - '#fall-damage-reduction#'
- '#fire-damage-reduction#' - '#fire-damage-reduction#'

View File

@ -34,6 +34,8 @@ lore-format:
- '#blunt-rating#' - '#blunt-rating#'
- '#weapon-damage#' - '#weapon-damage#'
- '#magic-damage#' - '#magic-damage#'
- '#physical-damage#'
- '#projectile-damage#'
- '#damage-reduction#' - '#damage-reduction#'
- '#fall-damage-reduction#' - '#fall-damage-reduction#'
- '#fire-damage-reduction#' - '#fire-damage-reduction#'