!Updated all abilities

This commit is contained in:
Indyuce 2019-12-28 14:13:37 +01:00
parent 8980c933b0
commit 9f89019ad4
70 changed files with 846 additions and 514 deletions

View File

@ -9,8 +9,10 @@ import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.LocationAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.mmogroup.mmolib.version.VersionSound;
@ -27,15 +29,16 @@ public class Black_Hole extends Ability {
}
@Override
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
Location loc = getTargetLocation(stats.getPlayer(), target);
if (loc == null) {
result.setSuccessful(false);
return;
}
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new LocationAbilityResult(ability, stats.getPlayer(), target);
}
double duration = data.getModifier("duration") * 20;
double radius = data.getModifier("radius");
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
Location loc = ((LocationAbilityResult) ability).getTarget();
double duration = ability.getModifier("duration") * 20;
double radius = ability.getModifier("radius");
loc.getWorld().playSound(loc, VersionSound.ENTITY_ENDERMAN_TELEPORT.toSound(), 3, 1);
new BukkitRunnable() {

View File

@ -7,8 +7,10 @@ import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.entity.LivingEntity;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.SimpleAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.mmogroup.mmolib.version.VersionSound;
@ -24,11 +26,16 @@ public class Blink extends Ability {
}
@Override
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new SimpleAbilityResult(ability);
}
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
stats.getPlayer().getWorld().spawnParticle(Particle.EXPLOSION_LARGE, stats.getPlayer().getLocation().add(0, 1, 0), 0);
stats.getPlayer().getWorld().spawnParticle(Particle.SPELL_INSTANT, stats.getPlayer().getLocation().add(0, 1, 0), 32, 0, 0, 0, .1);
stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(), VersionSound.ENTITY_ENDERMAN_TELEPORT.toSound(), 1, 1);
Location loc = stats.getPlayer().getTargetBlock((Set<Material>) null, (int) data.getModifier("range")).getLocation().add(0, 1, 0);
Location loc = stats.getPlayer().getTargetBlock((Set<Material>) null, (int) ability.getModifier("range")).getLocation().add(0, 1, 0);
loc.setYaw(stats.getPlayer().getLocation().getYaw());
loc.setPitch(stats.getPlayer().getLocation().getPitch());
stats.getPlayer().teleport(loc);

View File

@ -11,8 +11,10 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.scheduler.BukkitRunnable;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.SimpleAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
@ -30,14 +32,19 @@ public class Blizzard extends Ability implements Listener {
}
@Override
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
double duration = data.getModifier("duration") * 10;
double force = data.getModifier("force");
double inaccuracy = data.getModifier("inaccuracy");
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new SimpleAbilityResult(ability);
}
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
double duration = ability.getModifier("duration") * 10;
double force = ability.getModifier("force");
double inaccuracy = ability.getModifier("inaccuracy");
new BukkitRunnable() {
int j = 0;
double damage = data.getModifier("damage");
double damage = ability.getModifier("damage");
public void run() {
j++;

View File

@ -10,8 +10,10 @@ import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.VectorAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.mmogroup.mmolib.api.AttackResult;
@ -31,11 +33,16 @@ public class Bouncy_Fireball extends Ability {
}
@Override
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new VectorAbilityResult(ability, stats.getPlayer(), target);
}
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(), Sound.ENTITY_SNOWBALL_THROW, 2, 0);
new BukkitRunnable() {
int j = 0;
Vector vec = getTargetDirection(stats.getPlayer(), target).setY(0).normalize().multiply(.5 * data.getModifier("speed"));
Vector vec = ((VectorAbilityResult) ability).getTarget().setY(0).normalize().multiply(.5 * ability.getModifier("speed"));
Location loc = stats.getPlayer().getLocation().clone().add(0, 1.2, 0);
int bounces = 0;
@ -68,9 +75,9 @@ public class Bouncy_Fireball extends Ability {
}
if (bounces > 2) {
double radius = data.getModifier("radius");
double damage = data.getModifier("damage");
double ignite = data.getModifier("ignite");
double radius = ability.getModifier("radius");
double damage = ability.getModifier("damage");
double ignite = ability.getModifier("ignite");
for (Entity entity : MMOUtils.getNearbyChunkEntities(loc))
if (entity.getLocation().distanceSquared(loc) < radius * radius)

View File

@ -14,8 +14,10 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.scheduler.BukkitRunnable;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.SimpleAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.mmogroup.mmolib.version.VersionSound;
@ -35,10 +37,15 @@ public class Bunny_Mode extends Ability implements Listener {
}
@Override
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
double duration = data.getModifier("duration") * 20;
double y = data.getModifier("jump-force");
double xz = data.getModifier("speed");
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new SimpleAbilityResult(ability);
}
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
double duration = ability.getModifier("duration") * 20;
double y = ability.getModifier("jump-force");
double xz = ability.getModifier("speed");
new BukkitRunnable() {
int j = 0;

View File

@ -11,8 +11,10 @@ import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.SimpleAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.mmogroup.mmolib.api.AttackResult;
@ -30,9 +32,14 @@ public class Burning_Hands extends Ability implements Listener {
}
@Override
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
double duration = data.getModifier("duration") * 10;
double damage = data.getModifier("damage") / 2;
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new SimpleAbilityResult(ability);
}
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
double duration = ability.getModifier("duration") * 10;
double damage = ability.getModifier("damage") / 2;
new BukkitRunnable() {
int j = 0;

View File

@ -10,8 +10,10 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.scheduler.BukkitRunnable;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.SimpleAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
@ -29,14 +31,19 @@ public class Chicken_Wraith extends Ability implements Listener {
}
@Override
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
double duration = data.getModifier("duration") * 10;
double force = data.getModifier("force");
double inaccuracy = data.getModifier("inaccuracy");
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new SimpleAbilityResult(ability);
}
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
double duration = ability.getModifier("duration") * 10;
double force = ability.getModifier("force");
double inaccuracy = ability.getModifier("inaccuracy");
new BukkitRunnable() {
int j = 0;
double damage = data.getModifier("damage");
double damage = ability.getModifier("damage");
public void run() {
j++;

View File

@ -10,8 +10,10 @@ import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.SimpleAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.mmogroup.mmolib.api.AttackResult;
@ -30,10 +32,15 @@ public class Circular_Slash extends Ability {
}
@Override
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
double damage = data.getModifier("damage");
double radius = data.getModifier("radius");
double knockback = data.getModifier("knockback");
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new SimpleAbilityResult(ability);
}
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
double damage = ability.getModifier("damage");
double radius = ability.getModifier("radius");
double knockback = ability.getModifier("knockback");
stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(), Sound.ENTITY_ZOMBIE_ATTACK_IRON_DOOR, 2, .5f);
stats.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 2, 254));

View File

