!skills update

This commit is contained in:
Indyuce 2022-01-01 13:17:25 +01:00
parent 987208c194
commit 44d039e8b0
98 changed files with 142 additions and 4576 deletions

View File

@ -134,14 +134,14 @@
<dependency>
<groupId>net.Indyuce</groupId>
<artifactId>MMOCore</artifactId>
<version>1.8.1</version>
<version>1.9</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.lumine</groupId>
<artifactId>MythicLib-dist</artifactId>
<version>1.3-R5</version>
<version>1.3-R11</version>
<scope>provided</scope>
</dependency>

View File

@ -172,7 +172,7 @@ public class MMOItems extends LuminePlugin {
new MMOItemsMetrics();
RecipeBrowserGUI.registerNativeRecipes();
skillManager.reload();
skillManager.initialize(false);
configManager = new ConfigManager();
final int configVersion = getConfig().contains("config-version", true) ? getConfig().getInt("config-version") : -1;

View File

@ -1,6 +1,7 @@
package net.Indyuce.mmoitems.ability;
import io.lumine.mythic.lib.damage.AttackMetadata;
import io.lumine.mythic.lib.damage.DamageMetadata;
import io.lumine.mythic.lib.player.cooldown.CooldownObject;
import io.lumine.mythic.lib.skill.SkillMetadata;
import io.lumine.mythic.lib.skill.handler.SkillHandler;
@ -73,7 +74,9 @@ public abstract class Ability<T extends AbilityMetadata> extends SkillHandler<T>
for (String mod : modifiers.keySet())
abilityData.setModifier(mod, meta.getModifier(mod));
return canBeCast(meta.getAttack(), meta.hasTargetEntity() && meta.getTargetEntityOrNull() instanceof LivingEntity ? (LivingEntity) meta.getTargetEntityOrNull() : null, abilityData);
// Make sure provided attack meta is not null
AttackMetadata attack = meta.hasAttackBound() ? meta.getAttack() : new AttackMetadata(new DamageMetadata(), meta.getCaster());
return canBeCast(attack, meta.hasTargetEntity() && meta.getTargetEntityOrNull() instanceof LivingEntity ? (LivingEntity) meta.getTargetEntityOrNull() : null, abilityData);
}
@Override

View File

@ -25,7 +25,7 @@ public class BackwardsCompatibleAbility extends Ability<BackwardsCompatibleAbili
@Nullable
@Override
public BackwardsCompatibleAbilityMetadata canBeCast(AttackMetadata attack, LivingEntity target, AbilityData ability) {
SkillMetadata skillMeta = new SkillMetadata(ability, attack.getStats(), new VariableList(VariableScope.SKILL), attack, attack.getPlayer().getLocation(), null, target);
SkillMetadata skillMeta = new SkillMetadata(ability, attack, new VariableList(VariableScope.SKILL), attack, attack.getPlayer().getLocation(), null, target);
return new BackwardsCompatibleAbilityMetadata(skillMeta, registeredSkill.getHandler().getResult(skillMeta), ability);
}

View File