@ -9,8 +9,10 @@ import org.bukkit.scheduler.BukkitRunnable;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.LocationAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.mmogroup.mmolib.MMOLib;
@ -30,20 +32,21 @@ public class Contamination extends Ability {
}
@Override
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
Location loc = getTargetLocation(stats.getPlayer(), target);
if (loc == null) {
result.setSuccessful(false);
return;
}
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new LocationAbilityResult(ability, stats.getPlayer(), target);
}
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
Location loc = ((LocationAbilityResult) ability).getTarget();
double duration = Math.min(30, data.getModifier("duration")) * 20;
double duration = Math.min(30, ability.getModifier("duration")) * 20;
loc.add(0, .1, 0);
new BukkitRunnable() {
double ti = 0;
int j = 0;
double dps = data.getModifier("damage") / 2;
double dps = ability.getModifier("damage") / 2;
public void run() {
j++;

View File

@ -9,8 +9,10 @@ import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.LocationAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.mmogroup.mmolib.MMOLib;
@ -31,16 +33,17 @@ public class Corrupt extends Ability {
}
@Override
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
Location loc = getTargetLocation(stats.getPlayer(), target);
if (loc == null) {
result.setSuccessful(false);
return;
}
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new LocationAbilityResult(ability, stats.getPlayer(), target);
}
double damage = data.getModifier("damage");
double duration = data.getModifier("duration");
double amplifier = data.getModifier("amplifier");
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
Location loc = ((LocationAbilityResult) ability).getTarget();
double damage = ability.getModifier("damage");
double duration = ability.getModifier("duration");
double amplifier = ability.getModifier("amplifier");
double radius = 2.7;
loc.add(0, -1, 0);

View File

@ -13,8 +13,10 @@ import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.VectorAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.mmogroup.mmolib.api.AttackResult;
@ -31,12 +33,17 @@ public class Corrupted_Fangs extends Ability implements Listener {
}
@Override
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
double damage1 = data.getModifier("damage");
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new VectorAbilityResult(ability, stats.getPlayer(), target);
}
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
double damage = ability.getModifier("damage");
stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(), Sound.ENTITY_WITHER_SHOOT, 2, 2);
new BukkitRunnable() {
Vector vec = getTargetDirection(stats.getPlayer(), target).setY(0).multiply(2);
Vector vec = ((VectorAbilityResult) ability).getTarget().setY(0).multiply(2);
Location loc = stats.getPlayer().getLocation();
double ti = 0;
@ -45,7 +52,7 @@ public class Corrupted_Fangs extends Ability implements Listener {
loc.add(vec);
EvokerFangs evokerFangs = (EvokerFangs) stats.getPlayer().getWorld().spawnEntity(loc, EntityType.EVOKER_FANGS);
MMOItems.plugin.getEntities().registerCustomEntity(evokerFangs, stats, damage1);
MMOItems.plugin.getEntities().registerCustomEntity(evokerFangs, stats, damage);
if (ti > 12)
cancel();

View File

@ -14,8 +14,10 @@ import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.VectorAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.mmogroup.mmolib.api.AttackResult;
@ -34,12 +36,17 @@ public class Cursed_Beam extends Ability {
}
@Override
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
double duration = data.getModifier("duration");
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new VectorAbilityResult(ability, stats.getPlayer(), target);
}
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
double duration = ability.getModifier("duration");
stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(), Sound.ENTITY_WITHER_SHOOT, 2, 2);
new BukkitRunnable() {
Vector dir = getTargetDirection(stats.getPlayer(), target).multiply(.3);
Vector dir = ((VectorAbilityResult) ability).getTarget().multiply(.3);
Location loc = stats.getPlayer().getEyeLocation().clone();
double r = 0.4;
int ti = 0;
@ -62,7 +69,7 @@ public class Cursed_Beam extends Ability {
for (Entity target : entities)
if (MMOUtils.canDamage(stats.getPlayer(), loc, target)) {
effect(target);
double damage = data.getModifier("damage");
double damage = ability.getModifier("damage");
loc.getWorld().playSound(loc, VersionSound.ENTITY_ENDERMAN_TELEPORT.toSound(), 2, .7f);
for (Entity entity : entities)

View File

@ -15,8 +15,11 @@ import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.SimpleAbilityResult;
import net.Indyuce.mmoitems.api.ability.VectorAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.mmogroup.mmolib.api.AttackResult;
@ -35,18 +38,18 @@ public class Earthquake extends Ability {
}
@Override
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
if (!stats.getPlayer().isOnGround()) {
result.setSuccessful(false);
return;
}
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return stats.getPlayer().isOnGround() ? new VectorAbilityResult(ability, stats.getPlayer(), target) : new SimpleAbilityResult(ability, false);
}
double damage = data.getModifier("damage");
double slowDuration = data.getModifier("duration");
double slowAmplifier = data.getModifier("amplifier");
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
double damage = ability.getModifier("damage");
double slowDuration = ability.getModifier("duration");
double slowAmplifier = ability.getModifier("amplifier");
new BukkitRunnable() {
Vector vec = getTargetDirection(stats.getPlayer(), target).setY(0);
Vector vec = ((VectorAbilityResult) ability).getTarget().setY(0);
Location loc = stats.getPlayer().getLocation();
int ti = 0;
List<Integer> hit = new ArrayList<>();

View File

@ -15,8 +15,10 @@ import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.SimpleAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.mmogroup.mmolib.api.AttackResult;
@ -38,11 +40,16 @@ public class Explosive_Turkey extends Ability implements Listener {
Chicken chicken = null;
@Override
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
double duration = data.getModifier("duration") * 10;
double damage = data.getModifier("damage");
double radiusSquared = Math.pow(data.getModifier("radius"), 2);
double knockback = data.getModifier("knockback");
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new SimpleAbilityResult(ability);
}
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
double duration = ability.getModifier("duration") * 10;
double damage = ability.getModifier("damage");
double radiusSquared = Math.pow(ability.getModifier("radius"), 2);
double knockback = ability.getModifier("knockback");
Vector vec = stats.getPlayer().getEyeLocation().getDirection().clone().multiply(.6);

View File

@ -11,8 +11,10 @@ import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.VectorAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.mmogroup.mmolib.api.AttackResult;
@ -32,12 +34,17 @@ public class Fire_Meteor extends Ability {
}
@Override
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new VectorAbilityResult(ability, stats.getPlayer(), target);
}
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(), VersionSound.ENTITY_ENDERMAN_TELEPORT.toSound(), 3, 1);
new BukkitRunnable() {
double ti = 0;
Location loc = stats.getPlayer().getLocation().clone().add(0, 10, 0);
Vector vec = getTargetDirection(stats.getPlayer(), target).multiply(1.3).setY(-1).normalize();
Vector vec = ((VectorAbilityResult) ability).getTarget().multiply(1.3).setY(-1).normalize();
public void run() {
ti++;
@ -53,9 +60,9 @@ public class Fire_Meteor extends Ability {
loc.getWorld().spawnParticle(Particle.EXPLOSION_NORMAL, loc, 32, 0, 0, 0, .3);
loc.getWorld().spawnParticle(Particle.FLAME, loc, 32, 0, 0, 0, .3);
double damage = data.getModifier("damage");
double knockback = data.getModifier("knockback");
double radius = data.getModifier("radius");
double damage = ability.getModifier("damage");
double knockback = ability.getModifier("knockback");
double radius = ability.getModifier("radius");
for (Entity entity : loc.getWorld().getEntitiesByClass(LivingEntity.class))
if (MMOUtils.canDamage(stats.getPlayer(), entity) && entity.getLocation().distanceSquared(loc) < radius * radius) {
new AttackResult(damage, DamageType.SKILL, DamageType.MAGICAL, DamageType.PROJECTILE).damage(stats.getPlayer(), (LivingEntity) entity);

View File

@ -12,8 +12,10 @@ import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.VectorAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.mmogroup.mmolib.api.AttackResult;
@ -32,10 +34,15 @@ public class Firebolt extends Ability {
}
@Override
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new VectorAbilityResult(ability, stats.getPlayer(), target);
}
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(), VersionSound.ENTITY_FIREWORK_ROCKET_BLAST.toSound(), 1, 1);
new BukkitRunnable() {
Vector vec = getTargetDirection(stats.getPlayer(), target).multiply(.8);
Vector vec = ((VectorAbilityResult) ability).getTarget().multiply(.8);
Location loc = stats.getPlayer().getEyeLocation();
int ti = 0;
@ -60,8 +67,8 @@ public class Firebolt extends Ability {
loc.getWorld().spawnParticle(Particle.LAVA, loc, 8, 0, 0, 0, 0);
loc.getWorld().spawnParticle(Particle.EXPLOSION_LARGE, loc, 0);
loc.getWorld().playSound(loc, Sound.ENTITY_GENERIC_EXPLODE, 3, 1);
new AttackResult(data.getModifier("damage"), DamageType.SKILL, DamageType.MAGICAL, DamageType.PROJECTILE).damage(stats.getPlayer(), (LivingEntity) target);
target.setFireTicks((int) data.getModifier("ignite") * 20);
new AttackResult(ability.getModifier("damage"), DamageType.SKILL, DamageType.MAGICAL, DamageType.PROJECTILE).damage(stats.getPlayer(), (LivingEntity) target);
target.setFireTicks((int) ability.getModifier("ignite") * 20);
cancel();
return;
}

View File

@ -11,8 +11,10 @@ import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.SimpleAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.mmogroup.mmolib.api.AttackResult;
@ -32,8 +34,13 @@ public class Firefly extends Ability {
}
@Override
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
double duration = data.getModifier("duration") * 20;
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new SimpleAbilityResult(ability);
}
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
double duration = ability.getModifier("duration") * 20;
new BukkitRunnable() {
int j = 0;
@ -54,8 +61,8 @@ public class Firefly extends Ability {
for (Entity entity : stats.getPlayer().getNearbyEntities(1, 1, 1))
if (MMOUtils.canDamage(stats.getPlayer(), entity)) {
double damage = data.getModifier("damage");
double knockback = data.getModifier("knockback");
double damage = ability.getModifier("damage");
double knockback = ability.getModifier("knockback");
stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(), Sound.ENTITY_ZOMBIE_ATTACK_IRON_DOOR, 1, .5f);
stats.getPlayer().getWorld().spawnParticle(Particle.LAVA, stats.getPlayer().getLocation().add(0, 1, 0), 32);

View File

@ -11,8 +11,10 @@ import org.bukkit.scheduler.BukkitRunnable;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.LocationAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.mmogroup.mmolib.api.AttackResult;
@ -33,8 +35,13 @@ public class Freezing_Curse extends Ability {
}
@Override
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
Location loc = getTargetLocation(stats.getPlayer(), target);
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new LocationAbilityResult(ability, stats.getPlayer(), target);
}
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
Location loc = ((LocationAbilityResult) ability).getTarget();
if (loc == null) {
result.setSuccessful(false);
return;
@ -60,10 +67,10 @@ public class Freezing_Curse extends Ability {
for (double j = 0; j < Math.PI * 2; j += Math.PI / 32)
loc.getWorld().spawnParticle(Particle.CLOUD, loc.clone().add(Math.cos(j) * 3, .1, Math.sin(j) * 3), 0);
double radius = data.getModifier("radius");
double amplifier = data.getModifier("amplifier");
double duration = data.getModifier("duration");
double damage = data.getModifier("damage");
double radius = ability.getModifier("radius");
double amplifier = ability.getModifier("amplifier");
double duration = ability.getModifier("duration");
double damage = ability.getModifier("damage");
for (Entity entity : MMOUtils.getNearbyChunkEntities(loc))
if (entity.getLocation().distanceSquared(loc) < radius * radius && MMOUtils.canDamage(stats.getPlayer(), entity)) {
new AttackResult(damage, DamageType.SKILL, DamageType.MAGICAL).damage(stats.getPlayer(), (LivingEntity) entity);

View File

@ -7,8 +7,10 @@ import org.bukkit.event.Listener;
import org.bukkit.scheduler.BukkitRunnable;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.SimpleAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.mmogroup.mmolib.version.VersionSound;
@ -26,10 +28,15 @@ public class Frog_Mode extends Ability implements Listener {
}
@Override
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
double duration = data.getModifier("duration") * 20;
double y = data.getModifier("jump-force");
double xz = data.getModifier("speed");
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new SimpleAbilityResult(ability);
}
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
double duration = ability.getModifier("duration") * 20;
double y = ability.getModifier("jump-force");
double xz = ability.getModifier("speed");
new BukkitRunnable() {
int j = 0;

View File

@ -11,8 +11,10 @@ import org.bukkit.scheduler.BukkitRunnable;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.SimpleAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
@ -29,10 +31,15 @@ public class Frozen_Aura extends Ability implements Listener {
}
@Override
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
double duration = data.getModifier("duration") * 20;
double radiusSquared = Math.pow(data.getModifier("radius"), 2);
double amplifier = data.getModifier("amplifier") - 1;
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new SimpleAbilityResult(ability);
}
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
double duration = ability.getModifier("duration") * 20;
double radiusSquared = Math.pow(ability.getModifier("radius"), 2);
double amplifier = ability.getModifier("amplifier") - 1;
new BukkitRunnable() {
double j = 0;

View File

@ -7,8 +7,10 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.SimpleAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
@ -24,9 +26,14 @@ public class Grand_Heal extends Ability {
}
@Override
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
double heal = data.getModifier("heal");
double radius = data.getModifier("radius");
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new SimpleAbilityResult(ability);
}
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
double heal = ability.getModifier("heal");
double radius = ability.getModifier("radius");
MMOUtils.heal(stats.getPlayer(), heal);
stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1, 2);

View File

@ -5,8 +5,10 @@ import org.bukkit.Sound;
import org.bukkit.entity.LivingEntity;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.SimpleAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
@ -21,10 +23,15 @@ public class Heal extends Ability {
}
@Override
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new SimpleAbilityResult(ability);
}
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1, 2);
stats.getPlayer().getWorld().spawnParticle(Particle.HEART, stats.getPlayer().getLocation().add(0, .75, 0), 16, 1, 1, 1, 0);
stats.getPlayer().getWorld().spawnParticle(Particle.VILLAGER_HAPPY, stats.getPlayer().getLocation().add(0, .75, 0), 16, 1, 1, 1, 0);
MMOUtils.heal(stats.getPlayer(), data.getModifier("heal"));
MMOUtils.heal(stats.getPlayer(), ability.getModifier("heal"));
}
}

View File

@ -9,8 +9,10 @@ import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.VectorAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.mmogroup.mmolib.api.AttackResult;
@ -28,12 +30,17 @@ public class Heavy_Charge extends Ability {
}
@Override
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
double knockback = data.getModifier("knockback");
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new VectorAbilityResult(ability, stats.getPlayer(), target);
}
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
double knockback = ability.getModifier("knockback");
new BukkitRunnable() {
double ti = 0;
Vector vec = getTargetDirection(stats.getPlayer(), target).setY(-1);
Vector vec = ((VectorAbilityResult) ability).getTarget().setY(-1);
public void run() {
ti++;
@ -51,7 +58,7 @@ public class Heavy_Charge extends Ability {
stats.getPlayer().getWorld().spawnParticle(Particle.EXPLOSION_LARGE, target.getLocation().add(0, 1, 0), 0);
target.setVelocity(stats.getPlayer().getVelocity().setY(0.3).multiply(1.7 * knockback));
stats.getPlayer().setVelocity(stats.getPlayer().getVelocity().setX(0).setY(0).setZ(0));
new AttackResult(data.getModifier("damage"), DamageType.SKILL, DamageType.PHYSICAL).damage(stats.getPlayer(), (LivingEntity) target);
new AttackResult(ability.getModifier("damage"), DamageType.SKILL, DamageType.PHYSICAL).damage(stats.getPlayer(), (LivingEntity) target);
cancel();
break;
}

View File

@ -10,8 +10,10 @@ import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.SimpleAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.mmogroup.mmolib.MMOLib;
@ -29,12 +31,12 @@ public class Hoearthquake extends Ability {
}
@Override
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
if (!stats.getPlayer().isOnGround()) {
result.setSuccessful(false);
return;
}
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new SimpleAbilityResult(ability, stats.getPlayer().isOnGround());
}
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
new BukkitRunnable() {
Vector vec = stats.getPlayer().getEyeLocation().getDirection().setY(0);
Location loc = stats.getPlayer().getLocation();

View File

@ -12,8 +12,10 @@ import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.VectorAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.mmogroup.mmolib.api.AttackResult;
@ -32,13 +34,18 @@ public class Holy_Missile extends Ability {
}
@Override
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
double duration = data.getModifier("duration") * 10;
double damage = data.getModifier("damage");
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new VectorAbilityResult(ability, stats.getPlayer(), target);
}
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
double duration = ability.getModifier("duration") * 10;
double damage = ability.getModifier("damage");
stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(), VersionSound.ENTITY_FIREWORK_ROCKET_BLAST.toSound(), 1, 1);
new BukkitRunnable() {
Vector vec = getTargetDirection(stats.getPlayer(), target).multiply(.45);
Vector vec = ((VectorAbilityResult) ability).getTarget().multiply(.45);
Location loc = stats.getPlayer().getLocation().clone().add(0, 1.3, 0);
double ti = 0;

View File

@ -15,8 +15,10 @@ import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.VectorAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.mmogroup.mmolib.MMOLib;
@ -37,10 +39,15 @@ public class Ice_Crystal extends Ability {
}
@Override
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new VectorAbilityResult(ability, stats.getPlayer(), target);
}
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(), VersionSound.ENTITY_FIREWORK_ROCKET_BLAST.toSound(), 1, 1);
new BukkitRunnable() {
Vector vec = getTargetDirection(stats.getPlayer(), target).multiply(.45);
Vector vec = ((VectorAbilityResult) ability).getTarget().multiply(.45);
Location loc = stats.getPlayer().getEyeLocation().clone().add(0, -.3, 0);
int ti = 0;
@ -74,8 +81,8 @@ public class Ice_Crystal extends Ability {
loc.getWorld().spawnParticle(Particle.EXPLOSION_LARGE, loc, 0);
loc.getWorld().spawnParticle(Particle.FIREWORKS_SPARK, loc, 48, 0, 0, 0, .2);
loc.getWorld().playSound(loc, Sound.ENTITY_GENERIC_EXPLODE, 2, 1);
new AttackResult(data.getModifier("damage"), DamageType.SKILL, DamageType.MAGICAL, DamageType.PROJECTILE).damage(stats.getPlayer(), (LivingEntity) entity);
((LivingEntity) entity).addPotionEffect(new PotionEffect(PotionEffectType.SLOW, (int) (data.getModifier("duration") * 20), (int) data.getModifier("amplifier")));
new AttackResult(ability.getModifier("damage"), DamageType.SKILL, DamageType.MAGICAL, DamageType.PROJECTILE).damage(stats.getPlayer(), (LivingEntity) entity);
((LivingEntity) entity).addPotionEffect(new PotionEffect(PotionEffectType.SLOW, (int) (ability.getModifier("duration") * 20), (int) ability.getModifier("amplifier")));
cancel();
return;
}

View File

@ -13,8 +13,10 @@ import org.bukkit.scheduler.BukkitRunnable;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.VectorAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.api.util.NoInteractItemEntity;
import net.Indyuce.mmoitems.stat.data.AbilityData;
@ -36,7 +38,12 @@ public class Item_Bomb extends Ability implements Listener {
}
@Override
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new VectorAbilityResult(ability, stats.getPlayer(), target);
}
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
ItemStack itemStack = stats.getPlayer().getInventory().getItemInMainHand().clone();
if (itemStack == null || itemStack.getType() == Material.AIR) {
result.setSuccessful(false);
@ -44,7 +51,7 @@ public class Item_Bomb extends Ability implements Listener {
}
final NoInteractItemEntity item = new NoInteractItemEntity(stats.getPlayer().getLocation().add(0, 1.2, 0), itemStack);
item.getEntity().setVelocity(getTargetDirection(stats.getPlayer(), target).multiply(1.3));
item.getEntity().setVelocity(((VectorAbilityResult) ability).getTarget().multiply(1.3));
stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(), Sound.ENTITY_SNOWBALL_THROW, 2, 0);
new BukkitRunnable() {
@ -52,10 +59,10 @@ public class Item_Bomb extends Ability implements Listener {
public void run() {
if (j++ > 40) {
double radius = data.getModifier("radius");
double damage = data.getModifier("damage");
double slowDuration = data.getModifier("slow-duration");
double slowAmplifier = data.getModifier("slow-amplifier");
double radius = ability.getModifier("radius");
double damage = ability.getModifier("damage");
double slowDuration = ability.getModifier("slow-duration");
double slowAmplifier = ability.getModifier("slow-amplifier");
for (Entity entity : item.getEntity().getNearbyEntities(radius, radius, radius))
if (MMOUtils.canDamage(stats.getPlayer(), entity)) {

View File

@ -11,8 +11,10 @@ import org.bukkit.scheduler.BukkitRunnable;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.VectorAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.api.util.NoInteractItemEntity;
import net.Indyuce.mmoitems.stat.data.AbilityData;
@ -31,7 +33,12 @@ public class Item_Throw extends Ability implements Listener {
}
@Override
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new VectorAbilityResult(ability, stats.getPlayer(), target);
}
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
ItemStack itemStack = stats.getPlayer().getInventory().getItemInMainHand().clone();
if (itemStack == null || itemStack.getType() == Material.AIR) {
result.setSuccessful(false);
@ -39,7 +46,7 @@ public class Item_Throw extends Ability implements Listener {
}
final NoInteractItemEntity item = new NoInteractItemEntity(stats.getPlayer().getLocation().add(0, 1.2, 0), itemStack);
item.getEntity().setVelocity(getTargetDirection(stats.getPlayer(), target).multiply(1.5 * data.getModifier("force")));
item.getEntity().setVelocity(((VectorAbilityResult) ability).getTarget().multiply(1.5 * ability.getModifier("force")));
stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(), Sound.ENTITY_SNOWBALL_THROW, 1, 0);
new BukkitRunnable() {
double ti = 0;
@ -54,7 +61,7 @@ public class Item_Throw extends Ability implements Listener {
item.getEntity().getWorld().spawnParticle(Particle.CRIT, item.getEntity().getLocation(), 0);
for (Entity target : item.getEntity().getNearbyEntities(1, 1, 1))
if (MMOUtils.canDamage(stats.getPlayer(), target)) {
new AttackResult(data.getModifier("damage"), DamageType.SKILL, DamageType.PHYSICAL, DamageType.PROJECTILE).damage(stats.getPlayer(), (LivingEntity) target);
new AttackResult(ability.getModifier("damage"), DamageType.SKILL, DamageType.PHYSICAL, DamageType.PROJECTILE).damage(stats.getPlayer(), (LivingEntity) target);
item.close();
cancel();
}

View File

@ -6,8 +6,10 @@ import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.SimpleAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.mmogroup.mmolib.version.VersionSound;
@ -23,15 +25,15 @@ public class Leap extends Ability {
}
@Override
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
if (!stats.getPlayer().isOnGround()) {
result.setSuccessful(false);
return;
}
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new SimpleAbilityResult(ability, stats.getPlayer().isOnGround());
}
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(), VersionSound.ENTITY_ENDER_DRAGON_FLAP.toSound(), 1, 0);
stats.getPlayer().getWorld().spawnParticle(Particle.EXPLOSION_NORMAL, stats.getPlayer().getLocation(), 16, 0, 0, 0.1);
Vector vec = stats.getPlayer().getEyeLocation().getDirection().multiply(2 * data.getModifier("force"));
Vector vec = stats.getPlayer().getEyeLocation().getDirection().multiply(2 * ability.getModifier("force"));
vec.setY(vec.getY() / 2);
stats.getPlayer().setVelocity(vec);
new BukkitRunnable() {

View File

@ -10,8 +10,10 @@ import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.LocationAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.mmogroup.mmolib.api.AttackResult;
@ -31,16 +33,16 @@ public class Life_Ender extends Ability {
}
@Override
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
double damage = data.getModifier("damage");
double knockback = data.getModifier("knockback");
double radius = data.getModifier("radius");
Location loc = getTargetLocation(stats.getPlayer(), target);
if (loc == null) {
result.setSuccessful(false);
return;
}
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new LocationAbilityResult(ability, stats.getPlayer(), target);
}
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
Location loc = ((LocationAbilityResult) ability).getTarget();
double damage = ability.getModifier("damage");
double knockback = ability.getModifier("knockback");
double radius = ability.getModifier("radius");
stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(), VersionSound.ENTITY_ENDERMAN_TELEPORT.toSound(), 2, 1);
new BukkitRunnable() {

View File

@ -11,8 +11,10 @@ import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.SimpleAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.mmogroup.mmolib.api.AttackResult;
@ -31,9 +33,14 @@ public class Light_Dash extends Ability {
}
@Override
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
double damage = data.getModifier("damage");
double length = data.getModifier("length");
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new SimpleAbilityResult(ability);
}
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
double damage = ability.getModifier("damage");
double length = ability.getModifier("length");
new BukkitRunnable() {
int j = 0;

View File

@ -7,8 +7,10 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.LocationAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.mmogroup.mmolib.api.AttackResult;
@ -27,17 +29,15 @@ public class Lightning_Beam extends Ability {
}
@Override
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
Location loc = getTargetLocation(stats.getPlayer(), target);
if (loc == null) {
result.setSuccessful(false);
return;
}
loc = getFirstNonSolidBlock(loc);
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new LocationAbilityResult(ability, stats.getPlayer(), target);
}
double damage = data.getModifier("damage");
double radius = data.getModifier("radius");
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
final Location loc = getFirstNonSolidBlock(((LocationAbilityResult) ability).getTarget());
double damage = ability.getModifier("damage");
double radius = ability.getModifier("radius");
for (Entity entity : MMOUtils.getNearbyChunkEntities(loc))
if (MMOUtils.canDamage(stats.getPlayer(), entity) && entity.getLocation().distanceSquared(loc) <= radius * radius)

View File

@ -14,16 +14,17 @@ import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.scheduler.BukkitRunnable;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.SimpleAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.mmogroup.mmolib.version.VersionSound;
public class Magical_Path extends Ability {
public Magical_Path() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK,
CastingMode.SHIFT_LEFT_CLICK, CastingMode.SHIFT_RIGHT_CLICK);
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK, CastingMode.SHIFT_RIGHT_CLICK);
addModifier("duration", 3);
addModifier("cooldown", 15);
@ -32,17 +33,21 @@ public class Magical_Path extends Ability {
}
@Override
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new SimpleAbilityResult(ability);
}
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
stats.getPlayer().setAllowFlight(true);
stats.getPlayer().setFlying(true);
stats.getPlayer().setVelocity(stats.getPlayer().getVelocity().setY(.5));
stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(),
VersionSound.ENTITY_ENDERMAN_TELEPORT.toSound(), 1, 1);
stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(), VersionSound.ENTITY_ENDERMAN_TELEPORT.toSound(), 1, 1);
new ShadowVeilHandler(stats.getPlayer(), data.getModifier("duration"));
new MagicalPathHandler(stats.getPlayer(), ability.getModifier("duration"));
}
public class ShadowVeilHandler extends BukkitRunnable implements Listener {
public class MagicalPathHandler extends BukkitRunnable implements Listener {
private final Player player;
private final long duration;
@ -53,7 +58,7 @@ public class Magical_Path extends Ability {
private int j = 0;
public ShadowVeilHandler(Player player, double duration) {
public MagicalPathHandler(Player player, double duration) {
this.player = player;
this.duration = (long) (duration * 10);
@ -88,8 +93,7 @@ public class Magical_Path extends Ability {
public void run() {
if (j++ > duration) {
player.getWorld().playSound(player.getLocation(), VersionSound.ENTITY_ENDERMAN_TELEPORT.toSound(), 1,
1);
player.getWorld().playSound(player.getLocation(), VersionSound.ENTITY_ENDERMAN_TELEPORT.toSound(), 1, 1);
player.setAllowFlight(false);
cancel();
return;

View File

@ -10,8 +10,10 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.scheduler.BukkitRunnable;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.SimpleAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.mmogroup.mmolib.MMOLib;
@ -32,15 +34,15 @@ public class Magical_Shield extends Ability {
}
@Override
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
if (!stats.getPlayer().isOnGround()) {
result.setSuccessful(false);
return;
}
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new SimpleAbilityResult(ability, stats.getPlayer().isOnGround());
}
double duration = data.getModifier("duration");
double radius = Math.pow(data.getModifier("radius"), 2);
double power = data.getModifier("power") / 100;
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
double duration = ability.getModifier("duration");
double radius = Math.pow(ability.getModifier("radius"), 2);
double power = ability.getModifier("power") / 100;
Location loc = stats.getPlayer().getLocation().clone();
stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(), VersionSound.ENTITY_ENDERMAN_TELEPORT.toSound(), 3, 0);

View File

@ -8,12 +8,12 @@ import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.TargetAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.mmogroup.mmolib.MMOLib;
import net.mmogroup.mmolib.api.AttackResult;
import net.mmogroup.mmolib.api.DamageType;
import net.mmogroup.mmolib.version.VersionSound;
@ -28,14 +28,15 @@ public class Magma_Fissure extends Ability {
addModifier("ignite", 4);
addModifier("damage", 4);
}
@Override
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new TargetAbilityResult(ability, stats.getPlayer(), target);
}
@Override
public void whenCast(CachedStats stats, LivingEntity initialTarget, AbilityData data, ItemAttackResult result) {
LivingEntity target = initialTarget == null ? MMOLib.plugin.getVersion().getWrapper().rayTrace(stats.getPlayer(), 50, entity -> MMOUtils.canDamage(stats.getPlayer(), entity)).getHit() : initialTarget;
if (target == null) {
result.setSuccessful(false);
return;
}
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
LivingEntity target = ((TargetAbilityResult) ability).getTarget();
new BukkitRunnable() {
int j = 0;
@ -58,8 +59,8 @@ public class Magma_Fissure extends Ability {
if (target.getLocation().distanceSquared(loc) < 1) {
loc.getWorld().playSound(loc, Sound.ENTITY_BLAZE_HURT, 2, 1);
target.setFireTicks((int) (target.getFireTicks() + data.getModifier("ignite") * 20));
new AttackResult(data.getModifier("damage"), DamageType.SKILL, DamageType.MAGICAL).damage(stats.getPlayer(), target);
target.setFireTicks((int) (target.getFireTicks() + ability.getModifier("ignite") * 20));
new AttackResult(ability.getModifier("damage"), DamageType.SKILL, DamageType.MAGICAL).damage(stats.getPlayer(), target);
cancel();
}
}

View File

@ -9,8 +9,10 @@ import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.SimpleAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.mmogroup.mmolib.api.AttackResult;
@ -29,9 +31,14 @@ public class Overload extends Ability {
}
@Override
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
double damage = data.getModifier("damage");
double radius = data.getModifier("radius");
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new SimpleAbilityResult(ability);
}
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
double damage = ability.getModifier("damage");
double radius = ability.getModifier("radius");
stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 2, 0);
stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(), VersionSound.ENTITY_FIREWORK_ROCKET_TWINKLE.toSound(), 2, 0);

View File

@ -18,8 +18,10 @@ import com.mojang.authlib.properties.Property;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.SimpleAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.api.util.NoInteractItemEntity;
import net.Indyuce.mmoitems.stat.data.AbilityData;
@ -58,12 +60,17 @@ public class Present_Throw extends Ability {
}
@Override
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
double damage = data.getModifier("damage");
double radiusSquared = Math.pow(data.getModifier("radius"), 2);
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new SimpleAbilityResult(ability);
}
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
double damage = ability.getModifier("damage");
double radiusSquared = Math.pow(ability.getModifier("radius"), 2);
final NoInteractItemEntity item = new NoInteractItemEntity(stats.getPlayer().getLocation().add(0, 1.2, 0), present);
item.getEntity().setVelocity(stats.getPlayer().getEyeLocation().getDirection().multiply(1.5 * data.getModifier("force")));
item.getEntity().setVelocity(stats.getPlayer().getEyeLocation().getDirection().multiply(1.5 * ability.getModifier("force")));
/*
* when items are moving through the air, they loose a percent of their

View File

@ -8,8 +8,9 @@ import org.bukkit.scheduler.BukkitRunnable;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.mmogroup.mmolib.MMOLib;
@ -26,18 +27,19 @@ public class Regen_Ally extends Ability {
}
@Override
public void whenCast(CachedStats stats, LivingEntity initialTarget, AbilityData data, ItemAttackResult result) {
LivingEntity target = initialTarget == null ? MMOLib.plugin.getVersion().getWrapper().rayTrace(stats.getPlayer(), 50, entity -> MMOUtils.canDamage(stats.getPlayer(), entity)).getHit() : initialTarget;
if (target == null || !(target instanceof Player)) {
result.setSuccessful(false);
return;
}
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new FriendlyTargetAbilityResult(ability, stats.getPlayer(), target);
}
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
LivingEntity target = ((FriendlyTargetAbilityResult) ability).getTarget();
new BukkitRunnable() {
double ti = 0;
double a = 0;
double duration = Math.min(data.getModifier("duration"), 60) * 20;
double hps = data.getModifier("heal") / duration * 4;
double duration = Math.min(ability.getModifier("duration"), 60) * 20;
double hps = ability.getModifier("heal") / duration * 4;
public void run() {
ti++;
@ -54,4 +56,26 @@ public class Regen_Ally extends Ability {
}
}.runTaskTimer(MMOItems.plugin, 0, 1);
}
/*
* TargetAbilityResult but only targets players
*/
public class FriendlyTargetAbilityResult extends AbilityResult {
private final LivingEntity target;
public FriendlyTargetAbilityResult(AbilityData ability, Player caster, LivingEntity target) {
super(ability);
this.target = target != null ? target : MMOLib.plugin.getVersion().getWrapper().rayTrace(caster, 50, entity -> (entity instanceof Player && MMOUtils.canDamage(caster, entity))).getHit();
}
public LivingEntity getTarget() {
return target;
}
@Override
public boolean isSuccessful() {
return target != null;
}
}
}

View File

@ -15,8 +15,10 @@ import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.SimpleAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.mmogroup.mmolib.MMOLib;
@ -33,9 +35,14 @@ public class Shockwave extends Ability {
}
@Override
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
double knockUp = data.getModifier("knock-up");
double length = data.getModifier("length");
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new SimpleAbilityResult(ability);
}
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
double knockUp = ability.getModifier("knock-up");
double length = ability.getModifier("length");
new BukkitRunnable() {
Vector vec = stats.getPlayer().getEyeLocation().getDirection().setY(0);

View File

@ -17,8 +17,10 @@ import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.VectorAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.mmogroup.mmolib.MMOLib;
@ -39,8 +41,13 @@ public class Shulker_Missile extends Ability implements Listener {
}
@Override
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
double duration = data.getModifier("duration");
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new VectorAbilityResult(ability, stats.getPlayer(), target);
}
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
double duration = ability.getModifier("duration");
new BukkitRunnable() {
double n = 0;
@ -51,11 +58,11 @@ public class Shulker_Missile extends Ability implements Listener {
cancel();
return;
}
Vector vec = getTargetDirection(stats.getPlayer(), target);
Vector vec = ((VectorAbilityResult) ability).getTarget();
stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(), Sound.ENTITY_WITHER_SHOOT, 2, 2);
ShulkerBullet shulkerBullet = (ShulkerBullet) stats.getPlayer().getWorld().spawnEntity(stats.getPlayer().getLocation().add(0, 1, 0), EntityType.SHULKER_BULLET);
shulkerBullet.setShooter(stats.getPlayer());
MMOItems.plugin.getEntities().registerCustomEntity(shulkerBullet, new AttackResult(data.getModifier("damage"), DamageType.SKILL, DamageType.MAGICAL, DamageType.PROJECTILE), data.getModifier("effect-duration"));
MMOItems.plugin.getEntities().registerCustomEntity(shulkerBullet, new AttackResult(ability.getModifier("damage"), DamageType.SKILL, DamageType.MAGICAL, DamageType.PROJECTILE), ability.getModifier("effect-duration"));
new BukkitRunnable() {
double ti = 0;

View File

@ -9,8 +9,10 @@ import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.SimpleAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.mmogroup.mmolib.api.AttackResult;
@ -28,9 +30,14 @@ public class Sky_Smash extends Ability {
}
@Override
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
double damage = data.getModifier("damage");
double knockUp = data.getModifier("knock-up");
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new SimpleAbilityResult(ability);
}
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
double damage = ability.getModifier("damage");
double knockUp = ability.getModifier("knock-up");
stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(), Sound.ENTITY_ZOMBIE_ATTACK_IRON_DOOR, 2, .5f);
stats.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 2, 254));

View File

@ -2,12 +2,12 @@ package net.Indyuce.mmoitems.ability;
import org.bukkit.entity.LivingEntity;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.TargetAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.mmogroup.mmolib.MMOLib;
import net.mmogroup.mmolib.api.AttackResult;
import net.mmogroup.mmolib.api.DamageType;
@ -22,14 +22,14 @@ public class Smite extends Ability {
}
@Override
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
target = target == null ? MMOLib.plugin.getVersion().getWrapper().rayTrace(stats.getPlayer(), 50, entity -> MMOUtils.canDamage(stats.getPlayer(), entity)).getHit() : target;
if (target == null) {
result.setSuccessful(false);
return;
}
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new TargetAbilityResult(ability, stats.getPlayer(), target);
}
new AttackResult(data.getModifier("damage"), DamageType.SKILL, DamageType.MAGICAL).damage(stats.getPlayer(), target);
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
LivingEntity target = ((TargetAbilityResult) ability).getTarget();
new AttackResult(ability.getModifier("damage"), DamageType.SKILL, DamageType.MAGICAL).damage(stats.getPlayer(), target);
target.getWorld().strikeLightningEffect(target.getLocation());
}
}

View File

@ -14,8 +14,10 @@ import org.bukkit.scheduler.BukkitRunnable;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.LocationAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.mmogroup.mmolib.version.VersionSound;
@ -33,16 +35,16 @@ public class Snowman_Turret extends Ability {
}
@Override
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
Location loc = getTargetLocation(stats.getPlayer(), target);
if (loc == null) {
result.setSuccessful(false);
return;
}
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new LocationAbilityResult(ability, stats.getPlayer(), target);
}
double duration = Math.min(data.getModifier("duration") * 20, 300);
double radiusSquared = Math.pow(data.getModifier("radius"), 2);
double damage1 = data.getModifier("damage");
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
Location loc = ((LocationAbilityResult) ability).getTarget();
double duration = Math.min(ability.getModifier("duration") * 20, 300);
double radiusSquared = Math.pow(ability.getModifier("radius"), 2);
double damage1 = ability.getModifier("damage");
loc.getWorld().playSound(loc, VersionSound.ENTITY_ENDERMAN_TELEPORT.toSound(), 2, 1);
final Snowman snowman = (Snowman) loc.getWorld().spawnEntity(loc.add(0, 1, 0), EntityType.SNOWMAN);