@ -1,67 +0,0 @@
package net.Indyuce.mmoitems.ability.list.location;
import io.lumine.mythic.lib.damage.AttackMetadata;
import io.lumine.mythic.lib.damage.DamageMetadata;
import io.lumine.mythic.lib.damage.DamageType;
import io.lumine.mythic.lib.version.VersionSound;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.LocationAbility;
import net.Indyuce.mmoitems.ability.metadata.LocationAbilityMetadata;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
public class Arcane_Hail extends LocationAbility {
public Arcane_Hail() {
super();
addModifier("damage", 3);
addModifier("duration", 4);
addModifier("radius", 3);
addModifier("cooldown", 10);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public void whenCast(AttackMetadata attack, LocationAbilityMetadata ability) {
Location loc = ability.getTarget();
double damage = ability.getModifier("damage");
double duration = ability.getModifier("duration") * 10;
double radius = ability.getModifier("radius");
new BukkitRunnable() {
int j = 0;
public void run() {
j++;
if (j > duration) {
cancel();
return;
}
Location loc1 = loc.clone().add(randomCoordMultiplier() * radius, 0, randomCoordMultiplier() * radius);
loc1.getWorld().playSound(loc1, VersionSound.ENTITY_ENDERMAN_HURT.toSound(), 1, 0);
for (Entity entity : MMOUtils.getNearbyChunkEntities(loc1))
if (MMOUtils.canTarget(attack.getPlayer(), entity) && entity.getLocation().distanceSquared(loc1) <= 4)
new AttackMetadata(new DamageMetadata(damage, DamageType.SKILL, DamageType.MAGIC), attack.getStats()).damage((LivingEntity) entity);
loc1.getWorld().spawnParticle(Particle.SPELL_WITCH, loc1, 12, 0, 0, 0, .1);
loc1.getWorld().spawnParticle(Particle.SMOKE_NORMAL, loc1, 6, 0, 0, 0, .1);
Vector vector = new Vector(randomCoordMultiplier() * .03, .3, randomCoordMultiplier() * .03);
for (double k = 0; k < 60; k++)
loc1.getWorld().spawnParticle(Particle.SPELL_WITCH, loc1.add(vector), 0);
}
}.runTaskTimer(MMOItems.plugin, 0, 2);
}
// random double between -1 and 1
private double randomCoordMultiplier() {
return (random.nextDouble() - .5) * 2;
}
}

View File

@ -1,60 +0,0 @@
package net.Indyuce.mmoitems.ability.list.location;
import io.lumine.mythic.lib.damage.AttackMetadata;
import io.lumine.mythic.lib.version.VersionSound;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.LocationAbility;
import net.Indyuce.mmoitems.ability.metadata.LocationAbilityMetadata;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.entity.Entity;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
public class Black_Hole extends LocationAbility {
public Black_Hole() {
super();
addModifier("radius", 2);
addModifier("duration", 2);
addModifier("cooldown", 35);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public void whenCast(AttackMetadata attack, LocationAbilityMetadata ability) {
Location loc = 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() {
int ti = 0;
final double r = 4;
public void run() {
if (ti++ > Math.min(300, duration))
cancel();
loc.getWorld().playSound(loc, VersionSound.BLOCK_NOTE_BLOCK_HAT.toSound(), 2, 2);
loc.getWorld().spawnParticle(Particle.EXPLOSION_LARGE, loc, 0);
for (int j = 0; j < 3; j++) {
double ran = random.nextDouble() * Math.PI * 2;
double ran_y = random.nextDouble() * 2 - 1;
double x = Math.cos(ran) * Math.sin(ran_y * Math.PI * 2);
double z = Math.sin(ran) * Math.sin(ran_y * Math.PI * 2);
Location loc1 = loc.clone().add(x * r, ran_y * r, z * r);
Vector v = loc.toVector().subtract(loc1.toVector());
loc1.getWorld().spawnParticle(Particle.SMOKE_LARGE, loc1, 0, v.getX(), v.getY(), v.getZ(), .1);
}
for (Entity entity : MMOUtils.getNearbyChunkEntities(loc))
if (entity.getLocation().distanceSquared(loc) < Math.pow(radius, 2) && MMOUtils.canTarget(attack.getPlayer(), entity))
entity.setVelocity(MMOUtils.normalize(loc.clone().subtract(entity.getLocation()).toVector()).multiply(.5));
}
}.runTaskTimer(MMOItems.plugin, 0, 1);
}
}

View File

@ -1,64 +0,0 @@
package net.Indyuce.mmoitems.ability.list.location;
import io.lumine.mythic.lib.damage.AttackMetadata;
import io.lumine.mythic.lib.damage.DamageMetadata;
import io.lumine.mythic.lib.damage.DamageType;
import io.lumine.mythic.lib.version.VersionSound;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.LocationAbility;
import net.Indyuce.mmoitems.ability.metadata.LocationAbilityMetadata;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.scheduler.BukkitRunnable;
public class Contamination extends LocationAbility {
public Contamination() {
super();
addModifier("damage", 2);
addModifier("duration", 8);
addModifier("cooldown", 10);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public void whenCast(AttackMetadata attack, LocationAbilityMetadata ability) {
Location loc = ability.getTarget();
double duration = Math.min(30, ability.getModifier("duration")) * 20;
loc.add(0, .1, 0);
new BukkitRunnable() {
final double dps = ability.getModifier("damage") / 2;
double ti = 0;
int j = 0;
public void run() {
j++;
if (j >= duration)
cancel();
loc.getWorld().spawnParticle(Particle.REDSTONE, loc.clone().add(Math.cos(ti / 3) * 5, 0, Math.sin(ti / 3) * 5), 1,
new Particle.DustOptions(Color.PURPLE, 1));
for (int j = 0; j < 3; j++) {
ti += Math.PI / 32;
double r = Math.sin(ti / 2) * 4;
for (double k = 0; k < Math.PI * 2; k += Math.PI * 2 / 3)
loc.getWorld().spawnParticle(Particle.SPELL_WITCH, loc.clone().add(r * Math.cos(k + ti / 4), 0, r * Math.sin(k + ti / 4)), 0);
}
if (j % 10 == 0) {
loc.getWorld().playSound(loc, VersionSound.ENTITY_ENDERMAN_HURT.toSound(), 2, 1);
for (Entity entity : MMOUtils.getNearbyChunkEntities(loc))
if (MMOUtils.canTarget(attack.getPlayer(), entity) && entity.getLocation().distanceSquared(loc) <= 25)
new AttackMetadata(new DamageMetadata(dps, DamageType.SKILL, DamageType.MAGIC), attack.getStats()).damage((LivingEntity) entity, false);
}
}
}.runTaskTimer(MMOItems.plugin, 0, 1);
}
}

View File

@ -1,45 +0,0 @@
package net.Indyuce.mmoitems.ability.list.location;
import io.lumine.mythic.lib.damage.AttackMetadata;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.LocationAbility;
import net.Indyuce.mmoitems.ability.metadata.LocationAbilityMetadata;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
public class Corrosion extends LocationAbility {
public Corrosion() {
super();
addModifier("duration", 4);
addModifier("amplifier", 1);
addModifier("radius", 5);
addModifier("cooldown", 10);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public void whenCast(AttackMetadata attack, LocationAbilityMetadata ability) {
Location loc = 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);
loc.getWorld().playSound(loc, Sound.BLOCK_BREWING_STAND_BREW, 2, 0);
for (Entity entity : MMOUtils.getNearbyChunkEntities(loc))
if (entity.getLocation().distanceSquared(loc) < radiusSquared && MMOUtils.canTarget(attack.getPlayer(), entity)) {
((LivingEntity) entity).removePotionEffect(PotionEffectType.POISON);
((LivingEntity) entity).addPotionEffect(new PotionEffect(PotionEffectType.POISON, duration, amplifier));
}
}
}

View File

@ -1,55 +0,0 @@
package net.Indyuce.mmoitems.ability.list.location;
import io.lumine.mythic.lib.damage.AttackMetadata;
import io.lumine.mythic.lib.damage.DamageMetadata;
import io.lumine.mythic.lib.damage.DamageType;
import io.lumine.mythic.lib.version.VersionSound;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.LocationAbility;
import net.Indyuce.mmoitems.ability.metadata.LocationAbilityMetadata;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
public class Corrupt extends LocationAbility {
public Corrupt() {
super();
addModifier("damage", 8);
addModifier("duration", 4);
addModifier("amplifier", 1);
addModifier("cooldown", 10);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public void whenCast(AttackMetadata attack, LocationAbilityMetadata ability) {
Location loc = 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);
attack.getPlayer().getWorld().playSound(attack.getPlayer().getLocation(), VersionSound.ENTITY_ENDERMAN_HURT.toSound(), 1, .5f);
for (double j = 0; j < Math.PI * 2; j += Math.PI / 36) {
Location loc1 = loc.clone().add(Math.cos(j) * radius, 1, Math.sin(j) * radius);
double y_max = .5 + random.nextDouble();
for (double y = 0; y < y_max; y += .1)
loc1.getWorld().spawnParticle(Particle.REDSTONE, loc1.clone().add(0, y, 0), 1, new Particle.DustOptions(Color.PURPLE, 1));
}
for (Entity entity : MMOUtils.getNearbyChunkEntities(loc))
if (MMOUtils.canTarget(attack.getPlayer(), entity) && entity.getLocation().distanceSquared(loc) <= radius * radius) {
new AttackMetadata(new DamageMetadata(damage, DamageType.SKILL, DamageType.MAGIC), attack.getStats()).damage((LivingEntity) entity);
((LivingEntity) entity).removePotionEffect(PotionEffectType.WITHER);
((LivingEntity) entity).addPotionEffect(new PotionEffect(PotionEffectType.WITHER, (int) (duration * 20), (int) amplifier));
}
}
}

View File

@ -1,52 +0,0 @@
package net.Indyuce.mmoitems.ability.list.location;
import io.lumine.mythic.lib.version.VersionSound;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.LocationAbility;
import net.Indyuce.mmoitems.ability.metadata.LocationAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
public class Freeze extends LocationAbility {
public Freeze() {
super();
addModifier("duration", 4);
addModifier("amplifier", 2);
addModifier("radius", 5);
addModifier("cooldown", 10);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public LocationAbilityMetadata canBeCast(AttackMetadata attack, LivingEntity target, AbilityData ability) {
return new LocationAbilityMetadata(ability, attack.getPlayer(), target);
}
@Override
public void whenCast(AttackMetadata attack, LocationAbilityMetadata ability) {
Location loc = 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);
loc.getWorld().spawnParticle(Particle.FIREWORKS_SPARK, loc, 24, 0, 0, 0, .2);
loc.getWorld().playSound(loc, VersionSound.ENTITY_FIREWORK_ROCKET_LARGE_BLAST.toSound(), 2, 1);
for (Entity entity : MMOUtils.getNearbyChunkEntities(loc))
if (entity.getLocation().distanceSquared(loc) < radiusSquared && MMOUtils.canTarget(attack.getPlayer(), entity)) {
((LivingEntity) entity).removePotionEffect(PotionEffectType.SLOW);
((LivingEntity) entity).addPotionEffect(new PotionEffect(PotionEffectType.SLOW, duration, amplifier));
}
}
}

View File

@ -1,73 +0,0 @@
package net.Indyuce.mmoitems.ability.list.location;
import io.lumine.mythic.lib.damage.AttackMetadata;
import io.lumine.mythic.lib.damage.DamageMetadata;
import io.lumine.mythic.lib.damage.DamageType;
import io.lumine.mythic.lib.version.VersionSound;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.LocationAbility;
import net.Indyuce.mmoitems.ability.metadata.LocationAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitRunnable;
public class Freezing_Curse extends LocationAbility {
public Freezing_Curse() {
super();
addModifier("cooldown", 7);
addModifier("duration", 3);
addModifier("damage", 3);
addModifier("radius", 3);
addModifier("amplifier", 1);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public void whenCast(AttackMetadata attack, LocationAbilityMetadata ability) {
Location loc = ability.getTarget();
new BukkitRunnable() {
final double rads = Math.toRadians(attack.getPlayer().getEyeLocation().getYaw() - 90);
double ti = rads;
int j = 0;
public void run() {
if (j++ % 2 == 0)
loc.getWorld().playSound(loc, VersionSound.BLOCK_NOTE_BLOCK_PLING.toSound(), 2, (float) (.5 + ((ti - rads) / (Math.PI * 2) * 1.5)));
for (int j = 0; j < 2; j++) {
ti += Math.PI / 32;
loc.getWorld().spawnParticle(Particle.SPELL_INSTANT, loc.clone().add(Math.cos(ti) * 3, .1, Math.sin(ti) * 3), 0);
}
if (ti > Math.PI * 2 + rads) {
loc.getWorld().playSound(loc, Sound.BLOCK_GLASS_BREAK, 3, .5f);
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 = 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.canTarget(attack.getPlayer(), entity)) {
new AttackMetadata(new DamageMetadata(damage, DamageType.SKILL, DamageType.MAGIC), attack.getStats()).damage((LivingEntity) entity);
((LivingEntity) entity).removePotionEffect(PotionEffectType.SLOW);
((LivingEntity) entity).addPotionEffect(new PotionEffect(PotionEffectType.SLOW, (int) (duration * 20), (int) amplifier));
}
cancel();
}
}
}.runTaskTimer(MMOItems.plugin, 0, 1);
}
}

View File

@ -1,41 +0,0 @@
package net.Indyuce.mmoitems.ability.list.location;
import io.lumine.mythic.lib.version.VersionSound;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.LocationAbility;
import net.Indyuce.mmoitems.ability.metadata.LocationAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.entity.Entity;
public class Ignite extends LocationAbility {
public Ignite() {
super();
addModifier("duration", 80);
addModifier("max-ignite", 200);
addModifier("radius", 5);
addModifier("cooldown", 10);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public void whenCast(AttackMetadata attack, LocationAbilityMetadata ability) {
Location loc = 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);
loc.getWorld().spawnParticle(Particle.FLAME, loc, 48, 0, 0, 0.13);
loc.getWorld().playSound(loc, VersionSound.ENTITY_FIREWORK_ROCKET_LARGE_BLAST.toSound(), 2, 1);
for (Entity entity : MMOUtils.getNearbyChunkEntities(loc))
if (entity.getLocation().distanceSquared(loc) < radiusSquared && MMOUtils.canTarget(attack.getPlayer(), entity))
entity.setFireTicks(Math.min(entity.getFireTicks() + ignite, maxIgnite));
}
}

View File

@ -1,75 +0,0 @@
package net.Indyuce.mmoitems.ability.list.location;
import io.lumine.mythic.lib.damage.AttackMetadata;
import io.lumine.mythic.lib.damage.DamageMetadata;
import io.lumine.mythic.lib.damage.DamageType;
import io.lumine.mythic.lib.version.VersionSound;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.LocationAbility;
import net.Indyuce.mmoitems.ability.metadata.LocationAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
public class Life_Ender extends LocationAbility {
public Life_Ender() {
super();
addModifier("damage", 5);
addModifier("knockback", 1);
addModifier("radius", 4);
addModifier("cooldown", 10);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public void whenCast(AttackMetadata attack, LocationAbilityMetadata ability) {
Location loc = ability.getTarget();
double damage = ability.getModifier("damage");
double knockback = ability.getModifier("knockback");
double radius = ability.getModifier("radius");
attack.getPlayer().getWorld().playSound(attack.getPlayer().getLocation(), VersionSound.ENTITY_ENDERMAN_TELEPORT.toSound(), 2, 1);
new BukkitRunnable() {
final Location source = loc.clone().add(5 * Math.cos(random.nextDouble() * 2 * Math.PI), 20, 5 * Math.sin(random.nextDouble() * 2 * Math.PI));
final Vector vec = loc.subtract(source).toVector().multiply((double) 1 / 30);
int ti = 0;
public void run() {
if (ti == 0)
loc.setDirection(vec);
for (int k = 0; k < 2; k++) {
ti++;
source.add(vec);
for (double i = 0; i < Math.PI * 2; i += Math.PI / 6) {
Vector vec = MMOUtils.rotateFunc(new Vector(Math.cos(i), Math.sin(i), 0), loc);
source.getWorld().spawnParticle(Particle.SMOKE_LARGE, source, 0, vec.getX(), vec.getY(), vec.getZ(), .1);
}
}
if (ti >= 30) {
source.getWorld().playSound(source, Sound.ENTITY_GENERIC_EXPLODE, 3, 1);
source.getWorld().spawnParticle(Particle.FLAME, source, 64, 0, 0, 0, .25);
source.getWorld().spawnParticle(Particle.LAVA, source, 32);
for (double j = 0; j < Math.PI * 2; j += Math.PI / 24)
source.getWorld().spawnParticle(Particle.SMOKE_LARGE, source, 0, Math.cos(j), 0, Math.sin(j), .5);
for (Entity entity : MMOUtils.getNearbyChunkEntities(source))
if (entity.getLocation().distanceSquared(source) < radius * radius && MMOUtils.canTarget(attack.getPlayer(), entity)) {
new AttackMetadata(new DamageMetadata(damage, DamageType.SKILL, DamageType.MAGIC), attack.getStats()).damage((LivingEntity) entity);
entity.setVelocity(entity.getLocation().subtract(source).toVector().setY(.75).normalize().multiply(knockback));
}
cancel();
}
}
}.runTaskTimer(MMOItems.plugin, 0, 1);
}
}

View File

@ -1,53 +0,0 @@
package net.Indyuce.mmoitems.ability.list.location;
import io.lumine.mythic.lib.damage.AttackMetadata;
import io.lumine.mythic.lib.damage.DamageMetadata;
import io.lumine.mythic.lib.damage.DamageType;
import io.lumine.mythic.lib.version.VersionSound;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.LocationAbility;
import net.Indyuce.mmoitems.ability.metadata.LocationAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.util.Vector;
public class Lightning_Beam extends LocationAbility {
public Lightning_Beam() {
super();
addModifier("damage", 8);
addModifier("radius", 5);
addModifier("cooldown", 10);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public void whenCast(AttackMetadata attack, LocationAbilityMetadata ability) {
final Location loc = getFirstNonSolidBlock(ability.getTarget());
double damage = ability.getModifier("damage");
double radius = ability.getModifier("radius");
for (Entity entity : MMOUtils.getNearbyChunkEntities(loc))
if (MMOUtils.canTarget(attack.getPlayer(), entity) && entity.getLocation().distanceSquared(loc) <= radius * radius)
new AttackMetadata(new DamageMetadata(damage, DamageType.SKILL, DamageType.MAGIC), attack.getStats()).damage((LivingEntity) entity);
attack.getPlayer().getWorld().playSound(attack.getPlayer().getLocation(), VersionSound.ENTITY_FIREWORK_ROCKET_BLAST.toSound(), 1, 0);
loc.getWorld().spawnParticle(Particle.FIREWORKS_SPARK, loc, 64, 0, 0, 0, .2);
loc.getWorld().spawnParticle(Particle.EXPLOSION_NORMAL, loc, 32, 0, 0, 0, .2);
Vector vec = new Vector(0, .3, 0);
for (double j = 0; j < 40; j += .3)
loc.getWorld().spawnParticle(Particle.FIREWORKS_SPARK, loc.add(vec), 6, .1, .1, .1, .01);
}
private Location getFirstNonSolidBlock(Location loc) {
Location initial = loc.clone();
for (int j = 0; j < 5; j++)
if (!loc.add(0, 1, 0).getBlock().getType().isSolid())
return loc;
return initial;
}
}

View File

@ -1,46 +0,0 @@
package net.Indyuce.mmoitems.ability.list.location;
import io.lumine.mythic.lib.damage.AttackMetadata;
import io.lumine.mythic.lib.damage.DamageMetadata;
import io.lumine.mythic.lib.damage.DamageType;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.LocationAbility;
import net.Indyuce.mmoitems.ability.metadata.LocationAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
public class Minor_Explosion extends LocationAbility {
public Minor_Explosion() {
super();
addModifier("damage", 6);
addModifier("knockback", 1);
addModifier("radius", 5);
addModifier("cooldown", 10);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public void whenCast(AttackMetadata attack, LocationAbilityMetadata ability) {
Location loc = 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);
loc.getWorld().playSound(loc, Sound.ENTITY_GENERIC_EXPLODE, 2, 1);
for (Entity entity : MMOUtils.getNearbyChunkEntities(loc))
if (entity.getLocation().distanceSquared(loc) < radiusSquared && MMOUtils.canTarget(attack.getPlayer(), entity)) {
new AttackMetadata(new DamageMetadata(damage, DamageType.SKILL, DamageType.MAGIC), attack.getStats()).damage((LivingEntity) entity);
entity.setVelocity(MMOUtils.normalize(entity.getLocation().subtract(loc).toVector().setY(0)).setY(.2).multiply(2 * knockback));
}
}
}

View File

@ -1,104 +0,0 @@
package net.Indyuce.mmoitems.ability.list.location;
import io.lumine.mythic.lib.api.util.TemporaryListener;
import io.lumine.mythic.lib.version.VersionSound;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.LocationAbility;
import net.Indyuce.mmoitems.ability.metadata.LocationAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Snowball;
import org.bukkit.entity.Snowman;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
public class Snowman_Turret extends LocationAbility {
public Snowman_Turret() {
super();
addModifier("duration", 6);
addModifier("cooldown", 35);
addModifier("damage", 2);
addModifier("radius", 20);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public void whenCast(AttackMetadata attack, LocationAbilityMetadata ability) {
Location loc = ability.getTarget();
double duration = Math.min(ability.getModifier("duration") * 20, 300);
double radiusSquared = Math.pow(ability.getModifier("radius"), 2);
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);
snowman.setInvulnerable(true);
snowman.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 100000, 254, true));
new BukkitRunnable() {
int ti = 0;
double j = 0;
final TurretHandler turret = new TurretHandler(ability.getModifier("damage"));
public void run() {
if (ti++ > duration || attack.getPlayer().isDead() || snowman == null || snowman.isDead()) {
turret.close(3 * 20);
snowman.remove();
cancel();
}
j += Math.PI / 24 % (2 * Math.PI);
for (double k = 0; k < 3; k++)
snowman.getWorld().spawnParticle(Particle.SPELL_INSTANT,
snowman.getLocation().add(Math.cos(j + k / 3 * 2 * Math.PI) * 1.3, 1, Math.sin(j + k / 3 * 2 * Math.PI) * 1.3), 0);
snowman.getWorld().spawnParticle(Particle.SPELL_INSTANT, snowman.getLocation().add(0, 1, 0), 1, 0, 0, 0, .2);
if (ti % 2 == 0)
for (Entity entity : MMOUtils.getNearbyChunkEntities(snowman.getLocation()))
if (!entity.equals(snowman) && MMOUtils.canTarget(attack.getPlayer(), entity)
&& entity.getLocation().distanceSquared(snowman.getLocation()) < radiusSquared) {
snowman.getWorld().playSound(snowman.getLocation(), Sound.ENTITY_SNOWBALL_THROW, 1, 1.3f);
Snowball snowball = snowman.launchProjectile(Snowball.class);
snowball.setVelocity(entity.getLocation().add(0, entity.getHeight() / 2, 0).toVector()
.subtract(snowman.getLocation().add(0, 1, 0).toVector()).normalize().multiply(1.3));
turret.entities.add(snowball.getUniqueId());
break;
}
}
}.runTaskTimer(MMOItems.plugin, 0, 1);
}
public static class TurretHandler extends TemporaryListener {
private final List<UUID> entities = new ArrayList<>();
private final double damage;
public TurretHandler(double damage) {
super(EntityDamageByEntityEvent.getHandlerList());
this.damage = damage;
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void a(EntityDamageByEntityEvent event) {
if (entities.contains(event.getDamager().getUniqueId()))
event.setDamage(damage);
}
@Override
public void whenClosed() {
// Nothing
}
}
}

View File

@ -1,73 +0,0 @@
package net.Indyuce.mmoitems.ability.list.misc;
import io.lumine.mythic.lib.damage.AttackMetadata;
import io.lumine.mythic.lib.damage.DamageMetadata;
import io.lumine.mythic.lib.damage.DamageType;
import io.lumine.mythic.lib.version.VersionSound;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.Ability;
import net.Indyuce.mmoitems.ability.metadata.VectorAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
import java.util.ArrayList;
import java.util.List;
public class Arcane_Rift extends Ability<VectorAbilityMetadata> {
public Arcane_Rift() {
super();
addModifier("damage", 5);
addModifier("amplifier", 2);
addModifier("cooldown", 10);
addModifier("speed", 1);
addModifier("duration", 1.5);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public VectorAbilityMetadata canBeCast(AttackMetadata attack, LivingEntity target, AbilityData ability) {
return attack.getPlayer().isOnGround() ? new VectorAbilityMetadata(ability, attack.getPlayer(), target) : null;
}
@Override
public void whenCast(AttackMetadata attack, VectorAbilityMetadata ability) {
double damage = ability.getModifier("damage");
double slowDuration = ability.getModifier("duration");
double slowAmplifier = ability.getModifier("amplifier");
attack.getPlayer().getWorld().playSound(attack.getPlayer().getLocation(), VersionSound.ENTITY_ENDERMAN_DEATH.toSound(), 2, .5f);
new BukkitRunnable() {
final Vector vec = ability.getTarget().setY(0).normalize().multiply(.5 * ability.getModifier("speed"));
final Location loc = attack.getPlayer().getLocation();
final int duration = (int) (20 * Math.min(ability.getModifier("duration"), 10.));
final List<Integer> hit = new ArrayList<>();
int ti = 0;
public void run() {
if (ti++ > duration)
cancel();
loc.add(vec);
loc.getWorld().spawnParticle(Particle.SPELL_WITCH, loc, 5, .5, 0, .5, 0);
for (Entity entity : MMOUtils.getNearbyChunkEntities(loc))
if (MMOUtils.canTarget(attack.getPlayer(), entity) && loc.distanceSquared(entity.getLocation()) < 2 && !hit.contains(entity.getEntityId())) {
hit.add(entity.getEntityId());
new AttackMetadata(new DamageMetadata(damage, DamageType.SKILL, DamageType.MAGIC), attack.getStats()).damage((LivingEntity) entity);
((LivingEntity) entity).addPotionEffect(new PotionEffect(PotionEffectType.SLOW, (int) (slowDuration * 20), (int) slowAmplifier));
}
}
}.runTaskTimer(MMOItems.plugin, 0, 1);
}
}

View File

@ -1,72 +0,0 @@
package net.Indyuce.mmoitems.ability.list.misc;
import io.lumine.mythic.lib.damage.AttackMetadata;
import io.lumine.mythic.lib.damage.DamageMetadata;
import io.lumine.mythic.lib.damage.DamageType;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.Ability;
import net.Indyuce.mmoitems.ability.metadata.VectorAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
import java.util.ArrayList;
import java.util.List;
public class Earthquake extends Ability<VectorAbilityMetadata> {
public Earthquake() {
super();
addModifier("damage", 3);
addModifier("duration", 2);
addModifier("amplifier", 1);
addModifier("cooldown", 10);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public VectorAbilityMetadata canBeCast(AttackMetadata attack, LivingEntity target, AbilityData ability) {
return attack.getPlayer().isOnGround() ? new VectorAbilityMetadata(ability, attack.getPlayer(), target) : null;
}
@Override
public void whenCast(AttackMetadata attack, VectorAbilityMetadata ability) {
double damage = ability.getModifier("damage");
double slowDuration = ability.getModifier("duration");
double slowAmplifier = ability.getModifier("amplifier");
new BukkitRunnable() {
final Vector vec = ability.getTarget().setY(0);
final Location loc = attack.getPlayer().getLocation();
final List<Integer> hit = new ArrayList<>();
int ti = 0;
public void run() {
ti++;
if (ti > 20)
cancel();
loc.add(vec);
loc.getWorld().spawnParticle(Particle.CLOUD, loc, 5, .5, 0, .5, 0);
loc.getWorld().playSound(loc, Sound.BLOCK_GRAVEL_BREAK, 2, 1);
for (Entity entity : MMOUtils.getNearbyChunkEntities(loc))
if (MMOUtils.canTarget(attack.getPlayer(), entity) && loc.distanceSquared(entity.getLocation()) < 2 && !hit.contains(entity.getEntityId())) {
hit.add(entity.getEntityId());
new AttackMetadata(new DamageMetadata(damage, DamageType.SKILL, DamageType.MAGIC), attack.getStats()).damage((LivingEntity) entity);
((LivingEntity) entity).addPotionEffect(new PotionEffect(PotionEffectType.SLOW, (int) (slowDuration * 20), (int) slowAmplifier));
}
}
}.runTaskTimer(MMOItems.plugin, 0, 1);
}
}

View File

@ -1,58 +0,0 @@
package net.Indyuce.mmoitems.ability.list.misc;
import io.lumine.mythic.lib.damage.AttackMetadata;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.ability.Ability;
import net.Indyuce.mmoitems.ability.metadata.SimpleAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
public class Hoearthquake extends Ability<SimpleAbilityMetadata> {
public Hoearthquake() {
super();
addModifier("cooldown", 10);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public SimpleAbilityMetadata canBeCast(AttackMetadata attack, LivingEntity target, AbilityData ability) {
return attack.getPlayer().isOnGround() ? new SimpleAbilityMetadata(ability) : null;
}
@Override
public void whenCast(AttackMetadata attack, SimpleAbilityMetadata ability) {
new BukkitRunnable() {
final Vector vec = attack.getPlayer().getEyeLocation().getDirection().setY(0);
final Location loc = attack.getPlayer().getLocation();
int ti = 0;
public void run() {
if (ti++ > 20)
cancel();
loc.add(vec);
loc.getWorld().playSound(loc, Sound.BLOCK_GRAVEL_BREAK, 2, 1);
loc.getWorld().spawnParticle(Particle.CLOUD, loc, 1, .5, 0, .5, 0);
for (int x = -1; x < 2; x++)
for (int z = -1; z < 2; z++) {
Block b = loc.clone().add(x, -1, z).getBlock();
if (b.getType() == Material.GRASS || b.getType() == Material.DIRT) {
BlockBreakEvent event = new BlockBreakEvent(b, attack.getPlayer());
event.setDropItems(false);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) b.setType(Material.FARMLAND);
}
}
}
}.runTaskTimer(MMOItems.plugin, 0, 1);
}
}

View File

@ -1,73 +0,0 @@
package net.Indyuce.mmoitems.ability.list.misc;
import io.lumine.mythic.lib.damage.AttackMetadata;
import io.lumine.mythic.lib.damage.DamageMetadata;
import io.lumine.mythic.lib.damage.DamageType;
import io.lumine.mythic.lib.version.VersionSound;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.ItemAbility;
import net.Indyuce.mmoitems.ability.metadata.ItemAbilityMetadata;
import net.Indyuce.mmoitems.api.util.NoClipItem;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitRunnable;
public class Item_Bomb extends ItemAbility {
public Item_Bomb() {
super();
addModifier("damage", 7);
addModifier("radius", 6);
addModifier("slow-duration", 4);
addModifier("slow-amplifier", 1);
addModifier("cooldown", 15);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public void whenCast(AttackMetadata attack, ItemAbilityMetadata ability) {
ItemStack itemStack = ability.getItem();
final NoClipItem item = new NoClipItem(attack.getPlayer().getLocation().add(0, 1.2, 0), itemStack);
item.getEntity().setVelocity(ability.getTarget().multiply(1.3));
attack.getPlayer().getWorld().playSound(attack.getPlayer().getLocation(), Sound.ENTITY_SNOWBALL_THROW, 2, 0);
new BukkitRunnable() {
int j = 0;
public void run() {
if (j++ > 40) {
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.canTarget(attack.getPlayer(), entity)) {
new AttackMetadata(new DamageMetadata(damage, DamageType.SKILL, DamageType.PHYSICAL), attack.getStats()).damage((LivingEntity) entity);
((LivingEntity) entity).removePotionEffect(PotionEffectType.SLOW);
((LivingEntity) entity).addPotionEffect(new PotionEffect(PotionEffectType.SLOW, (int) (slowDuration * 20), (int) slowAmplifier));
}
item.getEntity().getWorld().spawnParticle(Particle.EXPLOSION_LARGE, item.getEntity().getLocation(), 24, 2, 2, 2, 0);
item.getEntity().getWorld().spawnParticle(Particle.EXPLOSION_NORMAL, item.getEntity().getLocation(), 48, 0, 0, 0, .2);
item.getEntity().getWorld().playSound(item.getEntity().getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 3, 0);
item.close();
cancel();
return;
}
item.getEntity().getWorld().spawnParticle(Particle.SMOKE_LARGE, item.getEntity().getLocation().add(0, .2, 0), 0);
item.getEntity().getWorld().spawnParticle(Particle.FIREWORKS_SPARK, item.getEntity().getLocation().add(0, .2, 0), 1, 0, 0, 0, .1);
item.getEntity().getWorld().playSound(item.getEntity().getLocation(), VersionSound.BLOCK_NOTE_BLOCK_HAT.toSound(), 2, (float) (.5 + (j / 40. * 1.5)));
}
}.runTaskTimer(MMOItems.plugin, 0, 1);
}
}

View File

@ -1,72 +0,0 @@
package net.Indyuce.mmoitems.ability.list.misc;
import io.lumine.mythic.lib.damage.AttackMetadata;
import io.lumine.mythic.lib.damage.DamageMetadata;
import io.lumine.mythic.lib.damage.DamageType;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.ItemAbility;
import net.Indyuce.mmoitems.ability.metadata.ItemAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import net.Indyuce.mmoitems.api.util.NoClipItem;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable;
public class Item_Throw extends ItemAbility {
public Item_Throw() {
super();
addModifier("damage", 6);
addModifier("force", 1);
addModifier("cooldown", 10);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public void whenCast(AttackMetadata attack, ItemAbilityMetadata ability) {
ItemStack itemStack = ability.getItem();
/*boolean hasAbility = false;
for (JsonElement entry : MythicLib.plugin.getJson().parse(nbtItem.getString("MMOITEMS_ABILITY"), JsonArray.class)) {
if (!entry.isJsonObject())
continue;
JsonObject object = entry.getAsJsonObject();
if (object.get("Id").getAsString().equalsIgnoreCase(getID())) {
hasAbility = true;
break;
}
}
if (!hasAbility)
return;*/
final NoClipItem item = new NoClipItem(attack.getPlayer().getLocation().add(0, 1.2, 0), itemStack);
item.getEntity().setVelocity(ability.getTarget().multiply(1.5 * ability.getModifier("force")));
attack.getPlayer().getWorld().playSound(attack.getPlayer().getLocation(), Sound.ENTITY_SNOWBALL_THROW, 1, 0);
new BukkitRunnable() {
double ti = 0;
public void run() {
ti++;
if (ti > 20 || item.getEntity().isDead()) {
item.close();
cancel();
}
item.getEntity().getWorld().spawnParticle(Particle.CRIT, item.getEntity().getLocation(), 0);
for (Entity target : item.getEntity().getNearbyEntities(1, 1, 1))
if (MMOUtils.canTarget(attack.getPlayer(), target)) {
new AttackMetadata(new DamageMetadata(ability.getModifier("damage"), DamageType.SKILL, DamageType.PHYSICAL, DamageType.PROJECTILE), attack.getStats()).damage((LivingEntity) target);
item.close();
cancel();
}
}
}.runTaskTimer(MMOItems.plugin, 0, 1);
}
}

View File

@ -1,48 +0,0 @@
package net.Indyuce.mmoitems.ability.list.misc;
import io.lumine.mythic.lib.version.VersionSound;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.ability.SimpleAbility;
import net.Indyuce.mmoitems.ability.metadata.SimpleAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import org.bukkit.Particle;
import org.bukkit.entity.LivingEntity;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
public class Leap extends SimpleAbility {
public Leap() {
super();
addModifier("force", 1);
addModifier("cooldown", 10);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public SimpleAbilityMetadata canBeCast(AttackMetadata attack, LivingEntity target, AbilityData ability) {
return attack.getPlayer().isOnGround() ? new SimpleAbilityMetadata(ability) : null;
}
@Override
public void whenCast(AttackMetadata attack, SimpleAbilityMetadata ability) {
attack.getPlayer().getWorld().playSound(attack.getPlayer().getLocation(), VersionSound.ENTITY_ENDER_DRAGON_FLAP.toSound(), 1, 0);
attack.getPlayer().getWorld().spawnParticle(Particle.EXPLOSION_NORMAL, attack.getPlayer().getLocation(), 16, 0, 0, 0.1);
Vector vec = attack.getPlayer().getEyeLocation().getDirection().multiply(2 * ability.getModifier("force"));
vec.setY(vec.getY() / 2);
attack.getPlayer().setVelocity(vec);
new BukkitRunnable() {
double ti = 0;
public void run() {
ti++;
if (ti > 20)
cancel();
attack.getPlayer().getWorld().spawnParticle(Particle.CLOUD, attack.getPlayer().getLocation().add(0, 1, 0), 0);
}
}.runTaskTimer(MMOItems.plugin, 0, 1);
}
}

View File

@ -1,48 +0,0 @@
package net.Indyuce.mmoitems.ability.list.misc;
import io.lumine.mythic.lib.damage.AttackMetadata;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.FriendlyTargetAbility;
import net.Indyuce.mmoitems.ability.metadata.FriendlyTargetAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Particle;
import org.bukkit.entity.LivingEntity;
import org.bukkit.scheduler.BukkitRunnable;
public class Regen_Ally extends FriendlyTargetAbility {
public Regen_Ally() {
super();
addModifier("heal", 7);
addModifier("duration", 3);
addModifier("cooldown", 10);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public void whenCast(AttackMetadata attack, FriendlyTargetAbilityMetadata ability) {
LivingEntity target = ability.getTarget();
new BukkitRunnable() {
final double duration = Math.min(ability.getModifier("duration"), 60) * 20;
final double hps = ability.getModifier("heal") / duration * 4;
double ti = 0;
double a = 0;
public void run() {
if (ti++ > duration || target.isDead()) {
cancel();
return;
}
a += Math.PI / 16;
target.getWorld().spawnParticle(Particle.HEART, target.getLocation().add(1.3 * Math.cos(a), .3, 1.3 * Math.sin(a)), 0);
if (ti % 4 == 0)
MMOUtils.heal(target, hps);
}
}.runTaskTimer(MMOItems.plugin, 0, 1);
}
}

View File

@ -1,32 +0,0 @@
package net.Indyuce.mmoitems.ability.list.simple;
import io.lumine.mythic.lib.version.VersionSound;
import net.Indyuce.mmoitems.ability.SimpleAbility;
import net.Indyuce.mmoitems.ability.metadata.SimpleAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Location;
import org.bukkit.Particle;
public class Blink extends SimpleAbility {
public Blink() {
super();
addModifier("range", 8);
addModifier("cooldown", 10);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public void whenCast(AttackMetadata attack, SimpleAbilityMetadata ability) {
attack.getPlayer().getWorld().spawnParticle(Particle.EXPLOSION_LARGE, attack.getPlayer().getLocation().add(0, 1, 0), 0);
attack.getPlayer().getWorld().spawnParticle(Particle.SPELL_INSTANT, attack.getPlayer().getLocation().add(0, 1, 0), 32, 0, 0, 0, .1);
attack.getPlayer().getWorld().playSound(attack.getPlayer().getLocation(), VersionSound.ENTITY_ENDERMAN_TELEPORT.toSound(), 1, 1);
Location loc = attack.getPlayer().getTargetBlock(null, (int) ability.getModifier("range")).getLocation().add(0, 1, 0);
loc.setYaw(attack.getPlayer().getLocation().getYaw());
loc.setPitch(attack.getPlayer().getLocation().getPitch());
attack.getPlayer().teleport(loc);
attack.getPlayer().getWorld().spawnParticle(Particle.EXPLOSION_LARGE, attack.getPlayer().getLocation().add(0, 1, 0), 0);
attack.getPlayer().getWorld().spawnParticle(Particle.SPELL_INSTANT, attack.getPlayer().getLocation().add(0, 1, 0), 32, 0, 0, 0, .1);
}
}

View File

@ -1,83 +0,0 @@
package net.Indyuce.mmoitems.ability.list.simple;
import io.lumine.mythic.lib.api.util.TemporaryListener;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.ability.SimpleAbility;
import net.Indyuce.mmoitems.ability.metadata.SimpleAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.entity.Snowball;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
public class Blizzard extends SimpleAbility {
public Blizzard() {
super();
addModifier("duration", 2.5);
addModifier("damage", 2);
addModifier("inaccuracy", 10);
addModifier("force", 1);
addModifier("cooldown", 10);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public void whenCast(AttackMetadata attack, SimpleAbilityMetadata ability) {
double duration = ability.getModifier("duration") * 10;
double force = ability.getModifier("force");
double inaccuracy = ability.getModifier("inaccuracy");
new BukkitRunnable() {
final SnowballThrower handler = new SnowballThrower(ability.getModifier("damage"));
int j = 0;
public void run() {
if (j++ > duration) {
handler.close(5 * 20);
cancel();
return;
}
Location loc = attack.getPlayer().getEyeLocation();
loc.setPitch((float) (loc.getPitch() + (random.nextDouble() - .5) * inaccuracy));
loc.setYaw((float) (loc.getYaw() + (random.nextDouble() - .5) * inaccuracy));
loc.getWorld().playSound(loc, Sound.ENTITY_SNOWBALL_THROW, 1, 1);
Snowball snowball = attack.getPlayer().launchProjectile(Snowball.class);
snowball.setVelocity(loc.getDirection().multiply(1.3 * force));
handler.entities.add(snowball.getUniqueId());
}
}.runTaskTimer(MMOItems.plugin, 0, 2);
}
public static class SnowballThrower extends TemporaryListener {
private final List<UUID> entities = new ArrayList<>();
private final double damage;
public SnowballThrower(double damage) {
super(EntityDamageByEntityEvent.getHandlerList());
this.damage = damage;
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void a(EntityDamageByEntityEvent event) {
if (entities.contains(event.getDamager().getUniqueId()))
event.setDamage(damage);
}
@Override
public void whenClosed() {
// Nothing
}
}
}

View File

@ -1,82 +0,0 @@
package net.Indyuce.mmoitems.ability.list.simple;
import io.lumine.mythic.lib.api.util.TemporaryListener;
import io.lumine.mythic.lib.version.VersionSound;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.ability.SimpleAbility;
import net.Indyuce.mmoitems.ability.metadata.SimpleAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Bukkit;
import org.bukkit.Particle;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.scheduler.BukkitRunnable;
public class Bunny_Mode extends SimpleAbility {
public Bunny_Mode() {
super();
addModifier("duration", 20);
addModifier("jump-force", 1);
addModifier("cooldown", 50);
addModifier("speed", 1);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public void whenCast(AttackMetadata attack, SimpleAbilityMetadata ability) {
double duration = ability.getModifier("duration") * 20;
double y = ability.getModifier("jump-force");
double xz = ability.getModifier("speed");
new BukkitRunnable() {
final BunnyHandler handler = new BunnyHandler(attack.getPlayer(), duration);
int j = 0;
public void run() {
if (j++ > duration) {
handler.close(3 * 20);
cancel();
return;
}
if (attack.getPlayer().getLocation().add(0, -.5, 0).getBlock().getType().isSolid()) {
attack.getPlayer()
.setVelocity(attack.getPlayer().getEyeLocation().getDirection().setY(0).normalize().multiply(.8 * xz).setY(0.5 * y / xz));
attack.getPlayer().getWorld().playSound(attack.getPlayer().getLocation(), VersionSound.ENTITY_ENDER_DRAGON_FLAP.toSound(), 2, 1);
for (double a = 0; a < Math.PI * 2; a += Math.PI / 12)
attack.getPlayer().getWorld().spawnParticle(Particle.CLOUD, attack.getPlayer().getLocation(), 0, Math.cos(a), 0, Math.sin(a),
.2);
}
}
}.runTaskTimer(MMOItems.plugin, 0, 1);
}
public static class BunnyHandler extends TemporaryListener {
private final Player player;
public BunnyHandler(Player player, double duration) {
super(EntityDamageEvent.getHandlerList());
this.player = player;
close((long) (duration *20));
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void a(EntityDamageEvent event) {
if (event.getEntity().equals(player) && event.getCause() == DamageCause.FALL)
event.setCancelled(true);
}
@Override
public void whenClosed() {
// Nothing
}
}
}

View File

@ -1,65 +0,0 @@
package net.Indyuce.mmoitems.ability.list.simple;
import io.lumine.mythic.lib.damage.AttackMetadata;
import io.lumine.mythic.lib.damage.DamageMetadata;
import io.lumine.mythic.lib.damage.DamageType;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.SimpleAbility;
import net.Indyuce.mmoitems.ability.metadata.SimpleAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
public class Burning_Hands extends SimpleAbility {
public Burning_Hands() {
super();
addModifier("duration", 3);
addModifier("damage", 2);
addModifier("cooldown", 10);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public void whenCast(AttackMetadata attack, SimpleAbilityMetadata ability) {
double duration = ability.getModifier("duration") * 10;
double damage = ability.getModifier("damage") / 2;
new BukkitRunnable() {
int j = 0;
public void run() {
if (j++ > duration)
cancel();
Location loc = attack.getPlayer().getLocation().add(0, 1.2, 0);
loc.getWorld().playSound(loc, Sound.BLOCK_FIRE_AMBIENT, 1, 1);
for (double m = -45; m < 45; m += 5) {
double a = (m + attack.getPlayer().getEyeLocation().getYaw() + 90) * Math.PI / 180;
Vector vec = new Vector(Math.cos(a), (random.nextDouble() - .5) * .2, Math.sin(a));
Location source = loc.clone().add(vec.clone().setY(0));
source.getWorld().spawnParticle(Particle.FLAME, source, 0, vec.getX(), vec.getY(), vec.getZ(), .5);
if (j % 2 == 0)
source.getWorld().spawnParticle(Particle.SMOKE_NORMAL, source, 0, vec.getX(), vec.getY(), vec.getZ(), .5);
}
if (j % 5 == 0)
for (Entity entity : MMOUtils.getNearbyChunkEntities(loc))
if (entity.getLocation().distanceSquared(loc) < 60
&& attack.getPlayer().getEyeLocation().getDirection()
.angle(entity.getLocation().toVector().subtract(attack.getPlayer().getLocation().toVector())) < Math.PI / 6
&& MMOUtils.canTarget(attack.getPlayer(), entity))
new AttackMetadata(new DamageMetadata(damage, DamageType.SKILL, DamageType.MAGIC), attack.getStats()).damage((LivingEntity) entity);
}
}.runTaskTimer(MMOItems.plugin, 0, 2);
}
}

View File

@ -1,90 +0,0 @@
package net.Indyuce.mmoitems.ability.list.simple;
import io.lumine.mythic.lib.api.util.TemporaryListener;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.ability.SimpleAbility;
import net.Indyuce.mmoitems.ability.metadata.SimpleAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.entity.Egg;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerEggThrowEvent;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.ArrayList;
import java.util.List;
public class Chicken_Wraith extends SimpleAbility {
public Chicken_Wraith() {
super();
addModifier("duration", 2.5);
addModifier("damage", 2);
addModifier("inaccuracy", 10);
addModifier("force", 1);
addModifier("cooldown", 10);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public void whenCast(AttackMetadata attack, SimpleAbilityMetadata ability) {
double duration = ability.getModifier("duration") * 10;
double force = ability.getModifier("force");
double inaccuracy = ability.getModifier("inaccuracy");
new BukkitRunnable() {
final EggHandler handler = new EggHandler(ability.getModifier("damage"));
int j = 0;
public void run() {
if (j++ > duration) {
handler.close(5 * 20);
cancel();
return;
}
Location loc = attack.getPlayer().getEyeLocation();
loc.setPitch((float) (loc.getPitch() + (random.nextDouble() - .5) * inaccuracy));
loc.setYaw((float) (loc.getYaw() + (random.nextDouble() - .5) * inaccuracy));
loc.getWorld().playSound(loc, Sound.ENTITY_CHICKEN_EGG, 1, 1);
Egg egg = attack.getPlayer().launchProjectile(Egg.class);
egg.setVelocity(loc.getDirection().multiply(1.3 * force));
handler.entities.add(egg.getEntityId());
}
}.runTaskTimer(MMOItems.plugin, 0, 2);
}
public static class EggHandler extends TemporaryListener {
private final List<Integer> entities = new ArrayList<>();
private final double damage;
public EggHandler(double damage) {
super(EntityDamageByEntityEvent.getHandlerList(), PlayerEggThrowEvent.getHandlerList());
this.damage = damage;
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void a(PlayerEggThrowEvent event) {
if (entities.contains(event.getEgg().getEntityId()))
event.setHatching(false);
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void b(EntityDamageByEntityEvent event) {
if (entities.contains(event.getDamager().getEntityId()))
event.setDamage(damage);
}
@Override
public void whenClosed() {
// Nothing
}
}
}

View File

@ -1,57 +0,0 @@
package net.Indyuce.mmoitems.ability.list.simple;
import io.lumine.mythic.lib.damage.AttackMetadata;
import io.lumine.mythic.lib.damage.DamageMetadata;
import io.lumine.mythic.lib.damage.DamageType;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.SimpleAbility;
import net.Indyuce.mmoitems.ability.metadata.SimpleAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector;
public class Circular_Slash extends SimpleAbility {
public Circular_Slash() {
super();
addModifier("damage", 6);
addModifier("radius", 3);
addModifier("knockback", 1);
addModifier("cooldown", 10);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public void whenCast(AttackMetadata attack, SimpleAbilityMetadata ability) {
double damage = ability.getModifier("damage");
double radius = ability.getModifier("radius");
double knockback = ability.getModifier("knockback");
attack.getPlayer().getWorld().playSound(attack.getPlayer().getLocation(), Sound.ENTITY_ZOMBIE_ATTACK_IRON_DOOR, 2, .5f);
attack.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 2, 254));
for (Entity entity : attack.getPlayer().getNearbyEntities(radius, radius, radius)) {
if (MMOUtils.canTarget(attack.getPlayer(), entity)) {
new AttackMetadata(new DamageMetadata(damage, DamageType.SKILL, DamageType.PHYSICAL), attack.getStats()).damage((LivingEntity) entity);
Vector v1 = entity.getLocation().toVector();
Vector v2 = attack.getPlayer().getLocation().toVector();
double y = .5;
Vector v3 = v1.subtract(v2).multiply(.5 * knockback).setY(knockback == 0 ? 0 : y);
entity.setVelocity(v3);
}
}
double step = 12 + (radius * 2.5);
for (double j = 0; j < Math.PI * 2; j += Math.PI / step) {
Location loc = attack.getPlayer().getLocation().clone();
loc.add(Math.cos(j) * radius, .75, Math.sin(j) * radius);
loc.getWorld().spawnParticle(Particle.SMOKE_LARGE, loc, 0);
}
attack.getPlayer().getWorld().spawnParticle(Particle.EXPLOSION_LARGE, attack.getPlayer().getLocation().add(0, 1, 0), 0);
}
}

View File

@ -1,85 +0,0 @@
package net.Indyuce.mmoitems.ability.list.simple;
import io.lumine.mythic.lib.damage.AttackMetadata;
import io.lumine.mythic.lib.damage.DamageMetadata;
import io.lumine.mythic.lib.damage.DamageType;
import io.lumine.mythic.lib.version.VersionSound;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.SimpleAbility;
import net.Indyuce.mmoitems.ability.metadata.SimpleAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
public class Firefly extends SimpleAbility {
public Firefly() {
super();
addModifier("damage", 6);
addModifier("duration", 2.5);
addModifier("knockback", 1);
addModifier("cooldown", 10);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public void whenCast(AttackMetadata attack, SimpleAbilityMetadata ability) {
double duration = ability.getModifier("duration") * 20;
new BukkitRunnable() {
int j = 0;
public void run() {
if (j++ > duration)
cancel();
if (attack.getPlayer().getLocation().getBlock().getType() == Material.WATER) {
attack.getPlayer().setVelocity(attack.getPlayer().getVelocity().multiply(3).setY(1.8));
attack.getPlayer().getWorld().playSound(attack.getPlayer().getLocation(), Sound.BLOCK_FIRE_EXTINGUISH, 1, .5f);
attack.getPlayer().getWorld().spawnParticle(Particle.EXPLOSION_NORMAL, attack.getPlayer().getLocation().add(0, 1, 0), 32, 0, 0, 0, .2);
attack.getPlayer().getWorld().spawnParticle(Particle.CLOUD, attack.getPlayer().getLocation().add(0, 1, 0), 32, 0, 0, 0, .2);
cancel();
return;
}
for (Entity entity : attack.getPlayer().getNearbyEntities(1, 1, 1))
if (MMOUtils.canTarget(attack.getPlayer(), entity)) {
double damage = ability.getModifier("damage");
double knockback = ability.getModifier("knockback");
attack.getPlayer().getWorld().playSound(attack.getPlayer().getLocation(), Sound.ENTITY_ZOMBIE_ATTACK_IRON_DOOR, 1, .5f);
attack.getPlayer().getWorld().spawnParticle(Particle.LAVA, attack.getPlayer().getLocation().add(0, 1, 0), 32);
attack.getPlayer().getWorld().spawnParticle(Particle.SMOKE_LARGE, attack.getPlayer().getLocation().add(0, 1, 0), 24, 0, 0, 0, .3);
attack.getPlayer().getWorld().spawnParticle(Particle.FLAME, attack.getPlayer().getLocation().add(0, 1, 0), 24, 0, 0, 0, .3);
entity.setVelocity(attack.getPlayer().getVelocity().setY(0.3).multiply(1.7 * knockback));
attack.getPlayer().setVelocity(attack.getPlayer().getEyeLocation().getDirection().multiply(-3).setY(.5));
new AttackMetadata(new DamageMetadata(damage, DamageType.SKILL, DamageType.MAGIC), attack.getStats()).damage((LivingEntity) entity);
cancel();
return;
}
Location loc = attack.getPlayer().getLocation().add(0, 1, 0);
for (double a = 0; a < Math.PI * 2; a += Math.PI / 9) {
Vector vec = new Vector(.6 * Math.cos(a), .6 * Math.sin(a), 0);
vec = MMOUtils.rotateFunc(vec, loc);
loc.add(vec);
attack.getPlayer().getWorld().spawnParticle(Particle.SMOKE_NORMAL, loc, 0);
if (random.nextDouble() < .3)
attack.getPlayer().getWorld().spawnParticle(Particle.FLAME, loc, 0);
loc.add(vec.multiply(-1));
}
attack.getPlayer().setVelocity(attack.getPlayer().getEyeLocation().getDirection());
attack.getPlayer().getWorld().playSound(attack.getPlayer().getLocation(), VersionSound.ENTITY_FIREWORK_ROCKET_BLAST.toSound(), 1, 1);
}
}.runTaskTimer(MMOItems.plugin, 0, 1);
}
}

View File

@ -1,47 +0,0 @@
package net.Indyuce.mmoitems.ability.list.simple;
import io.lumine.mythic.lib.version.VersionSound;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.ability.SimpleAbility;
import net.Indyuce.mmoitems.ability.metadata.SimpleAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.scheduler.BukkitRunnable;
public class Frog_Mode extends SimpleAbility {
public Frog_Mode() {
super();
addModifier("duration", 20);
addModifier("jump-force", 1);
addModifier("speed", 1);
addModifier("cooldown", 50);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public void whenCast(AttackMetadata attack, SimpleAbilityMetadata ability) {
double duration = ability.getModifier("duration") * 20;
double y = ability.getModifier("jump-force");
double xz = ability.getModifier("speed");
new BukkitRunnable() {
int j = 0;
public void run() {
j++;
if (j > duration)
cancel();
if (attack.getPlayer().getLocation().getBlock().getType() == Material.WATER) {
attack.getPlayer().setVelocity(attack.getPlayer().getEyeLocation().getDirection().setY(0).normalize().multiply(.8 * xz).setY(0.5 / xz * y));
attack.getPlayer().getWorld().playSound(attack.getPlayer().getLocation(), VersionSound.ENTITY_ENDER_DRAGON_FLAP.toSound(), 2, 1);
for (double a = 0; a < Math.PI * 2; a += Math.PI / 12)
attack.getPlayer().getWorld().spawnParticle(Particle.CLOUD, attack.getPlayer().getLocation(), 0, Math.cos(a), 0, Math.sin(a), .2);
}
}
}.runTaskTimer(MMOItems.plugin, 0, 1);
}
}

View File

@ -1,58 +0,0 @@
package net.Indyuce.mmoitems.ability.list.simple;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.SimpleAbility;
import net.Indyuce.mmoitems.ability.metadata.SimpleAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitRunnable;
public class Frozen_Aura extends SimpleAbility {
public Frozen_Aura() {
super();
addModifier("duration", 6);
addModifier("amplifier", 1);
addModifier("radius", 10);
addModifier("cooldown", 10);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public void whenCast(AttackMetadata attack, SimpleAbilityMetadata ability) {
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;
int ti = 0;
public void run() {
if (ti++ > duration)
cancel();
j += Math.PI / 60;
for (double k = 0; k < Math.PI * 2; k += Math.PI / 2)
attack.getPlayer().getWorld().spawnParticle(Particle.SPELL_INSTANT, attack.getPlayer().getLocation().add(Math.cos(k + j) * 2, 1 + Math.sin(k + j * 7) / 3, Math.sin(k + j) * 2), 0);
if (ti % 2 == 0)
attack.getPlayer().getWorld().playSound(attack.getPlayer().getLocation(), Sound.BLOCK_SNOW_BREAK, 1, 1);
if (ti % 7 == 0)
for (Entity entity : MMOUtils.getNearbyChunkEntities(attack.getPlayer().getLocation()))
if (entity.getLocation().distanceSquared(attack.getPlayer().getLocation()) < radiusSquared && MMOUtils.canTarget(attack.getPlayer(), entity)) {
((LivingEntity) entity).removePotionEffect(PotionEffectType.SLOW);
((LivingEntity) entity).addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 40, (int) amplifier));
}
}
}.runTaskTimer(MMOItems.plugin, 0, 1);
}
}

View File

@ -1,36 +0,0 @@
package net.Indyuce.mmoitems.ability.list.simple;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.SimpleAbility;
import net.Indyuce.mmoitems.ability.metadata.SimpleAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
public class Grand_Heal extends SimpleAbility {
public Grand_Heal() {
super();
addModifier("heal", 5);
addModifier("radius", 5);
addModifier("cooldown", 15);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public void whenCast(AttackMetadata attack, SimpleAbilityMetadata ability) {
double heal = ability.getModifier("heal");
double radius = ability.getModifier("radius");
MMOUtils.heal(attack.getPlayer(), heal);
attack.getPlayer().getWorld().playSound(attack.getPlayer().getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1, 2);
attack.getPlayer().getWorld().spawnParticle(Particle.HEART, attack.getPlayer().getLocation().add(0, .75, 0), 16, 1, 1, 1, 0);
attack.getPlayer().getWorld().spawnParticle(Particle.VILLAGER_HAPPY, attack.getPlayer().getLocation().add(0, .75, 0), 16, 1, 1, 1, 0);
for (Entity entity : attack.getPlayer().getNearbyEntities(radius, radius, radius))
if (entity instanceof Player)
MMOUtils.heal((Player) entity, heal);
}
}

View File

@ -1,27 +0,0 @@
package net.Indyuce.mmoitems.ability.list.simple;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.SimpleAbility;
import net.Indyuce.mmoitems.ability.metadata.SimpleAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Particle;
import org.bukkit.Sound;
public class Heal extends SimpleAbility {
public Heal() {
super();
addModifier("heal", 4);
addModifier("cooldown", 10);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public void whenCast(AttackMetadata attack, SimpleAbilityMetadata ability) {
attack.getPlayer().getWorld().playSound(attack.getPlayer().getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1, 2);
attack.getPlayer().getWorld().spawnParticle(Particle.HEART, attack.getPlayer().getLocation().add(0, .75, 0), 16, 1, 1, 1, 0);
attack.getPlayer().getWorld().spawnParticle(Particle.VILLAGER_HAPPY, attack.getPlayer().getLocation().add(0, .75, 0), 16, 1, 1, 1, 0);
MMOUtils.heal(attack.getPlayer(), ability.getModifier("heal"));
}
}

View File

@ -1,57 +0,0 @@
package net.Indyuce.mmoitems.ability.list.simple;
import io.lumine.mythic.lib.damage.AttackMetadata;
import io.lumine.mythic.lib.damage.DamageMetadata;
import io.lumine.mythic.lib.damage.DamageType;
import io.lumine.mythic.lib.version.VersionSound;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.SimpleAbility;
import net.Indyuce.mmoitems.ability.metadata.SimpleAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Particle;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
import java.util.ArrayList;
import java.util.List;
public class Light_Dash extends SimpleAbility {
public Light_Dash() {
super();
addModifier("damage", 3);
addModifier("cooldown", 10);
addModifier("length", 1);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public void whenCast(AttackMetadata attack, SimpleAbilityMetadata ability) {
double damage = ability.getModifier("damage");
double length = ability.getModifier("length");
new BukkitRunnable() {
final Vector vec = attack.getPlayer().getEyeLocation().getDirection();
final List<Integer> hit = new ArrayList<>();
int j = 0;
public void run() {
if (j++ > 10 * Math.min(10, length))
cancel();
attack.getPlayer().setVelocity(vec);
attack.getPlayer().getWorld().spawnParticle(Particle.SMOKE_LARGE, attack.getPlayer().getLocation().add(0, 1, 0), 0);
attack.getPlayer().getWorld().playSound(attack.getPlayer().getLocation(), VersionSound.ENTITY_ENDER_DRAGON_FLAP.toSound(), 1, 2);
for (Entity entity : attack.getPlayer().getNearbyEntities(1, 1, 1))
if (!hit.contains(entity.getEntityId()) && MMOUtils.canTarget(attack.getPlayer(), entity)) {
hit.add(entity.getEntityId());
new AttackMetadata(new DamageMetadata(damage, DamageType.SKILL, DamageType.PHYSICAL), attack.getStats()).damage((LivingEntity) entity);
}
}
}.runTaskTimer(MMOItems.plugin, 0, 2);
}
}

View File

@ -1,96 +0,0 @@
package net.Indyuce.mmoitems.ability.list.simple;
import io.lumine.mythic.lib.version.VersionSound;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.ability.SimpleAbility;
import net.Indyuce.mmoitems.ability.metadata.SimpleAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Bukkit;
import org.bukkit.Particle;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.scheduler.BukkitRunnable;
public class Magical_Path extends SimpleAbility {
public Magical_Path() {
super();
addModifier("duration", 3);
addModifier("cooldown", 15);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public void whenCast(AttackMetadata attack, SimpleAbilityMetadata ability) {
attack.getPlayer().setAllowFlight(true);
attack.getPlayer().setFlying(true);
attack.getPlayer().setVelocity(attack.getPlayer().getVelocity().setY(.5));
attack.getPlayer().getWorld().playSound(attack.getPlayer().getLocation(), VersionSound.ENTITY_ENDERMAN_TELEPORT.toSound(), 1, 1);
new MagicalPathHandler(attack.getPlayer(), ability.getModifier("duration"));
}
public static class MagicalPathHandler extends BukkitRunnable implements Listener {
private final Player player;
private final long duration;
/*
* when true, the next fall damage is negated
*/
private boolean safe = true;
private int j = 0;
public MagicalPathHandler(Player player, double duration) {
this.player = player;
this.duration = (long) (duration * 10);
runTaskTimer(MMOItems.plugin, 0, 2);
Bukkit.getPluginManager().registerEvents(this, MMOItems.plugin);
}
public void close() {
player.setAllowFlight(false);
HandlerList.unregisterAll(this);
cancel();
}
@EventHandler(priority = EventPriority.LOW)
public void a(EntityDamageEvent event) {
if (safe && event.getEntity().equals(player) && event.getCause() == DamageCause.FALL) {
event.setCancelled(true);
safe = false;
player.getWorld().spawnParticle(Particle.SPELL, player.getLocation(), 8, .35, 0, .35, .08);
player.getWorld().spawnParticle(Particle.SPELL_INSTANT, player.getLocation(), 16, .35, 0, .35, .08);
player.getWorld().playSound(player.getLocation(), VersionSound.ENTITY_ENDERMAN_HURT.toSound(), 1, 2);
}
}
@EventHandler
public void b(PlayerQuitEvent event) {
close();
}
@Override
public void run() {
if (j++ > duration) {
player.getWorld().playSound(player.getLocation(), VersionSound.ENTITY_ENDERMAN_TELEPORT.toSound(), 1, 1);
player.setAllowFlight(false);
cancel();
return;
}
player.getWorld().spawnParticle(Particle.SPELL, player.getLocation(), 8, .5, 0, .5, .1);
player.getWorld().spawnParticle(Particle.SPELL_INSTANT, player.getLocation(), 16, .5, 0, .5, .1);
}
}
}

View File

@ -1,88 +0,0 @@
package net.Indyuce.mmoitems.ability.list.simple;
import io.lumine.mythic.lib.version.VersionSound;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.ability.SimpleAbility;
import net.Indyuce.mmoitems.ability.metadata.SimpleAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import org.bukkit.Bukkit;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.scheduler.BukkitRunnable;
public class Magical_Shield extends SimpleAbility {
public Magical_Shield() {
super();
addModifier("power", 40);
addModifier("radius", 5);
addModifier("duration", 5);
addModifier("cooldown", 35);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public SimpleAbilityMetadata canBeCast(AttackMetadata attack, LivingEntity target, AbilityData ability) {
return attack.getPlayer().isOnGround() ? new SimpleAbilityMetadata(ability) : null;
}
@Override
public void whenCast(AttackMetadata attack, SimpleAbilityMetadata ability) {
double duration = ability.getModifier("duration");
double radiusSquared = Math.pow(ability.getModifier("radius"), 2);
double power = ability.getModifier("power") / 100;
attack.getPlayer().getWorld().playSound(attack.getPlayer().getLocation(), VersionSound.ENTITY_ENDERMAN_TELEPORT.toSound(), 3, 0);
new MagicalShield(attack.getPlayer().getLocation().clone(), duration, radiusSquared, power);
}
public static class MagicalShield extends BukkitRunnable implements Listener {
private final Location loc;
private final double duration, radius, power;
int ti = 0;
public MagicalShield(Location loc, double duration, double radius, double power) {
this.loc = loc;
this.duration = duration;
this.radius = radius;
this.power = power;
runTaskTimer(MMOItems.plugin, 0, 3);
Bukkit.getPluginManager().registerEvents(this, MMOItems.plugin);
}
private void close() {
cancel();
EntityDamageEvent.getHandlerList().unregister(this);
}
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void a(EntityDamageEvent event) {
if (event.getEntity() instanceof Player && event.getEntity().getWorld().equals(loc.getWorld()) && event.getEntity().getLocation().distanceSquared(loc) < radius)
event.setDamage(event.getDamage() * (1 - power));
}
@Override
public void run() {
if (ti++ > duration * 20. / 3.)
close();
for (double j = 0; j < Math.PI / 2; j += Math.PI / (28 + random.nextInt(5)))
for (double i = 0; i < Math.PI * 2; i += Math.PI / (14 + random.nextInt(5)))
loc.getWorld().spawnParticle(Particle.REDSTONE,
loc.clone().add(2.5 * Math.cos(i + j) * Math.sin(j), 2.5 * Math.cos(j), 2.5 * Math.sin(i + j) * Math.sin(j)), 1,
new Particle.DustOptions(Color.FUCHSIA, 1));
}
}
}

View File

@ -1,50 +0,0 @@
package net.Indyuce.mmoitems.ability.list.simple;
import io.lumine.mythic.lib.damage.AttackMetadata;
import io.lumine.mythic.lib.damage.DamageMetadata;
import io.lumine.mythic.lib.damage.DamageType;
import io.lumine.mythic.lib.version.VersionSound;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.SimpleAbility;
import net.Indyuce.mmoitems.ability.metadata.SimpleAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
public class Overload extends SimpleAbility {
public Overload() {
super();
addModifier("damage", 6);
addModifier("cooldown", 10);
addModifier("radius", 6);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public void whenCast(AttackMetadata attack, SimpleAbilityMetadata ability) {
double damage = ability.getModifier("damage");
double radius = ability.getModifier("radius");
attack.getPlayer().getWorld().playSound(attack.getPlayer().getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 2, 0);
attack.getPlayer().getWorld().playSound(attack.getPlayer().getLocation(), VersionSound.ENTITY_FIREWORK_ROCKET_TWINKLE.toSound(), 2, 0);
attack.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 2, 254));
for (Entity entity : attack.getPlayer().getNearbyEntities(radius, radius, radius))
if (MMOUtils.canTarget(attack.getPlayer(), entity))
new AttackMetadata(new DamageMetadata(damage, DamageType.SKILL, DamageType.MAGIC), attack.getStats()).damage((LivingEntity) entity);
double step = 12 + (radius * 2.5);
for (double j = 0; j < Math.PI * 2; j += Math.PI / step) {
Location loc = attack.getPlayer().getLocation().clone().add(Math.cos(j) * radius, 1, Math.sin(j) * radius);
attack.getPlayer().getWorld().spawnParticle(Particle.CLOUD, loc, 4, 0, 0, 0, .05);
attack.getPlayer().getWorld().spawnParticle(Particle.FIREWORKS_SPARK, loc, 4, 0, 0, 0, .05);
}
}
}

View File

@ -1,98 +0,0 @@
package net.Indyuce.mmoitems.ability.list.simple;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
import io.lumine.mythic.lib.damage.AttackMetadata;
import io.lumine.mythic.lib.damage.DamageMetadata;
import io.lumine.mythic.lib.damage.DamageType;
import io.lumine.mythic.lib.version.VersionMaterial;
import io.lumine.mythic.lib.version.VersionSound;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.SimpleAbility;
import net.Indyuce.mmoitems.ability.metadata.SimpleAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import net.Indyuce.mmoitems.api.util.NoClipItem;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.scheduler.BukkitRunnable;
import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder;
import java.lang.reflect.Field;
import java.util.UUID;
import java.util.logging.Level;
public class Present_Throw extends SimpleAbility {
private final ItemStack present = VersionMaterial.PLAYER_HEAD.toItem();
public Present_Throw() {
super();
addModifier("damage", 6);
addModifier("radius", 4);
addModifier("force", 1);
addModifier("cooldown", 10);
addModifier("mana", 0);
addModifier("stamina", 0);
ItemMeta presentMeta = present.getItemMeta();
GameProfile profile = new GameProfile(UUID.randomUUID(), null);
byte[] encodedData = Base64Coder.encodeLines(String.format("{textures:{SKIN:{url:\"%s\"}}}", "http://textures.minecraft.net/texture/47e55fcc809a2ac1861da2a67f7f31bd7237887d162eca1eda526a7512a64910").getBytes()).getBytes();
profile.getProperties().put("textures", new Property("textures", new String(encodedData)));
try {
Field profileField = presentMeta.getClass().getDeclaredField("profile");
profileField.setAccessible(true);
profileField.set(presentMeta, profile);
} catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
MMOItems.plugin.getLogger().log(Level.WARNING, "Could not load the skull texture for the Present Throw item ability.");
}
present.setItemMeta(presentMeta);
}
@Override
public void whenCast(AttackMetadata attack, SimpleAbilityMetadata ability) {
double damage = ability.getModifier("damage");
double radiusSquared = Math.pow(ability.getModifier("radius"), 2);
final NoClipItem item = new NoClipItem(attack.getPlayer().getLocation().add(0, 1.2, 0), present);
item.getEntity().setVelocity(attack.getPlayer().getEyeLocation().getDirection().multiply(1.5 * ability.getModifier("force")));
/*
* when items are moving through the air, they loose a percent of their
* velocity proportionally to their coordinates in each axis. this means
* that if the trajectory is not affected, the ratio of x/y will always
* be the same. check for any change of that ratio to check for a
* trajectory change
*/
final double trajRatio = item.getEntity().getVelocity().getX() / item.getEntity().getVelocity().getZ();
attack.getPlayer().getWorld().playSound(attack.getPlayer().getLocation(), Sound.ENTITY_SNOWBALL_THROW, 1, 0);
new BukkitRunnable() {
double ti = 0;
public void run() {
if (ti++ > 70 || item.getEntity().isDead()) {
item.close();
cancel();
}
double currentTrajRatio = item.getEntity().getVelocity().getX() / item.getEntity().getVelocity().getZ();
item.getEntity().getWorld().spawnParticle(Particle.SPELL_INSTANT, item.getEntity().getLocation().add(0, .1, 0), 0);
if (item.getEntity().isOnGround() || Math.abs(trajRatio - currentTrajRatio) > .1) {
item.getEntity().getWorld().spawnParticle(Particle.FIREWORKS_SPARK, item.getEntity().getLocation().add(0, .1, 0), 128, 0, 0, 0, .25);
item.getEntity().getWorld().playSound(item.getEntity().getLocation(), VersionSound.ENTITY_FIREWORK_ROCKET_TWINKLE.toSound(), 2, 1.5f);
for (Entity entity : MMOUtils.getNearbyChunkEntities(item.getEntity().getLocation()))
if (entity.getLocation().distanceSquared(item.getEntity().getLocation()) < radiusSquared && MMOUtils.canTarget(attack.getPlayer(), entity))
new AttackMetadata(new DamageMetadata(damage, DamageType.SKILL, DamageType.MAGIC, DamageType.PROJECTILE), attack.getStats()).damage((LivingEntity) entity);
item.close();
cancel();
}
}
}.runTaskTimer(MMOItems.plugin, 0, 1);
}
}

View File

@ -1,121 +0,0 @@
package net.Indyuce.mmoitems.ability.list.simple;
import io.lumine.mythic.lib.api.util.ui.SilentNumbers;
import io.lumine.mythic.lib.version.VersionSound;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.ability.SimpleAbility;
import net.Indyuce.mmoitems.ability.metadata.SimpleAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.entity.Mob;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.scheduler.BukkitRunnable;
public class Shadow_Veil extends SimpleAbility {
public Shadow_Veil() {
super();
addModifier("cooldown", 35);
addModifier("duration", 5);
addModifier("deception", 1);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public void whenCast(AttackMetadata attack, SimpleAbilityMetadata ability) {
double duration = ability.getModifier("duration");
attack.getPlayer().getWorld().playSound(attack.getPlayer().getLocation(), VersionSound.ENTITY_ENDERMAN_TELEPORT.toSound(), 3, 0);
for (Player online : Bukkit.getOnlinePlayers())
online.hidePlayer(MMOItems.plugin, attack.getPlayer());
/*
* clears the target of any entity around the player
*/
for (Mob serverEntities : attack.getPlayer().getWorld().getEntitiesByClass(Mob.class))
if (serverEntities.getTarget() != null && serverEntities.getTarget().equals(attack.getPlayer()))
serverEntities.setTarget(null);
ShadowVeilHandler svh = new ShadowVeilHandler(attack.getPlayer(), duration);
svh.setDeceptions(SilentNumbers.floor(ability.getModifier("deception")));
}
public static class ShadowVeilHandler extends BukkitRunnable implements Listener {
private final Player player;
private final double duration;
private final Location loc;
int deceptions = 1;
public void setDeceptions(int dec) { deceptions = dec; }
double ti = 0;
double y = 0;
boolean cancelled;
public ShadowVeilHandler(Player player, double duration) {
this.player = player;
this.duration = duration;
this.loc = player.getLocation();
runTaskTimer(MMOItems.plugin, 0, 1);
Bukkit.getPluginManager().registerEvents(this, MMOItems.plugin);
}
private void close() {
if (ti < 0)
return;
player.getWorld().spawnParticle(Particle.SMOKE_LARGE, player.getLocation().add(0, 1, 0), 32, 0, 0, 0, .13);
player.getWorld().playSound(player.getLocation(), VersionSound.ENTITY_ENDERMAN_TELEPORT.toSound(), 3, 0);
// sets time to -1 so that next calls know the handler has already
// been closed
ti = -1;
EntityDamageByEntityEvent.getHandlerList().unregister(this);
EntityTargetEvent.getHandlerList().unregister(this);
for (Player online : Bukkit.getOnlinePlayers())
online.showPlayer(MMOItems.plugin, player);
cancel();
}
@Override
public void run() {
if (ti++ > duration * 20 || !player.isOnline()) {
close();
return;
}
if (y < 4)
for (int j1 = 0; j1 < 5; j1++) {
y += .04;
for (int j = 0; j < 4; j++) {
double a = y * Math.PI * .8 + (j * Math.PI / 2);
player.getWorld().spawnParticle(Particle.SMOKE_LARGE, loc.clone().add(Math.cos(a) * 2.5, y, Math.sin(a) * 2.5), 0);
}
}
}
@EventHandler
public void cancelShadowVeil(EntityDamageByEntityEvent event) {
if (event.getDamager().equals(player)) {
deceptions--;
if (deceptions <= 0) { close(); } }
}
@EventHandler
public void cancelMobTarget(EntityTargetEvent event) {
if (event.getTarget() != null && event.getTarget().equals(player))
event.setCancelled(true);
}
}
}

View File

@ -1,59 +0,0 @@
package net.Indyuce.mmoitems.ability.list.simple;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.SimpleAbility;
import net.Indyuce.mmoitems.ability.metadata.SimpleAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.*;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
import java.util.ArrayList;
import java.util.List;
public class Shockwave extends SimpleAbility {
public Shockwave() {
super();
addModifier("cooldown", 7.5);
addModifier("knock-up", 1);
addModifier("length", 5);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public void whenCast(AttackMetadata attack, SimpleAbilityMetadata ability) {
double knockUp = ability.getModifier("knock-up");
double length = ability.getModifier("length");
new BukkitRunnable() {
final Vector vec = attack.getPlayer().getEyeLocation().getDirection().setY(0);
final Location loc = attack.getPlayer().getLocation();
final List<Integer> hit = new ArrayList<>();
int ti = 0;
public void run() {
ti++;
if (ti >= Math.min(20, length))
cancel();
loc.add(vec);
loc.getWorld().playSound(loc, Sound.BLOCK_GRAVEL_BREAK, 1, 2);
loc.getWorld().spawnParticle(Particle.BLOCK_CRACK, loc, 12, .5, 0, .5, 0, Material.DIRT.createBlockData());
for (Entity ent : MMOUtils.getNearbyChunkEntities(loc))
if (ent.getLocation().distance(loc) < 1.1 && ent instanceof LivingEntity && !ent.equals(attack.getPlayer())
&& !hit.contains(ent.getEntityId())) {
hit.add(ent.getEntityId());
ent.playEffect(EntityEffect.HURT);
ent.setVelocity(ent.getVelocity().setY(.4 * knockUp));
}
}
}.runTaskTimer(MMOItems.plugin, 0, 1);
}
}

View File

@ -1,48 +0,0 @@
package net.Indyuce.mmoitems.ability.list.simple;
import io.lumine.mythic.lib.damage.AttackMetadata;
import io.lumine.mythic.lib.damage.DamageMetadata;
import io.lumine.mythic.lib.damage.DamageType;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.SimpleAbility;
import net.Indyuce.mmoitems.ability.metadata.SimpleAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
public class Sky_Smash extends SimpleAbility {
public Sky_Smash() {
super();
addModifier("cooldown", 10);
addModifier("damage", 3);
addModifier("knock-up", 1);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public void whenCast(AttackMetadata attack, SimpleAbilityMetadata ability) {
double damage = ability.getModifier("damage");
double knockUp = ability.getModifier("knock-up");
attack.getPlayer().getWorld().playSound(attack.getPlayer().getLocation(), Sound.ENTITY_ZOMBIE_ATTACK_IRON_DOOR, 2, .5f);
attack.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 2, 254));
Location loc = attack.getPlayer().getEyeLocation().add(attack.getPlayer().getEyeLocation().getDirection().multiply(3));
loc.getWorld().spawnParticle(Particle.EXPLOSION_LARGE, loc, 0);
loc.getWorld().spawnParticle(Particle.SMOKE_LARGE, loc, 16, 0, 0, 0, .1);
for (Entity entity : MMOUtils.getNearbyChunkEntities(loc))
if (MMOUtils.canTarget(attack.getPlayer(), entity) && entity.getLocation().distanceSquared(loc) < 10) {
new AttackMetadata(new DamageMetadata(damage, DamageType.SKILL, DamageType.PHYSICAL), attack.getStats()).damage((LivingEntity) entity);
Location loc1 = attack.getPlayer().getEyeLocation().clone();
loc1.setPitch(-70);
entity.setVelocity(loc1.getDirection().multiply(1.2 * knockUp));
}
}
}

View File

@ -1,35 +0,0 @@
package net.Indyuce.mmoitems.ability.list.simple;
import io.lumine.mythic.lib.version.VersionSound;
import net.Indyuce.mmoitems.ability.SimpleAbility;
import net.Indyuce.mmoitems.ability.metadata.SimpleAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Particle;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
public class Swiftness extends SimpleAbility {
public Swiftness() {
super();
addModifier("cooldown", 15);
addModifier("duration", 4);
addModifier("amplifier", 1);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public void whenCast(AttackMetadata attack, SimpleAbilityMetadata ability) {
double duration = ability.getModifier("duration");
int amplifier = (int) ability.getModifier("amplifier");
attack.getPlayer().getWorld().playSound(attack.getPlayer().getLocation(), VersionSound.ENTITY_ZOMBIE_PIGMAN_ANGRY.toSound(), 1, .3f);
for (double y = 0; y <= 2; y += .2)
for (double j = 0; j < Math.PI * 2; j += Math.PI / 16)
if (random.nextDouble() <= .7)
attack.getPlayer().getWorld().spawnParticle(Particle.SPELL_INSTANT, attack.getPlayer().getLocation().add(Math.cos(j), y, Math.sin(j)), 0);
attack.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.SPEED, (int) (duration * 20), amplifier));
attack.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.JUMP, (int) (duration * 20), amplifier));
}
}

View File

@ -1,59 +0,0 @@
package net.Indyuce.mmoitems.ability.list.simple;
import io.lumine.mythic.lib.damage.AttackMetadata;
import io.lumine.mythic.lib.damage.DamageMetadata;
import io.lumine.mythic.lib.damage.DamageType;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.SimpleAbility;
import net.Indyuce.mmoitems.ability.metadata.SimpleAbilityMetadata;
import net.Indyuce.mmoitems.api.util.NoClipItem;
import org.bukkit.*;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable;
public class Throw_Up extends SimpleAbility {
public Throw_Up() {
super();
addModifier("duration", 2.5);
addModifier("damage", 2);
addModifier("cooldown", 10);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public void whenCast(AttackMetadata attack, SimpleAbilityMetadata ability) {
double duration = ability.getModifier("duration") * 10;
double dps = ability.getModifier("damage") / 2;
new BukkitRunnable() {
int j = 0;
public void run() {
j++;
if (j > duration)
cancel();
Location loc = attack.getPlayer().getEyeLocation();
loc.setPitch((float) (loc.getPitch() + (random.nextDouble() - .5) * 30));
loc.setYaw((float) (loc.getYaw() + (random.nextDouble() - .5) * 30));
if (j % 5 == 0)
for (Entity entity : MMOUtils.getNearbyChunkEntities(loc))
if (entity.getLocation().distanceSquared(loc) < 40 && attack.getPlayer().getEyeLocation().getDirection().angle(entity.getLocation().toVector().subtract(attack.getPlayer().getLocation().toVector())) < Math.PI / 6 && MMOUtils.canTarget(attack.getPlayer(), entity))
new AttackMetadata(new DamageMetadata(dps, DamageType.SKILL, DamageType.PHYSICAL, DamageType.PROJECTILE), attack.getStats()).damage((LivingEntity) entity);
loc.getWorld().playSound(loc, Sound.ENTITY_ZOMBIE_HURT, 1, 1);
NoClipItem item = new NoClipItem(attack.getPlayer().getLocation().add(0, 1.2, 0), new ItemStack(Material.ROTTEN_FLESH));
Bukkit.getScheduler().scheduleSyncDelayedTask(MMOItems.plugin, item::close, 40);
item.getEntity().setVelocity(loc.getDirection().multiply(.8));
attack.getPlayer().getWorld().spawnParticle(Particle.SMOKE_LARGE, attack.getPlayer().getLocation().add(0, 1.2, 0), 0, loc.getDirection().getX(), loc.getDirection().getY(), loc.getDirection().getZ(), 1);
}
}.runTaskTimer(MMOItems.plugin, 0, 2);
}
}

View File

@ -1,40 +0,0 @@
package net.Indyuce.mmoitems.ability.list.target;
import io.lumine.mythic.lib.version.VersionSound;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.TargetAbility;
import net.Indyuce.mmoitems.ability.metadata.TargetAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.entity.LivingEntity;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector;
public class Blind extends TargetAbility {
public Blind() {
super();
addModifier("duration", 5);
addModifier("cooldown", 9);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public void whenCast(AttackMetadata attack, TargetAbilityMetadata ability) {
LivingEntity target = 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)
for (double j = 0; j < 2; j++) {
Location loc = target.getLocation();
Vector vec = MMOUtils.rotateFunc(new Vector(Math.cos(i), 1 + Math.cos(i + (Math.PI * j)) * .5, Math.sin(i)),
attack.getPlayer().getLocation());
loc.getWorld().spawnParticle(Particle.REDSTONE, loc.add(vec), 1, new Particle.DustOptions(Color.BLACK, 1));
}
target.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, (int) (ability.getModifier("duration") * 20), 0));
}
}

View File

@ -1,28 +0,0 @@
package net.Indyuce.mmoitems.ability.list.target;
import net.Indyuce.mmoitems.ability.TargetAbility;
import net.Indyuce.mmoitems.ability.metadata.TargetAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Effect;
import org.bukkit.Sound;
import org.bukkit.entity.LivingEntity;
public class Bloodbath extends TargetAbility {
public Bloodbath() {
super();
addModifier("amount", 2);
addModifier("cooldown", 8);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public void whenCast(AttackMetadata attack, TargetAbilityMetadata ability) {
LivingEntity target = 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);
attack.getPlayer().setFoodLevel((int) Math.min(20, attack.getPlayer().getFoodLevel() + ability.getModifier("amount")));
}
}

View File

@ -1,47 +0,0 @@
package net.Indyuce.mmoitems.ability.list.target;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.ability.TargetAbility;
import net.Indyuce.mmoitems.ability.metadata.TargetAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.entity.LivingEntity;
import org.bukkit.scheduler.BukkitRunnable;
public class Burn extends TargetAbility {
public Burn() {
super();
addModifier("duration", 3);
addModifier("cooldown", 8);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public void whenCast(AttackMetadata attack, TargetAbilityMetadata ability) {
LivingEntity target = ability.getTarget();
new BukkitRunnable() {
final Location loc = target.getLocation();
double y = 0;
public void run() {
for (int j1 = 0; j1 < 3; j1++) {
y += .04;
for (int j = 0; j < 2; j++) {
double xz = y * Math.PI * 1.3 + (j * Math.PI);
Location loc1 = loc.clone().add(Math.cos(xz), y, Math.sin(xz));
loc.getWorld().spawnParticle(Particle.FLAME, loc1, 0);
}
}
if (y >= 1.7)
cancel();
}
}.runTaskTimer(MMOItems.plugin, 0, 1);
target.getWorld().playSound(target.getLocation(), Sound.ENTITY_BLAZE_HURT, 1, 2);
target.setFireTicks((int) (target.getFireTicks() + ability.getModifier("duration") * 20));
}
}

View File

@ -1,47 +0,0 @@
package net.Indyuce.mmoitems.ability.list.target;
import io.lumine.mythic.lib.damage.AttackMetadata;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.ability.TargetAbility;
import net.Indyuce.mmoitems.ability.metadata.TargetAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.entity.LivingEntity;
import org.bukkit.scheduler.BukkitRunnable;
public class Confuse extends TargetAbility {
public Confuse() {
super();
addModifier("cooldown", 7);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public void whenCast(AttackMetadata attack, TargetAbilityMetadata ability) {
LivingEntity target = ability.getTarget();
target.getWorld().playSound(target.getLocation(), Sound.ENTITY_SHEEP_DEATH, 1, 2);
new BukkitRunnable() {
final Location loc = target.getLocation();
final double rads = Math.toRadians(attack.getPlayer().getEyeLocation().getYaw() - 90);
double ti = rads;
public void run() {
for (int j1 = 0; j1 < 3; j1++) {
ti += Math.PI / 15;
Location loc1 = loc.clone().add(Math.cos(ti), 1, Math.sin(ti));
loc.getWorld().spawnParticle(Particle.SPELL_WITCH, loc1, 0);
}
if (ti >= Math.PI * 2 + rads)
cancel();
}
}.runTaskTimer(MMOItems.plugin, 0, 1);
Location loc = target.getLocation().clone();
loc.setYaw(target.getLocation().getYaw() - 180);
target.teleport(loc);
}
}

View File

@ -1,56 +0,0 @@
package net.Indyuce.mmoitems.ability.list.target;
import io.lumine.mythic.lib.damage.AttackMetadata;
import io.lumine.mythic.lib.damage.DamageMetadata;
import io.lumine.mythic.lib.damage.DamageType;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.ability.TargetAbility;
import net.Indyuce.mmoitems.ability.metadata.TargetAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.entity.LivingEntity;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitRunnable;
public class Death_Mark extends TargetAbility {
public Death_Mark() {
super();
addModifier("cooldown", 7);
addModifier("damage", 5);
addModifier("duration", 3);
addModifier("amplifier", 1);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public void whenCast(AttackMetadata attack, TargetAbilityMetadata ability) {
LivingEntity target = ability.getTarget();
double duration = ability.getModifier("duration") * 20;
double dps = ability.getModifier("damage") / duration * 20;
new BukkitRunnable() {
double ti = 0;
public void run() {
ti++;
if (ti > duration || target == null || target.isDead()) {
cancel();
return;
}
target.getWorld().spawnParticle(Particle.SPELL_MOB, target.getLocation(), 4, .2, 0, .2, 0);
if (ti % 20 == 0)
new AttackMetadata(new DamageMetadata(dps, DamageType.SKILL, DamageType.MAGIC), attack.getStats()).damage(target);
}
}.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) ability.getModifier("amplifier")));
}
}

View File

@ -1,61 +0,0 @@
package net.Indyuce.mmoitems.ability.list.target;
import io.lumine.mythic.lib.damage.AttackMetadata;
import io.lumine.mythic.lib.damage.DamageMetadata;
import io.lumine.mythic.lib.damage.DamageType;
import io.lumine.mythic.lib.version.VersionSound;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.ability.TargetAbility;
import net.Indyuce.mmoitems.ability.metadata.TargetAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.entity.LivingEntity;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
public class Magma_Fissure extends TargetAbility {
public Magma_Fissure() {
super();
addModifier("cooldown", 10);
addModifier("mana", 0);
addModifier("stamina", 0);
addModifier("ignite", 4);
addModifier("damage", 4);
}
@Override
public void whenCast(AttackMetadata attack, TargetAbilityMetadata ability) {
LivingEntity target = ability.getTarget();
new BukkitRunnable() {
final Location loc = attack.getPlayer().getLocation().add(0, .2, 0);
int j = 0;
public void run() {
j++;
if (target.isDead() || !target.getWorld().equals(loc.getWorld()) || j > 200) {
cancel();
return;
}
Vector vec = target.getLocation().add(0, .2, 0).subtract(loc).toVector().normalize().multiply(.6);
loc.add(vec);
loc.getWorld().spawnParticle(Particle.LAVA, loc, 2, .2, 0, .2, 0);
loc.getWorld().spawnParticle(Particle.FLAME, loc, 2, .2, 0, .2, 0);
loc.getWorld().spawnParticle(Particle.SMOKE_NORMAL, loc, 2, .2, 0, .2, 0);
loc.getWorld().playSound(loc, VersionSound.BLOCK_NOTE_BLOCK_HAT.toSound(), 1, 1);
if (target.getLocation().distanceSquared(loc) < 1) {
loc.getWorld().playSound(loc, Sound.ENTITY_BLAZE_HURT, 2, 1);
target.setFireTicks((int) (target.getFireTicks() + ability.getModifier("ignite") * 20));
new AttackMetadata(new DamageMetadata(ability.getModifier("damage"), DamageType.SKILL, DamageType.MAGIC), attack.getStats()).damage(target);
cancel();
}
}
}.runTaskTimer(MMOItems.plugin, 0, 1);
}
}

View File

@ -1,32 +0,0 @@
package net.Indyuce.mmoitems.ability.list.target;
import net.Indyuce.mmoitems.ability.TargetAbility;
import net.Indyuce.mmoitems.ability.metadata.TargetAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.entity.LivingEntity;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
public class Poison extends TargetAbility {
public Poison() {
super();
addModifier("duration", 4);
addModifier("cooldown", 10);
addModifier("amplifier", 1);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public void whenCast(AttackMetadata attack, TargetAbilityMetadata ability) {
LivingEntity target = 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) (ability.getModifier("duration") * 20), (int) ability.getModifier("amplifier")));
}
}

View File

@ -1,57 +0,0 @@
package net.Indyuce.mmoitems.ability.list.target;
import io.lumine.mythic.lib.version.VersionSound;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.ability.TargetAbility;
import net.Indyuce.mmoitems.ability.metadata.TargetAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.EntityEffect;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.entity.LivingEntity;
import org.bukkit.scheduler.BukkitRunnable;
public class Shock extends TargetAbility {
public Shock() {
super();
addModifier("duration", 2);
addModifier("cooldown", 8);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public void whenCast(AttackMetadata attack, TargetAbilityMetadata ability) {
LivingEntity target = ability.getTarget();
double duration = ability.getModifier("duration");
target.getWorld().playSound(target.getLocation(), VersionSound.ENTITY_ZOMBIE_PIGMAN_ANGRY.toSound(), 1, 2);
new BukkitRunnable() {
final Location loc = target.getLocation();
final double rads = Math.toRadians(attack.getPlayer().getEyeLocation().getYaw() - 90);
double ti = rads;
public void run() {
for (int j = 0; j < 3; j++) {
ti += Math.PI / 15;
target.getWorld().spawnParticle(Particle.SMOKE_LARGE, loc.clone().add(Math.cos(ti), 1, Math.sin(ti)), 0);
}
if (ti >= Math.PI * 2 + rads)
cancel();
}
}.runTaskTimer(MMOItems.plugin, 0, 1);
new BukkitRunnable() {
int ti;
public void run() {
if (ti++ > (duration > 300 ? 300 : duration * 10) || target.isDead())
cancel();
else
target.playEffect(EntityEffect.HURT);
}
}.runTaskTimer(MMOItems.plugin, 0, 2);
}
}

View File

@ -1,52 +0,0 @@
package net.Indyuce.mmoitems.ability.list.target;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.ability.TargetAbility;
import net.Indyuce.mmoitems.ability.metadata.TargetAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.entity.LivingEntity;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitRunnable;
public class Slow extends TargetAbility {
public Slow() {
super();
addModifier("cooldown", 5);
addModifier("duration", 3);
addModifier("amplifier", 1);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public void whenCast(AttackMetadata attack, TargetAbilityMetadata ability) {
LivingEntity target = ability.getTarget();
new BukkitRunnable() {
final Location loc = target.getLocation();
double ti = 0;
public void run() {
ti += Math.PI / 10;
if (ti >= Math.PI * 2)
cancel();
for (double j = 0; j < Math.PI * 2; j += Math.PI)
for (double r = 0; r < .7; r += .1)
loc.getWorld().spawnParticle(Particle.REDSTONE,
loc.clone().add(Math.cos((ti / 2) + j + (Math.PI * r)) * r * 2, .1, Math.sin((ti / 2) + j + (Math.PI * r)) * r * 2),
1, new Particle.DustOptions(Color.WHITE, 1));
}
}.runTaskTimer(MMOItems.plugin, 0, 1);
target.getWorld().playSound(target.getLocation(), Sound.ENTITY_LLAMA_ANGRY, 1, 2);
target.addPotionEffect(
new PotionEffect(PotionEffectType.SLOW, (int) (ability.getModifier("duration") * 20), (int) ability.getModifier("amplifier")));
}
}

View File

@ -1,27 +0,0 @@
package net.Indyuce.mmoitems.ability.list.target;
import io.lumine.mythic.lib.damage.AttackMetadata;
import io.lumine.mythic.lib.damage.DamageMetadata;
import io.lumine.mythic.lib.damage.DamageType;
import net.Indyuce.mmoitems.ability.TargetAbility;
import net.Indyuce.mmoitems.ability.metadata.TargetAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.entity.LivingEntity;
public class Smite extends TargetAbility {
public Smite() {
super();
addModifier("cooldown", 10);
addModifier("damage", 8);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public void whenCast(AttackMetadata attack, TargetAbilityMetadata ability) {
LivingEntity target = ability.getTarget();
new AttackMetadata(new DamageMetadata(ability.getModifier("damage"), DamageType.SKILL, DamageType.MAGIC), attack.getStats()).damage(target);
target.getWorld().strikeLightningEffect(target.getLocation());
}
}

View File

@ -1,54 +0,0 @@
package net.Indyuce.mmoitems.ability.list.target;
import io.lumine.mythic.lib.damage.AttackMetadata;
import io.lumine.mythic.lib.damage.DamageMetadata;
import io.lumine.mythic.lib.damage.DamageType;
import io.lumine.mythic.lib.version.VersionSound;
import net.Indyuce.mmoitems.ability.TargetAbility;
import net.Indyuce.mmoitems.ability.metadata.TargetAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.util.Vector;
public class Sparkle extends TargetAbility {
public Sparkle() {
super();
addModifier("cooldown", 10);
addModifier("damage", 4);
addModifier("limit", 5);
addModifier("radius", 6);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public void whenCast(AttackMetadata attack, TargetAbilityMetadata ability) {
LivingEntity target = ability.getTarget();
double damage = ability.getModifier("damage");
double radius = ability.getModifier("radius");
double limit = ability.getModifier("limit");
new AttackMetadata(new DamageMetadata(damage, DamageType.SKILL, DamageType.MAGIC), attack.getStats()).damage(target);
target.getWorld().spawnParticle(Particle.EXPLOSION_LARGE, target.getLocation().add(0, 1, 0), 0);
target.getWorld().playSound(target.getLocation(), VersionSound.ENTITY_FIREWORK_ROCKET_TWINKLE.toSound(), 2, 2);
int count = 0;
for (Entity entity : target.getNearbyEntities(radius, radius, radius))
if (count < limit && entity instanceof LivingEntity && entity != attack.getPlayer() && !(entity instanceof ArmorStand)) {
count++;
new AttackMetadata(new DamageMetadata(damage, DamageType.SKILL, DamageType.MAGIC), attack.getStats()).damage((LivingEntity) entity);
entity.getWorld().playSound(entity.getLocation(), VersionSound.ENTITY_FIREWORK_ROCKET_TWINKLE.toSound(), 2, 2);
Location loc_t = target.getLocation().add(0, .75, 0);
Location loc_ent = entity.getLocation().add(0, .75, 0);
for (double j1 = 0; j1 < 1; j1 += .04) {
Vector d = loc_ent.toVector().subtract(loc_t.toVector());
target.getWorld().spawnParticle(Particle.FIREWORKS_SPARK, loc_t.clone().add(d.multiply(j1)), 3, .1, .1, .1, .008);
}
}
}
}

View File

@ -1,55 +0,0 @@
package net.Indyuce.mmoitems.ability.list.target;
import io.lumine.mythic.lib.damage.DamageType;
import io.lumine.mythic.lib.version.VersionSound;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.ability.TargetAbility;
import net.Indyuce.mmoitems.ability.metadata.TargetAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.entity.LivingEntity;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
public class Starfall extends TargetAbility {
public Starfall() {
super();
addModifier("cooldown", 8);
addModifier("damage", 3.5);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public void whenCast(AttackMetadata attack, TargetAbilityMetadata ability) {
LivingEntity target = ability.getTarget();
new BukkitRunnable() {
final double ran = random.nextDouble() * Math.PI * 2;
final Location loc = target.getLocation().add(Math.cos(ran) * 3, 6, Math.sin(ran) * 3);
final Vector vec = target.getLocation().add(0, .65, 0).toVector().subtract(loc.toVector()).multiply(.05);
double ti = 0;
public void run() {
loc.getWorld().playSound(loc, VersionSound.BLOCK_NOTE_BLOCK_HAT.toSound(), 2, 2);
for (int j = 0; j < 2; j++) {
ti += .05;
loc.add(vec);
loc.getWorld().spawnParticle(Particle.FIREWORKS_SPARK, loc, 1, .04, 0, .04, 0);
if (ti >= 1) {
loc.getWorld().spawnParticle(Particle.FIREWORKS_SPARK, loc, 24, 0, 0, 0, .12);
loc.getWorld().playSound(loc, VersionSound.ENTITY_FIREWORK_ROCKET_BLAST.toSound(), 1, 2);
cancel();
}
}
}
}.runTaskTimer(MMOItems.plugin, 0, 1);
target.getWorld().playSound(target.getLocation(), Sound.ENTITY_WITHER_SHOOT, 2, 2);
attack.getDamage().add(ability.getModifier("damage"), DamageType.SKILL, DamageType.MAGIC);
}
}

View File

@ -1,31 +0,0 @@
package net.Indyuce.mmoitems.ability.list.target;
import net.Indyuce.mmoitems.ability.TargetAbility;
import net.Indyuce.mmoitems.ability.metadata.TargetAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Effect;
import org.bukkit.Sound;
import org.bukkit.entity.LivingEntity;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
public class Stun extends TargetAbility {
public Stun() {
super();
addModifier("cooldown", 10);
addModifier("duration", 2);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public void whenCast(AttackMetadata attack, TargetAbilityMetadata ability) {
LivingEntity target = 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) (ability.getModifier("duration") * 20), 254));
}
}

View File

@ -1,82 +0,0 @@
package net.Indyuce.mmoitems.ability.list.target;
import io.lumine.mythic.lib.damage.AttackMetadata;
import io.lumine.mythic.lib.damage.DamageMetadata;
import io.lumine.mythic.lib.damage.DamageType;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.TargetAbility;
import net.Indyuce.mmoitems.ability.metadata.TargetAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
import java.util.ArrayList;
import java.util.List;
public class Tactical_Grenade extends TargetAbility {
public Tactical_Grenade() {
super();
addModifier("cooldown", 10);
addModifier("mana", 0);
addModifier("stamina", 0);
addModifier("knock-up", 1);
addModifier("damage", 4);
addModifier("radius", 4);
}
@Override
public void whenCast(AttackMetadata attack, TargetAbilityMetadata ability) {
LivingEntity target = ability.getTarget();
new BukkitRunnable() {
final Location loc = attack.getPlayer().getLocation().add(0, .1, 0);
final double radius = ability.getModifier("radius");
final double knockup = .7 * ability.getModifier("knock-up");
final List<Integer> hit = new ArrayList<>();
int j = 0;
public void run() {
j++;
if (target.isDead() || !target.getWorld().equals(loc.getWorld()) || j > 200) {
cancel();
return;
}
Vector vec = target.getLocation().add(0, .1, 0).subtract(loc).toVector();
vec = vec.length() < 3 ? vec : vec.normalize().multiply(3);
loc.add(vec);
loc.getWorld().spawnParticle(Particle.CLOUD, loc, 32, 1, 0, 1, 0);
loc.getWorld().spawnParticle(Particle.EXPLOSION_NORMAL, loc, 16, 1, 0, 1, .05);
loc.getWorld().playSound(loc, Sound.BLOCK_ANVIL_LAND, 2, 0);
loc.getWorld().playSound(loc, Sound.ENTITY_GENERIC_EXPLODE, 2, 1);
for (Entity entity : MMOUtils.getNearbyChunkEntities(loc))
if (!hit.contains(entity.getEntityId()) && MMOUtils.canTarget(attack.getPlayer(), entity) && entity.getLocation().distanceSquared(loc) < radius * radius) {
/*
* stop the runnable as soon as the grenade finally hits
* the initial target.
*/
hit.add(entity.getEntityId());
if (entity.equals(target))
cancel();
new AttackMetadata(new DamageMetadata(ability.getModifier("damage"), DamageType.SKILL, DamageType.MAGIC), attack.getStats()).damage((LivingEntity) entity);
entity.setVelocity(entity.getVelocity().add(offsetVector(knockup)));
}
}
}.runTaskTimer(MMOItems.plugin, 0, 12);
}
private Vector offsetVector(double y) {
return new Vector(2 * (random.nextDouble() - .5), y, 2 * (random.nextDouble() - .5));
}
}

View File

@ -1,66 +0,0 @@
package net.Indyuce.mmoitems.ability.list.target;
import io.lumine.mythic.lib.damage.AttackMetadata;
import io.lumine.mythic.lib.damage.DamageMetadata;
import io.lumine.mythic.lib.damage.DamageType;
import io.lumine.mythic.lib.version.VersionSound;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.TargetAbility;
import net.Indyuce.mmoitems.ability.metadata.TargetAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.entity.LivingEntity;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
public class Targeted_Fireball extends TargetAbility {
public Targeted_Fireball() {
super();
addModifier("cooldown", 10);
addModifier("mana", 0);
addModifier("stamina", 0);
addModifier("ignite", 4);
addModifier("damage", 4);
}
@Override
public void whenCast(AttackMetadata attack, TargetAbilityMetadata ability) {
LivingEntity target = ability.getTarget();
new BukkitRunnable() {
final Location loc = attack.getPlayer().getLocation().add(0, 1.3, 0);
int j = 0;
public void run() {
j++;
if (target.isDead() || !target.getWorld().equals(loc.getWorld()) || j > 200) {
cancel();
return;
}
Vector dir = target.getLocation().add(0, target.getHeight() / 2, 0).subtract(loc).toVector().normalize();
loc.add(dir.multiply(.6));
loc.setDirection(dir);
for (double a = 0; a < Math.PI * 2; a += Math.PI / 6) {
Vector rotated = MMOUtils.rotateFunc(new Vector(Math.cos(a), Math.sin(a), 0), loc);
loc.getWorld().spawnParticle(Particle.FLAME, loc, 0, rotated.getX(), rotated.getY(), rotated.getZ(), .06);
}
loc.getWorld().playSound(loc, VersionSound.BLOCK_NOTE_BLOCK_HAT.toSound(), 1, 1);
if (target.getLocation().add(0, target.getHeight() / 2, 0).distanceSquared(loc) < 1.3) {
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() + ability.getModifier("ignite") * 20));
new AttackMetadata(new DamageMetadata(ability.getModifier("damage"), DamageType.SKILL, DamageType.MAGIC, DamageType.PROJECTILE), attack.getStats()).damage(target);
cancel();
}
}
}.runTaskTimer(MMOItems.plugin, 0, 1);
}
}

View File

@ -1,51 +0,0 @@
package net.Indyuce.mmoitems.ability.list.target;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.TargetAbility;
import net.Indyuce.mmoitems.ability.metadata.TargetAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.entity.LivingEntity;
import org.bukkit.scheduler.BukkitRunnable;
public class Vampirism extends TargetAbility {
public Vampirism() {
super();
addModifier("cooldown", 8);
addModifier("drain", 10);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public void whenCast(AttackMetadata attack, TargetAbilityMetadata ability) {
LivingEntity target = ability.getTarget();
new BukkitRunnable() {
final Location loc = target.getLocation();
double ti = 0;
double dis = 0;
public void run() {
for (int j1 = 0; j1 < 4; j1++) {
ti += .75;
dis += ti <= 10 ? .15 : -.15;
for (double j = 0; j < Math.PI * 2; j += Math.PI / 4)
loc.getWorld().spawnParticle(Particle.REDSTONE,
loc.clone().add(Math.cos(j + (ti / 20)) * dis, 0, Math.sin(j + (ti / 20)) * dis), 1,
new Particle.DustOptions(Color.RED, 1));
}
if (ti >= 17)
cancel();
}
}.runTaskTimer(MMOItems.plugin, 0, 1);
target.getWorld().playSound(target.getLocation(), Sound.ENTITY_WITCH_DRINK, 1, 2);
MMOUtils.heal(attack.getPlayer(), attack.getDamage().getDamage() * ability.getModifier("drain") / 100);
}
}

View File

@ -1,118 +0,0 @@
package net.Indyuce.mmoitems.ability.list.target;
import io.lumine.mythic.lib.version.VersionSound;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.ability.TargetAbility;
import net.Indyuce.mmoitems.ability.metadata.TargetAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.player.PlayerItemConsumeEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
public class Weaken_Target extends TargetAbility implements Listener {
public final Map<UUID, WeakenedInfo> marked = new HashMap<>();
public Weaken_Target() {
super();
addModifier("duration", 4);
addModifier("extra-damage", 40);
addModifier("cooldown", 10);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public void whenCast(AttackMetadata attack, TargetAbilityMetadata ability) {
LivingEntity target = 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);
/*
* display particles until the entity is hit again and eventually remove
* the mark from the entity
*/
new BukkitRunnable() {
final long duration = (long) (ability.getModifier("duration") * 1000);
public void run() {
if (!marked.containsKey(target.getUniqueId()) || marked.get(target.getUniqueId()).date + duration < System.currentTimeMillis()) {
cancel();
return;
}
for (double j = 0; j < Math.PI * 2; j += Math.PI / 18)
target.getWorld().spawnParticle(Particle.SMOKE_NORMAL, target.getLocation().clone().add(Math.cos(j) * .7, .1, Math.sin(j) * .7),
0);
}
}.runTaskTimer(MMOItems.plugin, 0, 20);
}
@EventHandler
public void a(EntityDamageEvent event) {
if (event.getCause() != DamageCause.ENTITY_ATTACK && event.getCause() != DamageCause.ENTITY_EXPLOSION
&& event.getCause() != DamageCause.PROJECTILE)
return;
Entity entity = event.getEntity();
if (marked.containsKey(entity.getUniqueId())) {
event.setDamage(event.getDamage() * (1 + marked.get(entity.getUniqueId()).extraDamage));
effect(entity.getLocation());
marked.remove(entity.getUniqueId());
entity.getWorld().playSound(entity.getLocation(), VersionSound.ENTITY_ENDERMAN_DEATH.toSound(), 2, 2);
}
}
@EventHandler
public void b(PlayerItemConsumeEvent event) {
Player player = event.getPlayer();
ItemStack item = event.getItem();
if (item.getType() == Material.MILK_BUCKET && marked.containsKey(player.getUniqueId())) {
marked.remove(player.getUniqueId());
player.getWorld().playSound(player.getLocation(), VersionSound.ENTITY_ENDERMAN_DEATH.toSound(), 2, 2);
}
}
private void effect(Location loc) {
new BukkitRunnable() {
double y = 0;
public void run() {
for (int j = 0; j < 3; j++) {
y += .07;
for (int k = 0; k < 3; k++)
loc.getWorld().spawnParticle(Particle.REDSTONE, loc.clone().add(Math.cos(y * Math.PI + (k * Math.PI * 2 / 3)) * (3 - y) / 2.5,
y, Math.sin(y * Math.PI + (k * Math.PI * 2 / 3)) * (3 - y) / 2.5), 1, new Particle.DustOptions(Color.BLACK, 1));
}
if (y > 3)
cancel();
}
}.runTaskTimer(MMOItems.plugin, 0, 1);
}
public static class WeakenedInfo {
private final long date = System.currentTimeMillis();
private final double extraDamage;
public WeakenedInfo(double extraDamage) {
this.extraDamage = extraDamage / 100;
}
}
}

View File

@ -1,54 +0,0 @@
package net.Indyuce.mmoitems.ability.list.target;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.ability.TargetAbility;
import net.Indyuce.mmoitems.ability.metadata.TargetAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.entity.LivingEntity;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitRunnable;
public class Wither extends TargetAbility {
public Wither() {
super();
addModifier("cooldown", 8);
addModifier("duration", 3);
addModifier("amplifier", 1);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public void whenCast(AttackMetadata attack, TargetAbilityMetadata ability) {
LivingEntity target = ability.getTarget();
new BukkitRunnable() {
final Location loc = target.getLocation();
double y = 0;
public void run() {
if (y > 3)
cancel();
for (int j1 = 0; j1 < 3; j1++) {
y += .07;
for (int j = 0; j < 3; j++) {
double a = y * Math.PI + (j * Math.PI * 2 / 3);
double x = Math.cos(a) * (3 - y) / 2.5;
double z = Math.sin(a) * (3 - y) / 2.5;
loc.getWorld().spawnParticle(Particle.REDSTONE, loc.clone().add(x, y, z), 1, new Particle.DustOptions(Color.BLACK, 1));
}
}
}
}.runTaskTimer(MMOItems.plugin, 0, 1);
target.getWorld().playSound(target.getLocation(), Sound.ENTITY_WITHER_SHOOT, 2, 2);
target.addPotionEffect(
new PotionEffect(PotionEffectType.WITHER, (int) (ability.getModifier("duration") * 20), (int) ability.getModifier("amplifier")));
}
}

View File

@ -1,88 +0,0 @@
package net.Indyuce.mmoitems.ability.list.vector;
import io.lumine.mythic.lib.damage.AttackMetadata;
import io.lumine.mythic.lib.damage.DamageMetadata;
import io.lumine.mythic.lib.damage.DamageType;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.VectorAbility;
import net.Indyuce.mmoitems.ability.metadata.VectorAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
public class Bouncy_Fireball extends VectorAbility {
public Bouncy_Fireball() {
super();
addModifier("cooldown", 20);
addModifier("damage", 5);
addModifier("ignite", 40);
addModifier("speed", 1);
addModifier("radius", 4);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public void whenCast(AttackMetadata attack, VectorAbilityMetadata ability) {
attack.getPlayer().getWorld().playSound(attack.getPlayer().getLocation(), Sound.ENTITY_SNOWBALL_THROW, 2, 0);
new BukkitRunnable() {
final Vector vec = ability.getTarget().setY(0).normalize().multiply(.5 * ability.getModifier("speed"));
final Location loc = attack.getPlayer().getLocation().clone().add(0, 1.2, 0);
int j = 0;
int bounces = 0;
double y = .3;
public void run() {
if (j++ > 100) {
loc.getWorld().spawnParticle(Particle.SMOKE_LARGE, loc, 32, 0, 0, 0, .05);
loc.getWorld().playSound(loc, Sound.BLOCK_FIRE_EXTINGUISH, 1, 1);
cancel();
return;
}
loc.add(vec);
loc.add(0, y, 0);
if (y > -.6)
y -= .05;
loc.getWorld().spawnParticle(Particle.LAVA, loc, 0);
loc.getWorld().spawnParticle(Particle.FLAME, loc, 4, 0, 0, 0, .03);
loc.getWorld().spawnParticle(Particle.SMOKE_NORMAL, loc, 1, 0, 0, 0, .03);
if (loc.getBlock().getType().isSolid()) {
loc.add(0, -y, 0);
loc.add(vec.clone().multiply(-1));
y = .4;
bounces++;
loc.getWorld().playSound(loc, Sound.ENTITY_BLAZE_HURT, 3, 2);
}
if (bounces > 2) {
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)
if (MMOUtils.canTarget(attack.getPlayer(), entity)) {
new AttackMetadata(new DamageMetadata(damage, DamageType.SKILL, DamageType.MAGIC, DamageType.PROJECTILE), attack.getStats()).damage((LivingEntity) entity);
entity.setFireTicks((int) (ignite * 20));
}
loc.getWorld().spawnParticle(Particle.EXPLOSION_LARGE, loc, 12, 2, 2, 2, 0);
loc.getWorld().spawnParticle(Particle.EXPLOSION_NORMAL, loc, 48, 0, 0, 0, .2);
loc.getWorld().playSound(loc, Sound.ENTITY_GENERIC_EXPLODE, 3, 0);
cancel();
}
}
}.runTaskTimer(MMOItems.plugin, 0, 1);
}
}

View File

@ -1,84 +0,0 @@
package net.Indyuce.mmoitems.ability.list.vector;
import io.lumine.mythic.lib.api.util.TemporaryListener;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.VectorAbility;
import net.Indyuce.mmoitems.ability.metadata.VectorAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.EvokerFangs;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
import java.util.HashSet;
import java.util.Set;
public class Corrupted_Fangs extends VectorAbility {
public Corrupted_Fangs() {
super();
addModifier("damage", 5);
addModifier("cooldown", 12);
addModifier("mana", 0);
addModifier("stamina", 0);
addModifier("fangs", 6);
}
@Override
public void whenCast(AttackMetadata attack, VectorAbilityMetadata ability) {
attack.getPlayer().getWorld().playSound(attack.getPlayer().getLocation(), Sound.ENTITY_WITHER_SHOOT, 2, 2);
new BukkitRunnable() {
final Vector vec = ability.getTarget().setY(0).multiply(2);
final Location loc = attack.getPlayer().getLocation();
final FangsHandler handler = new FangsHandler(attack, ability.getModifier("damage"));
final double fangAmount = ability.getModifier("fangs");
double ti = 0;
public void run() {
if (ti++ >= fangAmount) {
handler.close(3 * 20);
cancel();
return;
}
loc.add(vec);
EvokerFangs evokerFangs = (EvokerFangs) attack.getPlayer().getWorld().spawnEntity(loc, EntityType.EVOKER_FANGS);
handler.entities.add(evokerFangs.getEntityId());
}
}.runTaskTimer(MMOItems.plugin, 0, 1);
}
public class FangsHandler extends TemporaryListener {
private final Set<Integer> entities = new HashSet<>();
private final AttackMetadata attackMeta;
private final double damage;
public FangsHandler(AttackMetadata attackMeta, double damage) {
super(EntityDamageByEntityEvent.getHandlerList());
this.attackMeta = attackMeta;
this.damage = damage;
}
@EventHandler
public void a(EntityDamageByEntityEvent event) {
if (event.getDamager() instanceof EvokerFangs && entities.contains(event.getDamager().getEntityId())) {
event.setCancelled(true);
if (MMOUtils.canTarget(attackMeta.getPlayer(), event.getEntity()))
attackMeta.damage((LivingEntity) event.getEntity());
}
}
@Override
public void whenClosed() {
// Nothing
}
}
}

View File

@ -1,98 +0,0 @@
package net.Indyuce.mmoitems.ability.list.vector;
import io.lumine.mythic.lib.damage.AttackMetadata;
import io.lumine.mythic.lib.damage.DamageMetadata;
import io.lumine.mythic.lib.damage.DamageType;
import io.lumine.mythic.lib.version.VersionSound;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.VectorAbility;
import net.Indyuce.mmoitems.ability.metadata.VectorAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
import java.util.List;
public class Cursed_Beam extends VectorAbility {
public Cursed_Beam() {
super();
addModifier("damage", 8);
addModifier("cooldown", 10);
addModifier("duration", 5);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public void whenCast(AttackMetadata attack, VectorAbilityMetadata ability) {
double duration = ability.getModifier("duration");
attack.getPlayer().getWorld().playSound(attack.getPlayer().getLocation(), Sound.ENTITY_WITHER_SHOOT, 2, 2);
new BukkitRunnable() {
final Vector dir = ability.getTarget().multiply(.3);
final Location loc = attack.getPlayer().getEyeLocation().clone();
final double r = 0.4;
int ti = 0;
public void run() {
ti++;
if (ti > 50)
cancel();
List<Entity> entities = MMOUtils.getNearbyChunkEntities(loc);
for (double j = 0; j < 4; j++) {
loc.add(dir);
for (double i = 0; i < Math.PI * 2; i += Math.PI / 6) {
Vector vec = MMOUtils.rotateFunc(new Vector(r * Math.cos(i), r * Math.sin(i), 0), loc);
loc.add(vec);
loc.getWorld().spawnParticle(Particle.SPELL_WITCH, loc, 0);
loc.add(vec.multiply(-1));
}
for (Entity target : entities)
if (MMOUtils.canTarget(attack.getPlayer(), loc, target)) {
effect(target);
double damage = ability.getModifier("damage");
loc.getWorld().playSound(loc, VersionSound.ENTITY_ENDERMAN_TELEPORT.toSound(), 2, .7f);
for (Entity entity : entities)
if (MMOUtils.canTarget(attack.getPlayer(), entity) && loc.distanceSquared(entity.getLocation().add(0, 1, 0)) < 9) {
new AttackMetadata(new DamageMetadata(damage, DamageType.SKILL, DamageType.MAGIC, DamageType.PROJECTILE), attack.getStats()).damage((LivingEntity) entity);
((LivingEntity) entity).addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, (int) (duration * 20), 0));
}
cancel();
return;
}
}
}
}.runTaskTimer(MMOItems.plugin, 0, 1);
}
private void effect(Entity ent) {
new BukkitRunnable() {
final Location loc2 = ent.getLocation();
double y = 0;
public void run() {
for (int i = 0; i < 3; i++) {
y += .05;
for (int j = 0; j < 2; j++) {
double xz = y * Math.PI * .8 + (j * Math.PI);
loc2.getWorld().spawnParticle(Particle.SPELL_WITCH, loc2.clone().add(Math.cos(xz) * 2.5, y, Math.sin(xz) * 2.5), 0);
}
}
if (y >= 3)
cancel();
}
}.runTaskTimer(MMOItems.plugin, 0, 1);
}
}

View File

@ -1,131 +0,0 @@
package net.Indyuce.mmoitems.ability.list.vector;
import io.lumine.mythic.lib.api.util.TemporaryListener;
import io.lumine.mythic.lib.damage.AttackMetadata;
import io.lumine.mythic.lib.damage.DamageMetadata;
import io.lumine.mythic.lib.damage.DamageType;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.VectorAbility;
import net.Indyuce.mmoitems.ability.metadata.VectorAbilityMetadata;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.attribute.Attribute;
import org.bukkit.entity.Chicken;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
public class Explosive_Turkey extends VectorAbility {
public Explosive_Turkey() {
super();
addModifier("damage", 6);
addModifier("radius", 4);
addModifier("duration", 4);
addModifier("knockback", 1);
addModifier("cooldown", 10);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public void whenCast(AttackMetadata attack, VectorAbilityMetadata ability) {
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 = ability.getTarget().normalize().multiply(.6);
Chicken chicken = (Chicken) attack.getPlayer().getWorld().spawnEntity(attack.getPlayer().getLocation().add(0, 1.3, 0).add(vec),
EntityType.CHICKEN);
ChickenHandler chickenHandler = new ChickenHandler(chicken);
chicken.setInvulnerable(true);
chicken.setSilent(true);
/*
* Sets the health to 2048 (Default max Spigot value) which stops the
* bug where you can kill the chicken for a brief few ticks after it
* spawns in!
*/
chicken.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(2048);
chicken.setHealth(2048);
/*
* When items are moving through the air, they loose a percent of their
* velocity proportionally to their coordinates in each axis. This means
* that if the trajectory is not affected, the ratio of x/y will always
* be the same. Check for any change of that ratio to check for a
* trajectory change
*/
chicken.setVelocity(vec);
final double trajRatio = chicken.getVelocity().getX() / chicken.getVelocity().getZ();
new BukkitRunnable() {
int ti = 0;
public void run() {
if (ti++ > duration || chicken.isDead()) {
chickenHandler.close();
cancel();
return;
}
chicken.setVelocity(vec);
if (ti % 4 == 0)
chicken.getWorld().playSound(chicken.getLocation(), Sound.ENTITY_CHICKEN_HURT, 2, 1);
chicken.getWorld().spawnParticle(Particle.EXPLOSION_NORMAL, chicken.getLocation().add(0, .3, 0), 0);
chicken.getWorld().spawnParticle(Particle.FIREWORKS_SPARK, chicken.getLocation().add(0, .3, 0), 1, 0, 0, 0, .05);
double currentTrajRatio = chicken.getVelocity().getX() / chicken.getVelocity().getZ();
if (chicken.isOnGround() || Math.abs(trajRatio - currentTrajRatio) > .1) {
chickenHandler.close();
cancel();
chicken.getWorld().spawnParticle(Particle.FIREWORKS_SPARK, chicken.getLocation().add(0, .3, 0), 128, 0, 0, 0, .25);
chicken.getWorld().spawnParticle(Particle.EXPLOSION_NORMAL, chicken.getLocation().add(0, .3, 0), 24, 0, 0, 0, .25);
chicken.getWorld().playSound(chicken.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 2, 1.5f);
for (Entity entity : MMOUtils.getNearbyChunkEntities(chicken.getLocation()))
if (!entity.isDead() && entity.getLocation().distanceSquared(chicken.getLocation()) < radiusSquared
&& MMOUtils.canTarget(attack.getPlayer(), entity)) {
new AttackMetadata(new DamageMetadata(damage, DamageType.SKILL, DamageType.MAGIC, DamageType.PROJECTILE), attack.getStats()).damage((LivingEntity) entity);
entity.setVelocity(entity.getLocation().toVector().subtract(chicken.getLocation().toVector()).multiply(.1 * knockback)
.setY(.4 * knockback));
}
}
}
}.runTaskTimer(MMOItems.plugin, 0, 1);
}
/**
* This fixes an issue where chickens sometimes drop
*/
public static class ChickenHandler extends TemporaryListener {
private final Chicken chicken;
public ChickenHandler(Chicken chicken) {
super(EntityDeathEvent.getHandlerList());
this.chicken = chicken;
}
@Override
public void whenClosed() {
chicken.remove();
}
@EventHandler
public void a(EntityDeathEvent event) {
if (event.getEntity().equals(chicken)) {
event.getDrops().clear();
event.setDroppedExp(0);
}
}
}
}

View File

@ -1,68 +0,0 @@
package net.Indyuce.mmoitems.ability.list.vector;
import io.lumine.mythic.lib.damage.AttackMetadata;
import io.lumine.mythic.lib.damage.DamageMetadata;
import io.lumine.mythic.lib.damage.DamageType;
import io.lumine.mythic.lib.version.VersionSound;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.VectorAbility;
import net.Indyuce.mmoitems.ability.metadata.VectorAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
public class Fire_Meteor extends VectorAbility {
public Fire_Meteor() {
super();
addModifier("damage", 6);
addModifier("knockback", 1);
addModifier("radius", 4);
addModifier("cooldown", 10);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public void whenCast(AttackMetadata attack, VectorAbilityMetadata ability) {
attack.getPlayer().getWorld().playSound(attack.getPlayer().getLocation(), VersionSound.ENTITY_ENDERMAN_TELEPORT.toSound(), 3, 1);
new BukkitRunnable() {
final Location loc = attack.getPlayer().getLocation().clone().add(0, 10, 0);
final Vector vec = ability.getTarget().multiply(1.3).setY(-1).normalize();
double ti = 0;
public void run() {
ti++;
if (ti > 40)
cancel();
loc.add(vec);
loc.getWorld().spawnParticle(Particle.EXPLOSION_LARGE, loc, 0);
loc.getWorld().spawnParticle(Particle.FLAME, loc, 4, .2, .2, .2, 0);
if (loc.getBlock().getRelative(BlockFace.DOWN).getType().isSolid() || loc.getBlock().getType().isSolid()) {
loc.getWorld().playSound(loc, Sound.ENTITY_GENERIC_EXPLODE, 3, .6f);
loc.getWorld().spawnParticle(Particle.EXPLOSION_LARGE, loc, 10, 2, 2, 2, 0);
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 = ability.getModifier("damage");
double knockback = ability.getModifier("knockback");
double radius = ability.getModifier("radius");
for (Entity entity : MMOUtils.getNearbyChunkEntities(loc))
if (MMOUtils.canTarget(attack.getPlayer(), entity) && entity.getLocation().distanceSquared(loc) < radius * radius) {
new AttackMetadata(new DamageMetadata(damage, DamageType.SKILL, DamageType.MAGIC, DamageType.PROJECTILE), attack.getStats()).damage((LivingEntity) entity);
entity.setVelocity(entity.getLocation().toVector().subtract(loc.toVector()).multiply(.1 * knockback).setY(.4 * knockback));
}
cancel();
}
}
}.runTaskTimer(MMOItems.plugin, 0, 1);
}
}

View File

@ -1,71 +0,0 @@
package net.Indyuce.mmoitems.ability.list.vector;
import io.lumine.mythic.lib.damage.AttackMetadata;
import io.lumine.mythic.lib.damage.DamageMetadata;
import io.lumine.mythic.lib.damage.DamageType;
import io.lumine.mythic.lib.version.VersionSound;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.VectorAbility;
import net.Indyuce.mmoitems.ability.metadata.VectorAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
import java.util.List;
public class Firebolt extends VectorAbility {
public Firebolt() {
super();
addModifier("damage", 6);
addModifier("ignite", 3);
addModifier("cooldown", 10);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public void whenCast(AttackMetadata attack, VectorAbilityMetadata ability) {
attack.getPlayer().getWorld().playSound(attack.getPlayer().getLocation(), VersionSound.ENTITY_FIREWORK_ROCKET_BLAST.toSound(), 1, 1);
new BukkitRunnable() {
final Vector vec = ability.getTarget().multiply(.8);
final Location loc = attack.getPlayer().getEyeLocation();
int ti = 0;
public void run() {
ti++;
if (ti > 20)
cancel();
List<Entity> entities = MMOUtils.getNearbyChunkEntities(loc);
loc.getWorld().playSound(loc, Sound.BLOCK_FIRE_AMBIENT, 2, 1);
for (int j = 0; j < 2; j++) {
loc.add(vec);
if (loc.getBlock().getType().isSolid())
cancel();
loc.getWorld().spawnParticle(Particle.FLAME, loc, 5, .12, .12, .12, 0);
if (random.nextDouble() < .3)
loc.getWorld().spawnParticle(Particle.LAVA, loc, 0);
for (Entity target : entities)
if (MMOUtils.canTarget(attack.getPlayer(), loc, target)) {
loc.getWorld().spawnParticle(Particle.FLAME, loc, 32, 0, 0, 0, .1);
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 AttackMetadata(new DamageMetadata(ability.getModifier("damage"), DamageType.SKILL, DamageType.MAGIC, DamageType.PROJECTILE), attack.getStats()).damage((LivingEntity) target);
target.setFireTicks((int) ability.getModifier("ignite") * 20);
cancel();
return;
}
}
}
}.runTaskTimer(MMOItems.plugin, 0, 1);
}
}

View File

@ -1,59 +0,0 @@
package net.Indyuce.mmoitems.ability.list.vector;
import io.lumine.mythic.lib.damage.AttackMetadata;
import io.lumine.mythic.lib.damage.DamageMetadata;
import io.lumine.mythic.lib.damage.DamageType;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.VectorAbility;
import net.Indyuce.mmoitems.ability.metadata.VectorAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
public class Heavy_Charge extends VectorAbility {
public Heavy_Charge() {
super();
addModifier("damage", 6);
addModifier("knockback", 1);
addModifier("cooldown", 10);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public void whenCast(AttackMetadata attack, VectorAbilityMetadata ability) {
double knockback = ability.getModifier("knockback");
new BukkitRunnable() {
final Vector vec = ability.getTarget().setY(-1);
double ti = 0;
public void run() {
if (ti++ > 20)
cancel();
if (ti < 9) {
attack.getPlayer().setVelocity(vec);
attack.getPlayer().getWorld().spawnParticle(Particle.EXPLOSION_NORMAL, attack.getPlayer().getLocation().add(0, 1, 0), 3, .13, .13, .13, 0);
}
for (Entity target : attack.getPlayer().getNearbyEntities(1, 1, 1))
if (MMOUtils.canTarget(attack.getPlayer(), target)) {
attack.getPlayer().getWorld().playSound(attack.getPlayer().getLocation(), Sound.ENTITY_ZOMBIE_ATTACK_IRON_DOOR, 1, 1);
attack.getPlayer().getWorld().spawnParticle(Particle.EXPLOSION_LARGE, target.getLocation().add(0, 1, 0), 0);
target.setVelocity(attack.getPlayer().getVelocity().setY(0.3).multiply(1.7 * knockback));
attack.getPlayer().setVelocity(attack.getPlayer().getVelocity().setX(0).setY(0).setZ(0));
new AttackMetadata(new DamageMetadata(ability.getModifier("damage"), DamageType.SKILL, DamageType.PHYSICAL), attack.getStats()).damage((LivingEntity) target);
cancel();
break;
}
}
}.runTaskTimer(MMOItems.plugin, 0, 1);
}
}

View File

@ -1,75 +0,0 @@
package net.Indyuce.mmoitems.ability.list.vector;
import io.lumine.mythic.lib.damage.AttackMetadata;
import io.lumine.mythic.lib.damage.DamageMetadata;
import io.lumine.mythic.lib.damage.DamageType;
import io.lumine.mythic.lib.version.VersionSound;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.VectorAbility;
import net.Indyuce.mmoitems.ability.metadata.VectorAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
import java.util.List;
public class Holy_Missile extends VectorAbility {
public Holy_Missile() {
super();
addModifier("damage", 6);
addModifier("cooldown", 10);
addModifier("duration", 4);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public void whenCast(AttackMetadata attack, VectorAbilityMetadata ability) {
double duration = ability.getModifier("duration") * 10;
double damage = ability.getModifier("damage");
attack.getPlayer().getWorld().playSound(attack.getPlayer().getLocation(), VersionSound.ENTITY_FIREWORK_ROCKET_BLAST.toSound(), 1, 1);
new BukkitRunnable() {
final Vector vec = ability.getTarget().multiply(.45);
final Location loc = attack.getPlayer().getLocation().clone().add(0, 1.3, 0);
double ti = 0;
public void run() {
if (ti++ > duration)
cancel();
loc.getWorld().playSound(loc, VersionSound.BLOCK_NOTE_BLOCK_HAT.toSound(), 2, 1);
List<Entity> entities = MMOUtils.getNearbyChunkEntities(loc);
for (int j = 0; j < 2; j++) {
loc.add(vec);
if (loc.getBlock().getType().isSolid())
cancel();
for (double i = -Math.PI; i < Math.PI; i += Math.PI / 2) {
Vector v = new Vector(Math.cos(i + ti / 4), Math.sin(i + ti / 4), 0);
v = MMOUtils.rotateFunc(v, loc);
loc.getWorld().spawnParticle(Particle.FIREWORKS_SPARK, loc, 0, v.getX(), v.getY(), v.getZ(), .08);
}
for (Entity entity : entities)
if (MMOUtils.canTarget(attack.getPlayer(), loc, entity)) {
loc.getWorld().spawnParticle(Particle.EXPLOSION_LARGE, loc, 1);
loc.getWorld().spawnParticle(Particle.FIREWORKS_SPARK, loc, 32, 0, 0, 0, .2);
loc.getWorld().playSound(loc, Sound.ENTITY_GENERIC_EXPLODE, 2, 1);
new AttackMetadata(new DamageMetadata(damage, DamageType.SKILL, DamageType.MAGIC, DamageType.PROJECTILE), attack.getStats()).damage((LivingEntity) entity);
cancel();
return;
}
}
}
}.runTaskTimer(MMOItems.plugin, 0, 1);
}
}

View File

@ -1,85 +0,0 @@
package net.Indyuce.mmoitems.ability.list.vector;
import io.lumine.mythic.lib.damage.AttackMetadata;
import io.lumine.mythic.lib.damage.DamageMetadata;
import io.lumine.mythic.lib.damage.DamageType;
import io.lumine.mythic.lib.version.VersionSound;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.VectorAbility;
import net.Indyuce.mmoitems.ability.metadata.VectorAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
import java.util.List;
public class Ice_Crystal extends VectorAbility {
public Ice_Crystal() {
super();
addModifier("damage", 6);
addModifier("duration", 3);
addModifier("amplifier", 1);
addModifier("cooldown", 10);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public void whenCast(AttackMetadata attack, VectorAbilityMetadata ability) {
attack.getPlayer().getWorld().playSound(attack.getPlayer().getLocation(), VersionSound.ENTITY_FIREWORK_ROCKET_BLAST.toSound(), 1, 1);
new BukkitRunnable() {
final Vector vec = ability.getTarget().multiply(.45);
final Location loc = attack.getPlayer().getEyeLocation().clone().add(0, -.3, 0);
int ti = 0;
public void run() {
if (ti++ > 25)
cancel();
loc.getWorld().playSound(loc, Sound.BLOCK_GLASS_BREAK, 2, 1);
List<Entity> entities = MMOUtils.getNearbyChunkEntities(loc);
for (int j = 0; j < 3; j++) {
loc.add(vec);
if (loc.getBlock().getType().isSolid())
cancel();
/*
* has a different particle effect since SNOW_DIG is not the
* same as in legacy minecraft, the particle effect is now a
* cross that rotates
*/
for (double r = 0; r < .4; r += .1)
for (double a = 0; a < Math.PI * 2; a += Math.PI / 2) {
Vector vec = MMOUtils.rotateFunc(new Vector(r * Math.cos(a + (double) ti / 10), r * Math.sin(a + (double) ti / 10), 0),
loc);
loc.add(vec);
loc.getWorld().spawnParticle(Particle.REDSTONE, loc, 1, new Particle.DustOptions(Color.WHITE, .7f));
loc.add(vec.multiply(-1));
}
for (Entity entity : entities)
if (MMOUtils.canTarget(attack.getPlayer(), loc, entity)) {
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 AttackMetadata(new DamageMetadata(ability.getModifier("damage"), DamageType.SKILL, DamageType.MAGIC, DamageType.PROJECTILE), attack.getStats()).damage((LivingEntity) entity);
((LivingEntity) entity).addPotionEffect(new PotionEffect(PotionEffectType.SLOW,
(int) (ability.getModifier("duration") * 20), (int) ability.getModifier("amplifier")));
cancel();
return;
}
}
}
}.runTaskTimer(MMOItems.plugin, 0, 1);
}
}

View File

@ -1,66 +0,0 @@
package net.Indyuce.mmoitems.ability.list.vector;
import io.lumine.mythic.lib.api.util.TemporaryListener;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.VectorAbility;
import net.Indyuce.mmoitems.ability.metadata.VectorAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.util.Vector;
public class TNT_Throw extends VectorAbility {
public TNT_Throw() {
super();
addModifier("cooldown", 10);
addModifier("force", 1);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public void whenCast(AttackMetadata attack, VectorAbilityMetadata ability) {
Vector vec = ability.getTarget().multiply(2 * ability.getModifier("force"));
TNTPrimed tnt = (TNTPrimed) attack.getPlayer().getWorld().spawnEntity(attack.getPlayer().getLocation().add(0, 1, 0), EntityType.PRIMED_TNT);
tnt.setFuseTicks(80);
tnt.setVelocity(vec);
new CancelTeamDamage(attack.getPlayer(), tnt);
attack.getPlayer().getWorld().playSound(attack.getPlayer().getLocation(), Sound.ENTITY_SNOWBALL_THROW, 1, 0);
attack.getPlayer().getWorld().spawnParticle(Particle.EXPLOSION_NORMAL, attack.getPlayer().getLocation().add(0, 1, 0), 12, 0, 0, 0, .1);
}
/**
* Used to cancel team damage and other things
*/
public static class CancelTeamDamage extends TemporaryListener {
private final Player player;
private final TNTPrimed tnt;
public CancelTeamDamage(Player player, TNTPrimed tnt) {
super(EntityDamageByEntityEvent.getHandlerList());
this.player = player;
this.tnt = tnt;
close(100);
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void a(EntityDamageByEntityEvent event) {
if (event.getDamager().equals(tnt) && !MMOUtils.canTarget(player, event.getEntity()))
event.setCancelled(true);
}
@Override
public void whenClosed() {
// Nothing
}
}
}

View File

@ -1,46 +0,0 @@
package net.Indyuce.mmoitems.ability.list.vector;
import io.lumine.mythic.lib.damage.AttackMetadata;
import io.lumine.mythic.lib.damage.DamageMetadata;
import io.lumine.mythic.lib.damage.DamageType;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.VectorAbility;
import net.Indyuce.mmoitems.ability.metadata.VectorAbilityMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector;
public class Thrust extends VectorAbility {
public Thrust() {
super();
addModifier("cooldown", 10);
addModifier("damage", 6);
addModifier("mana", 0);
addModifier("stamina", 0);
}
@Override
public void whenCast(AttackMetadata attack, VectorAbilityMetadata ability) {
double damage = ability.getModifier("damage");
attack.getPlayer().getWorld().playSound(attack.getPlayer().getLocation(), Sound.ENTITY_ZOMBIE_ATTACK_IRON_DOOR, 1, 0);
attack.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 2, 3));
Location loc = attack.getPlayer().getEyeLocation().clone();
Vector vec = ability.getTarget().multiply(.5);
for (double j = 0; j < 7; j += .5) {
loc.add(vec);
for (Entity entity : MMOUtils.getNearbyChunkEntities(loc))
if (MMOUtils.canTarget(attack.getPlayer(), loc, entity))
new AttackMetadata(new DamageMetadata(damage, DamageType.SKILL, DamageType.PHYSICAL), attack.getStats()).damage((LivingEntity) entity);
loc.getWorld().spawnParticle(Particle.SMOKE_LARGE, loc, 0);
}
}
}

View File

@ -80,7 +80,7 @@ public enum Element {
target.getWorld().playSound(target.getLocation(), VersionSound.ENTITY_FIREWORK_ROCKET_LARGE_BLAST.toSound(), 2, 0);
for (Entity entity : target.getNearbyEntities(3, 2, 3))
if (MMOUtils.canTarget(attack.getPlayer(), entity, InteractionType.OFFENSE_ACTION))
MythicLib.plugin.getDamage().damage(new ItemAttackMetadata(new DamageMetadata(attack.getDamage().getDamage() * damage / 100, DamageType.WEAPON), attack.getStats()), (LivingEntity) entity);
MythicLib.plugin.getDamage().damage(new ItemAttackMetadata(new DamageMetadata(attack.getDamage().getDamage() * damage / 100, DamageType.WEAPON), attack), (LivingEntity) entity);
attack.getDamage().add(absolute);
for (double k = 0; k < Math.PI * 2; k += Math.PI / 16)

View File

@ -6,6 +6,7 @@ import io.lumine.mythic.lib.api.stat.StatMap;
import io.lumine.mythic.lib.damage.AttackMetadata;
import io.lumine.mythic.lib.damage.DamageMetadata;
import io.lumine.mythic.lib.damage.DamageType;
import io.lumine.mythic.lib.player.PlayerMetadata;
import net.Indyuce.mmoitems.api.player.PlayerData;
import org.bukkit.entity.LivingEntity;
@ -18,12 +19,12 @@ import org.bukkit.entity.LivingEntity;
*/
@Deprecated
public class ItemAttackMetadata extends AttackMetadata {
public ItemAttackMetadata(DamageMetadata damage, StatMap.CachedStatMap damager) {
public ItemAttackMetadata(DamageMetadata damage, PlayerMetadata damager) {
super(damage, damager);
}
public ItemAttackMetadata(AttackMetadata attackMeta) {
super(attackMeta.getDamage(), attackMeta.getStats());
super(attackMeta.getDamage(), attackMeta);
}
public PlayerData getPlayerData() {
@ -31,7 +32,7 @@ public class ItemAttackMetadata extends AttackMetadata {
}
public ItemAttackMetadata clone() {
return new ItemAttackMetadata(getDamage().clone(), getStats());
return new ItemAttackMetadata(getDamage().clone(), this);
}
/**

View File

@ -1,10 +1,10 @@
package net.Indyuce.mmoitems.api;
import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.api.player.EquipmentSlot;
import io.lumine.mythic.lib.api.player.MMOPlayerData;
import io.lumine.mythic.lib.damage.AttackMetadata;
import io.lumine.mythic.lib.damage.DamageMetadata;
import io.lumine.mythic.lib.player.PlayerMetadata;
import io.lumine.mythic.lib.skill.trigger.TriggerMetadata;
import io.lumine.mythic.lib.skill.trigger.TriggerType;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.ability.Ability;
@ -16,6 +16,7 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Map;
import java.util.Objects;
@ -24,7 +25,7 @@ public class MMOItemsAPI {
private final JavaPlugin plugin;
/**
* @param plugin Plugin
* @param plugin Plugin using the API
*/
public MMOItemsAPI(JavaPlugin plugin) {
this.plugin = plugin;
@ -47,9 +48,33 @@ public class MMOItemsAPI {
}
/**
* @return Ability with the specified identifier like FIREBOLT
* Registers an ability in MMOItems. This must be called before MMOItems enables,
* therefore either using a loadbefore of MMOItems and while the plugin enables,
* or using a dependency and usign #onLoad().
* <p>
* This method does NOT register listeners.
* <p>
* Throws an IAE if anything goes wrong.
*
* @param skill Skill to register
*/
public RegisteredSkill getAbilityById(String id) {
public void registerSkill(RegisteredSkill skill) {
MMOItems.plugin.getSkills().registerSkill(skill);
}
/**
* @return Ability with the specified identifier like 'FIREBOLT'
* @deprecated Use {@link #getSkillById(String)}
*/
@Deprecated
public Ability getAbilityById(String id) {
return MMOItems.plugin.getAbilities().getAbility(id);
}
/**
* @return Skill with the specified identifier like 'FIREBOLT'
*/
public RegisteredSkill getSkillById(String id) {
return Objects.requireNonNull(MMOItems.plugin.getSkills().getSkill(id), "Could not find skill with ID '" + id + "'");
}
@ -65,32 +90,34 @@ public class MMOItemsAPI {
* Forces a player to cast an ability
*
* @param player Player casting the ability
* @param abilityName Ability name. The ability is found using {@link #getAbilityById(String)}
* @param abilityName Skill name. Skill is found using {@link #getAbilityById(String)}
* @param modifiers Ability modifiers
* @param target The ability target (null if no target)
*/
public AttackMetadata castAbility(Player player, String abilityName, Map<String, Double> modifiers, @NotNull LivingEntity target) {
AttackMetadata attackMeta = new AttackMetadata(new DamageMetadata(), MMOPlayerData.get(player).getStatMap().cache(EquipmentSlot.MAIN_HAND));
return castAbility(player, abilityName, modifiers, target, attackMeta);
@Deprecated
@Nullable
public AttackMetadata castAbility(Player player, String abilityName, Map<String, Double> modifiers, @Nullable LivingEntity target) {
return castAbility(player, abilityName, modifiers, target, null);
}
/**
* Forces a player to cast an ability
*
* @param player Player casting the ability
* @param abilityName Ability name. The ability is found using {@link #getAbilityById(String)}
* @param modifiers Ability modifiers
* @param target The ability target (null if no target)
* @param attackMeta If the trigger type is ATTACK, the corresponding AttackMetadata is provided. This allows
* MMOItems to increase the damage of the current attack or even add new damage packets.
* This parameter is useless for trigger types like RIGHT_CLICK or SNEAK which aren't
* based on entity attacks; in that case the attackMeta will have an empty DamageMetadata
* @param player Player casting the ability
* @param skillName Ability name. The ability is found using {@link #getSkillById(String)}
* @param modifiers Ability modifiers
* @param target The ability target (null if no target)
* @param attackMeta If the trigger type is ATTACK, the corresponding AttackMetadata is provided. This allows
* MMOItems to increase the damage of the current attack or even add new damage packets.
* This parameter is useless for trigger types like RIGHT_CLICK or SNEAK which aren't
* based on entity attacks; in that case the attackMeta will have an empty DamageMetadata
*/
@Deprecated
public AttackMetadata castAbility(Player player, String abilityName, Map<String, Double> modifiers, @NotNull LivingEntity target, AttackMetadata attackMeta) {
@Nullable
public AttackMetadata castAbility(Player player, String skillName, Map<String, Double> modifiers, @Nullable LivingEntity target, @Nullable AttackMetadata attackMeta) {
// Setup ability
AbilityData abilityData = new AbilityData(getAbilityById(abilityName), TriggerType.RIGHT_CLICK);
AbilityData abilityData = new AbilityData(getSkillById(skillName), TriggerType.API);
modifiers.forEach((key, value) -> abilityData.setModifier(key, value));
// Cast ability
@ -106,11 +133,35 @@ public class MMOItemsAPI {
* @param attackMeta If the trigger type is ATTACK, the corresponding AttackMetadata is provided. This allows
* MMOItems to increase the damage of the current attack or even add new damage packets.
* This parameter is useless for trigger types like RIGHT_CLICK or SNEAK which aren't
* based on entity attacks; in that case the attackMeta will have an empty DamageMetadata
* based on entity attacks; in that case no attack metadata is provided.
*/
@Nullable
@Deprecated
public AttackMetadata castAbility(PlayerData playerData, AbilityData ability, @NotNull LivingEntity target, AttackMetadata attackMeta) {
public AttackMetadata castAbility(PlayerData playerData, AbilityData ability, @Nullable LivingEntity target, @Nullable AttackMetadata attackMeta) {
playerData.cast(attackMeta, target, ability);
return attackMeta;
}
/**
* Forces a player to cast a skill on a specific target, with
* custom modifiers and an attack bound to the cast skill.
*
* @param player Player casting the ability
* @param skill Ability being cast. Can be found using {@link #getSkillById(String)}
* @param modifiers Ability modifiers. Can be empty; if one of the skill
* modifiers is not found in that map, MMOItems will take
* its default value.
* @param target The ability target (null if no target)
* @param attackMeta If the trigger type is ATTACK, the corresponding AttackMetadata is provided. This allows
* MMOItems to increase the damage of the current attack or even add new damage packets.
* This parameter is useless for trigger types like RIGHT_CLICK or SNEAK which aren't
* based on entity attacks; in that case no attack metadata is provided.
*/
public void castSkill(Player player, RegisteredSkill skill, @NotNull Map<String, Double> modifiers, @Nullable LivingEntity target, @Nullable AttackMetadata attackMeta) {
AbilityData castable = new AbilityData(skill, TriggerType.API);
modifiers.forEach((mod, value) -> castable.setModifier(mod, value));
PlayerMetadata caster = MMOPlayerData.get(player).getStatMap().cache(EquipmentSlot.MAIN_HAND);
castable.cast(new TriggerMetadata(caster, attackMeta, target));
}
}

View File

@ -42,7 +42,7 @@ public enum TypeSet {
&& attack.getPlayer().getEyeLocation().getDirection()
.angle(entity.getLocation().subtract(attack.getPlayer().getLocation()).toVector()) < Math.PI / 3
&& MMOUtils.canTarget(attack.getPlayer(), entity, InteractionType.OFFENSE_ACTION) && !entity.equals(target)) {
ItemAttackMetadata subAttack = new ItemAttackMetadata(attack.getDamage().clone(), attack.getStats());
ItemAttackMetadata subAttack = new ItemAttackMetadata(attack.getDamage().clone(), attack);
subAttack.getDamage().multiply(.4);
subAttack.applyEffectsAndDamage(weapon.getNBTItem(), (LivingEntity) entity);
}
@ -71,7 +71,7 @@ public enum TypeSet {
&& attack.getPlayer().getEyeLocation().getDirection()
.angle(entity.getLocation().toVector().subtract(attack.getPlayer().getLocation().toVector())) < Math.PI / 18
&& MMOUtils.canTarget(attack.getPlayer(), entity, InteractionType.OFFENSE_ACTION) && !entity.equals(target)) {
ItemAttackMetadata subAttack = new ItemAttackMetadata(attack.getDamage().clone(), attack.getStats());
ItemAttackMetadata subAttack = new ItemAttackMetadata(attack.getDamage().clone(), attack);
subAttack.getDamage().multiply(.4);
subAttack.applyEffectsAndDamage(weapon.getNBTItem(), (LivingEntity) entity);
}
@ -91,13 +91,13 @@ public enum TypeSet {
damager.applyCooldown(CooldownType.SPECIAL_ATTACK, MMOItems.plugin.getConfig().getDouble("item-ability.blunt.aoe.cooldown"));
target.getWorld().playSound(target.getLocation(), Sound.BLOCK_ANVIL_LAND, 0.6f, pitchRange);
target.getWorld().spawnParticle(Particle.EXPLOSION_LARGE, target.getLocation().add(0, 1, 0), 0);
double bluntPower = attack.getStats().getStat("BLUNT_POWER");
double bluntPower = attack.getStat("BLUNT_POWER");
if (bluntPower > 0) {
double bluntRating = weapon.getValue(attack.getStats().getStat("BLUNT_RATING"),
double bluntRating = weapon.getValue(attack.getStat("BLUNT_RATING"),
MMOItems.plugin.getConfig().getDouble("default.blunt-rating")) / 100;
for (Entity entity : target.getNearbyEntities(bluntPower, bluntPower, bluntPower))
if (MMOUtils.canTarget(attack.getPlayer(), entity, InteractionType.OFFENSE_ACTION) && !entity.equals(target)) {
ItemAttackMetadata subAttack = new ItemAttackMetadata(attack.getDamage().clone(), attack.getStats());
ItemAttackMetadata subAttack = new ItemAttackMetadata(attack.getDamage().clone(), attack);
subAttack.getDamage().multiply(bluntRating);
subAttack.applyEffectsAndDamage(weapon.getNBTItem(), (LivingEntity) entity);
}

View File

@ -1,7 +1,7 @@
package net.Indyuce.mmoitems.api.interaction.util;
import io.lumine.mythic.lib.api.player.EquipmentSlot;
import org.bukkit.entity.Player;
import org.bukkit.inventory.EquipmentSlot;
import io.lumine.mythic.lib.api.item.NBTItem;

View File

@ -51,6 +51,7 @@ public class Weapon extends UseItem {
* @param attackSpeed The weapon attack speed
* @param cooldown The weapon cooldown type. When set to null, no
* cooldown will be applied. This is made to handle
* custom weapons
* @return If requirements were met ie the attack was cast successfully
*/
public boolean applyWeaponCosts(double attackSpeed, @Nullable CooldownType cooldown) {

View File

@ -1,7 +1,8 @@
package net.Indyuce.mmoitems.api.interaction.weapon.untargeted;
import io.lumine.mythic.lib.api.item.NBTItem;
import io.lumine.mythic.lib.api.stat.StatMap;
import io.lumine.mythic.lib.api.player.EquipmentSlot;
import io.lumine.mythic.lib.player.PlayerMetadata;
import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.interaction.util.UntargetedDurabilityItem;
@ -11,7 +12,6 @@ import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Player;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
public class Crossbow extends UntargetedWeapon {
@ -26,7 +26,7 @@ public class Crossbow extends UntargetedWeapon {
if (getPlayer().getGameMode() != GameMode.CREATIVE && !getPlayer().getInventory().containsAtLeast(new ItemStack(Material.ARROW), 1))
return;
StatMap.CachedStatMap stats = getPlayerData().getStats().newTemporary(io.lumine.mythic.lib.api.player.EquipmentSlot.fromBukkit(slot));
PlayerMetadata stats = getPlayerData().getStats().newTemporary(slot);
if (!applyWeaponCosts(1 / getValue(stats.getStat("ATTACK_SPEED"), MMOItems.plugin.getConfig().getDouble("default.attack-speed")),
CooldownType.ATTACK))
return;

View File

@ -3,15 +3,15 @@ package net.Indyuce.mmoitems.api.interaction.weapon.untargeted;
import com.google.gson.JsonObject;
import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.api.item.NBTItem;
import io.lumine.mythic.lib.api.stat.StatMap;
import io.lumine.mythic.lib.api.player.EquipmentSlot;
import io.lumine.mythic.lib.comp.target.InteractionType;
import io.lumine.mythic.lib.damage.DamageMetadata;
import io.lumine.mythic.lib.damage.DamageType;
import io.lumine.mythic.lib.player.PlayerMetadata;
import io.lumine.mythic.lib.version.VersionSound;
import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import io.lumine.mythic.lib.damage.AttackMetadata;
import net.Indyuce.mmoitems.api.ItemAttackMetadata;
import net.Indyuce.mmoitems.api.interaction.util.UntargetedDurabilityItem;
import net.Indyuce.mmoitems.api.player.PlayerData.CooldownType;
@ -23,7 +23,6 @@ import org.bukkit.Particle;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
@ -36,8 +35,7 @@ public class Lute extends UntargetedWeapon {
@Override
public void untargetedAttack(EquipmentSlot slot) {
StatMap.CachedStatMap stats = getPlayerData().getStats().newTemporary(io.lumine.mythic.lib.api.player.EquipmentSlot.fromBukkit(slot));
PlayerMetadata stats = getPlayerData().getStats().newTemporary(slot);
double attackSpeed = 1 / getValue(stats.getStat("ATTACK_SPEED"), MMOItems.plugin.getConfig().getDouble("default.attack-speed"));
if (!applyWeaponCosts(attackSpeed, CooldownType.ATTACK))
return;

View File

@ -3,14 +3,14 @@ package net.Indyuce.mmoitems.api.interaction.weapon.untargeted;
import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.api.MMORayTraceResult;
import io.lumine.mythic.lib.api.item.NBTItem;
import io.lumine.mythic.lib.api.stat.StatMap;
import io.lumine.mythic.lib.api.player.EquipmentSlot;
import io.lumine.mythic.lib.comp.target.InteractionType;
import io.lumine.mythic.lib.damage.DamageMetadata;
import io.lumine.mythic.lib.damage.DamageType;
import io.lumine.mythic.lib.player.PlayerMetadata;
import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import io.lumine.mythic.lib.damage.AttackMetadata;
import net.Indyuce.mmoitems.api.ItemAttackMetadata;
import net.Indyuce.mmoitems.api.interaction.util.UntargetedDurabilityItem;
import net.Indyuce.mmoitems.api.player.PlayerData.CooldownType;
@ -18,7 +18,6 @@ import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.util.Vector;
public class Musket extends UntargetedWeapon {
@ -28,7 +27,7 @@ public class Musket extends UntargetedWeapon {
@Override
public void untargetedAttack(EquipmentSlot slot) {
StatMap.CachedStatMap stats = getPlayerData().getStats().newTemporary(io.lumine.mythic.lib.api.player.EquipmentSlot.fromBukkit(slot));
PlayerMetadata stats = getPlayerData().getStats().newTemporary(slot);
if (!applyWeaponCosts(1 / getValue(stats.getStat("ATTACK_SPEED"), MMOItems.plugin.getConfig().getDouble("default.attack-speed")),
CooldownType.ATTACK))

View File

@ -3,15 +3,15 @@ package net.Indyuce.mmoitems.api.interaction.weapon.untargeted;
import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.api.MMORayTraceResult;
import io.lumine.mythic.lib.api.item.NBTItem;
import io.lumine.mythic.lib.api.stat.StatMap;
import io.lumine.mythic.lib.api.player.EquipmentSlot;
import io.lumine.mythic.lib.comp.target.InteractionType;
import io.lumine.mythic.lib.damage.DamageMetadata;
import io.lumine.mythic.lib.damage.DamageType;
import io.lumine.mythic.lib.player.PlayerMetadata;
import io.lumine.mythic.lib.version.VersionSound;
import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import io.lumine.mythic.lib.damage.AttackMetadata;
import net.Indyuce.mmoitems.api.ItemAttackMetadata;
import net.Indyuce.mmoitems.api.interaction.util.UntargetedDurabilityItem;
import net.Indyuce.mmoitems.api.player.PlayerData.CooldownType;
@ -22,7 +22,6 @@ import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.util.Vector;
public class Staff extends UntargetedWeapon {
@ -33,7 +32,7 @@ public class Staff extends UntargetedWeapon {
@Override
public void untargetedAttack(EquipmentSlot slot) {
StatMap.CachedStatMap stats = getPlayerData().getStats().newTemporary(io.lumine.mythic.lib.api.player.EquipmentSlot.fromBukkit(slot));
PlayerMetadata stats = getPlayerData().getStats().newTemporary(slot);
if (!applyWeaponCosts(1 / getValue(stats.getStat("ATTACK_SPEED"), MMOItems.plugin.getConfig().getDouble("default.attack-speed")),
CooldownType.ATTACK))
return;

View File

@ -1,8 +1,8 @@
package net.Indyuce.mmoitems.api.interaction.weapon.untargeted;
import io.lumine.mythic.lib.api.player.EquipmentSlot;
import org.bukkit.entity.Player;
import org.bukkit.event.block.Action;
import org.bukkit.inventory.EquipmentSlot;
import net.Indyuce.mmoitems.api.interaction.weapon.Weapon;
import io.lumine.mythic.lib.api.item.NBTItem;

View File

@ -3,22 +3,21 @@ package net.Indyuce.mmoitems.api.interaction.weapon.untargeted;
import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.api.MMORayTraceResult;
import io.lumine.mythic.lib.api.item.NBTItem;
import io.lumine.mythic.lib.api.stat.StatMap;
import io.lumine.mythic.lib.api.player.EquipmentSlot;
import io.lumine.mythic.lib.comp.target.InteractionType;
import io.lumine.mythic.lib.damage.DamageMetadata;
import io.lumine.mythic.lib.damage.DamageType;
import io.lumine.mythic.lib.player.PlayerMetadata;
import io.lumine.mythic.lib.version.VersionSound;
import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import io.lumine.mythic.lib.damage.AttackMetadata;
import net.Indyuce.mmoitems.api.ItemAttackMetadata;
import net.Indyuce.mmoitems.api.interaction.util.UntargetedDurabilityItem;
import net.Indyuce.mmoitems.api.player.PlayerData.CooldownType;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.entity.Player;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.util.Vector;
public class Whip extends UntargetedWeapon {
@ -29,7 +28,7 @@ public class Whip extends UntargetedWeapon {
@Override
public void untargetedAttack(EquipmentSlot slot) {
StatMap.CachedStatMap stats = getPlayerData().getStats().newTemporary(io.lumine.mythic.lib.api.player.EquipmentSlot.fromBukkit(slot));
PlayerMetadata stats = getPlayerData().getStats().newTemporary(slot);
if (!applyWeaponCosts(1 / getValue(stats.getStat("ATTACK_SPEED"), MMOItems.plugin.getConfig().getDouble("default.attack-speed")),
CooldownType.ATTACK))
return;

View File

@ -6,6 +6,7 @@ import io.lumine.mythic.lib.api.player.EquipmentSlot;
import io.lumine.mythic.lib.api.player.MMOPlayerData;
import io.lumine.mythic.lib.api.stat.modifier.ModifierSource;
import io.lumine.mythic.lib.damage.AttackMetadata;
import io.lumine.mythic.lib.player.PlayerMetadata;
import io.lumine.mythic.lib.skill.trigger.PassiveSkill;
import io.lumine.mythic.lib.skill.trigger.TriggerMetadata;
import net.Indyuce.mmoitems.ItemStats;
@ -34,6 +35,7 @@ import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitRunnable;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.*;
@ -360,8 +362,9 @@ public class PlayerData {
* @deprecated
*/
@Deprecated
public void cast(AttackMetadata attack, LivingEntity target, AbilityData ability) {
ability.cast(new TriggerMetadata(attack, target));
public void cast(@Nullable AttackMetadata attack, @Nullable LivingEntity target, @NotNull AbilityData ability) {
PlayerMetadata caster = getMMOPlayerData().getStatMap().cache(EquipmentSlot.MAIN_HAND);
ability.cast(new TriggerMetadata(caster, attack, target));
}
public boolean isOnCooldown(CooldownType type) {

View File

@ -6,6 +6,7 @@ import io.lumine.mythic.lib.api.stat.StatMap;
import io.lumine.mythic.lib.api.stat.modifier.ModifierSource;
import io.lumine.mythic.lib.api.stat.modifier.ModifierType;
import io.lumine.mythic.lib.api.stat.modifier.StatModifier;
import io.lumine.mythic.lib.player.PlayerMetadata;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.player.inventory.EquippedPlayerItem;
@ -44,7 +45,7 @@ public class PlayerStats {
* source will NOT be taken into account for stat calculation
* @return
*/
public StatMap.CachedStatMap newTemporary(EquipmentSlot castSlot) {
public PlayerMetadata newTemporary(EquipmentSlot castSlot) {
return playerData.getMMOPlayerData().getStatMap().cache(castSlot);
}

View File

@ -1,14 +1,13 @@
package net.Indyuce.mmoitems.command.mmoitems;
import io.lumine.mythic.lib.api.player.EquipmentSlot;
import io.lumine.mythic.lib.api.player.MMOPlayerData;
import io.lumine.mythic.lib.commands.mmolib.api.CommandTreeNode;
import io.lumine.mythic.lib.commands.mmolib.api.Parameter;
import io.lumine.mythic.lib.damage.AttackMetadata;
import io.lumine.mythic.lib.damage.DamageMetadata;
import io.lumine.mythic.lib.player.PlayerMetadata;
import io.lumine.mythic.lib.skill.trigger.TriggerMetadata;
import io.lumine.mythic.lib.skill.trigger.TriggerType;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.player.PlayerData;
import net.Indyuce.mmoitems.skill.RegisteredSkill;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import org.bukkit.Bukkit;
@ -61,7 +60,7 @@ public class AbilityCommandTreeNode extends CommandTreeNode {
}
// modifiers
AbilityData ability = new AbilityData(MMOItems.plugin.getSkills().getSkill(key), TriggerType.RIGHT_CLICK);
AbilityData ability = new AbilityData(MMOItems.plugin.getSkills().getSkill(key), TriggerType.API);
for (int j = 3; j < args.length - 1; j += 2) {
String name = args[j];
String value = args[j + 1];
@ -74,9 +73,8 @@ public class AbilityCommandTreeNode extends CommandTreeNode {
}
}
PlayerData data = PlayerData.get(target);
AttackMetadata attackMeta = new AttackMetadata(new DamageMetadata(), data.getMMOPlayerData().getStatMap().cache(EquipmentSlot.MAIN_HAND));
ability.cast(new TriggerMetadata(attackMeta, null));
PlayerMetadata caster = MMOPlayerData.get(target).getStatMap().cache(EquipmentSlot.MAIN_HAND);
ability.cast(new TriggerMetadata(caster, null, null));
return CommandResult.SUCCESS;
}
}

View File

@ -8,6 +8,7 @@ import io.lumine.mythic.lib.api.stat.StatMap;
import io.lumine.mythic.lib.damage.DamageMetadata;
import io.lumine.mythic.lib.damage.DamageType;
import io.lumine.mythic.lib.damage.AttackMetadata;
import io.lumine.mythic.lib.player.PlayerMetadata;
import net.Indyuce.mmoitems.api.ItemAttackMetadata;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.TypeSet;
@ -71,7 +72,7 @@ public class RealDualWieldHook implements Listener {
}
private ItemAttackMetadata getAttack(PlayerData playerData, PlayerDamageEntityWithOffhandEvent event) {
StatMap.CachedStatMap cachedStatMap = playerData.getMMOPlayerData().getStatMap().cache(EquipmentSlot.OFF_HAND);
PlayerMetadata cachedStatMap = playerData.getMMOPlayerData().getStatMap().cache(EquipmentSlot.OFF_HAND);
return new ItemAttackMetadata(new DamageMetadata(event.getDamage(), DamageType.WEAPON, DamageType.PHYSICAL), cachedStatMap);
}
}

View File

@ -4,16 +4,13 @@ import io.lumine.xikage.mythicmobs.MythicMobs;
import io.lumine.xikage.mythicmobs.api.bukkit.events.MythicReloadedEvent;
import io.lumine.xikage.mythicmobs.mobs.MythicMob;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.comp.mythicmobs.skill.MythicMobsAbility;
import net.Indyuce.mmoitems.comp.mythicmobs.stat.FactionDamage;
import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import java.util.*;
import java.util.logging.Level;
public class MythicMobsCompatibility implements Listener {
@ -37,7 +34,7 @@ public class MythicMobsCompatibility implements Listener {
public void a(MythicReloadedEvent event) {
// Update skills
MMOItems.plugin.getSkills().reload();
MMOItems.plugin.getSkills().initialize(true);
}
private Set<String> getFactions() {

View File

@ -1,77 +0,0 @@
package net.Indyuce.mmoitems.comp.mythicmobs.skill;
import io.lumine.mythic.lib.damage.AttackMetadata;
import io.lumine.xikage.mythicmobs.MythicMobs;
import io.lumine.xikage.mythicmobs.adapters.AbstractEntity;
import io.lumine.xikage.mythicmobs.adapters.AbstractLocation;
import io.lumine.xikage.mythicmobs.adapters.bukkit.BukkitAdapter;
import io.lumine.xikage.mythicmobs.mobs.GenericCaster;
import io.lumine.xikage.mythicmobs.skills.Skill;
import io.lumine.xikage.mythicmobs.skills.SkillCaster;
import io.lumine.xikage.mythicmobs.skills.SkillMetadata;
import io.lumine.xikage.mythicmobs.skills.SkillTrigger;
import net.Indyuce.mmoitems.ability.Ability;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import org.apache.commons.lang.Validate;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.LivingEntity;
import java.util.HashSet;
import java.util.Optional;
public class MythicMobsAbility extends Ability<MythicMobsAbilityMetadata> {
private Skill skill;
public MythicMobsAbility(String id, FileConfiguration config) {
super(id, config.getString("name"));
String skillName = config.getString("mythicmobs-skill-id");
Validate.notNull(skillName, "Could not find MM skill name");
Optional<io.lumine.xikage.mythicmobs.skills.Skill> opt = MythicMobs.inst().getSkillManager().getSkill(skillName);
Validate.isTrue(opt.isPresent(), "Could not find MM skill with name '" + skillName + "'");
skill = opt.get();
addModifier("cooldown", 10);
addModifier("mana", 0);
addModifier("stamina", 0);
for (String mod : config.getKeys(false))
if (!mod.equals("name") && !mod.equals("mythicmobs-skill-id") && !mod.equals("self-only"))
addModifier(mod.toLowerCase().replace("_", "-").replace(" ", "-"), config.getInt(mod));
}
public String getInternalName() {
return skill.getInternalName();
}
public void setSkill(Skill skill) {
this.skill = skill;
}
@Override
public void whenCast(AttackMetadata attackMeta, MythicMobsAbilityMetadata ability) {
skill.execute(ability.getSkillMetadata());
}
@Override
public MythicMobsAbilityMetadata canBeCast(AttackMetadata attackMeta, LivingEntity target, AbilityData data) {
// TODO what's the difference between trigger and caster.
AbstractEntity trigger = BukkitAdapter.adapt(attackMeta.getPlayer());
SkillCaster caster = new GenericCaster(trigger);
HashSet<AbstractEntity> targetEntities = new HashSet<>();
HashSet<AbstractLocation> targetLocations = new HashSet<>();
targetEntities.add(BukkitAdapter.adapt(target));
SkillMetadata skillMeta = new SkillMetadata(SkillTrigger.CAST, caster, trigger, BukkitAdapter.adapt(attackMeta.getPlayer().getEyeLocation()), targetEntities, targetLocations, 1);
// Stats are cached inside a variable
skillMeta.getVariables().putObject("MMOStatMap", attackMeta.getStats());
skillMeta.getVariables().putObject("MMOSkill", data);
return new MythicMobsAbilityMetadata(data, skill, skillMeta);
}
}

View File

@ -1,28 +0,0 @@
package net.Indyuce.mmoitems.comp.mythicmobs.skill;
import io.lumine.xikage.mythicmobs.skills.Skill;
import io.lumine.xikage.mythicmobs.skills.SkillMetadata;
import io.lumine.xikage.mythicmobs.skills.SkillTrigger;
import net.Indyuce.mmoitems.ability.AbilityMetadata;
import net.Indyuce.mmoitems.stat.data.AbilityData;
public class MythicMobsAbilityMetadata extends AbilityMetadata {
private final Skill skill;
private final SkillMetadata skillMeta;
public MythicMobsAbilityMetadata(AbilityData ability, Skill skill, SkillMetadata skillMeta) {
super(ability);
this.skill = skill;
this.skillMeta = skillMeta;
}
public SkillMetadata getSkillMetadata() {
return skillMeta;
}
@Override
public boolean isSuccessful() {
return skill.usable(skillMeta, SkillTrigger.CAST);
}
}

View File

@ -98,7 +98,7 @@ public class ItemUse implements Listener {
UntargetedWeapon weapon = (UntargetedWeapon) useItem;
if ((event.getAction().name().contains("RIGHT_CLICK") && weapon.getWeaponType() == WeaponType.RIGHT_CLICK)
|| (event.getAction().name().contains("LEFT_CLICK") && weapon.getWeaponType() == WeaponType.LEFT_CLICK))
weapon.untargetedAttack(event.getHand());
weapon.untargetedAttack(EquipmentSlot.fromBukkit(event.getHand()));
}
}

View File

@ -50,7 +50,6 @@ public class AbilityManager {
* @param ability Ability to register
*/
public void registerAbility(Ability ability) {
MythicLib.plugin.getSkills().registerSkillHandler(ability);
MMOItems.plugin.getSkills().registerSkill(new RegisteredSkill(ability));
}
}

View File

@ -1,11 +1,10 @@
package net.Indyuce.mmoitems.manager;
import io.lumine.mythic.lib.api.item.NBTItem;
import io.lumine.mythic.lib.api.stat.StatMap;
import io.lumine.mythic.lib.damage.DamageMetadata;
import io.lumine.mythic.lib.damage.DamageType;
import io.lumine.mythic.lib.player.PlayerMetadata;
import net.Indyuce.mmoitems.MMOItems;
import io.lumine.mythic.lib.damage.AttackMetadata;
import net.Indyuce.mmoitems.api.ItemAttackMetadata;
import net.Indyuce.mmoitems.api.interaction.projectile.ArrowParticles;
import net.Indyuce.mmoitems.api.interaction.projectile.EntityData;
@ -37,8 +36,8 @@ public class EntityManager implements Listener {
private final WeakHashMap<Integer, ProjectileData> projectiles = new WeakHashMap<>();
public void registerCustomProjectile(NBTItem sourceItem, StatMap.CachedStatMap stats, Entity entity, boolean customWeapon) {
registerCustomProjectile(sourceItem, stats, entity, customWeapon, 1);
public void registerCustomProjectile(NBTItem sourceItem, PlayerMetadata attacker, Entity entity, boolean customWeapon) {
registerCustomProjectile(sourceItem, attacker, entity, customWeapon, 1);
}
/**
@ -47,13 +46,13 @@ public class EntityManager implements Listener {
* Default bow/trident damage is set to 7 just like vanilla Minecraft.
*
* @param sourceItem Item used to shoot the projectile
* @param stats Cached stats of the player shooting the projectile
* @param attacker Cached stats of the player shooting the projectile
* @param entity The custom entity
* @param customWeapon Is the source weapon is a custom item
* @param damageMultiplicator The damage coefficient. For bows, this is basically the pull force.
* For tridents or anything else this is always set to 1
*/
public void registerCustomProjectile(NBTItem sourceItem, StatMap.CachedStatMap stats, Entity entity, boolean customWeapon, double damageMultiplicator) {
public void registerCustomProjectile(NBTItem sourceItem, PlayerMetadata attacker, Entity entity, boolean customWeapon, double damageMultiplicator) {
/*
* For bows, MC default value is 7. When using custom bows, the attack
@ -64,11 +63,11 @@ public class EntityManager implements Listener {
* Damage coefficient is how much you pull the bow. It's something between 0
* and 1 for bows, and it's always 1 for tridents or crossbows.
*/
double damage = stats.getStat("ATTACK_DAMAGE");
double damage = attacker.getStat("ATTACK_DAMAGE");
damage = (customWeapon ? damage : 5 + damage) * damageMultiplicator;
ItemAttackMetadata attackMeta = new ItemAttackMetadata(new DamageMetadata(damage, DamageType.WEAPON, DamageType.PHYSICAL, DamageType.PROJECTILE), stats);
stats.setStat("ATTACK_DAMAGE", damage);
ItemAttackMetadata attackMeta = new ItemAttackMetadata(new DamageMetadata(damage, DamageType.WEAPON, DamageType.PHYSICAL, DamageType.PROJECTILE), attacker);
attacker.setStat("ATTACK_DAMAGE", damage);
/*
* Load arrow particles if the entity is an arrow and if the item has

View File

@ -48,7 +48,10 @@ public class SkillManager {
return skills.values();
}
public void reload() {
public void initialize(boolean clearBefore) {
if (clearBefore)
skills.clear();
// Check for default files
File skillFolder = new File(MMOItems.plugin.getDataFolder() + "/skill");

View File

@ -62,7 +62,7 @@ public class Shulker_Missile extends SkillHandler<VectorSkillResult> implements
EntityType.SHULKER_BULLET);
shulkerBullet.setShooter(caster);
ItemAttackMetadata attackMeta = new ItemAttackMetadata(new DamageMetadata(skillMeta.getModifier("damage"), DamageType.SKILL, DamageType.MAGIC, DamageType.PROJECTILE), skillMeta.getStats());
ItemAttackMetadata attackMeta = new ItemAttackMetadata(new DamageMetadata(skillMeta.getModifier("damage"), DamageType.SKILL, DamageType.MAGIC, DamageType.PROJECTILE), skillMeta.getCaster());
MMOItems.plugin.getEntities().registerCustomEntity(shulkerBullet, new ShulkerMissileEntityData(attackMeta, skillMeta.getModifier("effect-duration")));
new BukkitRunnable() {

View File

@ -83,12 +83,12 @@ public class AbilityData extends Skill {
@Override
public boolean getResult(SkillMetadata meta) {
PlayerData playerData = PlayerData.get(meta.getCaster().getUniqueId());
PlayerData playerData = PlayerData.get(meta.getCaster().getData().getUniqueId());
RPGPlayer rpgPlayer = playerData.getRPG();
Player player = meta.getCaster().getPlayer();
// Check for cooldown
if (meta.getCaster().getCooldownMap().isOnCooldown(this)) {
if (meta.getCaster().getData().getCooldownMap().isOnCooldown(this)) {
CooldownInfo info = playerData.getMMOPlayerData().getCooldownMap().getInfo(this);
if (!triggerType.isSilent()) {
StringBuilder progressBar = new StringBuilder(ChatColor.YELLOW + "");
@ -125,7 +125,7 @@ public class AbilityData extends Skill {
@Override
public void whenCast(SkillMetadata meta) {
PlayerData playerData = PlayerData.get(meta.getCaster().getUniqueId());
PlayerData playerData = PlayerData.get(meta.getCaster().getData().getUniqueId());
RPGPlayer rpgPlayer = playerData.getRPG();
// Apply mana cost
@ -137,9 +137,9 @@ public class AbilityData extends Skill {
rpgPlayer.giveStamina(-meta.getModifier("stamina"));
// Apply cooldown
double cooldown = meta.getModifier("cooldown") * (1 - Math.min(.8, meta.getStats().getStat("COOLDOWN_REDUCTION") / 100));
double cooldown = meta.getModifier("cooldown") * (1 - Math.min(.8, meta.getCaster().getStat("COOLDOWN_REDUCTION") / 100));
if (cooldown > 0)
meta.getCaster().getCooldownMap().applyCooldown(this, cooldown);
meta.getCaster().getData().getCooldownMap().applyCooldown(this, cooldown);
}
@Override