View File

@ -7,12 +7,12 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.TargetAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.mmogroup.mmolib.MMOLib;
import net.mmogroup.mmolib.api.AttackResult;
import net.mmogroup.mmolib.api.DamageType;
import net.mmogroup.mmolib.version.VersionSound;
@ -30,16 +30,16 @@ public class Sparkle extends Ability {
}
@Override
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
target = target == null ? MMOLib.plugin.getVersion().getWrapper().rayTrace(stats.getPlayer(), 50, entity -> MMOUtils.canDamage(stats.getPlayer(), entity)).getHit() : target;
if (target == null) {
result.setSuccessful(false);
return;
}
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new TargetAbilityResult(ability, stats.getPlayer(), target);
}
double damage = data.getModifier("damage");
double radius = data.getModifier("radius");
double limit = data.getModifier("limit");
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
LivingEntity target = ((TargetAbilityResult) ability).getTarget();
double damage = ability.getModifier("damage");
double radius = ability.getModifier("radius");
double limit = ability.getModifier("limit");
new AttackResult(damage, DamageType.SKILL, DamageType.MAGICAL).damage(stats.getPlayer(), target);
target.getWorld().spawnParticle(Particle.EXPLOSION_LARGE, target.getLocation().add(0, 1, 0), 0);

View File

@ -5,8 +5,10 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.SimpleAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.mmogroup.mmolib.version.VersionSound;
@ -23,9 +25,14 @@ public class Swiftness extends Ability {
}
@Override
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
double duration = data.getModifier("duration");
int amplifier = (int) data.getModifier("amplifier");
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new SimpleAbilityResult(ability);
}
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
double duration = ability.getModifier("duration");
int amplifier = (int) ability.getModifier("amplifier");
stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(), VersionSound.ENTITY_ZOMBIE_PIGMAN_ANGRY.toSound(), 1, .3f);
for (double y = 0; y <= 2; y += .2)

View File

@ -13,8 +13,10 @@ import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.VectorAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
@ -29,8 +31,13 @@ public class TNT_Throw extends Ability implements Listener {
}
@Override
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
Vector vec = getTargetDirection(stats.getPlayer(), target).multiply(2 * data.getModifier("force"));
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new VectorAbilityResult(ability, stats.getPlayer(), target);
}
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
Vector vec = ((VectorAbilityResult) ability).getTarget().multiply(2 * ability.getModifier("force"));
TNTPrimed tnt = (TNTPrimed) stats.getPlayer().getWorld().spawnEntity(stats.getPlayer().getLocation().add(0, 1, 0), EntityType.PRIMED_TNT);
tnt.setFuseTicks(80);
tnt.setVelocity(vec);
@ -39,6 +46,7 @@ public class TNT_Throw extends Ability implements Listener {
stats.getPlayer().getWorld().spawnParticle(Particle.EXPLOSION_NORMAL, stats.getPlayer().getLocation().add(0, 1, 0), 12, 0, 0, 0, .1);
}
@EventHandler
public void a(EntityDamageByEntityEvent event) {
Entity damager = event.getDamager();

View File

@ -13,11 +13,12 @@ import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.TargetAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.mmogroup.mmolib.MMOLib;
import net.mmogroup.mmolib.api.AttackResult;
import net.mmogroup.mmolib.api.DamageType;
@ -34,18 +35,18 @@ public class Tactical_Grenade extends Ability {
}
@Override
public void whenCast(CachedStats stats, LivingEntity initialTarget, AbilityData data, ItemAttackResult result) {
LivingEntity target = initialTarget == null ? MMOLib.plugin.getVersion().getWrapper().rayTrace(stats.getPlayer(), 50, entity -> MMOUtils.canDamage(stats.getPlayer(), entity)).getHit() : initialTarget;
if (target == null) {
result.setSuccessful(false);
return;
}
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new TargetAbilityResult(ability, stats.getPlayer(), target);
}
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
LivingEntity target = ((TargetAbilityResult) ability).getTarget();
new BukkitRunnable() {
int j = 0;
Location loc = stats.getPlayer().getLocation().add(0, .1, 0);
double radius = data.getModifier("radius");
double knockup = .7 * data.getModifier("knock-up");
double radius = ability.getModifier("radius");
double knockup = .7 * ability.getModifier("knock-up");
List<Integer> hit = new ArrayList<>();
public void run() {
@ -75,7 +76,7 @@ public class Tactical_Grenade extends Ability {
if (entity.equals(target))
cancel();
new AttackResult(data.getModifier("damage"), DamageType.SKILL, DamageType.MAGICAL).damage(stats.getPlayer(), (LivingEntity) entity);
new AttackResult(ability.getModifier("damage"), DamageType.SKILL, DamageType.MAGICAL).damage(stats.getPlayer(), (LivingEntity) entity);
entity.setVelocity(entity.getVelocity().add(offsetVector(knockup)));
}
}

View File

@ -7,12 +7,12 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.scheduler.BukkitRunnable;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.TargetAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.mmogroup.mmolib.MMOLib;
import net.mmogroup.mmolib.api.AttackResult;
import net.mmogroup.mmolib.api.DamageType;
import net.mmogroup.mmolib.version.VersionSound;
@ -27,14 +27,14 @@ public class Targeted_Fireball extends Ability {
addModifier("ignite", 4);
addModifier("damage", 4);
}
@Override
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new TargetAbilityResult(ability, stats.getPlayer(), target);
}
@Override
public void whenCast(CachedStats stats, LivingEntity initialTarget, AbilityData data, ItemAttackResult result) {
LivingEntity target = initialTarget == null ? MMOLib.plugin.getVersion().getWrapper().rayTrace(stats.getPlayer(), 50, entity -> MMOUtils.canDamage(stats.getPlayer(), entity)).getHit() : initialTarget;
if (target == null) {
result.setSuccessful(false);
return;
}
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
LivingEntity target = ((TargetAbilityResult) ability).getTarget();
new BukkitRunnable() {
int j = 0;
@ -57,8 +57,8 @@ public class Targeted_Fireball extends Ability {
loc.getWorld().spawnParticle(Particle.LAVA, loc, 8);
loc.getWorld().spawnParticle(Particle.FLAME, loc, 32, 0, 0, 0, .1);
loc.getWorld().playSound(loc, Sound.ENTITY_BLAZE_HURT, 2, 1);
target.setFireTicks((int) (target.getFireTicks() + data.getModifier("ignite") * 20));
new AttackResult(data.getModifier("damage"), DamageType.SKILL, DamageType.MAGICAL, DamageType.PROJECTILE).damage(stats.getPlayer(), target);
target.setFireTicks((int) (target.getFireTicks() + ability.getModifier("ignite") * 20));
new AttackResult(ability.getModifier("damage"), DamageType.SKILL, DamageType.MAGICAL, DamageType.PROJECTILE).damage(stats.getPlayer(), target);
cancel();
}
}

View File

@ -13,8 +13,10 @@ import org.bukkit.scheduler.BukkitRunnable;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.SimpleAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.api.util.NoInteractItemEntity;
import net.Indyuce.mmoitems.stat.data.AbilityData;
@ -35,9 +37,14 @@ public class Throw_Up extends Ability implements Listener {
}
@Override
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
double duration = data.getModifier("duration") * 10;
double dps = data.getModifier("damage") / 2;
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new SimpleAbilityResult(ability);
}
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
double duration = ability.getModifier("duration") * 10;
double dps = ability.getModifier("damage") / 2;
new BukkitRunnable() {
int j = 0;

View File

@ -10,8 +10,10 @@ import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.VectorAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.mmogroup.mmolib.api.AttackResult;
@ -28,14 +30,19 @@ public class Thrust extends Ability {
}
@Override
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
double damage = data.getModifier("damage");
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new VectorAbilityResult(ability, stats.getPlayer(), target);
}
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
double damage = ability.getModifier("damage");
stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(), Sound.ENTITY_ZOMBIE_ATTACK_IRON_DOOR, 1, 0);
stats.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 2, 3));
Location loc = stats.getPlayer().getEyeLocation().clone();
Vector vec = getTargetDirection(stats.getPlayer(), target).multiply(.5);
Vector vec = ((VectorAbilityResult) ability).getTarget().multiply(.5);
for (double j = 0; j < 7; j += .5) {
loc.add(vec);
for (Entity entity : MMOUtils.getNearbyChunkEntities(loc))

View File

@ -9,8 +9,10 @@ import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.LocationAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.mmogroup.mmolib.api.AttackResult;
@ -30,16 +32,17 @@ public class Arcane_Hail extends Ability {
}
@Override
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
Location loc = getTargetLocation(stats.getPlayer(), target);
if (loc == null) {
result.setSuccessful(false);
return;
}
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new LocationAbilityResult(ability, stats.getPlayer(), target);
}
double damage = data.getModifier("damage");
double duration = data.getModifier("duration") * 10;
double radius = data.getModifier("radius");
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
Location loc = ((LocationAbilityResult) ability).getTarget();
double damage = ability.getModifier("damage");
double duration = ability.getModifier("duration") * 10;
double radius = ability.getModifier("radius");
new BukkitRunnable() {
int j = 0;
@ -71,4 +74,3 @@ public class Arcane_Hail extends Ability {
return (random.nextDouble() - .5) * 2;
}
}

View File

@ -14,8 +14,11 @@ import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.SimpleAbilityResult;
import net.Indyuce.mmoitems.api.ability.VectorAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.mmogroup.mmolib.api.AttackResult;
@ -36,21 +39,24 @@ public class Arcane_Rift extends Ability {
}
@Override
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
if (!stats.getPlayer().isOnGround()) {
result.setSuccessful(false);
return;
}
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
if (!stats.getPlayer().isOnGround())
return new SimpleAbilityResult(ability, false);
double damage = data.getModifier("damage");
double slowDuration = data.getModifier("duration");
double slowAmplifier = data.getModifier("amplifier");
return new VectorAbilityResult(ability, stats.getPlayer(), target);
}
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
double damage = ability.getModifier("damage");
double slowDuration = ability.getModifier("duration");
double slowAmplifier = ability.getModifier("amplifier");
stats.getPlayer().getWorld().playSound(stats.getPlayer().getLocation(), VersionSound.ENTITY_ENDERMAN_DEATH.toSound(), 2, .5f);
new BukkitRunnable() {
Vector vec = getTargetDirection(stats.getPlayer(), target).setY(0).normalize().multiply(.5 * data.getModifier("speed"));
Vector vec = ((VectorAbilityResult) ability).getTarget().setY(0).normalize().multiply(.5 * ability.getModifier("speed"));
Location loc = stats.getPlayer().getLocation();
int ti = 0, duration = (int) (20 * Math.min(data.getModifier("duration"), 10.));
int ti = 0, duration = (int) (20 * Math.min(ability.getModifier("duration"), 10.));
List<Integer> hit = new ArrayList<>();
public void run() {

View File

@ -9,8 +9,10 @@ import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.TargetAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.mmogroup.mmolib.MMOLib;
@ -26,13 +28,15 @@ public class Blind extends Ability {
addModifier("stamina", 0);
}
@Override
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
target = target == null ? MMOLib.plugin.getVersion().getWrapper().rayTrace(stats.getPlayer(), 50, entity -> MMOUtils.canDamage(stats.getPlayer(), entity)).getHit() : target;
if (target == null) {
result.setSuccessful(false);
return;
}
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new TargetAbilityResult(ability, stats.getPlayer(), target);
}
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
LivingEntity target = ((TargetAbilityResult) ability).getTarget();
target.getWorld().playSound(target.getLocation(), VersionSound.ENTITY_ENDERMAN_HURT.toSound(), 1, 2);
for (double i = 0; i < Math.PI * 2; i += Math.PI / 24)
@ -41,6 +45,6 @@ public class Blind extends Ability {
Vector vec = MMOUtils.rotateFunc(new Vector(Math.cos(i), 1 + Math.cos(i + (Math.PI * j)) * .5, Math.sin(i)), stats.getPlayer().getLocation());
MMOLib.plugin.getVersion().getWrapper().spawnParticle(Particle.REDSTONE, loc.add(vec), Color.BLACK);
}
target.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, (int) (data.getModifier("duration") * 20), 0));
target.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, (int) (ability.getModifier("duration") * 20), 0));
}
}

View File

@ -4,12 +4,12 @@ import org.bukkit.Effect;
import org.bukkit.Sound;
import org.bukkit.entity.LivingEntity;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.TargetAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.mmogroup.mmolib.MMOLib;
public class Bloodbath extends Ability {
public Bloodbath() {
@ -22,15 +22,16 @@ public class Bloodbath extends Ability {
}
@Override
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
target = target == null ? MMOLib.plugin.getVersion().getWrapper().rayTrace(stats.getPlayer(), 50, entity -> MMOUtils.canDamage(stats.getPlayer(), entity)).getHit() : target;
if (target == null) {
result.setSuccessful(false);
return;
}
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new TargetAbilityResult(ability, stats.getPlayer(), target);
}
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
LivingEntity target = ((TargetAbilityResult) ability).getTarget();
target.getWorld().playSound(target.getLocation(), Sound.ENTITY_COW_HURT, 1, 2);
target.getWorld().playEffect(target.getLocation().add(0, 1, 0), Effect.STEP_SOUND, 152);
stats.getPlayer().setFoodLevel((int) Math.min(20, stats.getPlayer().getFoodLevel() + data.getModifier("amount")));
stats.getPlayer().setFoodLevel((int) Math.min(20, stats.getPlayer().getFoodLevel() + ability.getModifier("amount")));
}
}

View File

@ -7,12 +7,12 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.scheduler.BukkitRunnable;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.TargetAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.mmogroup.mmolib.MMOLib;
public class Burn extends Ability {
public Burn() {
@ -25,12 +25,13 @@ public class Burn extends Ability {
}
@Override
public void whenCast(CachedStats stats, LivingEntity initialTarget, AbilityData data, ItemAttackResult result) {
LivingEntity target = initialTarget == null ? MMOLib.plugin.getVersion().getWrapper().rayTrace(stats.getPlayer(), 50, entity -> MMOUtils.canDamage(stats.getPlayer(), entity)).getHit() : initialTarget;
if (target == null) {
result.setSuccessful(false);
return;
}
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new TargetAbilityResult(ability, stats.getPlayer(), target);
}
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
LivingEntity target = ((TargetAbilityResult) ability).getTarget();
new BukkitRunnable() {
final Location loc = target.getLocation();
@ -50,6 +51,6 @@ public class Burn extends Ability {
}
}.runTaskTimer(MMOItems.plugin, 0, 1);
target.getWorld().playSound(target.getLocation(), Sound.ENTITY_BLAZE_HURT, 1, 2);
target.setFireTicks((int) (target.getFireTicks() + data.getModifier("duration") * 20));
target.setFireTicks((int) (target.getFireTicks() + ability.getModifier("duration") * 20));
}
}

View File

@ -7,12 +7,12 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.scheduler.BukkitRunnable;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.TargetAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.mmogroup.mmolib.MMOLib;
public class Confuse extends Ability {
public Confuse() {
@ -24,12 +24,13 @@ public class Confuse extends Ability {
}
@Override
public void whenCast(CachedStats stats, LivingEntity initialTarget, AbilityData data, ItemAttackResult result) {
LivingEntity target = initialTarget == null ? MMOLib.plugin.getVersion().getWrapper().rayTrace(stats.getPlayer(), 50, entity -> MMOUtils.canDamage(stats.getPlayer(), entity)).getHit() : initialTarget;
if (target == null) {
result.setSuccessful(false);
return;
}
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new TargetAbilityResult(ability, stats.getPlayer(), target);
}
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
LivingEntity target = ((TargetAbilityResult) ability).getTarget();
target.getWorld().playSound(target.getLocation(), Sound.ENTITY_SHEEP_DEATH, 1, 2);
new BukkitRunnable() {

View File

@ -9,8 +9,10 @@ import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.LocationAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
@ -27,16 +29,17 @@ public class Corrosion extends Ability {
}
@Override
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
Location loc = getTargetLocation(stats.getPlayer(), target);
if (loc == null) {
result.setSuccessful(false);
return;
}
int duration = (int) (data.getModifier("duration") * 20);
int amplifier = (int) data.getModifier("amplifier");
double radiusSquared = Math.pow(data.getModifier("radius"), 2);
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new LocationAbilityResult(ability, stats.getPlayer(), target);
}
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
Location loc = ((LocationAbilityResult) ability).getTarget();
int duration = (int) (ability.getModifier("duration") * 20);
int amplifier = (int) ability.getModifier("amplifier");
double radiusSquared = Math.pow(ability.getModifier("radius"), 2);
loc.getWorld().spawnParticle(Particle.SLIME, loc, 48, 2, 2, 2, 0);
loc.getWorld().spawnParticle(Particle.VILLAGER_HAPPY, loc, 32, 2, 2, 2, 0);

View File

@ -8,9 +8,10 @@ import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitRunnable;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.TargetAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.mmogroup.mmolib.MMOLib;
@ -30,15 +31,16 @@ public class Death_Mark extends Ability {
}
@Override
public void whenCast(CachedStats stats, LivingEntity initialTarget, AbilityData data, ItemAttackResult result) {
LivingEntity target = initialTarget == null ? MMOLib.plugin.getVersion().getWrapper().rayTrace(stats.getPlayer(), 50, entity -> MMOUtils.canDamage(stats.getPlayer(), entity)).getHit() : initialTarget;
if (target == null) {
result.setSuccessful(false);
return;
}
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new TargetAbilityResult(ability, stats.getPlayer(), target);
}
double duration = data.getModifier("duration") * 20;
double dps = data.getModifier("damage") / duration * 20;
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
LivingEntity target = ((TargetAbilityResult) ability).getTarget();
double duration = ability.getModifier("duration") * 20;
double dps = ability.getModifier("damage") / duration * 20;
new BukkitRunnable() {
double ti = 0;
@ -58,6 +60,6 @@ public class Death_Mark extends Ability {
}.runTaskTimer(MMOItems.plugin, 0, 1);
target.getWorld().playSound(target.getLocation(), Sound.ENTITY_BLAZE_HURT, 1, 2);
target.removePotionEffect(PotionEffectType.SLOW);
target.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, (int) duration, (int) data.getModifier("amplifier")));
target.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, (int) duration, (int) ability.getModifier("amplifier")));
}
}

View File

@ -8,8 +8,10 @@ import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.LocationAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.mmogroup.mmolib.version.VersionSound;
@ -27,16 +29,17 @@ public class Freeze extends Ability {
}
@Override
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
Location loc = getTargetLocation(stats.getPlayer(), target);
if (loc == null) {
result.setSuccessful(false);
return;
}
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new LocationAbilityResult(ability, stats.getPlayer(), target);
}
int duration = (int) (data.getModifier("duration") * 20);
int amplifier = (int) (data.getModifier("amplifier") - 1);
double radiusSquared = Math.pow(data.getModifier("radius"), 2);
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
Location loc = ((LocationAbilityResult) ability).getTarget();
int duration = (int) (ability.getModifier("duration") * 20);
int amplifier = (int) (ability.getModifier("amplifier") - 1);
double radiusSquared = Math.pow(ability.getModifier("radius"), 2);
loc.getWorld().spawnParticle(Particle.EXPLOSION_LARGE, loc.add(0, .1, 0), 0);
loc.getWorld().spawnParticle(Particle.SNOW_SHOVEL, loc, 48, 0, 0, 0, .2);

View File

@ -6,8 +6,10 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.LocationAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.mmogroup.mmolib.version.VersionSound;
@ -25,16 +27,17 @@ public class Ignite extends Ability {
}
@Override
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
Location loc = getTargetLocation(stats.getPlayer(), target);
if (loc == null) {
result.setSuccessful(false);
return;
}
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new LocationAbilityResult(ability, stats.getPlayer(), target);
}
int maxIgnite = (int) (data.getModifier("max-ignite") * 20);
int ignite = (int) (data.getModifier("duration") * 20);
double radiusSquared = Math.pow(data.getModifier("radius"), 2);
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
Location loc = ((LocationAbilityResult) ability).getTarget();
int maxIgnite = (int) (ability.getModifier("max-ignite") * 20);
int ignite = (int) (ability.getModifier("duration") * 20);
double radiusSquared = Math.pow(ability.getModifier("radius"), 2);
loc.getWorld().spawnParticle(Particle.EXPLOSION_LARGE, loc.add(0, .1, 0), 0);
loc.getWorld().spawnParticle(Particle.LAVA, loc, 12);

View File

@ -7,8 +7,10 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.LocationAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.mmogroup.mmolib.api.AttackResult;
@ -27,16 +29,17 @@ public class Minor_Explosion extends Ability {
}
@Override
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
Location loc = getTargetLocation(stats.getPlayer(), target);
if (loc == null) {
result.setSuccessful(false);
return;
}
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new LocationAbilityResult(ability, stats.getPlayer(), target);
}
double damage = data.getModifier("damage");
double radiusSquared = Math.pow(data.getModifier("radius"), 2);
double knockback = data.getModifier("knockback");
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
Location loc = ((LocationAbilityResult) ability).getTarget();
double damage = ability.getModifier("damage");
double radiusSquared = Math.pow(ability.getModifier("radius"), 2);
double knockback = ability.getModifier("knockback");
loc.getWorld().spawnParticle(Particle.EXPLOSION_LARGE, loc.add(0, .1, 0), 32, 1.7, 1.7, 1.7, 0);
loc.getWorld().spawnParticle(Particle.EXPLOSION_LARGE, loc, 64, 0, 0, 0, .3);

View File

@ -6,12 +6,12 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.TargetAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.mmogroup.mmolib.MMOLib;
public class Poison extends Ability {
public Poison() {
@ -25,16 +25,17 @@ public class Poison extends Ability {
}
@Override
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
target = target == null ? MMOLib.plugin.getVersion().getWrapper().rayTrace(stats.getPlayer(), 50, entity -> MMOUtils.canDamage(stats.getPlayer(), entity)).getHit() : target;
if (target == null) {
result.setSuccessful(false);
return;
}
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new TargetAbilityResult(ability, stats.getPlayer(), target);
}
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
LivingEntity target = ((TargetAbilityResult) ability).getTarget();
target.getWorld().spawnParticle(Particle.SLIME, target.getLocation().add(0, 1, 0), 32, 1, 1, 1, 0);
target.getWorld().spawnParticle(Particle.VILLAGER_HAPPY, target.getLocation().add(0, 1, 0), 24, 1, 1, 1, 0);
target.getWorld().playSound(target.getLocation(), Sound.BLOCK_BREWING_STAND_BREW, 1.5f, 2);
target.addPotionEffect(new PotionEffect(PotionEffectType.POISON, (int) (data.getModifier("duration") * 20), (int) data.getModifier("amplifier")));
target.addPotionEffect(new PotionEffect(PotionEffectType.POISON, (int) (ability.getModifier("duration") * 20), (int) ability.getModifier("amplifier")));
}
}

View File

@ -7,12 +7,12 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.scheduler.BukkitRunnable;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.TargetAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.mmogroup.mmolib.MMOLib;
import net.mmogroup.mmolib.version.VersionSound;
public class Shock extends Ability {
@ -26,14 +26,15 @@ public class Shock extends Ability {
}
@Override
public void whenCast(CachedStats stats, LivingEntity initialTarget, AbilityData data, ItemAttackResult result) {
LivingEntity target = initialTarget == null ? MMOLib.plugin.getVersion().getWrapper().rayTrace(stats.getPlayer(), 50, entity -> MMOUtils.canDamage(stats.getPlayer(), entity)).getHit() : initialTarget;
if (target == null) {
result.setSuccessful(false);
return;
}
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new TargetAbilityResult(ability, stats.getPlayer(), target);
}
double duration = data.getModifier("duration");
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
LivingEntity target = ((TargetAbilityResult) ability).getTarget();
double duration = ability.getModifier("duration");
target.getWorld().playSound(target.getLocation(), VersionSound.ENTITY_ZOMBIE_PIGMAN_ANGRY.toSound(), 1, 2);
new BukkitRunnable() {
@ -52,13 +53,12 @@ public class Shock extends Ability {
}.runTaskTimer(MMOItems.plugin, 0, 1);
new BukkitRunnable() {
double ti = 0;
int ti;
public void run() {
ti++;
if (ti > (duration > 30 ? 30 : duration) * 10)
if (ti++ > (duration > 300 ? 300 : duration * 10) || target.isDead())
cancel();
if (!target.isDead())
else
target.playEffect(EntityEffect.HURT);
}
}.runTaskTimer(MMOItems.plugin, 0, 2);

View File

@ -10,9 +10,10 @@ import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitRunnable;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.TargetAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.mmogroup.mmolib.MMOLib;
@ -29,12 +30,13 @@ public class Slow extends Ability {
}
@Override
public void whenCast(CachedStats stats, LivingEntity initialTarget, AbilityData data, ItemAttackResult result) {
LivingEntity target = initialTarget == null ? MMOLib.plugin.getVersion().getWrapper().rayTrace(stats.getPlayer(), 50, entity -> MMOUtils.canDamage(stats.getPlayer(), entity)).getHit() : initialTarget;
if (target == null) {
result.setSuccessful(false);
return;
}
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new TargetAbilityResult(ability, stats.getPlayer(), target);
}
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
LivingEntity target = ((TargetAbilityResult) ability).getTarget();
new BukkitRunnable() {
final Location loc = target.getLocation();
@ -52,6 +54,6 @@ public class Slow extends Ability {
}
}.runTaskTimer(MMOItems.plugin, 0, 1);
target.getWorld().playSound(target.getLocation(), Sound.ENTITY_LLAMA_ANGRY, 1, 2);
target.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, (int) (data.getModifier("duration") * 20), (int) data.getModifier("amplifier")));
target.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, (int) (ability.getModifier("duration") * 20), (int) ability.getModifier("amplifier")));
}
}

View File

@ -8,8 +8,10 @@ import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.TargetAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.mmogroup.mmolib.version.VersionSound;
@ -25,11 +27,13 @@ public class Starfall extends Ability {
}
@Override
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
if (target == null) {
result.setSuccessful(false);
return;
}
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new TargetAbilityResult(ability, stats.getPlayer(), target);
}
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
LivingEntity target = ((TargetAbilityResult) ability).getTarget();
new BukkitRunnable() {
double ran = random.nextDouble() * Math.PI * 2;
@ -53,6 +57,6 @@ public class Starfall extends Ability {
}
}.runTaskTimer(MMOItems.plugin, 0, 1);
target.getWorld().playSound(target.getLocation(), Sound.ENTITY_WITHER_SHOOT, 2, 2);
result.addDamage(data.getModifier("damage"));
result.addDamage(ability.getModifier("damage"));
}
}

View File

@ -6,12 +6,12 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.TargetAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.mmogroup.mmolib.MMOLib;
public class Stun extends Ability {
public Stun() {
@ -24,16 +24,17 @@ public class Stun extends Ability {
}
@Override
public void whenCast(CachedStats stats, LivingEntity target, AbilityData data, ItemAttackResult result) {
target = target == null ? MMOLib.plugin.getVersion().getWrapper().rayTrace(stats.getPlayer(), 50, entity -> MMOUtils.canDamage(stats.getPlayer(), entity)).getHit() : target;
if (target == null) {
result.setSuccessful(false);
return;
}
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new TargetAbilityResult(ability, stats.getPlayer(), target);
}
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
LivingEntity target = ((TargetAbilityResult) ability).getTarget();
target.getWorld().playSound(target.getLocation(), Sound.BLOCK_ANVIL_LAND, 1, 2);
target.getWorld().playEffect(target.getLocation(), Effect.STEP_SOUND, 42);
target.getWorld().playEffect(target.getLocation().add(0, 1, 0), Effect.STEP_SOUND, 42);
target.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, (int) (data.getModifier("duration") * 20), 254));
target.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, (int) (ability.getModifier("duration") * 20), 254));
}
}

View File

@ -9,8 +9,10 @@ import org.bukkit.scheduler.BukkitRunnable;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.TargetAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.mmogroup.mmolib.MMOLib;
@ -26,12 +28,13 @@ public class Vampirism extends Ability {
}
@Override
public void whenCast(CachedStats stats, LivingEntity initialTarget, AbilityData data, ItemAttackResult result) {
LivingEntity target = initialTarget == null ? MMOLib.plugin.getVersion().getWrapper().rayTrace(stats.getPlayer(), 50, entity -> MMOUtils.canDamage(stats.getPlayer(), entity)).getHit() : initialTarget;
if (target == null) {
result.setSuccessful(false);
return;
}
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new TargetAbilityResult(ability, stats.getPlayer(), target);
}
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
LivingEntity target = ((TargetAbilityResult) ability).getTarget();
new BukkitRunnable() {
double ti = 0;
@ -51,6 +54,6 @@ public class Vampirism extends Ability {
}
}.runTaskTimer(MMOItems.plugin, 0, 1);
target.getWorld().playSound(target.getLocation(), Sound.ENTITY_WITCH_DRINK, 1, 2);
MMOUtils.heal(stats.getPlayer(), result.getDamage() * data.getModifier("drain") / 100);
MMOUtils.heal(stats.getPlayer(), result.getDamage() * ability.getModifier("drain") / 100);
}
}

View File

@ -20,9 +20,10 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.TargetAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.mmogroup.mmolib.MMOLib;
@ -42,14 +43,15 @@ public class Weaken_Target extends Ability implements Listener {
}
@Override
public void whenCast(CachedStats stats, LivingEntity initialTarget, AbilityData data, ItemAttackResult result) {
LivingEntity target = initialTarget == null ? MMOLib.plugin.getVersion().getWrapper().rayTrace(stats.getPlayer(), 50, entity -> MMOUtils.canDamage(stats.getPlayer(), entity)).getHit() : initialTarget;
if (target == null || marked.containsKey(target.getUniqueId())) {
result.setSuccessful(false);
return;
}
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new TargetAbilityResult(ability, stats.getPlayer(), target);
}
marked.put(target.getUniqueId(), new WeakenedInfo(data.getModifier("extra-damage")));
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
LivingEntity target = ((TargetAbilityResult) ability).getTarget();
marked.put(target.getUniqueId(), new WeakenedInfo(ability.getModifier("extra-damage")));
effect(target.getLocation());
target.getWorld().playSound(target.getLocation(), VersionSound.ENTITY_ENDERMAN_HURT.toSound(), 2, 1.5f);
@ -58,7 +60,7 @@ public class Weaken_Target extends Ability implements Listener {
* the mark from the entity
*/
new BukkitRunnable() {
long duration = (long) (data.getModifier("duration") * 1000);
long duration = (long) (ability.getModifier("duration") * 1000);
public void run() {
if (!marked.containsKey(target.getUniqueId()) || marked.get(target.getUniqueId()).date + duration < System.currentTimeMillis()) {

View File

@ -10,9 +10,10 @@ import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitRunnable;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Ability;
import net.Indyuce.mmoitems.api.ItemAttackResult;
import net.Indyuce.mmoitems.api.ability.Ability;
import net.Indyuce.mmoitems.api.ability.AbilityResult;
import net.Indyuce.mmoitems.api.ability.TargetAbilityResult;
import net.Indyuce.mmoitems.api.player.PlayerStats.CachedStats;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.mmogroup.mmolib.MMOLib;
@ -29,12 +30,13 @@ public class Wither extends Ability {
}
@Override
public void whenCast(CachedStats stats, LivingEntity initialTarget, AbilityData data, ItemAttackResult result) {
LivingEntity target = initialTarget == null ? MMOLib.plugin.getVersion().getWrapper().rayTrace(stats.getPlayer(), 50, entity -> MMOUtils.canDamage(stats.getPlayer(), entity)).getHit() : initialTarget;
if (target == null) {
result.setSuccessful(false);
return;
}
public AbilityResult whenRan(CachedStats stats, LivingEntity target, AbilityData ability, ItemAttackResult result) {
return new TargetAbilityResult(ability, stats.getPlayer(), target);
}
@Override
public void whenCast(CachedStats stats, AbilityResult ability, ItemAttackResult result) {
LivingEntity target = ((TargetAbilityResult) ability).getTarget();
new BukkitRunnable() {
final Location loc = target.getLocation();
@ -56,6 +58,6 @@ public class Wither extends Ability {
}
}.runTaskTimer(MMOItems.plugin, 0, 1);
target.getWorld().playSound(target.getLocation(), Sound.ENTITY_WITHER_SHOOT, 2, 2);
target.addPotionEffect(new PotionEffect(PotionEffectType.WITHER, (int) (data.getModifier("duration") * 20), (int) data.getModifier("amplifier")));
target.addPotionEffect(new PotionEffect(PotionEffectType.WITHER, (int) (ability.getModifier("duration") * 20), (int) ability.getModifier("amplifier")));
}
}

View File

@ -15,6 +15,10 @@ public class TargetAbilityResult extends AbilityResult {
this.target = target != null ? target : MMOLib.plugin.getVersion().getWrapper().rayTrace(caster, 50, entity -> MMOUtils.canDamage(caster, entity)).getHit();
}
public LivingEntity getTarget() {
return target;
}
@Override
public boolean isSuccessful() {