ability update

- new casting modes
- casting modes are now 'triggers' and are shared with mmocore
This commit is contained in:
Indyuce 2021-10-31 12:08:41 +01:00
parent 09cbc38dfe
commit 8ff4ec50dc
129 changed files with 706 additions and 938 deletions

View File

@ -1,8 +1,7 @@
package net.Indyuce.mmoitems.ability;
import io.lumine.mythic.lib.player.CooldownObject;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.ItemAttackMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import io.lumine.mythic.lib.player.cooldown.CooldownObject;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import org.apache.commons.lang.Validate;
import org.bukkit.entity.LivingEntity;
@ -12,24 +11,21 @@ import java.util.*;
public abstract class Ability<T extends AbilityMetadata> implements CooldownObject {
private final String name, id;
private final List<CastingMode> allowedModes;
private final Map<String, Double> modifiers = new HashMap<>();
protected static final Random random = new Random();
public Ability(CastingMode... allowedModes) {
public Ability() {
this.id = getClass().getSimpleName().toUpperCase().replace("-", "_").replace(" ", "_").replaceAll("[^A-Z_]", "");
this.name = getClass().getSimpleName().replace("_", " ");
this.allowedModes = Arrays.asList(allowedModes);
}
public Ability(String id, String name, CastingMode... allowedModes) {
public Ability(String id, String name) {
Validate.notNull(id, "Id cannot be null");
Validate.notNull(name, "Name cannot be null");
this.id = id.toUpperCase().replace("-", "_").replace(" ", "_").replaceAll("[^A-Z_]", "");
this.name = name;
this.allowedModes = Arrays.asList(allowedModes);
}
public String getID() {
@ -44,18 +40,6 @@ public abstract class Ability<T extends AbilityMetadata> implements CooldownObje
return name;
}
public boolean isAllowedMode(CastingMode castingMode) {
return allowedModes.contains(castingMode);
}
/**
* @return The list of all the casting modes which are compatible with this
* ability
*/
public List<CastingMode> getSupportedCastingModes() {
return allowedModes;
}
public double getDefaultValue(String path) {
return modifiers.get(path);
}
@ -68,17 +52,6 @@ public abstract class Ability<T extends AbilityMetadata> implements CooldownObje
modifiers.put(modifier, defaultValue);
}
/**
* Disables an ability. This method must be called before MMOItems registers
* this ability since it is just a boolean check when registering abilities
* through the abilityManager
*
* @deprecated Useless
*/
@Deprecated
public void disable() {
}
@Override
public String getCooldownPath() {
return "mmoitems_skill_" + id.toLowerCase();
@ -97,7 +70,7 @@ public abstract class Ability<T extends AbilityMetadata> implements CooldownObje
* This can also return a null instance which means the ability was not cast.
*/
@Nullable
public abstract T canBeCast(ItemAttackMetadata attack, LivingEntity target, AbilityData ability);
public abstract T canBeCast(AttackMetadata attack, LivingEntity target, AbilityData ability);
/**
* Called when a player successfully casts an ability
@ -107,74 +80,7 @@ public abstract class Ability<T extends AbilityMetadata> implements CooldownObje
* @param ability All the information about the ability being cast. This is the
* same instance as the one returned in whenRan(..)
*/
public abstract void whenCast(ItemAttackMetadata attack, T ability);
public enum CastingMode {
/**
* When the player hits another entity
*/
ON_HIT(false),
/**
* When the player is hit by another entity
*/
WHEN_HIT(false),
/**
* When the player performs a left click
*/
LEFT_CLICK,
/**
* When the player performs a right click
*/
RIGHT_CLICK,
/**
* Performing a left click while sneaking
*/
SHIFT_LEFT_CLICK,
/**
* Performing a right click while sneaking
*/
SHIFT_RIGHT_CLICK,
/**
* When player Sneaks
*/
SNEAK;
private final boolean message;
CastingMode() {
this(true);
}
CastingMode(boolean message) {
this.message = message;
}
public boolean displaysMessage() {
return message;
}
public String getName() {
return MMOUtils.caseOnWords(name().toLowerCase().replace("_", " "));
}
public String getLowerCaseId() {
return name().toLowerCase().replace("_", "-");
}
public static CastingMode safeValueOf(String format) {
for (CastingMode mode : values())
if (mode.name().equals(format))
return mode;
return null;
}
}
public abstract void whenCast(AttackMetadata attack, T ability);
@Override
public boolean equals(Object obj) {

View File

@ -1,22 +1,23 @@
package net.Indyuce.mmoitems.ability;
import io.lumine.mythic.lib.damage.AttackMetadata;
import net.Indyuce.mmoitems.ability.metadata.FriendlyTargetAbilityMetadata;
import net.Indyuce.mmoitems.api.ItemAttackMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import org.bukkit.entity.LivingEntity;
public abstract class FriendlyTargetAbility extends Ability<FriendlyTargetAbilityMetadata> {
public FriendlyTargetAbility(CastingMode... allowedModes) {
super(allowedModes);
public FriendlyTargetAbility() {
super();
}
public FriendlyTargetAbility(String id, String name, CastingMode... allowedModes) {
super(id, name, allowedModes);
public FriendlyTargetAbility(String id, String name) {
super(id, name);
}
public FriendlyTargetAbilityMetadata canBeCast(ItemAttackMetadata attack, LivingEntity target, AbilityData ability) {
return new FriendlyTargetAbilityMetadata(ability, attack.getDamager(), target);
public FriendlyTargetAbilityMetadata canBeCast(AttackMetadata attack, LivingEntity target, AbilityData ability) {
return new FriendlyTargetAbilityMetadata(ability, attack.getPlayer(), target);
}
public abstract void whenCast(ItemAttackMetadata attack, FriendlyTargetAbilityMetadata ability);
public abstract void whenCast(AttackMetadata attack, FriendlyTargetAbilityMetadata ability);
}

View File

@ -1,22 +1,20 @@
package net.Indyuce.mmoitems.ability;
import io.lumine.mythic.lib.damage.AttackMetadata;
import net.Indyuce.mmoitems.ability.metadata.ItemAbilityMetadata;
import net.Indyuce.mmoitems.api.ItemAttackMetadata;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import org.bukkit.entity.LivingEntity;
public abstract class ItemAbility extends Ability<ItemAbilityMetadata> {
public ItemAbility(CastingMode... allowedModes) {
super(allowedModes);
public ItemAbility() {
super();
}
public ItemAbility(String id, String name, CastingMode... allowedModes) {
super(id, name, allowedModes);
public ItemAbility(String id, String name) {
super(id, name);
}
public ItemAbilityMetadata canBeCast(ItemAttackMetadata attack, LivingEntity target, AbilityData ability) {
return new ItemAbilityMetadata(ability, attack.getDamager(), target);
public ItemAbilityMetadata canBeCast(AttackMetadata attack, LivingEntity target, AbilityData ability) {
return new ItemAbilityMetadata(ability, attack.getPlayer(), target);
}
public abstract void whenCast(ItemAttackMetadata attack, ItemAbilityMetadata ability);
}

View File

@ -1,22 +1,20 @@
package net.Indyuce.mmoitems.ability;
import io.lumine.mythic.lib.damage.AttackMetadata;
import net.Indyuce.mmoitems.ability.metadata.LocationAbilityMetadata;
import net.Indyuce.mmoitems.api.ItemAttackMetadata;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import org.bukkit.entity.LivingEntity;
public abstract class LocationAbility extends Ability<LocationAbilityMetadata> {
public LocationAbility(CastingMode... allowedModes) {
super(allowedModes);
public LocationAbility() {
super();
}
public LocationAbility(String id, String name, CastingMode... allowedModes) {
super(id, name, allowedModes);
public LocationAbility(String id, String name) {
super(id, name);
}
public LocationAbilityMetadata canBeCast(ItemAttackMetadata attack, LivingEntity target, AbilityData ability) {
return new LocationAbilityMetadata(ability, attack.getDamager(), target);
public LocationAbilityMetadata canBeCast(AttackMetadata attack, LivingEntity target, AbilityData ability) {
return new LocationAbilityMetadata(ability, attack.getPlayer(), target);
}
public abstract void whenCast(ItemAttackMetadata attack, LocationAbilityMetadata ability);
}

View File

@ -1,24 +1,21 @@
package net.Indyuce.mmoitems.ability;
import io.lumine.mythic.lib.damage.AttackMetadata;
import net.Indyuce.mmoitems.ability.metadata.SimpleAbilityMetadata;
import net.Indyuce.mmoitems.api.ItemAttackMetadata;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import org.bukkit.entity.LivingEntity;
public abstract class SimpleAbility extends Ability<SimpleAbilityMetadata> {
public SimpleAbility(CastingMode... allowedModes) {
super(allowedModes);
public SimpleAbility() {
super();
}
public SimpleAbility(String id, String name, CastingMode... allowedModes) {
super(id, name, allowedModes);
public SimpleAbility(String id, String name) {
super(id, name);
}
@Override
public SimpleAbilityMetadata canBeCast(ItemAttackMetadata attack, LivingEntity target, AbilityData ability) {
public SimpleAbilityMetadata canBeCast(AttackMetadata attack, LivingEntity target, AbilityData ability) {
return new SimpleAbilityMetadata(ability);
}
@Override
public abstract void whenCast(ItemAttackMetadata attack, SimpleAbilityMetadata ability);
}

View File

@ -1,22 +1,20 @@
package net.Indyuce.mmoitems.ability;
import net.Indyuce.mmoitems.ability.metadata.TargetAbilityMetadata;
import net.Indyuce.mmoitems.api.ItemAttackMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import org.bukkit.entity.LivingEntity;
public abstract class TargetAbility extends Ability<TargetAbilityMetadata> {
public TargetAbility(CastingMode... allowedModes) {
super(allowedModes);
public TargetAbility() {
super();
}
public TargetAbility(String id, String name, CastingMode... allowedModes) {
super(id, name, allowedModes);
public TargetAbility(String id, String name) {
super(id, name);
}
public TargetAbilityMetadata canBeCast(ItemAttackMetadata attack, LivingEntity target, AbilityData ability) {
return new TargetAbilityMetadata(ability, attack.getDamager(), target);
public TargetAbilityMetadata canBeCast(AttackMetadata attack, LivingEntity target, AbilityData ability) {
return new TargetAbilityMetadata(ability, attack.getPlayer(), target);
}
public abstract void whenCast(ItemAttackMetadata attack, TargetAbilityMetadata ability);
}

View File

@ -1,8 +1,8 @@
package net.Indyuce.mmoitems.ability;
import io.lumine.mythic.lib.damage.AttackMetadata;
import net.Indyuce.mmoitems.ability.list.vector.Firebolt;
import net.Indyuce.mmoitems.ability.metadata.VectorAbilityMetadata;
import net.Indyuce.mmoitems.api.ItemAttackMetadata;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import org.bukkit.entity.LivingEntity;
@ -11,17 +11,15 @@ import org.bukkit.entity.LivingEntity;
* instance, a projectile like {@link Firebolt}
*/
public abstract class VectorAbility extends Ability<VectorAbilityMetadata> {
public VectorAbility(CastingMode... allowedModes) {
super(allowedModes);
public VectorAbility() {
super();
}
public VectorAbility(String id, String name, CastingMode... allowedModes) {
super(id, name, allowedModes);
public VectorAbility(String id, String name) {
super(id, name);
}
public VectorAbilityMetadata canBeCast(ItemAttackMetadata attack, LivingEntity target, AbilityData ability) {
return new VectorAbilityMetadata(ability, attack.getDamager(), target);
public VectorAbilityMetadata canBeCast(AttackMetadata attack, LivingEntity target, AbilityData ability) {
return new VectorAbilityMetadata(ability, attack.getPlayer(), target);
}
public abstract void whenCast(ItemAttackMetadata attack, VectorAbilityMetadata ability);
}

View File

@ -8,7 +8,6 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.LocationAbility;
import net.Indyuce.mmoitems.ability.metadata.LocationAbilityMetadata;
import net.Indyuce.mmoitems.api.ItemAttackMetadata;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.entity.Entity;
@ -18,7 +17,7 @@ import org.bukkit.util.Vector;
public class Arcane_Hail extends LocationAbility {
public Arcane_Hail() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK, CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("damage", 3);
addModifier("duration", 4);
@ -29,7 +28,7 @@ public class Arcane_Hail extends LocationAbility {
}
@Override
public void whenCast(ItemAttackMetadata attack, LocationAbilityMetadata ability) {
public void whenCast(AttackMetadata attack, LocationAbilityMetadata ability) {
Location loc = ability.getTarget();
double damage = ability.getModifier("damage");
@ -49,7 +48,7 @@ public class Arcane_Hail extends LocationAbility {
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.getDamager(), entity) && entity.getLocation().distanceSquared(loc1) <= 4)
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);

View File

@ -1,11 +1,11 @@
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 net.Indyuce.mmoitems.api.ItemAttackMetadata;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.entity.Entity;
@ -14,7 +14,7 @@ import org.bukkit.util.Vector;
public class Black_Hole extends LocationAbility {
public Black_Hole() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK, CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("radius", 2);
addModifier("duration", 2);
@ -24,7 +24,7 @@ public class Black_Hole extends LocationAbility {
}
@Override
public void whenCast(ItemAttackMetadata attack, LocationAbilityMetadata ability) {
public void whenCast(AttackMetadata attack, LocationAbilityMetadata ability) {
Location loc = ability.getTarget();
double duration = ability.getModifier("duration") * 20;
@ -52,7 +52,7 @@ public class Black_Hole extends LocationAbility {
}
for (Entity entity : MMOUtils.getNearbyChunkEntities(loc))
if (entity.getLocation().distanceSquared(loc) < Math.pow(radius, 2) && MMOUtils.canTarget(attack.getDamager(), entity))
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

@ -8,7 +8,6 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.LocationAbility;
import net.Indyuce.mmoitems.ability.metadata.LocationAbilityMetadata;
import net.Indyuce.mmoitems.api.ItemAttackMetadata;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Particle;
@ -18,8 +17,7 @@ import org.bukkit.scheduler.BukkitRunnable;
public class Contamination extends LocationAbility {
public Contamination() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK,
CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("damage", 2);
addModifier("duration", 8);
@ -29,7 +27,7 @@ public class Contamination extends LocationAbility {
}
@Override
public void whenCast(ItemAttackMetadata attack, LocationAbilityMetadata ability) {
public void whenCast(AttackMetadata attack, LocationAbilityMetadata ability) {
Location loc = ability.getTarget();
double duration = Math.min(30, ability.getModifier("duration")) * 20;
@ -57,7 +55,7 @@ public class Contamination extends LocationAbility {
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.getDamager(), entity) && entity.getLocation().distanceSquared(loc) <= 25)
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);
}
}

View File

@ -1,9 +1,9 @@
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 net.Indyuce.mmoitems.api.ItemAttackMetadata;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.Sound;
@ -14,7 +14,7 @@ import org.bukkit.potion.PotionEffectType;
public class Corrosion extends LocationAbility {
public Corrosion() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT);
super();
addModifier("duration", 4);
addModifier("amplifier", 1);
@ -25,7 +25,7 @@ public class Corrosion extends LocationAbility {
}
@Override
public void whenCast(ItemAttackMetadata attack, LocationAbilityMetadata ability) {
public void whenCast(AttackMetadata attack, LocationAbilityMetadata ability) {
Location loc = ability.getTarget();
int duration = (int) (ability.getModifier("duration") * 20);
@ -37,7 +37,7 @@ public class Corrosion extends LocationAbility {
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.getDamager(), entity)) {
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

@ -7,7 +7,6 @@ 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 net.Indyuce.mmoitems.api.ItemAttackMetadata;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Particle;
@ -18,8 +17,7 @@ import org.bukkit.potion.PotionEffectType;
public class Corrupt extends LocationAbility {
public Corrupt() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK,
CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("damage", 8);
addModifier("duration", 4);
@ -30,7 +28,7 @@ public class Corrupt extends LocationAbility {
}
@Override
public void whenCast(ItemAttackMetadata attack, LocationAbilityMetadata ability) {
public void whenCast(AttackMetadata attack, LocationAbilityMetadata ability) {
Location loc = ability.getTarget();
double damage = ability.getModifier("damage");
@ -39,7 +37,7 @@ public class Corrupt extends LocationAbility {
double radius = 2.7;
loc.add(0, -1, 0);
attack.getDamager().getWorld().playSound(attack.getDamager().getLocation(), VersionSound.ENTITY_ENDERMAN_HURT.toSound(), 1, .5f);
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();
@ -48,7 +46,7 @@ public class Corrupt extends LocationAbility {
}
for (Entity entity : MMOUtils.getNearbyChunkEntities(loc))
if (MMOUtils.canTarget(attack.getDamager(), entity) && entity.getLocation().distanceSquared(loc) <= radius * radius) {
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

@ -4,7 +4,7 @@ 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 net.Indyuce.mmoitems.api.ItemAttackMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import org.bukkit.Location;
import org.bukkit.Particle;
@ -15,7 +15,7 @@ import org.bukkit.potion.PotionEffectType;
public class Freeze extends LocationAbility {
public Freeze() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT);
super();
addModifier("duration", 4);
addModifier("amplifier", 2);
@ -26,12 +26,12 @@ public class Freeze extends LocationAbility {
}
@Override
public LocationAbilityMetadata canBeCast(ItemAttackMetadata attack, LivingEntity target, AbilityData ability) {
return new LocationAbilityMetadata(ability, attack.getDamager(), target);
public LocationAbilityMetadata canBeCast(AttackMetadata attack, LivingEntity target, AbilityData ability) {
return new LocationAbilityMetadata(ability, attack.getPlayer(), target);
}
@Override
public void whenCast(ItemAttackMetadata attack, LocationAbilityMetadata ability) {
public void whenCast(AttackMetadata attack, LocationAbilityMetadata ability) {
Location loc = ability.getTarget();
int duration = (int) (ability.getModifier("duration") * 20);
@ -44,7 +44,7 @@ public class Freeze extends LocationAbility {
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.getDamager(), entity)) {
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

@ -8,7 +8,7 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.LocationAbility;
import net.Indyuce.mmoitems.ability.metadata.LocationAbilityMetadata;
import net.Indyuce.mmoitems.api.ItemAttackMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.Sound;
@ -20,7 +20,7 @@ import org.bukkit.scheduler.BukkitRunnable;
public class Freezing_Curse extends LocationAbility {
public Freezing_Curse() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK, CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("cooldown", 7);
addModifier("duration", 3);
@ -32,11 +32,11 @@ public class Freezing_Curse extends LocationAbility {
}
@Override
public void whenCast(ItemAttackMetadata attack, LocationAbilityMetadata ability) {
public void whenCast(AttackMetadata attack, LocationAbilityMetadata ability) {
Location loc = ability.getTarget();
new BukkitRunnable() {
final double rads = Math.toRadians(attack.getDamager().getEyeLocation().getYaw() - 90);
final double rads = Math.toRadians(attack.getPlayer().getEyeLocation().getYaw() - 90);
double ti = rads;
int j = 0;
@ -60,7 +60,7 @@ public class Freezing_Curse extends LocationAbility {
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.getDamager(), entity)) {
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));

View File

@ -4,14 +4,14 @@ 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 net.Indyuce.mmoitems.api.ItemAttackMetadata;
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(CastingMode.ON_HIT, CastingMode.WHEN_HIT);
super();
addModifier("duration", 80);
addModifier("max-ignite", 200);
@ -22,7 +22,7 @@ public class Ignite extends LocationAbility {
}
@Override
public void whenCast(ItemAttackMetadata attack, LocationAbilityMetadata ability) {
public void whenCast(AttackMetadata attack, LocationAbilityMetadata ability) {
Location loc = ability.getTarget();
int maxIgnite = (int) (ability.getModifier("max-ignite") * 20);
@ -35,7 +35,7 @@ public class Ignite extends LocationAbility {
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.getDamager(), entity))
if (entity.getLocation().distanceSquared(loc) < radiusSquared && MMOUtils.canTarget(attack.getPlayer(), entity))
entity.setFireTicks(Math.min(entity.getFireTicks() + ignite, maxIgnite));
}
}

View File

@ -8,7 +8,7 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.LocationAbility;
import net.Indyuce.mmoitems.ability.metadata.LocationAbilityMetadata;
import net.Indyuce.mmoitems.api.ItemAttackMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.Sound;
@ -19,7 +19,7 @@ import org.bukkit.util.Vector;
public class Life_Ender extends LocationAbility {
public Life_Ender() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK, CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("damage", 5);
addModifier("knockback", 1);
@ -30,13 +30,13 @@ public class Life_Ender extends LocationAbility {
}
@Override
public void whenCast(ItemAttackMetadata attack, LocationAbilityMetadata ability) {
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.getDamager().getWorld().playSound(attack.getDamager().getLocation(), VersionSound.ENTITY_ENDERMAN_TELEPORT.toSound(), 2, 1);
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);
@ -63,7 +63,7 @@ public class Life_Ender extends LocationAbility {
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.getDamager(), entity)) {
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));
}

View File

@ -7,7 +7,7 @@ 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 net.Indyuce.mmoitems.api.ItemAttackMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.entity.Entity;
@ -16,7 +16,7 @@ import org.bukkit.util.Vector;
public class Lightning_Beam extends LocationAbility {
public Lightning_Beam() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK, CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("damage", 8);
addModifier("radius", 5);
@ -26,16 +26,16 @@ public class Lightning_Beam extends LocationAbility {
}
@Override
public void whenCast(ItemAttackMetadata attack, LocationAbilityMetadata ability) {
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.getDamager(), entity) && entity.getLocation().distanceSquared(loc) <= radius * radius)
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.getDamager().getWorld().playSound(attack.getDamager().getLocation(), VersionSound.ENTITY_FIREWORK_ROCKET_BLAST.toSound(), 1, 0);
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);

View File

@ -6,7 +6,7 @@ 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 net.Indyuce.mmoitems.api.ItemAttackMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.Sound;
@ -15,7 +15,7 @@ import org.bukkit.entity.LivingEntity;
public class Minor_Explosion extends LocationAbility {
public Minor_Explosion() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT);
super();
addModifier("damage", 6);
addModifier("knockback", 1);
@ -26,7 +26,7 @@ public class Minor_Explosion extends LocationAbility {
}
@Override
public void whenCast(ItemAttackMetadata attack, LocationAbilityMetadata ability) {
public void whenCast(AttackMetadata attack, LocationAbilityMetadata ability) {
Location loc = ability.getTarget();
double damage = ability.getModifier("damage");
@ -38,7 +38,7 @@ public class Minor_Explosion extends LocationAbility {
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.getDamager(), entity)) {
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,12 +1,12 @@
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 net.Indyuce.mmoitems.api.ItemAttackMetadata;
import net.Indyuce.mmoitems.api.util.TemporaryListener;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.Sound;
@ -27,8 +27,7 @@ import java.util.UUID;
public class Snowman_Turret extends LocationAbility {
public Snowman_Turret() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK,
CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("duration", 6);
addModifier("cooldown", 35);
@ -39,7 +38,7 @@ public class Snowman_Turret extends LocationAbility {
}
@Override
public void whenCast(ItemAttackMetadata attack, LocationAbilityMetadata ability) {
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);
@ -54,7 +53,7 @@ public class Snowman_Turret extends LocationAbility {
final TurretHandler turret = new TurretHandler(ability.getModifier("damage"));
public void run() {
if (ti++ > duration || attack.getDamager().isDead() || snowman == null || snowman.isDead()) {
if (ti++ > duration || attack.getPlayer().isDead() || snowman == null || snowman.isDead()) {
turret.close(3 * 20);
snowman.remove();
cancel();
@ -68,7 +67,7 @@ public class Snowman_Turret extends LocationAbility {
if (ti % 2 == 0)
for (Entity entity : MMOUtils.getNearbyChunkEntities(snowman.getLocation()))
if (!entity.equals(snowman) && MMOUtils.canTarget(attack.getDamager(), entity)
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);

View File

@ -8,7 +8,7 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.Ability;
import net.Indyuce.mmoitems.ability.metadata.VectorAbilityMetadata;
import net.Indyuce.mmoitems.api.ItemAttackMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import org.bukkit.Location;
import org.bukkit.Particle;
@ -24,7 +24,7 @@ import java.util.List;
public class Arcane_Rift extends Ability<VectorAbilityMetadata> {
public Arcane_Rift() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK, CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("damage", 5);
addModifier("amplifier", 2);
@ -36,20 +36,20 @@ public class Arcane_Rift extends Ability<VectorAbilityMetadata> {
}
@Override
public VectorAbilityMetadata canBeCast(ItemAttackMetadata attack, LivingEntity target, AbilityData ability) {
return attack.getDamager().isOnGround() ? new VectorAbilityMetadata(ability, attack.getDamager(), target) : null;
public VectorAbilityMetadata canBeCast(AttackMetadata attack, LivingEntity target, AbilityData ability) {
return attack.getPlayer().isOnGround() ? new VectorAbilityMetadata(ability, attack.getPlayer(), target) : null;
}
@Override
public void whenCast(ItemAttackMetadata attack, VectorAbilityMetadata ability) {
public void whenCast(AttackMetadata attack, VectorAbilityMetadata ability) {
double damage = ability.getModifier("damage");
double slowDuration = ability.getModifier("duration");
double slowAmplifier = ability.getModifier("amplifier");
attack.getDamager().getWorld().playSound(attack.getDamager().getLocation(), VersionSound.ENTITY_ENDERMAN_DEATH.toSound(), 2, .5f);
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.getDamager().getLocation();
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;
@ -62,7 +62,7 @@ public class Arcane_Rift extends Ability<VectorAbilityMetadata> {
loc.getWorld().spawnParticle(Particle.SPELL_WITCH, loc, 5, .5, 0, .5, 0);
for (Entity entity : MMOUtils.getNearbyChunkEntities(loc))
if (MMOUtils.canTarget(attack.getDamager(), entity) && loc.distanceSquared(entity.getLocation()) < 2 && !hit.contains(entity.getEntityId())) {
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));

View File

@ -7,7 +7,7 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.Ability;
import net.Indyuce.mmoitems.ability.metadata.VectorAbilityMetadata;
import net.Indyuce.mmoitems.api.ItemAttackMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import org.bukkit.Location;
import org.bukkit.Particle;
@ -24,7 +24,7 @@ import java.util.List;
public class Earthquake extends Ability<VectorAbilityMetadata> {
public Earthquake() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK, CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("damage", 3);
addModifier("duration", 2);
@ -35,19 +35,19 @@ public class Earthquake extends Ability<VectorAbilityMetadata> {
}
@Override
public VectorAbilityMetadata canBeCast(ItemAttackMetadata attack, LivingEntity target, AbilityData ability) {
return attack.getDamager().isOnGround() ? new VectorAbilityMetadata(ability, attack.getDamager(), target) : null;
public VectorAbilityMetadata canBeCast(AttackMetadata attack, LivingEntity target, AbilityData ability) {
return attack.getPlayer().isOnGround() ? new VectorAbilityMetadata(ability, attack.getPlayer(), target) : null;
}
@Override
public void whenCast(ItemAttackMetadata attack, VectorAbilityMetadata ability) {
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.getDamager().getLocation();
final Location loc = attack.getPlayer().getLocation();
final List<Integer> hit = new ArrayList<>();
int ti = 0;
@ -61,7 +61,7 @@ public class Earthquake extends Ability<VectorAbilityMetadata> {
loc.getWorld().playSound(loc, Sound.BLOCK_GRAVEL_BREAK, 2, 1);
for (Entity entity : MMOUtils.getNearbyChunkEntities(loc))
if (MMOUtils.canTarget(attack.getDamager(), entity) && loc.distanceSquared(entity.getLocation()) < 2 && !hit.contains(entity.getEntityId())) {
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));

View File

@ -1,9 +1,10 @@
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 net.Indyuce.mmoitems.api.ItemAttackMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import org.bukkit.*;
import org.bukkit.block.Block;
@ -14,7 +15,7 @@ import org.bukkit.util.Vector;
public class Hoearthquake extends Ability<SimpleAbilityMetadata> {
public Hoearthquake() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK, CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("cooldown", 10);
addModifier("mana", 0);
@ -22,15 +23,15 @@ public class Hoearthquake extends Ability<SimpleAbilityMetadata> {
}
@Override
public SimpleAbilityMetadata canBeCast(ItemAttackMetadata attack, LivingEntity target, AbilityData ability) {
return attack.getDamager().isOnGround() ? new SimpleAbilityMetadata(ability) : null;
public SimpleAbilityMetadata canBeCast(AttackMetadata attack, LivingEntity target, AbilityData ability) {
return attack.getPlayer().isOnGround() ? new SimpleAbilityMetadata(ability) : null;
}
@Override
public void whenCast(ItemAttackMetadata attack, SimpleAbilityMetadata ability) {
public void whenCast(AttackMetadata attack, SimpleAbilityMetadata ability) {
new BukkitRunnable() {
final Vector vec = attack.getDamager().getEyeLocation().getDirection().setY(0);
final Location loc = attack.getDamager().getLocation();
final Vector vec = attack.getPlayer().getEyeLocation().getDirection().setY(0);
final Location loc = attack.getPlayer().getLocation();
int ti = 0;
public void run() {
@ -45,7 +46,7 @@ public class Hoearthquake extends Ability<SimpleAbilityMetadata> {
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.getDamager());
BlockBreakEvent event = new BlockBreakEvent(b, attack.getPlayer());
event.setDropItems(false);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) b.setType(Material.FARMLAND);

View File

@ -8,7 +8,7 @@ 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.ItemAttackMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import net.Indyuce.mmoitems.api.util.NoClipItem;
import org.bukkit.Particle;
import org.bukkit.Sound;
@ -22,7 +22,7 @@ import org.bukkit.scheduler.BukkitRunnable;
public class Item_Bomb extends ItemAbility implements Listener {
public Item_Bomb() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK, CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("damage", 7);
addModifier("radius", 6);
@ -34,11 +34,11 @@ public class Item_Bomb extends ItemAbility implements Listener {
}
@Override
public void whenCast(ItemAttackMetadata attack, ItemAbilityMetadata ability) {
public void whenCast(AttackMetadata attack, ItemAbilityMetadata ability) {
ItemStack itemStack = ability.getItem();
final NoClipItem item = new NoClipItem(attack.getDamager().getLocation().add(0, 1.2, 0), itemStack);
final NoClipItem item = new NoClipItem(attack.getPlayer().getLocation().add(0, 1.2, 0), itemStack);
item.getEntity().setVelocity(ability.getTarget().multiply(1.3));
attack.getDamager().getWorld().playSound(attack.getDamager().getLocation(), Sound.ENTITY_SNOWBALL_THROW, 2, 0);
attack.getPlayer().getWorld().playSound(attack.getPlayer().getLocation(), Sound.ENTITY_SNOWBALL_THROW, 2, 0);
new BukkitRunnable() {
int j = 0;
@ -51,7 +51,7 @@ public class Item_Bomb extends ItemAbility implements Listener {
double slowAmplifier = ability.getModifier("slow-amplifier");
for (Entity entity : item.getEntity().getNearbyEntities(radius, radius, radius))
if (MMOUtils.canTarget(attack.getDamager(), entity)) {
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));

View File

@ -7,7 +7,7 @@ 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.ItemAttackMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import net.Indyuce.mmoitems.api.util.NoClipItem;
import org.bukkit.Particle;
import org.bukkit.Sound;
@ -19,7 +19,7 @@ import org.bukkit.scheduler.BukkitRunnable;
public class Item_Throw extends ItemAbility implements Listener {
public Item_Throw() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK, CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("damage", 6);
addModifier("force", 1);
@ -29,7 +29,7 @@ public class Item_Throw extends ItemAbility implements Listener {
}
@Override
public void whenCast(ItemAttackMetadata attack, ItemAbilityMetadata ability) {
public void whenCast(AttackMetadata attack, ItemAbilityMetadata ability) {
ItemStack itemStack = ability.getItem();
/*boolean hasAbility = false;
@ -47,9 +47,9 @@ public class Item_Throw extends ItemAbility implements Listener {
if (!hasAbility)
return;*/
final NoClipItem item = new NoClipItem(attack.getDamager().getLocation().add(0, 1.2, 0), itemStack);
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.getDamager().getWorld().playSound(attack.getDamager().getLocation(), Sound.ENTITY_SNOWBALL_THROW, 1, 0);
attack.getPlayer().getWorld().playSound(attack.getPlayer().getLocation(), Sound.ENTITY_SNOWBALL_THROW, 1, 0);
new BukkitRunnable() {
double ti = 0;
@ -62,7 +62,7 @@ public class Item_Throw extends ItemAbility implements Listener {
item.getEntity().getWorld().spawnParticle(Particle.CRIT, item.getEntity().getLocation(), 0);
for (Entity target : item.getEntity().getNearbyEntities(1, 1, 1))
if (MMOUtils.canTarget(attack.getDamager(), target)) {
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();

View File

@ -4,7 +4,7 @@ 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 net.Indyuce.mmoitems.api.ItemAttackMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import org.bukkit.Particle;
import org.bukkit.entity.LivingEntity;
@ -13,7 +13,7 @@ import org.bukkit.util.Vector;
public class Leap extends SimpleAbility {
public Leap() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK, CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("force", 1);
addModifier("cooldown", 10);
@ -22,17 +22,17 @@ public class Leap extends SimpleAbility {
}
@Override
public SimpleAbilityMetadata canBeCast(ItemAttackMetadata attack, LivingEntity target, AbilityData ability) {
return attack.getDamager().isOnGround() ? new SimpleAbilityMetadata(ability) : null;
public SimpleAbilityMetadata canBeCast(AttackMetadata attack, LivingEntity target, AbilityData ability) {
return attack.getPlayer().isOnGround() ? new SimpleAbilityMetadata(ability) : null;
}
@Override
public void whenCast(ItemAttackMetadata attack, SimpleAbilityMetadata ability) {
attack.getDamager().getWorld().playSound(attack.getDamager().getLocation(), VersionSound.ENTITY_ENDER_DRAGON_FLAP.toSound(), 1, 0);
attack.getDamager().getWorld().spawnParticle(Particle.EXPLOSION_NORMAL, attack.getDamager().getLocation(), 16, 0, 0, 0.1);
Vector vec = attack.getDamager().getEyeLocation().getDirection().multiply(2 * ability.getModifier("force"));
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.getDamager().setVelocity(vec);
attack.getPlayer().setVelocity(vec);
new BukkitRunnable() {
double ti = 0;
@ -41,7 +41,7 @@ public class Leap extends SimpleAbility {
if (ti > 20)
cancel();
attack.getDamager().getWorld().spawnParticle(Particle.CLOUD, attack.getDamager().getLocation().add(0, 1, 0), 0);
attack.getPlayer().getWorld().spawnParticle(Particle.CLOUD, attack.getPlayer().getLocation().add(0, 1, 0), 0);
}
}.runTaskTimer(MMOItems.plugin, 0, 1);
}

View File

@ -1,17 +1,18 @@
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 net.Indyuce.mmoitems.api.ItemAttackMetadata;
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(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK, CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("heal", 7);
addModifier("duration", 3);
@ -21,7 +22,7 @@ public class Regen_Ally extends FriendlyTargetAbility {
}
@Override
public void whenCast(ItemAttackMetadata attack, FriendlyTargetAbilityMetadata ability) {
public void whenCast(AttackMetadata attack, FriendlyTargetAbilityMetadata ability) {
LivingEntity target = ability.getTarget();
new BukkitRunnable() {

View File

@ -3,13 +3,13 @@ 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 net.Indyuce.mmoitems.api.ItemAttackMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Location;
import org.bukkit.Particle;
public class Blink extends SimpleAbility {
public Blink() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK, CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("range", 8);
addModifier("cooldown", 10);
@ -18,15 +18,15 @@ public class Blink extends SimpleAbility {
}
@Override
public void whenCast(ItemAttackMetadata attack, SimpleAbilityMetadata ability) {
attack.getDamager().getWorld().spawnParticle(Particle.EXPLOSION_LARGE, attack.getDamager().getLocation().add(0, 1, 0), 0);
attack.getDamager().getWorld().spawnParticle(Particle.SPELL_INSTANT, attack.getDamager().getLocation().add(0, 1, 0), 32, 0, 0, 0, .1);
attack.getDamager().getWorld().playSound(attack.getDamager().getLocation(), VersionSound.ENTITY_ENDERMAN_TELEPORT.toSound(), 1, 1);
Location loc = attack.getDamager().getTargetBlock(null, (int) ability.getModifier("range")).getLocation().add(0, 1, 0);
loc.setYaw(attack.getDamager().getLocation().getYaw());
loc.setPitch(attack.getDamager().getLocation().getPitch());
attack.getDamager().teleport(loc);
attack.getDamager().getWorld().spawnParticle(Particle.EXPLOSION_LARGE, attack.getDamager().getLocation().add(0, 1, 0), 0);
attack.getDamager().getWorld().spawnParticle(Particle.SPELL_INSTANT, attack.getDamager().getLocation().add(0, 1, 0), 32, 0, 0, 0, .1);
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,10 +1,10 @@
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 net.Indyuce.mmoitems.api.ItemAttackMetadata;
import net.Indyuce.mmoitems.api.util.TemporaryListener;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.entity.Snowball;
@ -19,8 +19,7 @@ import java.util.UUID;
public class Blizzard extends SimpleAbility {
public Blizzard() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK,
CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("duration", 2.5);
addModifier("damage", 2);
@ -32,7 +31,7 @@ public class Blizzard extends SimpleAbility {
}
@Override
public void whenCast(ItemAttackMetadata attack, SimpleAbilityMetadata ability) {
public void whenCast(AttackMetadata attack, SimpleAbilityMetadata ability) {
double duration = ability.getModifier("duration") * 10;
double force = ability.getModifier("force");
double inaccuracy = ability.getModifier("inaccuracy");
@ -48,12 +47,12 @@ public class Blizzard extends SimpleAbility {
return;
}
Location loc = attack.getDamager().getEyeLocation();
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.getDamager().launchProjectile(Snowball.class);
Snowball snowball = attack.getPlayer().launchProjectile(Snowball.class);
snowball.setVelocity(loc.getDirection().multiply(1.3 * force));
handler.entities.add(snowball.getUniqueId());
}

View File

@ -1,11 +1,11 @@
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 net.Indyuce.mmoitems.api.ItemAttackMetadata;
import net.Indyuce.mmoitems.api.util.TemporaryListener;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Bukkit;
import org.bukkit.Particle;
import org.bukkit.entity.Player;
@ -17,8 +17,7 @@ import org.bukkit.scheduler.BukkitRunnable;
public class Bunny_Mode extends SimpleAbility {
public Bunny_Mode() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK,
CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("duration", 20);
addModifier("jump-force", 1);
@ -29,13 +28,13 @@ public class Bunny_Mode extends SimpleAbility {
}
@Override
public void whenCast(ItemAttackMetadata attack, SimpleAbilityMetadata ability) {
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.getDamager(), duration);
final BunnyHandler handler = new BunnyHandler(attack.getPlayer(), duration);
int j = 0;
public void run() {
@ -45,12 +44,12 @@ public class Bunny_Mode extends SimpleAbility {
return;
}
if (attack.getDamager().getLocation().add(0, -.5, 0).getBlock().getType().isSolid()) {
attack.getDamager()
.setVelocity(attack.getDamager().getEyeLocation().getDirection().setY(0).normalize().multiply(.8 * xz).setY(0.5 * y / xz));
attack.getDamager().getWorld().playSound(attack.getDamager().getLocation(), VersionSound.ENTITY_ENDER_DRAGON_FLAP.toSound(), 2, 1);
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.getDamager().getWorld().spawnParticle(Particle.CLOUD, attack.getDamager().getLocation(), 0, Math.cos(a), 0, Math.sin(a),
attack.getPlayer().getWorld().spawnParticle(Particle.CLOUD, attack.getPlayer().getLocation(), 0, Math.cos(a), 0, Math.sin(a),
.2);
}
}
@ -66,7 +65,7 @@ public class Bunny_Mode extends SimpleAbility {
this.player = player;
Bukkit.getScheduler().runTaskLater(MMOItems.plugin, (Runnable) this::close, (long) (duration * 20));
close((long) (duration *20));
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)

View File

@ -7,7 +7,7 @@ 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.ItemAttackMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.Sound;
@ -18,8 +18,7 @@ import org.bukkit.util.Vector;
public class Burning_Hands extends SimpleAbility {
public Burning_Hands() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK,
CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("duration", 3);
addModifier("damage", 2);
@ -29,7 +28,7 @@ public class Burning_Hands extends SimpleAbility {
}
@Override
public void whenCast(ItemAttackMetadata attack, SimpleAbilityMetadata ability) {
public void whenCast(AttackMetadata attack, SimpleAbilityMetadata ability) {
double duration = ability.getModifier("duration") * 10;
double damage = ability.getModifier("damage") / 2;
@ -40,11 +39,11 @@ public class Burning_Hands extends SimpleAbility {
if (j++ > duration)
cancel();
Location loc = attack.getDamager().getLocation().add(0, 1.2, 0);
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.getDamager().getEyeLocation().getYaw() + 90) * Math.PI / 180;
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);
@ -55,9 +54,9 @@ public class Burning_Hands extends SimpleAbility {
if (j % 5 == 0)
for (Entity entity : MMOUtils.getNearbyChunkEntities(loc))
if (entity.getLocation().distanceSquared(loc) < 60
&& attack.getDamager().getEyeLocation().getDirection()
.angle(entity.getLocation().toVector().subtract(attack.getDamager().getLocation().toVector())) < Math.PI / 6
&& MMOUtils.canTarget(attack.getDamager(), entity))
&& 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);
}

View File

@ -1,10 +1,10 @@
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 net.Indyuce.mmoitems.api.ItemAttackMetadata;
import net.Indyuce.mmoitems.api.util.TemporaryListener;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.entity.Egg;
@ -19,8 +19,7 @@ import java.util.List;
public class Chicken_Wraith extends SimpleAbility {
public Chicken_Wraith() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK,
CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("duration", 2.5);
addModifier("damage", 2);
@ -32,7 +31,7 @@ public class Chicken_Wraith extends SimpleAbility {
}
@Override
public void whenCast(ItemAttackMetadata attack, SimpleAbilityMetadata ability) {
public void whenCast(AttackMetadata attack, SimpleAbilityMetadata ability) {
double duration = ability.getModifier("duration") * 10;
double force = ability.getModifier("force");
double inaccuracy = ability.getModifier("inaccuracy");
@ -48,12 +47,12 @@ public class Chicken_Wraith extends SimpleAbility {
return;
}
Location loc = attack.getDamager().getEyeLocation();
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.getDamager().launchProjectile(Egg.class);
Egg egg = attack.getPlayer().launchProjectile(Egg.class);
egg.setVelocity(loc.getDirection().multiply(1.3 * force));
handler.entities.add(egg.getEntityId());

View File

@ -6,7 +6,7 @@ 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 net.Indyuce.mmoitems.api.ItemAttackMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.Sound;
@ -18,7 +18,7 @@ import org.bukkit.util.Vector;
public class Circular_Slash extends SimpleAbility {
public Circular_Slash() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK, CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("damage", 6);
addModifier("radius", 3);
@ -29,18 +29,18 @@ public class Circular_Slash extends SimpleAbility {
}
@Override
public void whenCast(ItemAttackMetadata attack, SimpleAbilityMetadata ability) {
public void whenCast(AttackMetadata attack, SimpleAbilityMetadata ability) {
double damage = ability.getModifier("damage");
double radius = ability.getModifier("radius");
double knockback = ability.getModifier("knockback");
attack.getDamager().getWorld().playSound(attack.getDamager().getLocation(), Sound.ENTITY_ZOMBIE_ATTACK_IRON_DOOR, 2, .5f);
attack.getDamager().addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 2, 254));
for (Entity entity : attack.getDamager().getNearbyEntities(radius, radius, radius)) {
if (MMOUtils.canTarget(attack.getDamager(), entity)) {
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.getDamager().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);
@ -48,10 +48,10 @@ public class Circular_Slash extends SimpleAbility {
}
double step = 12 + (radius * 2.5);
for (double j = 0; j < Math.PI * 2; j += Math.PI / step) {
Location loc = attack.getDamager().getLocation().clone();
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.getDamager().getWorld().spawnParticle(Particle.EXPLOSION_LARGE, attack.getDamager().getLocation().add(0, 1, 0), 0);
attack.getPlayer().getWorld().spawnParticle(Particle.EXPLOSION_LARGE, attack.getPlayer().getLocation().add(0, 1, 0), 0);
}
}

View File

@ -8,7 +8,7 @@ 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.ItemAttackMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Particle;
@ -20,7 +20,7 @@ import org.bukkit.util.Vector;
public class Firefly extends SimpleAbility {
public Firefly() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK, CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("damage", 6);
addModifier("duration", 2.5);
@ -31,7 +31,7 @@ public class Firefly extends SimpleAbility {
}
@Override
public void whenCast(ItemAttackMetadata attack, SimpleAbilityMetadata ability) {
public void whenCast(AttackMetadata attack, SimpleAbilityMetadata ability) {
double duration = ability.getModifier("duration") * 20;
new BukkitRunnable() {
@ -41,44 +41,44 @@ public class Firefly extends SimpleAbility {
if (j++ > duration)
cancel();
if (attack.getDamager().getLocation().getBlock().getType() == Material.WATER) {
attack.getDamager().setVelocity(attack.getDamager().getVelocity().multiply(3).setY(1.8));
attack.getDamager().getWorld().playSound(attack.getDamager().getLocation(), Sound.BLOCK_FIRE_EXTINGUISH, 1, .5f);
attack.getDamager().getWorld().spawnParticle(Particle.EXPLOSION_NORMAL, attack.getDamager().getLocation().add(0, 1, 0), 32, 0, 0, 0, .2);
attack.getDamager().getWorld().spawnParticle(Particle.CLOUD, attack.getDamager().getLocation().add(0, 1, 0), 32, 0, 0, 0, .2);
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.getDamager().getNearbyEntities(1, 1, 1))
if (MMOUtils.canTarget(attack.getDamager(), entity)) {
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.getDamager().getWorld().playSound(attack.getDamager().getLocation(), Sound.ENTITY_ZOMBIE_ATTACK_IRON_DOOR, 1, .5f);
attack.getDamager().getWorld().spawnParticle(Particle.LAVA, attack.getDamager().getLocation().add(0, 1, 0), 32);
attack.getDamager().getWorld().spawnParticle(Particle.SMOKE_LARGE, attack.getDamager().getLocation().add(0, 1, 0), 24, 0, 0, 0, .3);
attack.getDamager().getWorld().spawnParticle(Particle.FLAME, attack.getDamager().getLocation().add(0, 1, 0), 24, 0, 0, 0, .3);
entity.setVelocity(attack.getDamager().getVelocity().setY(0.3).multiply(1.7 * knockback));
attack.getDamager().setVelocity(attack.getDamager().getEyeLocation().getDirection().multiply(-3).setY(.5));
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.getDamager().getLocation().add(0, 1, 0);
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.getDamager().getWorld().spawnParticle(Particle.SMOKE_NORMAL, loc, 0);
attack.getPlayer().getWorld().spawnParticle(Particle.SMOKE_NORMAL, loc, 0);
if (random.nextDouble() < .3)
attack.getDamager().getWorld().spawnParticle(Particle.FLAME, loc, 0);
attack.getPlayer().getWorld().spawnParticle(Particle.FLAME, loc, 0);
loc.add(vec.multiply(-1));
}
attack.getDamager().setVelocity(attack.getDamager().getEyeLocation().getDirection());
attack.getDamager().getWorld().playSound(attack.getDamager().getLocation(), VersionSound.ENTITY_FIREWORK_ROCKET_BLAST.toSound(), 1, 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

@ -4,7 +4,7 @@ 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 net.Indyuce.mmoitems.api.ItemAttackMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.event.Listener;
@ -12,7 +12,7 @@ import org.bukkit.scheduler.BukkitRunnable;
public class Frog_Mode extends SimpleAbility implements Listener {
public Frog_Mode() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK, CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("duration", 20);
addModifier("jump-force", 1);
@ -23,7 +23,7 @@ public class Frog_Mode extends SimpleAbility implements Listener {
}
@Override
public void whenCast(ItemAttackMetadata attack, SimpleAbilityMetadata ability) {
public void whenCast(AttackMetadata attack, SimpleAbilityMetadata ability) {
double duration = ability.getModifier("duration") * 20;
double y = ability.getModifier("jump-force");
double xz = ability.getModifier("speed");
@ -36,11 +36,11 @@ public class Frog_Mode extends SimpleAbility implements Listener {
if (j > duration)
cancel();
if (attack.getDamager().getLocation().getBlock().getType() == Material.WATER) {
attack.getDamager().setVelocity(attack.getDamager().getEyeLocation().getDirection().setY(0).normalize().multiply(.8 * xz).setY(0.5 / xz * y));
attack.getDamager().getWorld().playSound(attack.getDamager().getLocation(), VersionSound.ENTITY_ENDER_DRAGON_FLAP.toSound(), 2, 1);
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.getDamager().getWorld().spawnParticle(Particle.CLOUD, attack.getDamager().getLocation(), 0, Math.cos(a), 0, Math.sin(a), .2);
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

@ -4,7 +4,7 @@ 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.ItemAttackMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.entity.Entity;
@ -16,7 +16,7 @@ import org.bukkit.scheduler.BukkitRunnable;
public class Frozen_Aura extends SimpleAbility implements Listener {
public Frozen_Aura() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK, CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("duration", 6);
addModifier("amplifier", 1);
@ -27,7 +27,7 @@ public class Frozen_Aura extends SimpleAbility implements Listener {
}
@Override
public void whenCast(ItemAttackMetadata attack, SimpleAbilityMetadata ability) {
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;
@ -42,14 +42,14 @@ public class Frozen_Aura extends SimpleAbility implements Listener {
j += Math.PI / 60;
for (double k = 0; k < Math.PI * 2; k += Math.PI / 2)
attack.getDamager().getWorld().spawnParticle(Particle.SPELL_INSTANT, attack.getDamager().getLocation().add(Math.cos(k + j) * 2, 1 + Math.sin(k + j * 7) / 3, Math.sin(k + j) * 2), 0);
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.getDamager().getWorld().playSound(attack.getDamager().getLocation(), Sound.BLOCK_SNOW_BREAK, 1, 1);
attack.getPlayer().getWorld().playSound(attack.getPlayer().getLocation(), Sound.BLOCK_SNOW_BREAK, 1, 1);
if (ti % 7 == 0)
for (Entity entity : MMOUtils.getNearbyChunkEntities(attack.getDamager().getLocation()))
if (entity.getLocation().distanceSquared(attack.getDamager().getLocation()) < radiusSquared && MMOUtils.canTarget(attack.getDamager(), entity)) {
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));
}

View File

@ -3,7 +3,7 @@ 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 net.Indyuce.mmoitems.api.ItemAttackMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.entity.Entity;
@ -11,7 +11,7 @@ import org.bukkit.entity.Player;
public class Grand_Heal extends SimpleAbility {
public Grand_Heal() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK, CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("heal", 5);
addModifier("radius", 5);
@ -21,15 +21,15 @@ public class Grand_Heal extends SimpleAbility {
}
@Override
public void whenCast(ItemAttackMetadata attack, SimpleAbilityMetadata ability) {
public void whenCast(AttackMetadata attack, SimpleAbilityMetadata ability) {
double heal = ability.getModifier("heal");
double radius = ability.getModifier("radius");
MMOUtils.heal(attack.getDamager(), heal);
attack.getDamager().getWorld().playSound(attack.getDamager().getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1, 2);
attack.getDamager().getWorld().spawnParticle(Particle.HEART, attack.getDamager().getLocation().add(0, .75, 0), 16, 1, 1, 1, 0);
attack.getDamager().getWorld().spawnParticle(Particle.VILLAGER_HAPPY, attack.getDamager().getLocation().add(0, .75, 0), 16, 1, 1, 1, 0);
for (Entity entity : attack.getDamager().getNearbyEntities(radius, radius, 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

@ -3,13 +3,13 @@ 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 net.Indyuce.mmoitems.api.ItemAttackMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Particle;
import org.bukkit.Sound;
public class Heal extends SimpleAbility {
public Heal() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK, CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("heal", 4);
addModifier("cooldown", 10);
@ -18,10 +18,10 @@ public class Heal extends SimpleAbility {
}
@Override
public void whenCast(ItemAttackMetadata attack, SimpleAbilityMetadata ability) {
attack.getDamager().getWorld().playSound(attack.getDamager().getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1, 2);
attack.getDamager().getWorld().spawnParticle(Particle.HEART, attack.getDamager().getLocation().add(0, .75, 0), 16, 1, 1, 1, 0);
attack.getDamager().getWorld().spawnParticle(Particle.VILLAGER_HAPPY, attack.getDamager().getLocation().add(0, .75, 0), 16, 1, 1, 1, 0);
MMOUtils.heal(attack.getDamager(), ability.getModifier("heal"));
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

@ -8,7 +8,7 @@ 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.ItemAttackMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Particle;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
@ -20,7 +20,7 @@ import java.util.List;
public class Light_Dash extends SimpleAbility {
public Light_Dash() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK, CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("damage", 3);
addModifier("cooldown", 10);
@ -30,12 +30,12 @@ public class Light_Dash extends SimpleAbility {
}
@Override
public void whenCast(ItemAttackMetadata attack, SimpleAbilityMetadata ability) {
public void whenCast(AttackMetadata attack, SimpleAbilityMetadata ability) {
double damage = ability.getModifier("damage");
double length = ability.getModifier("length");
new BukkitRunnable() {
final Vector vec = attack.getDamager().getEyeLocation().getDirection();
final Vector vec = attack.getPlayer().getEyeLocation().getDirection();
final List<Integer> hit = new ArrayList<>();
int j = 0;
@ -43,11 +43,11 @@ public class Light_Dash extends SimpleAbility {
if (j++ > 10 * Math.min(10, length))
cancel();
attack.getDamager().setVelocity(vec);
attack.getDamager().getWorld().spawnParticle(Particle.SMOKE_LARGE, attack.getDamager().getLocation().add(0, 1, 0), 0);
attack.getDamager().getWorld().playSound(attack.getDamager().getLocation(), VersionSound.ENTITY_ENDER_DRAGON_FLAP.toSound(), 1, 2);
for (Entity entity : attack.getDamager().getNearbyEntities(1, 1, 1))
if (!hit.contains(entity.getEntityId()) && MMOUtils.canTarget(attack.getDamager(), entity)) {
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);
}

View File

@ -4,7 +4,7 @@ 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 net.Indyuce.mmoitems.api.ItemAttackMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Bukkit;
import org.bukkit.Particle;
import org.bukkit.entity.Player;
@ -19,7 +19,7 @@ import org.bukkit.scheduler.BukkitRunnable;
public class Magical_Path extends SimpleAbility {
public Magical_Path() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK, CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("duration", 3);
addModifier("cooldown", 15);
@ -28,13 +28,13 @@ public class Magical_Path extends SimpleAbility {
}
@Override
public void whenCast(ItemAttackMetadata attack, SimpleAbilityMetadata ability) {
attack.getDamager().setAllowFlight(true);
attack.getDamager().setFlying(true);
attack.getDamager().setVelocity(attack.getDamager().getVelocity().setY(.5));
attack.getDamager().getWorld().playSound(attack.getDamager().getLocation(), VersionSound.ENTITY_ENDERMAN_TELEPORT.toSound(), 1, 1);
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.getDamager(), ability.getModifier("duration"));
new MagicalPathHandler(attack.getPlayer(), ability.getModifier("duration"));
}
public static class MagicalPathHandler extends BukkitRunnable implements Listener {

View File

@ -4,7 +4,7 @@ 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 net.Indyuce.mmoitems.api.ItemAttackMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import org.bukkit.Bukkit;
import org.bukkit.Color;
@ -20,8 +20,7 @@ import org.bukkit.scheduler.BukkitRunnable;
public class Magical_Shield extends SimpleAbility {
public Magical_Shield() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK,
CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("power", 40);
addModifier("radius", 5);
@ -32,18 +31,18 @@ public class Magical_Shield extends SimpleAbility {
}
@Override
public SimpleAbilityMetadata canBeCast(ItemAttackMetadata attack, LivingEntity target, AbilityData ability) {
return attack.getDamager().isOnGround() ? new SimpleAbilityMetadata(ability) : null;
public SimpleAbilityMetadata canBeCast(AttackMetadata attack, LivingEntity target, AbilityData ability) {
return attack.getPlayer().isOnGround() ? new SimpleAbilityMetadata(ability) : null;
}
@Override
public void whenCast(ItemAttackMetadata attack, SimpleAbilityMetadata ability) {
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.getDamager().getWorld().playSound(attack.getDamager().getLocation(), VersionSound.ENTITY_ENDERMAN_TELEPORT.toSound(), 3, 0);
new MagicalShield(attack.getDamager().getLocation().clone(), duration, radiusSquared, power);
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 {

View File

@ -7,7 +7,7 @@ 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 net.Indyuce.mmoitems.api.ItemAttackMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.Sound;
@ -18,7 +18,7 @@ import org.bukkit.potion.PotionEffectType;
public class Overload extends SimpleAbility {
public Overload() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK, CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("damage", 6);
addModifier("cooldown", 10);
@ -28,23 +28,23 @@ public class Overload extends SimpleAbility {
}
@Override
public void whenCast(ItemAttackMetadata attack, SimpleAbilityMetadata ability) {
public void whenCast(AttackMetadata attack, SimpleAbilityMetadata ability) {
double damage = ability.getModifier("damage");
double radius = ability.getModifier("radius");
attack.getDamager().getWorld().playSound(attack.getDamager().getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 2, 0);
attack.getDamager().getWorld().playSound(attack.getDamager().getLocation(), VersionSound.ENTITY_FIREWORK_ROCKET_TWINKLE.toSound(), 2, 0);
attack.getDamager().addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 2, 254));
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.getDamager().getNearbyEntities(radius, radius, radius))
if (MMOUtils.canTarget(attack.getDamager(), entity))
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.getDamager().getLocation().clone().add(Math.cos(j) * radius, 1, Math.sin(j) * radius);
attack.getDamager().getWorld().spawnParticle(Particle.CLOUD, loc, 4, 0, 0, 0, .05);
attack.getDamager().getWorld().spawnParticle(Particle.FIREWORKS_SPARK, loc, 4, 0, 0, 0, .05);
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

@ -11,7 +11,7 @@ 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.ItemAttackMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import net.Indyuce.mmoitems.api.util.NoClipItem;
import org.bukkit.Particle;
import org.bukkit.Sound;
@ -30,7 +30,7 @@ public class Present_Throw extends SimpleAbility {
private final ItemStack present = VersionMaterial.PLAYER_HEAD.toItem();
public Present_Throw() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK, CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("damage", 6);
addModifier("radius", 4);
@ -56,12 +56,12 @@ public class Present_Throw extends SimpleAbility {
}
@Override
public void whenCast(ItemAttackMetadata attack, SimpleAbilityMetadata ability) {
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.getDamager().getLocation().add(0, 1.2, 0), present);
item.getEntity().setVelocity(attack.getDamager().getEyeLocation().getDirection().multiply(1.5 * ability.getModifier("force")));
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
@ -71,7 +71,7 @@ public class Present_Throw extends SimpleAbility {
* trajectory change
*/
final double trajRatio = item.getEntity().getVelocity().getX() / item.getEntity().getVelocity().getZ();
attack.getDamager().getWorld().playSound(attack.getDamager().getLocation(), Sound.ENTITY_SNOWBALL_THROW, 1, 0);
attack.getPlayer().getWorld().playSound(attack.getPlayer().getLocation(), Sound.ENTITY_SNOWBALL_THROW, 1, 0);
new BukkitRunnable() {
double ti = 0;
@ -87,7 +87,7 @@ public class Present_Throw extends SimpleAbility {
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.getDamager(), entity))
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();

View File

@ -5,7 +5,7 @@ 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 net.Indyuce.mmoitems.api.ItemAttackMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Particle;
@ -19,8 +19,7 @@ import org.bukkit.scheduler.BukkitRunnable;
public class Shadow_Veil extends SimpleAbility implements Listener {
public Shadow_Veil() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK,
CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("cooldown", 35);
addModifier("duration", 5);
@ -30,21 +29,21 @@ public class Shadow_Veil extends SimpleAbility implements Listener {
}
@Override
public void whenCast(ItemAttackMetadata attack, SimpleAbilityMetadata ability) {
public void whenCast(AttackMetadata attack, SimpleAbilityMetadata ability) {
double duration = ability.getModifier("duration");
attack.getDamager().getWorld().playSound(attack.getDamager().getLocation(), VersionSound.ENTITY_ENDERMAN_TELEPORT.toSound(), 3, 0);
attack.getPlayer().getWorld().playSound(attack.getPlayer().getLocation(), VersionSound.ENTITY_ENDERMAN_TELEPORT.toSound(), 3, 0);
for (Player online : Bukkit.getOnlinePlayers())
online.hidePlayer(MMOItems.plugin, attack.getDamager());
online.hidePlayer(MMOItems.plugin, attack.getPlayer());
/*
* clears the target of any entity around the player
*/
for (Mob serverEntities : attack.getDamager().getWorld().getEntitiesByClass(Mob.class))
if (serverEntities.getTarget() != null && serverEntities.getTarget().equals(attack.getDamager()))
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.getDamager(), duration);
ShadowVeilHandler svh = new ShadowVeilHandler(attack.getPlayer(), duration);
svh.setDeceptions(SilentNumbers.floor(ability.getModifier("deception")));
}

View File

@ -4,7 +4,7 @@ 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.ItemAttackMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.*;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
@ -16,8 +16,7 @@ import java.util.List;
public class Shockwave extends SimpleAbility {
public Shockwave() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK,
CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("cooldown", 7.5);
addModifier("knock-up", 1);
@ -27,13 +26,13 @@ public class Shockwave extends SimpleAbility {
}
@Override
public void whenCast(ItemAttackMetadata attack, SimpleAbilityMetadata ability) {
public void whenCast(AttackMetadata attack, SimpleAbilityMetadata ability) {
double knockUp = ability.getModifier("knock-up");
double length = ability.getModifier("length");
new BukkitRunnable() {
final Vector vec = attack.getDamager().getEyeLocation().getDirection().setY(0);
final Location loc = attack.getDamager().getLocation();
final Vector vec = attack.getPlayer().getEyeLocation().getDirection().setY(0);
final Location loc = attack.getPlayer().getLocation();
final List<Integer> hit = new ArrayList<>();
int ti = 0;
@ -48,7 +47,7 @@ public class Shockwave extends SimpleAbility {
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.getDamager())
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);

View File

@ -6,7 +6,7 @@ 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 net.Indyuce.mmoitems.api.ItemAttackMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.Sound;
@ -17,7 +17,7 @@ import org.bukkit.potion.PotionEffectType;
public class Sky_Smash extends SimpleAbility {
public Sky_Smash() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK, CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("cooldown", 10);
addModifier("damage", 3);
@ -27,20 +27,20 @@ public class Sky_Smash extends SimpleAbility {
}
@Override
public void whenCast(ItemAttackMetadata attack, SimpleAbilityMetadata ability) {
public void whenCast(AttackMetadata attack, SimpleAbilityMetadata ability) {
double damage = ability.getModifier("damage");
double knockUp = ability.getModifier("knock-up");
attack.getDamager().getWorld().playSound(attack.getDamager().getLocation(), Sound.ENTITY_ZOMBIE_ATTACK_IRON_DOOR, 2, .5f);
attack.getDamager().addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 2, 254));
Location loc = attack.getDamager().getEyeLocation().add(attack.getDamager().getEyeLocation().getDirection().multiply(3));
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.getDamager(), entity) && entity.getLocation().distanceSquared(loc) < 10) {
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.getDamager().getEyeLocation().clone();
Location loc1 = attack.getPlayer().getEyeLocation().clone();
loc1.setPitch(-70);
entity.setVelocity(loc1.getDirection().multiply(1.2 * knockUp));
}

View File

@ -3,14 +3,14 @@ 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 net.Indyuce.mmoitems.api.ItemAttackMetadata;
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(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK, CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("cooldown", 15);
addModifier("duration", 4);
@ -20,16 +20,16 @@ public class Swiftness extends SimpleAbility {
}
@Override
public void whenCast(ItemAttackMetadata attack, SimpleAbilityMetadata ability) {
public void whenCast(AttackMetadata attack, SimpleAbilityMetadata ability) {
double duration = ability.getModifier("duration");
int amplifier = (int) ability.getModifier("amplifier");
attack.getDamager().getWorld().playSound(attack.getDamager().getLocation(), VersionSound.ENTITY_ZOMBIE_PIGMAN_ANGRY.toSound(), 1, .3f);
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.getDamager().getWorld().spawnParticle(Particle.SPELL_INSTANT, attack.getDamager().getLocation().add(Math.cos(j), y, Math.sin(j)), 0);
attack.getDamager().addPotionEffect(new PotionEffect(PotionEffectType.SPEED, (int) (duration * 20), amplifier));
attack.getDamager().addPotionEffect(new PotionEffect(PotionEffectType.JUMP, (int) (duration * 20), amplifier));
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

@ -7,7 +7,7 @@ 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.ItemAttackMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import net.Indyuce.mmoitems.api.util.NoClipItem;
import org.bukkit.*;
import org.bukkit.entity.Entity;
@ -18,7 +18,7 @@ import org.bukkit.scheduler.BukkitRunnable;
public class Throw_Up extends SimpleAbility implements Listener {
public Throw_Up() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK, CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("duration", 2.5);
addModifier("damage", 2);
@ -28,7 +28,7 @@ public class Throw_Up extends SimpleAbility implements Listener {
}
@Override
public void whenCast(ItemAttackMetadata attack, SimpleAbilityMetadata ability) {
public void whenCast(AttackMetadata attack, SimpleAbilityMetadata ability) {
double duration = ability.getModifier("duration") * 10;
double dps = ability.getModifier("damage") / 2;
@ -40,21 +40,21 @@ public class Throw_Up extends SimpleAbility implements Listener {
if (j > duration)
cancel();
Location loc = attack.getDamager().getEyeLocation();
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.getDamager().getEyeLocation().getDirection().angle(entity.getLocation().toVector().subtract(attack.getDamager().getLocation().toVector())) < Math.PI / 6 && MMOUtils.canTarget(attack.getDamager(), entity))
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.getDamager().getLocation().add(0, 1.2, 0), new ItemStack(Material.ROTTEN_FLESH));
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.getDamager().getWorld().spawnParticle(Particle.SMOKE_LARGE, attack.getDamager().getLocation().add(0, 1.2, 0), 0, loc.getDirection().getX(), loc.getDirection().getY(), loc.getDirection().getZ(), 1);
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

@ -4,7 +4,7 @@ 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 net.Indyuce.mmoitems.api.ItemAttackMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Particle;
@ -15,8 +15,7 @@ import org.bukkit.util.Vector;
public class Blind extends TargetAbility {
public Blind() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK,
CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("duration", 5);
addModifier("cooldown", 9);
@ -25,7 +24,7 @@ public class Blind extends TargetAbility {
}
@Override
public void whenCast(ItemAttackMetadata attack, TargetAbilityMetadata ability) {
public void whenCast(AttackMetadata attack, TargetAbilityMetadata ability) {
LivingEntity target = ability.getTarget();
target.getWorld().playSound(target.getLocation(), VersionSound.ENTITY_ENDERMAN_HURT.toSound(), 1, 2);
@ -33,7 +32,7 @@ public class Blind extends TargetAbility {
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.getDamager().getLocation());
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

@ -2,14 +2,14 @@ package net.Indyuce.mmoitems.ability.list.target;
import net.Indyuce.mmoitems.ability.TargetAbility;
import net.Indyuce.mmoitems.ability.metadata.TargetAbilityMetadata;
import net.Indyuce.mmoitems.api.ItemAttackMetadata;
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(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK, CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("amount", 2);
addModifier("cooldown", 8);
@ -18,11 +18,11 @@ public class Bloodbath extends TargetAbility {
}
@Override
public void whenCast(ItemAttackMetadata attack, TargetAbilityMetadata ability) {
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.getDamager().setFoodLevel((int) Math.min(20, attack.getDamager().getFoodLevel() + ability.getModifier("amount")));
attack.getPlayer().setFoodLevel((int) Math.min(20, attack.getPlayer().getFoodLevel() + ability.getModifier("amount")));
}
}

View File

@ -3,7 +3,7 @@ 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 net.Indyuce.mmoitems.api.ItemAttackMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.Sound;
@ -12,7 +12,7 @@ import org.bukkit.scheduler.BukkitRunnable;
public class Burn extends TargetAbility {
public Burn() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK, CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("duration", 3);
addModifier("cooldown", 8);
@ -21,7 +21,7 @@ public class Burn extends TargetAbility {
}
@Override
public void whenCast(ItemAttackMetadata attack, TargetAbilityMetadata ability) {
public void whenCast(AttackMetadata attack, TargetAbilityMetadata ability) {
LivingEntity target = ability.getTarget();
new BukkitRunnable() {

View File

@ -1,9 +1,10 @@
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 net.Indyuce.mmoitems.api.ItemAttackMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.Sound;
@ -12,7 +13,7 @@ import org.bukkit.scheduler.BukkitRunnable;
public class Confuse extends TargetAbility {
public Confuse() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK, CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("cooldown", 7);
addModifier("mana", 0);
@ -20,13 +21,13 @@ public class Confuse extends TargetAbility {
}
@Override
public void whenCast(ItemAttackMetadata attack, TargetAbilityMetadata ability) {
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.getDamager().getEyeLocation().getYaw() - 90);
final double rads = Math.toRadians(attack.getPlayer().getEyeLocation().getYaw() - 90);
double ti = rads;
public void run() {

View File

@ -6,7 +6,7 @@ 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 net.Indyuce.mmoitems.api.ItemAttackMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.entity.LivingEntity;
@ -16,7 +16,7 @@ import org.bukkit.scheduler.BukkitRunnable;
public class Death_Mark extends TargetAbility {
public Death_Mark() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK, CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("cooldown", 7);
addModifier("damage", 5);
@ -27,7 +27,7 @@ public class Death_Mark extends TargetAbility {
}
@Override
public void whenCast(ItemAttackMetadata attack, TargetAbilityMetadata ability) {
public void whenCast(AttackMetadata attack, TargetAbilityMetadata ability) {
LivingEntity target = ability.getTarget();
double duration = ability.getModifier("duration") * 20;

View File

@ -7,7 +7,7 @@ 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 net.Indyuce.mmoitems.api.ItemAttackMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.Sound;
@ -17,7 +17,7 @@ import org.bukkit.util.Vector;
public class Magma_Fissure extends TargetAbility {
public Magma_Fissure() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK, CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("cooldown", 10);
addModifier("mana", 0);
@ -27,11 +27,11 @@ public class Magma_Fissure extends TargetAbility {
}
@Override
public void whenCast(ItemAttackMetadata attack, TargetAbilityMetadata ability) {
public void whenCast(AttackMetadata attack, TargetAbilityMetadata ability) {
LivingEntity target = ability.getTarget();
new BukkitRunnable() {
final Location loc = attack.getDamager().getLocation().add(0, .2, 0);
final Location loc = attack.getPlayer().getLocation().add(0, .2, 0);
int j = 0;
public void run() {

View File

@ -2,7 +2,7 @@ package net.Indyuce.mmoitems.ability.list.target;
import net.Indyuce.mmoitems.ability.TargetAbility;
import net.Indyuce.mmoitems.ability.metadata.TargetAbilityMetadata;
import net.Indyuce.mmoitems.api.ItemAttackMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.entity.LivingEntity;
@ -11,7 +11,7 @@ import org.bukkit.potion.PotionEffectType;
public class Poison extends TargetAbility {
public Poison() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK, CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("duration", 4);
addModifier("cooldown", 10);
@ -21,7 +21,7 @@ public class Poison extends TargetAbility {
}
@Override
public void whenCast(ItemAttackMetadata attack, TargetAbilityMetadata ability) {
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);

View File

@ -4,7 +4,7 @@ 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 net.Indyuce.mmoitems.api.ItemAttackMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.EntityEffect;
import org.bukkit.Location;
import org.bukkit.Particle;
@ -13,7 +13,7 @@ import org.bukkit.scheduler.BukkitRunnable;
public class Shock extends TargetAbility {
public Shock() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK, CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("duration", 2);
addModifier("cooldown", 8);
@ -22,7 +22,7 @@ public class Shock extends TargetAbility {
}
@Override
public void whenCast(ItemAttackMetadata attack, TargetAbilityMetadata ability) {
public void whenCast(AttackMetadata attack, TargetAbilityMetadata ability) {
LivingEntity target = ability.getTarget();
double duration = ability.getModifier("duration");
@ -30,7 +30,7 @@ public class Shock extends TargetAbility {
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.getDamager().getEyeLocation().getYaw() - 90);
final double rads = Math.toRadians(attack.getPlayer().getEyeLocation().getYaw() - 90);
double ti = rads;
public void run() {

View File

@ -3,7 +3,7 @@ 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 net.Indyuce.mmoitems.api.ItemAttackMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Particle;
@ -15,8 +15,7 @@ import org.bukkit.scheduler.BukkitRunnable;
public class Slow extends TargetAbility {
public Slow() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK,
CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("cooldown", 5);
addModifier("duration", 3);
@ -26,7 +25,7 @@ public class Slow extends TargetAbility {
}
@Override
public void whenCast(ItemAttackMetadata attack, TargetAbilityMetadata ability) {
public void whenCast(AttackMetadata attack, TargetAbilityMetadata ability) {
LivingEntity target = ability.getTarget();
new BukkitRunnable() {

View File

@ -5,12 +5,12 @@ 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 net.Indyuce.mmoitems.api.ItemAttackMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.entity.LivingEntity;
public class Smite extends TargetAbility {
public Smite() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK, CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("cooldown", 10);
addModifier("damage", 8);
@ -19,7 +19,7 @@ public class Smite extends TargetAbility {
}
@Override
public void whenCast(ItemAttackMetadata attack, TargetAbilityMetadata ability) {
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

@ -6,7 +6,7 @@ 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 net.Indyuce.mmoitems.api.ItemAttackMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.entity.ArmorStand;
@ -16,7 +16,7 @@ import org.bukkit.util.Vector;
public class Sparkle extends TargetAbility {
public Sparkle() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK, CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("cooldown", 10);
addModifier("damage", 4);
@ -27,7 +27,7 @@ public class Sparkle extends TargetAbility {
}
@Override
public void whenCast(ItemAttackMetadata attack, TargetAbilityMetadata ability) {
public void whenCast(AttackMetadata attack, TargetAbilityMetadata ability) {
LivingEntity target = ability.getTarget();
double damage = ability.getModifier("damage");
double radius = ability.getModifier("radius");
@ -39,7 +39,7 @@ public class Sparkle extends TargetAbility {
int count = 0;
for (Entity entity : target.getNearbyEntities(radius, radius, radius))
if (count < limit && entity instanceof LivingEntity && entity != attack.getDamager() && !(entity instanceof ArmorStand)) {
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);

View File

@ -5,7 +5,7 @@ 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 net.Indyuce.mmoitems.api.ItemAttackMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.Sound;
@ -15,7 +15,7 @@ import org.bukkit.util.Vector;
public class Starfall extends TargetAbility {
public Starfall() {
super(CastingMode.ON_HIT);
super();
addModifier("cooldown", 8);
addModifier("damage", 3.5);
@ -24,7 +24,7 @@ public class Starfall extends TargetAbility {
}
@Override
public void whenCast(ItemAttackMetadata attack, TargetAbilityMetadata ability) {
public void whenCast(AttackMetadata attack, TargetAbilityMetadata ability) {
LivingEntity target = ability.getTarget();
new BukkitRunnable() {

View File

@ -2,7 +2,7 @@ package net.Indyuce.mmoitems.ability.list.target;
import net.Indyuce.mmoitems.ability.TargetAbility;
import net.Indyuce.mmoitems.ability.metadata.TargetAbilityMetadata;
import net.Indyuce.mmoitems.api.ItemAttackMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Effect;
import org.bukkit.Sound;
import org.bukkit.entity.LivingEntity;
@ -11,7 +11,7 @@ import org.bukkit.potion.PotionEffectType;
public class Stun extends TargetAbility {
public Stun() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK, CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("cooldown", 10);
addModifier("duration", 2);
@ -20,7 +20,7 @@ public class Stun extends TargetAbility {
}
@Override
public void whenCast(ItemAttackMetadata attack, TargetAbilityMetadata ability) {
public void whenCast(AttackMetadata attack, TargetAbilityMetadata ability) {
LivingEntity target = ability.getTarget();
target.getWorld().playSound(target.getLocation(), Sound.BLOCK_ANVIL_LAND, 1, 2);

View File

@ -7,7 +7,7 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.TargetAbility;
import net.Indyuce.mmoitems.ability.metadata.TargetAbilityMetadata;
import net.Indyuce.mmoitems.api.ItemAttackMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.Sound;
@ -21,7 +21,7 @@ import java.util.List;
public class Tactical_Grenade extends TargetAbility {
public Tactical_Grenade() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK, CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("cooldown", 10);
addModifier("mana", 0);
@ -32,11 +32,11 @@ public class Tactical_Grenade extends TargetAbility {
}
@Override
public void whenCast(ItemAttackMetadata attack, TargetAbilityMetadata ability) {
public void whenCast(AttackMetadata attack, TargetAbilityMetadata ability) {
LivingEntity target = ability.getTarget();
new BukkitRunnable() {
final Location loc = attack.getDamager().getLocation().add(0, .1, 0);
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<>();
@ -59,7 +59,7 @@ public class Tactical_Grenade extends TargetAbility {
loc.getWorld().playSound(loc, Sound.ENTITY_GENERIC_EXPLODE, 2, 1);
for (Entity entity : MMOUtils.getNearbyChunkEntities(loc))
if (!hit.contains(entity.getEntityId()) && MMOUtils.canTarget(attack.getDamager(), entity) && entity.getLocation().distanceSquared(loc) < radius * radius) {
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

View File

@ -8,7 +8,7 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.TargetAbility;
import net.Indyuce.mmoitems.ability.metadata.TargetAbilityMetadata;
import net.Indyuce.mmoitems.api.ItemAttackMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.Sound;
@ -18,8 +18,7 @@ import org.bukkit.util.Vector;
public class Targeted_Fireball extends TargetAbility {
public Targeted_Fireball() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK,
CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("cooldown", 10);
addModifier("mana", 0);
@ -29,11 +28,11 @@ public class Targeted_Fireball extends TargetAbility {
}
@Override
public void whenCast(ItemAttackMetadata attack, TargetAbilityMetadata ability) {
public void whenCast(AttackMetadata attack, TargetAbilityMetadata ability) {
LivingEntity target = ability.getTarget();
new BukkitRunnable() {
final Location loc = attack.getDamager().getLocation().add(0, 1.3, 0);
final Location loc = attack.getPlayer().getLocation().add(0, 1.3, 0);
int j = 0;
public void run() {

View File

@ -4,7 +4,7 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.TargetAbility;
import net.Indyuce.mmoitems.ability.metadata.TargetAbilityMetadata;
import net.Indyuce.mmoitems.api.ItemAttackMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Particle;
@ -14,8 +14,7 @@ import org.bukkit.scheduler.BukkitRunnable;
public class Vampirism extends TargetAbility {
public Vampirism() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK,
CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("cooldown", 8);
addModifier("drain", 10);
@ -24,7 +23,7 @@ public class Vampirism extends TargetAbility {
}
@Override
public void whenCast(ItemAttackMetadata attack, TargetAbilityMetadata ability) {
public void whenCast(AttackMetadata attack, TargetAbilityMetadata ability) {
LivingEntity target = ability.getTarget();
new BukkitRunnable() {
@ -47,6 +46,6 @@ public class Vampirism extends TargetAbility {
}
}.runTaskTimer(MMOItems.plugin, 0, 1);
target.getWorld().playSound(target.getLocation(), Sound.ENTITY_WITCH_DRINK, 1, 2);
MMOUtils.heal(attack.getDamager(), attack.getDamage().getDamage() * ability.getModifier("drain") / 100);
MMOUtils.heal(attack.getPlayer(), attack.getDamage().getDamage() * ability.getModifier("drain") / 100);
}
}

View File

@ -4,7 +4,7 @@ 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 net.Indyuce.mmoitems.api.ItemAttackMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Material;
@ -28,7 +28,7 @@ public class Weaken_Target extends TargetAbility implements Listener {
public final Map<UUID, WeakenedInfo> marked = new HashMap<>();
public Weaken_Target() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT);
super();
addModifier("duration", 4);
addModifier("extra-damage", 40);
@ -38,7 +38,7 @@ public class Weaken_Target extends TargetAbility implements Listener {
}
@Override
public void whenCast(ItemAttackMetadata attack, TargetAbilityMetadata ability) {
public void whenCast(AttackMetadata attack, TargetAbilityMetadata ability) {
LivingEntity target = ability.getTarget();
marked.put(target.getUniqueId(), new WeakenedInfo(ability.getModifier("extra-damage")));

View File

@ -3,7 +3,7 @@ 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 net.Indyuce.mmoitems.api.ItemAttackMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Particle;
@ -15,8 +15,7 @@ import org.bukkit.scheduler.BukkitRunnable;
public class Wither extends TargetAbility {
public Wither() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK,
CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("cooldown", 8);
addModifier("duration", 3);
@ -26,7 +25,7 @@ public class Wither extends TargetAbility {
}
@Override
public void whenCast(ItemAttackMetadata attack, TargetAbilityMetadata ability) {
public void whenCast(AttackMetadata attack, TargetAbilityMetadata ability) {
LivingEntity target = ability.getTarget();
new BukkitRunnable() {

View File

@ -7,7 +7,7 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.VectorAbility;
import net.Indyuce.mmoitems.ability.metadata.VectorAbilityMetadata;
import net.Indyuce.mmoitems.api.ItemAttackMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.Sound;
@ -18,7 +18,7 @@ import org.bukkit.util.Vector;
public class Bouncy_Fireball extends VectorAbility {
public Bouncy_Fireball() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK, CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("cooldown", 20);
addModifier("damage", 5);
@ -30,11 +30,11 @@ public class Bouncy_Fireball extends VectorAbility {
}
@Override
public void whenCast(ItemAttackMetadata attack, VectorAbilityMetadata ability) {
attack.getDamager().getWorld().playSound(attack.getDamager().getLocation(), Sound.ENTITY_SNOWBALL_THROW, 2, 0);
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.getDamager().getLocation().clone().add(0, 1.2, 0);
final Location loc = attack.getPlayer().getLocation().clone().add(0, 1.2, 0);
int j = 0;
int bounces = 0;
@ -72,7 +72,7 @@ public class Bouncy_Fireball extends VectorAbility {
for (Entity entity : MMOUtils.getNearbyChunkEntities(loc))
if (entity.getLocation().distanceSquared(loc) < radius * radius)
if (MMOUtils.canTarget(attack.getDamager(), entity)) {
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));
}

View File

@ -1,11 +1,11 @@
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 net.Indyuce.mmoitems.api.ItemAttackMetadata;
import net.Indyuce.mmoitems.api.util.TemporaryListener;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.entity.EntityType;
@ -22,8 +22,7 @@ import java.util.Set;
public class Corrupted_Fangs extends VectorAbility implements Listener {
public Corrupted_Fangs() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK,
CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("damage", 5);
addModifier("cooldown", 12);
@ -33,11 +32,11 @@ public class Corrupted_Fangs extends VectorAbility implements Listener {
}
@Override
public void whenCast(ItemAttackMetadata attack, VectorAbilityMetadata ability) {
attack.getDamager().getWorld().playSound(attack.getDamager().getLocation(), Sound.ENTITY_WITHER_SHOOT, 2, 2);
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.getDamager().getLocation();
final Location loc = attack.getPlayer().getLocation();
final FangsHandler handler = new FangsHandler(attack, ability.getModifier("damage"));
final double fangAmount = ability.getModifier("fangs");
double ti = 0;
@ -50,7 +49,7 @@ public class Corrupted_Fangs extends VectorAbility implements Listener {
}
loc.add(vec);
EvokerFangs evokerFangs = (EvokerFangs) attack.getDamager().getWorld().spawnEntity(loc, EntityType.EVOKER_FANGS);
EvokerFangs evokerFangs = (EvokerFangs) attack.getPlayer().getWorld().spawnEntity(loc, EntityType.EVOKER_FANGS);
handler.entities.add(evokerFangs.getEntityId());
}
}.runTaskTimer(MMOItems.plugin, 0, 1);
@ -58,10 +57,10 @@ public class Corrupted_Fangs extends VectorAbility implements Listener {
public class FangsHandler extends TemporaryListener {
private final Set<Integer> entities = new HashSet<>();
private final ItemAttackMetadata attackMeta;
private final AttackMetadata attackMeta;
private final double damage;
public FangsHandler(ItemAttackMetadata attackMeta, double damage) {
public FangsHandler(AttackMetadata attackMeta, double damage) {
super(EntityDamageByEntityEvent.getHandlerList());
this.attackMeta = attackMeta;
@ -73,7 +72,7 @@ public class Corrupted_Fangs extends VectorAbility implements Listener {
if (event.getDamager() instanceof EvokerFangs && entities.contains(event.getDamager().getEntityId())) {
event.setCancelled(true);
if (MMOUtils.canTarget(attackMeta.getDamager(), event.getEntity()))
if (MMOUtils.canTarget(attackMeta.getPlayer(), event.getEntity()))
attackMeta.damage((LivingEntity) event.getEntity());
}
}

View File

@ -8,7 +8,7 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.VectorAbility;
import net.Indyuce.mmoitems.ability.metadata.VectorAbilityMetadata;
import net.Indyuce.mmoitems.api.ItemAttackMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.Sound;
@ -23,7 +23,7 @@ import java.util.List;
public class Cursed_Beam extends VectorAbility {
public Cursed_Beam() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK, CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("damage", 8);
addModifier("cooldown", 10);
@ -33,13 +33,13 @@ public class Cursed_Beam extends VectorAbility {
}
@Override
public void whenCast(ItemAttackMetadata attack, VectorAbilityMetadata ability) {
public void whenCast(AttackMetadata attack, VectorAbilityMetadata ability) {
double duration = ability.getModifier("duration");
attack.getDamager().getWorld().playSound(attack.getDamager().getLocation(), Sound.ENTITY_WITHER_SHOOT, 2, 2);
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.getDamager().getEyeLocation().clone();
final Location loc = attack.getPlayer().getEyeLocation().clone();
final double r = 0.4;
int ti = 0;
@ -59,13 +59,13 @@ public class Cursed_Beam extends VectorAbility {
}
for (Entity target : entities)
if (MMOUtils.canTarget(attack.getDamager(), loc, target)) {
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.getDamager(), entity) && loc.distanceSquared(entity.getLocation().add(0, 1, 0)) < 9) {
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));
}

View File

@ -1,5 +1,6 @@
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;
@ -7,8 +8,6 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.VectorAbility;
import net.Indyuce.mmoitems.ability.metadata.VectorAbilityMetadata;
import net.Indyuce.mmoitems.api.ItemAttackMetadata;
import net.Indyuce.mmoitems.api.util.TemporaryListener;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.attribute.Attribute;
@ -24,8 +23,7 @@ import org.bukkit.util.Vector;
public class Explosive_Turkey extends VectorAbility implements Listener {
public Explosive_Turkey() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK,
CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("damage", 6);
addModifier("radius", 4);
@ -37,7 +35,7 @@ public class Explosive_Turkey extends VectorAbility implements Listener {
}
@Override
public void whenCast(ItemAttackMetadata attack, VectorAbilityMetadata ability) {
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);
@ -45,7 +43,7 @@ public class Explosive_Turkey extends VectorAbility implements Listener {
Vector vec = ability.getTarget().normalize().multiply(.6);
Chicken chicken = (Chicken) attack.getDamager().getWorld().spawnEntity(attack.getDamager().getLocation().add(0, 1.3, 0).add(vec),
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);
@ -60,10 +58,10 @@ public class Explosive_Turkey extends VectorAbility implements Listener {
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
* 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
* be the same. Check for any change of that ratio to check for a
* trajectory change
*/
chicken.setVelocity(vec);
@ -96,7 +94,7 @@ public class Explosive_Turkey extends VectorAbility implements Listener {
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.getDamager(), entity)) {
&& 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));
@ -106,8 +104,8 @@ public class Explosive_Turkey extends VectorAbility implements Listener {
}.runTaskTimer(MMOItems.plugin, 0, 1);
}
/*
* this fixes an issue where chickens sometimes drop
/**
* This fixes an issue where chickens sometimes drop
*/
public static class ChickenHandler extends TemporaryListener {
private final Chicken chicken;
@ -119,13 +117,15 @@ public class Explosive_Turkey extends VectorAbility implements Listener {
}
/*
* make sure the chicken is ALWAYS killed, this class really uses
* Make sure the chicken is ALWAYS killed, this class really uses
* overkill methods but there are plently issues with chickens remaining
*/
@Override
public void close() {
chicken.remove();
super.close();
public boolean close() {
boolean b = super.close();
if (b)
chicken.remove();
return b;
}
@EventHandler

View File

@ -8,7 +8,7 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.VectorAbility;
import net.Indyuce.mmoitems.ability.metadata.VectorAbilityMetadata;
import net.Indyuce.mmoitems.api.ItemAttackMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.Sound;
@ -20,7 +20,7 @@ import org.bukkit.util.Vector;
public class Fire_Meteor extends VectorAbility {
public Fire_Meteor() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK, CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("damage", 6);
addModifier("knockback", 1);
@ -31,10 +31,10 @@ public class Fire_Meteor extends VectorAbility {
}
@Override
public void whenCast(ItemAttackMetadata attack, VectorAbilityMetadata ability) {
attack.getDamager().getWorld().playSound(attack.getDamager().getLocation(), VersionSound.ENTITY_ENDERMAN_TELEPORT.toSound(), 3, 1);
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.getDamager().getLocation().clone().add(0, 10, 0);
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;
@ -56,7 +56,7 @@ public class Fire_Meteor extends VectorAbility {
double knockback = ability.getModifier("knockback");
double radius = ability.getModifier("radius");
for (Entity entity : MMOUtils.getNearbyChunkEntities(loc))
if (MMOUtils.canTarget(attack.getDamager(), entity) && entity.getLocation().distanceSquared(loc) < radius * radius) {
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));
}

View File

@ -8,7 +8,7 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.VectorAbility;
import net.Indyuce.mmoitems.ability.metadata.VectorAbilityMetadata;
import net.Indyuce.mmoitems.api.ItemAttackMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.Sound;
@ -21,7 +21,7 @@ import java.util.List;
public class Firebolt extends VectorAbility {
public Firebolt() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK, CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("damage", 6);
addModifier("ignite", 3);
@ -31,11 +31,11 @@ public class Firebolt extends VectorAbility {
}
@Override
public void whenCast(ItemAttackMetadata attack, VectorAbilityMetadata ability) {
attack.getDamager().getWorld().playSound(attack.getDamager().getLocation(), VersionSound.ENTITY_FIREWORK_ROCKET_BLAST.toSound(), 1, 1);
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.getDamager().getEyeLocation();
final Location loc = attack.getPlayer().getEyeLocation();
int ti = 0;
public void run() {
@ -54,7 +54,7 @@ public class Firebolt extends VectorAbility {
if (random.nextDouble() < .3)
loc.getWorld().spawnParticle(Particle.LAVA, loc, 0);
for (Entity target : entities)
if (MMOUtils.canTarget(attack.getDamager(), loc, target)) {
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);

View File

@ -7,7 +7,7 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.VectorAbility;
import net.Indyuce.mmoitems.ability.metadata.VectorAbilityMetadata;
import net.Indyuce.mmoitems.api.ItemAttackMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.entity.Entity;
@ -17,7 +17,7 @@ import org.bukkit.util.Vector;
public class Heavy_Charge extends VectorAbility {
public Heavy_Charge() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK, CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("damage", 6);
addModifier("knockback", 1);
@ -27,7 +27,7 @@ public class Heavy_Charge extends VectorAbility {
}
@Override
public void whenCast(ItemAttackMetadata attack, VectorAbilityMetadata ability) {
public void whenCast(AttackMetadata attack, VectorAbilityMetadata ability) {
double knockback = ability.getModifier("knockback");
new BukkitRunnable() {
@ -39,16 +39,16 @@ public class Heavy_Charge extends VectorAbility {
cancel();
if (ti < 9) {
attack.getDamager().setVelocity(vec);
attack.getDamager().getWorld().spawnParticle(Particle.EXPLOSION_NORMAL, attack.getDamager().getLocation().add(0, 1, 0), 3, .13, .13, .13, 0);
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.getDamager().getNearbyEntities(1, 1, 1))
if (MMOUtils.canTarget(attack.getDamager(), target)) {
attack.getDamager().getWorld().playSound(attack.getDamager().getLocation(), Sound.ENTITY_ZOMBIE_ATTACK_IRON_DOOR, 1, 1);
attack.getDamager().getWorld().spawnParticle(Particle.EXPLOSION_LARGE, target.getLocation().add(0, 1, 0), 0);
target.setVelocity(attack.getDamager().getVelocity().setY(0.3).multiply(1.7 * knockback));
attack.getDamager().setVelocity(attack.getDamager().getVelocity().setX(0).setY(0).setZ(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;

View File

@ -8,7 +8,7 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.VectorAbility;
import net.Indyuce.mmoitems.ability.metadata.VectorAbilityMetadata;
import net.Indyuce.mmoitems.api.ItemAttackMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.Sound;
@ -21,7 +21,7 @@ import java.util.List;
public class Holy_Missile extends VectorAbility {
public Holy_Missile() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK, CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("damage", 6);
addModifier("cooldown", 10);
@ -31,14 +31,14 @@ public class Holy_Missile extends VectorAbility {
}
@Override
public void whenCast(ItemAttackMetadata attack, VectorAbilityMetadata ability) {
public void whenCast(AttackMetadata attack, VectorAbilityMetadata ability) {
double duration = ability.getModifier("duration") * 10;
double damage = ability.getModifier("damage");
attack.getDamager().getWorld().playSound(attack.getDamager().getLocation(), VersionSound.ENTITY_FIREWORK_ROCKET_BLAST.toSound(), 1, 1);
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.getDamager().getLocation().clone().add(0, 1.3, 0);
final Location loc = attack.getPlayer().getLocation().clone().add(0, 1.3, 0);
double ti = 0;
public void run() {
@ -59,7 +59,7 @@ public class Holy_Missile extends VectorAbility {
}
for (Entity entity : entities)
if (MMOUtils.canTarget(attack.getDamager(), loc, entity)) {
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);

View File

@ -8,7 +8,7 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.ability.VectorAbility;
import net.Indyuce.mmoitems.ability.metadata.VectorAbilityMetadata;
import net.Indyuce.mmoitems.api.ItemAttackMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Particle;
@ -24,8 +24,7 @@ import java.util.List;
public class Ice_Crystal extends VectorAbility {
public Ice_Crystal() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK,
CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("damage", 6);
addModifier("duration", 3);
@ -36,11 +35,11 @@ public class Ice_Crystal extends VectorAbility {
}
@Override
public void whenCast(ItemAttackMetadata attack, VectorAbilityMetadata ability) {
attack.getDamager().getWorld().playSound(attack.getDamager().getLocation(), VersionSound.ENTITY_FIREWORK_ROCKET_BLAST.toSound(), 1, 1);
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.getDamager().getEyeLocation().clone().add(0, -.3, 0);
final Location loc = attack.getPlayer().getEyeLocation().clone().add(0, -.3, 0);
int ti = 0;
public void run() {
@ -69,7 +68,7 @@ public class Ice_Crystal extends VectorAbility {
}
for (Entity entity : entities)
if (MMOUtils.canTarget(attack.getDamager(), loc, entity)) {
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);

View File

@ -8,6 +8,7 @@ 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 net.Indyuce.mmoitems.api.ItemAttackMetadata;
import net.Indyuce.mmoitems.api.interaction.projectile.EntityData;
import org.bukkit.Color;
@ -29,8 +30,7 @@ import javax.annotation.Nullable;
public class Shulker_Missile extends VectorAbility implements Listener {
public Shulker_Missile() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK,
CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("cooldown", 12);
addModifier("damage", 5);
@ -41,7 +41,7 @@ public class Shulker_Missile extends VectorAbility implements Listener {
}
@Override
public void whenCast(ItemAttackMetadata attack, VectorAbilityMetadata ability) {
public void whenCast(AttackMetadata attack, VectorAbilityMetadata ability) {
double duration = ability.getModifier("duration");
new BukkitRunnable() {
@ -54,10 +54,10 @@ public class Shulker_Missile extends VectorAbility implements Listener {
}
Vector vec = ability.getTarget();
attack.getDamager().getWorld().playSound(attack.getDamager().getLocation(), Sound.ENTITY_WITHER_SHOOT, 2, 2);
ShulkerBullet shulkerBullet = (ShulkerBullet) attack.getDamager().getWorld().spawnEntity(attack.getDamager().getLocation().add(0, 1, 0),
attack.getPlayer().getWorld().playSound(attack.getPlayer().getLocation(), Sound.ENTITY_WITHER_SHOOT, 2, 2);
ShulkerBullet shulkerBullet = (ShulkerBullet) attack.getPlayer().getWorld().spawnEntity(attack.getPlayer().getLocation().add(0, 1, 0),
EntityType.SHULKER_BULLET);
shulkerBullet.setShooter(attack.getDamager());
shulkerBullet.setShooter(attack.getPlayer());
ItemAttackMetadata attackMeta = new ItemAttackMetadata(new DamageMetadata(ability.getModifier("damage"), DamageType.SKILL, DamageType.MAGIC, DamageType.PROJECTILE), attack.getStats());
MMOItems.plugin.getEntities().registerCustomEntity(shulkerBullet, new ShulkerMissileEntityData(attackMeta, ability.getModifier("effect-duration")));
@ -86,7 +86,7 @@ public class Shulker_Missile extends VectorAbility implements Listener {
return;
ShulkerMissileEntityData data = (ShulkerMissileEntityData) MMOItems.plugin.getEntities().getEntityData(damager);
if (!MMOUtils.canTarget(data.attackMeta.getDamager(), null, entity, data.isWeaponAttack() ? InteractionType.OFFENSE_ACTION : InteractionType.OFFENSE_SKILL)) {
if (!MMOUtils.canTarget(data.attackMeta.getPlayer(), null, entity, data.isWeaponAttack() ? InteractionType.OFFENSE_ACTION : InteractionType.OFFENSE_SKILL)) {
event.setCancelled(true);
return;
}

View File

@ -1,10 +1,10 @@
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 net.Indyuce.mmoitems.api.ItemAttackMetadata;
import net.Indyuce.mmoitems.api.util.TemporaryListener;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.entity.EntityType;
@ -18,8 +18,7 @@ import org.bukkit.util.Vector;
public class TNT_Throw extends VectorAbility implements Listener {
public TNT_Throw() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK,
CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("cooldown", 10);
addModifier("force", 1);
@ -28,14 +27,14 @@ public class TNT_Throw extends VectorAbility implements Listener {
}
@Override
public void whenCast(ItemAttackMetadata attack, VectorAbilityMetadata ability) {
public void whenCast(AttackMetadata attack, VectorAbilityMetadata ability) {
Vector vec = ability.getTarget().multiply(2 * ability.getModifier("force"));
TNTPrimed tnt = (TNTPrimed) attack.getDamager().getWorld().spawnEntity(attack.getDamager().getLocation().add(0, 1, 0), EntityType.PRIMED_TNT);
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.getDamager(), tnt);
attack.getDamager().getWorld().playSound(attack.getDamager().getLocation(), Sound.ENTITY_SNOWBALL_THROW, 1, 0);
attack.getDamager().getWorld().spawnParticle(Particle.EXPLOSION_NORMAL, attack.getDamager().getLocation().add(0, 1, 0), 12, 0, 0, 0, .1);
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);
}
/*

View File

@ -6,7 +6,7 @@ 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 net.Indyuce.mmoitems.api.ItemAttackMetadata;
import io.lumine.mythic.lib.damage.AttackMetadata;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.Sound;
@ -18,7 +18,7 @@ import org.bukkit.util.Vector;
public class Thrust extends VectorAbility {
public Thrust() {
super(CastingMode.ON_HIT, CastingMode.WHEN_HIT, CastingMode.LEFT_CLICK, CastingMode.RIGHT_CLICK, CastingMode.SHIFT_LEFT_CLICK, CastingMode.SHIFT_RIGHT_CLICK);
super();
addModifier("cooldown", 10);
addModifier("damage", 6);
@ -27,18 +27,18 @@ public class Thrust extends VectorAbility {
}
@Override
public void whenCast(ItemAttackMetadata attack, VectorAbilityMetadata ability) {
public void whenCast(AttackMetadata attack, VectorAbilityMetadata ability) {
double damage = ability.getModifier("damage");
attack.getDamager().getWorld().playSound(attack.getDamager().getLocation(), Sound.ENTITY_ZOMBIE_ATTACK_IRON_DOOR, 1, 0);
attack.getDamager().addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 2, 3));
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.getDamager().getEyeLocation().clone();
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.getDamager(), loc, entity))
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

@ -50,10 +50,10 @@ public enum Element {
WIND(Material.FEATHER, ChatColor.GRAY, new ElementParticle(Particle.EXPLOSION_NORMAL, .06f, 8), (attack, target, damage, absolute) -> {
target.getWorld().playSound(target.getLocation(), VersionSound.ENTITY_ENDER_DRAGON_GROWL.toSound(), 2, 2f);
Vector vec = target.getLocation().subtract(attack.getDamager().getLocation()).toVector().normalize().multiply(1.7).setY(.5);
Vector vec = target.getLocation().subtract(attack.getPlayer().getLocation()).toVector().normalize().multiply(1.7).setY(.5);
target.setVelocity(vec);
for (Entity entity : target.getNearbyEntities(3, 1, 3))
if (MMOUtils.canTarget(attack.getDamager(), entity, InteractionType.OFFENSE_ACTION)) {
if (MMOUtils.canTarget(attack.getPlayer(), entity, InteractionType.OFFENSE_ACTION)) {
entity.playEffect(EntityEffect.HURT);
entity.setVelocity(vec);
}
@ -72,14 +72,14 @@ public enum Element {
target.setVelocity(new Vector(0, 1, 0));
for (Entity entity : target.getNearbyEntities(3, 1, 3))
if (MMOUtils.canTarget(attack.getDamager(), entity, InteractionType.OFFENSE_ACTION))
if (MMOUtils.canTarget(attack.getPlayer(), entity, InteractionType.OFFENSE_ACTION))
entity.setVelocity(new Vector(0, 1, 0));
}, 29, 33),
THUNDER(VersionMaterial.GUNPOWDER.toMaterial(), ChatColor.YELLOW, new ElementParticle(Particle.FIREWORKS_SPARK, .05f, 8), (attack, target, damage, absolute) -> {
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.getDamager(), entity, InteractionType.OFFENSE_ACTION))
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);
attack.getDamage().add(absolute);

View File

@ -25,7 +25,7 @@ public class ItemAttackMetadata extends AttackMetadata {
}
public PlayerData getPlayerData() {
return PlayerData.get(getDamager().getUniqueId());
return PlayerData.get(getPlayer().getUniqueId());
}
/**
@ -47,7 +47,6 @@ public class ItemAttackMetadata extends AttackMetadata {
* @return The unedited attack result
*/
public ItemAttackMetadata applyEffects(NBTItem item, LivingEntity target) {
applyOnHitEffects(target);
if (getDamage().hasType(DamageType.WEAPON))
applyElementalEffects(item, target);
return this;
@ -65,17 +64,4 @@ public class ItemAttackMetadata extends AttackMetadata {
new ElementalAttack(item, this, target).apply();
return this;
}
/**
* This method is called when a player uses ANY weapon, vanilla or custom.
* It does not take into input any weapon as it just applies non weapon
* specific on-hit effects
*
* @param target The entity target
* @return The unedited attack result
*/
public ItemAttackMetadata applyOnHitEffects(LivingEntity target) {
getPlayerData().castAbilities(this, target, Ability.CastingMode.ON_HIT);
return this;
}
}

View File

@ -2,7 +2,7 @@ package net.Indyuce.mmoitems.api;
import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.api.item.NBTItem;
import io.lumine.mythic.lib.api.player.EquipmentSlot;
import io.lumine.mythic.lib.player.EquipmentSlot;
import io.lumine.mythic.lib.api.util.ui.SilentNumbers;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.item.util.identify.UnidentifiedItem;

View File

@ -30,7 +30,7 @@ public enum TypeSet {
return;
damager.applyCooldown(CooldownType.SET_TYPE_ATTACK, MMOItems.plugin.getConfig().getDouble("item-ability.slashing.cooldown"));
Location loc = attack.getDamager().getLocation().clone().add(0, 1.3, 0);
Location loc = attack.getPlayer().getLocation().clone().add(0, 1.3, 0);
final double a1 = (loc.getYaw() + 90) / 180 * Math.PI, p = -loc.getPitch() / 180 * Math.PI;
for (double r = 1; r < 5; r += .3)
@ -39,9 +39,9 @@ public enum TypeSet {
for (Entity entity : MMOUtils.getNearbyChunkEntities(loc))
if (entity.getLocation().distanceSquared(loc) < 40
&& attack.getDamager().getEyeLocation().getDirection()
.angle(entity.getLocation().subtract(attack.getDamager().getLocation()).toVector()) < Math.PI / 3
&& MMOUtils.canTarget(attack.getDamager(), entity, InteractionType.OFFENSE_ACTION) && !entity.equals(target)) {
&& 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());
subAttack.getDamage().multiply(.4);
subAttack.applyEffectsAndDamage(weapon.getNBTItem(), (LivingEntity) entity);
@ -59,7 +59,7 @@ public enum TypeSet {
return;
damager.applyCooldown(CooldownType.SET_TYPE_ATTACK, MMOItems.plugin.getConfig().getDouble("item-ability.piercing.cooldown"));
Location loc = attack.getDamager().getLocation().clone().add(0, 1.3, 0);
Location loc = attack.getPlayer().getLocation().clone().add(0, 1.3, 0);
final double a1 = (loc.getYaw() + 90) / 180 * Math.PI, p = -loc.getPitch() / 180 * Math.PI;
for (double r = 1; r < 5; r += .3)
@ -67,10 +67,10 @@ public enum TypeSet {
loc.getWorld().spawnParticle(Particle.CRIT, loc.clone().add(Math.cos(a + a1) * r, Math.sin(p) * r, Math.sin(a + a1) * r), 0);
for (Entity entity : MMOUtils.getNearbyChunkEntities(loc))
if (entity.getLocation().distanceSquared(attack.getDamager().getLocation()) < 40
&& attack.getDamager().getEyeLocation().getDirection()
.angle(entity.getLocation().toVector().subtract(attack.getDamager().getLocation().toVector())) < Math.PI / 18
&& MMOUtils.canTarget(attack.getDamager(), entity, InteractionType.OFFENSE_ACTION) && !entity.equals(target)) {
if (entity.getLocation().distanceSquared(attack.getPlayer().getLocation()) < 40
&& 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());
subAttack.getDamage().multiply(.4);
subAttack.applyEffectsAndDamage(weapon.getNBTItem(), (LivingEntity) entity);
@ -96,7 +96,7 @@ public enum TypeSet {
double bluntRating = weapon.getValue(attack.getStats().getStat("BLUNT_RATING"),
MMOItems.plugin.getConfig().getDouble("default.blunt-rating")) / 100;
for (Entity entity : target.getNearbyEntities(bluntPower, bluntPower, bluntPower))
if (MMOUtils.canTarget(attack.getDamager(), entity, InteractionType.OFFENSE_ACTION) && !entity.equals(target)) {
if (MMOUtils.canTarget(attack.getPlayer(), entity, InteractionType.OFFENSE_ACTION) && !entity.equals(target)) {
ItemAttackMetadata subAttack = new ItemAttackMetadata(attack.getDamage().clone(), attack.getStats());
subAttack.getDamage().multiply(bluntRating);
subAttack.applyEffectsAndDamage(weapon.getNBTItem(), (LivingEntity) entity);

View File

@ -5,6 +5,7 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.api.item.NBTItem;
import io.lumine.mythic.lib.damage.AttackMetadata;
import net.Indyuce.mmoitems.api.ItemAttackMetadata;
import net.Indyuce.mmoitems.stat.data.PotionEffectData;
import org.bukkit.entity.LivingEntity;

View File

@ -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));
StatMap.CachedStatMap stats = getPlayerData().getStats().newTemporary(io.lumine.mythic.lib.player.EquipmentSlot.fromBukkit(slot));
if (!applyWeaponCosts(1 / getValue(stats.getStat("ATTACK_SPEED"), MMOItems.plugin.getConfig().getDouble("default.attack-speed")),
CooldownType.ATTACK))
return;

View File

@ -11,6 +11,7 @@ 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;
@ -36,7 +37,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));
StatMap.CachedStatMap stats = getPlayerData().getStats().newTemporary(io.lumine.mythic.lib.player.EquipmentSlot.fromBukkit(slot));
double attackSpeed = 1 / getValue(stats.getStat("ATTACK_SPEED"), MMOItems.plugin.getConfig().getDouble("default.attack-speed"));
if (!applyWeaponCosts(attackSpeed, CooldownType.ATTACK))
return;

View File

@ -10,6 +10,7 @@ import io.lumine.mythic.lib.damage.DamageType;
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;
@ -27,7 +28,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));
StatMap.CachedStatMap stats = getPlayerData().getStats().newTemporary(io.lumine.mythic.lib.player.EquipmentSlot.fromBukkit(slot));
if (!applyWeaponCosts(1 / getValue(stats.getStat("ATTACK_SPEED"), MMOItems.plugin.getConfig().getDouble("default.attack-speed")),
CooldownType.ATTACK))

View File

@ -11,6 +11,7 @@ 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;
@ -32,7 +33,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));
StatMap.CachedStatMap stats = getPlayerData().getStats().newTemporary(io.lumine.mythic.lib.player.EquipmentSlot.fromBukkit(slot));
if (!applyWeaponCosts(1 / getValue(stats.getStat("ATTACK_SPEED"), MMOItems.plugin.getConfig().getDouble("default.attack-speed")),
CooldownType.ATTACK))
return;

View File

@ -11,6 +11,7 @@ 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;
@ -28,7 +29,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));
StatMap.CachedStatMap stats = getPlayerData().getStats().newTemporary(io.lumine.mythic.lib.player.EquipmentSlot.fromBukkit(slot));
if (!applyWeaponCosts(1 / getValue(stats.getStat("ATTACK_SPEED"), MMOItems.plugin.getConfig().getDouble("default.attack-speed")),
CooldownType.ATTACK))
return;

View File

@ -8,6 +8,7 @@ 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 io.lumine.mythic.lib.damage.AttackMetadata;
import net.Indyuce.mmoitems.api.ItemAttackMetadata;
import net.Indyuce.mmoitems.api.util.SoundReader;
import net.Indyuce.mmoitems.stat.data.ProjectileParticlesData;
@ -25,8 +26,8 @@ public class BruteLuteAttack implements LuteAttackHandler {
@Override
public void handle(ItemAttackMetadata attack, NBTItem nbt, double attackDamage, double range, Vector weight, SoundReader sound) {
new BukkitRunnable() {
final Vector vec = attack.getDamager().getEyeLocation().getDirection().multiply(.4);
final Location loc = attack.getDamager().getEyeLocation();
final Vector vec = attack.getPlayer().getEyeLocation().getDirection().multiply(.4);
final Location loc = attack.getPlayer().getEyeLocation();
int ti = 0;
public void run() {
@ -49,10 +50,10 @@ public class BruteLuteAttack implements LuteAttackHandler {
double red = Double.parseDouble(String.valueOf(obj.get("Red")));
double green = Double.parseDouble(String.valueOf(obj.get("Green")));
double blue = Double.parseDouble(String.valueOf(obj.get("Blue")));
ProjectileParticlesData.shootParticle(attack.getDamager(), particle, loc, red, green, blue);
ProjectileParticlesData.shootParticle(attack.getPlayer(), particle, loc, red, green, blue);
// If it's not colored, just shoot the particle
} else {
ProjectileParticlesData.shootParticle(attack.getDamager(), particle, loc, 0, 0, 0);
ProjectileParticlesData.shootParticle(attack.getPlayer(), particle, loc, 0, 0, 0);
}
// If no particle has been provided via projectile particle attribute, default to this particle
} else
@ -61,7 +62,7 @@ public class BruteLuteAttack implements LuteAttackHandler {
if (j == 0) sound.play(loc, 2, (float) (.5 + (double) ti / range));
for (Entity target : entities)
if (MMOUtils.canTarget(attack.getDamager(), loc, target, InteractionType.OFFENSE_ACTION)) {
if (MMOUtils.canTarget(attack.getPlayer(), loc, target, InteractionType.OFFENSE_ACTION)) {
new ItemAttackMetadata(new DamageMetadata(attackDamage, DamageType.WEAPON, DamageType.PHYSICAL, DamageType.PROJECTILE), attack.getStats()).applyEffectsAndDamage(nbt, (LivingEntity) target);
cancel();
return;

View File

@ -8,6 +8,7 @@ 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 io.lumine.mythic.lib.damage.AttackMetadata;
import net.Indyuce.mmoitems.api.ItemAttackMetadata;
import net.Indyuce.mmoitems.api.util.SoundReader;
import net.Indyuce.mmoitems.stat.data.ProjectileParticlesData;
@ -25,8 +26,8 @@ public class CircularLuteAttack implements LuteAttackHandler {
@Override
public void handle(ItemAttackMetadata attack, NBTItem nbt, double attackDamage, double range, Vector weight, SoundReader sound) {
new BukkitRunnable() {
final Vector vec = attack.getDamager().getEyeLocation().getDirection().multiply(.4);
final Location loc = attack.getDamager().getEyeLocation();
final Vector vec = attack.getPlayer().getEyeLocation().getDirection().multiply(.4);
final Location loc = attack.getPlayer().getEyeLocation();
int ti = 0;
public void run() {
@ -52,12 +53,12 @@ public class CircularLuteAttack implements LuteAttackHandler {
double red = Double.parseDouble(String.valueOf(obj.get("Red")));
double green = Double.parseDouble(String.valueOf(obj.get("Green")));
double blue = Double.parseDouble(String.valueOf(obj.get("Blue")));
ProjectileParticlesData.shootParticle(attack.getDamager(), particle, loc.clone().add(vec), red, green, blue);
ProjectileParticlesData.shootParticle(attack.getDamager(), particle, loc.clone().add(vec.multiply(-1)), red, green, blue);
ProjectileParticlesData.shootParticle(attack.getPlayer(), particle, loc.clone().add(vec), red, green, blue);
ProjectileParticlesData.shootParticle(attack.getPlayer(), particle, loc.clone().add(vec.multiply(-1)), red, green, blue);
// If it's not colored, just shoot the particle
} else {
ProjectileParticlesData.shootParticle(attack.getDamager(), particle, loc.clone().add(vec), 0, 0, 0);
ProjectileParticlesData.shootParticle(attack.getDamager(), particle, loc.clone().add(vec.multiply(-1)), 0, 0, 0);
ProjectileParticlesData.shootParticle(attack.getPlayer(), particle, loc.clone().add(vec), 0, 0, 0);
ProjectileParticlesData.shootParticle(attack.getPlayer(), particle, loc.clone().add(vec.multiply(-1)), 0, 0, 0);
}
// If no particle has been provided via projectile particle attribute, default to this particle
} else {
@ -68,7 +69,7 @@ public class CircularLuteAttack implements LuteAttackHandler {
if (j == 0) sound.play(loc, 2, (float) (.5 + (double) ti / range));
for (Entity target : entities)
if (MMOUtils.canTarget(attack.getDamager(), loc, target, InteractionType.OFFENSE_ACTION)) {
if (MMOUtils.canTarget(attack.getPlayer(), loc, target, InteractionType.OFFENSE_ACTION)) {
new ItemAttackMetadata(new DamageMetadata(attackDamage, DamageType.WEAPON, DamageType.PROJECTILE), attack.getStats()).applyEffectsAndDamage(nbt, (LivingEntity) target);
cancel();
return;

View File

@ -1,6 +1,7 @@
package net.Indyuce.mmoitems.api.interaction.weapon.untargeted.lute;
import io.lumine.mythic.lib.api.item.NBTItem;
import io.lumine.mythic.lib.damage.AttackMetadata;
import net.Indyuce.mmoitems.api.ItemAttackMetadata;
import net.Indyuce.mmoitems.api.util.SoundReader;
import org.bukkit.util.Vector;

View File

@ -8,6 +8,7 @@ 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 io.lumine.mythic.lib.damage.AttackMetadata;
import net.Indyuce.mmoitems.api.ItemAttackMetadata;
import net.Indyuce.mmoitems.api.util.SoundReader;
import net.Indyuce.mmoitems.stat.data.ProjectileParticlesData;
@ -25,8 +26,8 @@ public class SimpleLuteAttack implements LuteAttackHandler {
@Override
public void handle(ItemAttackMetadata attack, NBTItem nbt, double attackDamage, double range, Vector weight, SoundReader sound) {
new BukkitRunnable() {
final Vector vec = attack.getDamager().getEyeLocation().getDirection().multiply(.4);
final Location loc = attack.getDamager().getEyeLocation();
final Vector vec = attack.getPlayer().getEyeLocation().getDirection().multiply(.4);
final Location loc = attack.getPlayer().getEyeLocation();
int ti = 0;
public void run() {
@ -48,10 +49,10 @@ public class SimpleLuteAttack implements LuteAttackHandler {
double red = Double.parseDouble(String.valueOf(obj.get("Red")));
double green = Double.parseDouble(String.valueOf(obj.get("Green")));
double blue = Double.parseDouble(String.valueOf(obj.get("Blue")));
ProjectileParticlesData.shootParticle(attack.getDamager(), particle, loc, red, green, blue);
ProjectileParticlesData.shootParticle(attack.getPlayer(), particle, loc, red, green, blue);
// If it's not colored, just shoot the particle
} else {
ProjectileParticlesData.shootParticle(attack.getDamager(), particle, loc, 0, 0, 0);
ProjectileParticlesData.shootParticle(attack.getPlayer(), particle, loc, 0, 0, 0);
}
// If no particle has been provided via projectile particle attribute, default to this particle
} else {
@ -61,7 +62,7 @@ public class SimpleLuteAttack implements LuteAttackHandler {
if (j == 0) sound.play(loc, 2, (float) (.5 + (double) ti / range));
for (Entity target : entities)
if (MMOUtils.canTarget(attack.getDamager(), loc, target, InteractionType.OFFENSE_ACTION)) {
if (MMOUtils.canTarget(attack.getPlayer(), loc, target, InteractionType.OFFENSE_ACTION)) {
new ItemAttackMetadata(new DamageMetadata(attackDamage, DamageType.WEAPON, DamageType.PROJECTILE), attack.getStats()).applyEffectsAndDamage(nbt, (LivingEntity) target);
cancel();
return;

View File

@ -8,6 +8,7 @@ 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 io.lumine.mythic.lib.damage.AttackMetadata;
import net.Indyuce.mmoitems.api.ItemAttackMetadata;
import net.Indyuce.mmoitems.api.util.SoundReader;
import net.Indyuce.mmoitems.stat.data.ProjectileParticlesData;
@ -23,8 +24,8 @@ public class SlashLuteAttack implements LuteAttackHandler {
@Override
public void handle(ItemAttackMetadata attack, NBTItem nbt, double attackDamage, double range, Vector weight, SoundReader sound) {
new BukkitRunnable() {
final Vector vec = attack.getDamager().getEyeLocation().getDirection();
final Location loc = attack.getDamager().getLocation().add(0, 1.3, 0);
final Vector vec = attack.getPlayer().getEyeLocation().getDirection();
final Location loc = attack.getPlayer().getLocation().add(0, 1.3, 0);
double ti = 1;
public void run() {
@ -35,7 +36,7 @@ public class SlashLuteAttack implements LuteAttackHandler {
if (random.nextBoolean()) {
loc.setDirection(vec);
loc.setYaw(loc.getYaw() + k);
loc.setPitch(attack.getDamager().getEyeLocation().getPitch());
loc.setPitch(attack.getPlayer().getEyeLocation().getPitch());
if (nbt.hasTag("MMOITEMS_PROJECTILE_PARTICLES")) {
JsonObject obj = MythicLib.plugin.getJson().parse(nbt.getString("MMOITEMS_PROJECTILE_PARTICLES"), JsonObject.class);
@ -45,10 +46,10 @@ public class SlashLuteAttack implements LuteAttackHandler {
double red = Double.parseDouble(String.valueOf(obj.get("Red")));
double green = Double.parseDouble(String.valueOf(obj.get("Green")));
double blue = Double.parseDouble(String.valueOf(obj.get("Blue")));
ProjectileParticlesData.shootParticle(attack.getDamager(), particle, loc.clone().add(loc.getDirection().multiply(1.5 * ti)), red, green, blue);
ProjectileParticlesData.shootParticle(attack.getPlayer(), particle, loc.clone().add(loc.getDirection().multiply(1.5 * ti)), red, green, blue);
// If it's not colored, just shoot the particle
} else {
ProjectileParticlesData.shootParticle(attack.getDamager(), particle, loc.clone().add(loc.getDirection().multiply(1.5 * ti)), 0, 0, 0);
ProjectileParticlesData.shootParticle(attack.getPlayer(), particle, loc.clone().add(loc.getDirection().multiply(1.5 * ti)), 0, 0, 0);
}
// If no particle has been provided via projectile particle attribute, default to this particle
} else {
@ -58,8 +59,8 @@ public class SlashLuteAttack implements LuteAttackHandler {
}
}.runTaskTimer(MMOItems.plugin, 0, 1);
for (Entity entity : MMOUtils.getNearbyChunkEntities(attack.getDamager().getLocation()))
if (entity.getLocation().distanceSquared(attack.getDamager().getLocation()) < 40 && attack.getDamager().getEyeLocation().getDirection().angle(entity.getLocation().toVector().subtract(attack.getDamager().getLocation().toVector())) < Math.PI / 6 && MMOUtils.canTarget(attack.getDamager(), entity, InteractionType.OFFENSE_ACTION))
for (Entity entity : MMOUtils.getNearbyChunkEntities(attack.getPlayer().getLocation()))
if (entity.getLocation().distanceSquared(attack.getPlayer().getLocation()) < 40 && attack.getPlayer().getEyeLocation().getDirection().angle(entity.getLocation().toVector().subtract(attack.getPlayer().getLocation().toVector())) < Math.PI / 6 && MMOUtils.canTarget(attack.getPlayer(), entity, InteractionType.OFFENSE_ACTION))
new ItemAttackMetadata(new DamageMetadata(attackDamage, DamageType.WEAPON, DamageType.PROJECTILE), attack.getStats()).applyEffectsAndDamage(nbt, (LivingEntity) entity);
}
}

View File

@ -8,6 +8,7 @@ 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 io.lumine.mythic.lib.damage.AttackMetadata;
import net.Indyuce.mmoitems.api.ItemAttackMetadata;
import net.Indyuce.mmoitems.api.util.SoundReader;
import net.Indyuce.mmoitems.stat.data.ProjectileParticlesData;
@ -25,8 +26,8 @@ public class WaveLuteAttack implements LuteAttackHandler {
@Override
public void handle(ItemAttackMetadata attack, NBTItem nbt, double attackDamage, double range, Vector weight, SoundReader sound) {
new BukkitRunnable() {
final Vector vec = attack.getDamager().getEyeLocation().getDirection().multiply(.4);
final Location loc = attack.getDamager().getEyeLocation();
final Vector vec = attack.getPlayer().getEyeLocation().getDirection().multiply(.4);
final Location loc = attack.getPlayer().getEyeLocation();
int ti = 0;
public void run() {
@ -50,12 +51,12 @@ public class WaveLuteAttack implements LuteAttackHandler {
double red = Double.parseDouble(String.valueOf(obj.get("Red")));
double green = Double.parseDouble(String.valueOf(obj.get("Green")));
double blue = Double.parseDouble(String.valueOf(obj.get("Blue")));
ProjectileParticlesData.shootParticle(attack.getDamager(), particle, loc.clone().add(vec.multiply(Math.sin((double) ti / 2))), red, green, blue);
ProjectileParticlesData.shootParticle(attack.getDamager(), particle, loc.clone().add(vec.multiply(-1)), red, green, blue);
ProjectileParticlesData.shootParticle(attack.getPlayer(), particle, loc.clone().add(vec.multiply(Math.sin((double) ti / 2))), red, green, blue);
ProjectileParticlesData.shootParticle(attack.getPlayer(), particle, loc.clone().add(vec.multiply(-1)), red, green, blue);
// If it's not colored, just shoot the particle
} else {
ProjectileParticlesData.shootParticle(attack.getDamager(), particle, loc.clone().add(vec.multiply(Math.sin((double) ti / 2))), 0, 0, 0);
ProjectileParticlesData.shootParticle(attack.getDamager(), particle, loc.clone().add(vec.multiply(-1)), 0, 0, 0);
ProjectileParticlesData.shootParticle(attack.getPlayer(), particle, loc.clone().add(vec.multiply(Math.sin((double) ti / 2))), 0, 0, 0);
ProjectileParticlesData.shootParticle(attack.getPlayer(), particle, loc.clone().add(vec.multiply(-1)), 0, 0, 0);
}
// If no particle has been provided via projectile particle attribute, default to this particle
} else {
@ -66,7 +67,7 @@ public class WaveLuteAttack implements LuteAttackHandler {
if (j == 0) sound.play(loc, 2, (float) (.5 + (double) ti / range));
for (Entity target : entities)
if (MMOUtils.canTarget(attack.getDamager(), loc, target, InteractionType.OFFENSE_ACTION)) {
if (MMOUtils.canTarget(attack.getPlayer(), loc, target, InteractionType.OFFENSE_ACTION)) {
new ItemAttackMetadata(new DamageMetadata(attackDamage, DamageType.WEAPON, DamageType.PROJECTILE), attack.getStats()).applyEffectsAndDamage(nbt, (LivingEntity) target);
cancel();
return;

View File

@ -14,15 +14,15 @@ public class LightningSpirit implements StaffAttackHandler {
@Override
public void handle(ItemAttackMetadata attackMeta, NBTItem nbt, double range) {
attackMeta.getDamager().getWorld().playSound(attackMeta.getDamager().getLocation(), VersionSound.ENTITY_FIREWORK_ROCKET_BLAST.toSound(), 2, 2);
attackMeta.getPlayer().getWorld().playSound(attackMeta.getPlayer().getLocation(), VersionSound.ENTITY_FIREWORK_ROCKET_BLAST.toSound(), 2, 2);
Location loc = attackMeta.getDamager().getEyeLocation();
MMORayTraceResult trace = MythicLib.plugin.getVersion().getWrapper().rayTrace(attackMeta.getDamager(), range,
entity -> MMOUtils.canTarget(attackMeta.getDamager(), entity, InteractionType.OFFENSE_ACTION));
Location loc = attackMeta.getPlayer().getEyeLocation();
MMORayTraceResult trace = MythicLib.plugin.getVersion().getWrapper().rayTrace(attackMeta.getPlayer(), range,
entity -> MMOUtils.canTarget(attackMeta.getPlayer(), entity, InteractionType.OFFENSE_ACTION));
if (trace.hasHit())
attackMeta.applyEffectsAndDamage(nbt, trace.getHit());
trace.draw(loc, attackMeta.getDamager().getEyeLocation().getDirection(), 2,
trace.draw(loc, attackMeta.getPlayer().getEyeLocation().getDirection(), 2,
loc1 -> loc1.getWorld().spawnParticle(Particle.FIREWORKS_SPARK, loc1, 0));
}
}

View File

@ -21,8 +21,8 @@ public class ManaSpirit implements StaffAttackHandler {
@Override
public void handle(ItemAttackMetadata attackMeta, NBTItem nbt, double range) {
new BukkitRunnable() {
final Vector vec = attackMeta.getDamager().getEyeLocation().getDirection().multiply(.4);
final Location loc = attackMeta.getDamager().getEyeLocation();
final Vector vec = attackMeta.getPlayer().getEyeLocation().getDirection().multiply(.4);
final Location loc = attackMeta.getPlayer().getEyeLocation();
int ti = 0;
final double r = .2;
@ -46,7 +46,7 @@ public class ManaSpirit implements StaffAttackHandler {
loc.getWorld().spawnParticle(Particle.REDSTONE, loc.clone().add(vec), 1, new Particle.DustOptions(Color.AQUA, 1));
}
for (Entity target : targets)
if (MMOUtils.canTarget(attackMeta.getDamager(), loc, target, InteractionType.OFFENSE_ACTION)) {
if (MMOUtils.canTarget(attackMeta.getPlayer(), loc, target, InteractionType.OFFENSE_ACTION)) {
attackMeta.applyEffectsAndDamage(nbt, (LivingEntity) target);
loc.getWorld().spawnParticle(Particle.EXPLOSION_LARGE, loc, 0);
cancel();

View File

@ -20,8 +20,8 @@ public class NetherSpirit implements StaffAttackHandler {
@Override
public void handle(ItemAttackMetadata attackMeta, NBTItem nbt, double range) {
new BukkitRunnable() {
final Vector vec = attackMeta.getDamager().getEyeLocation().getDirection().multiply(.3);
final Location loc = attackMeta.getDamager().getEyeLocation();
final Vector vec = attackMeta.getPlayer().getEyeLocation().getDirection().multiply(.3);
final Location loc = attackMeta.getPlayer().getEyeLocation();
int ti = 0;
public void run() {
@ -38,7 +38,7 @@ public class NetherSpirit implements StaffAttackHandler {
loc.getWorld().spawnParticle(Particle.FLAME, loc, 2, .07, .07, .07, 0);
loc.getWorld().spawnParticle(Particle.SMOKE_NORMAL, loc, 0);
for (Entity target : targets)
if (MMOUtils.canTarget(attackMeta.getDamager(), loc, target, InteractionType.OFFENSE_ACTION)) {
if (MMOUtils.canTarget(attackMeta.getPlayer(), loc, target, InteractionType.OFFENSE_ACTION)) {
attackMeta.applyEffectsAndDamage(nbt, (LivingEntity) target);
loc.getWorld().spawnParticle(Particle.EXPLOSION_LARGE, loc, 0);
cancel();

View File

@ -18,9 +18,9 @@ public class SunfireSpirit implements StaffAttackHandler {
@Override
public void handle(ItemAttackMetadata attackMeta, NBTItem nbt, double range) {
attackMeta.getDamager().getWorld().playSound(attackMeta.getDamager().getLocation(), Sound.ENTITY_WITHER_SHOOT, 2, 2);
attackMeta.getPlayer().getWorld().playSound(attackMeta.getPlayer().getLocation(), Sound.ENTITY_WITHER_SHOOT, 2, 2);
new BukkitRunnable() {
final Location target = getGround(attackMeta.getDamager().getTargetBlock(null, (int) range * 2).getLocation()).add(0, 1.2, 0);
final Location target = getGround(attackMeta.getPlayer().getTargetBlock(null, (int) range * 2).getLocation()).add(0, 1.2, 0);
final double a = random.nextDouble() * Math.PI * 2;
final Location loc = target.clone().add(Math.cos(a) * 4, 10, Math.sin(a) * 4);
final Vector vec = target.toVector().subtract(loc.toVector()).multiply(.015);
@ -38,7 +38,7 @@ public class SunfireSpirit implements StaffAttackHandler {
loc.getWorld().spawnParticle(Particle.EXPLOSION_LARGE, loc, 0);
loc.getWorld().playSound(loc, VersionSound.ENTITY_FIREWORK_ROCKET_BLAST.toSound(), 2, 2);
for (Entity target : MMOUtils.getNearbyChunkEntities(loc))
if (MMOUtils.canTarget(attackMeta.getDamager(), target, InteractionType.OFFENSE_ACTION) && target.getLocation().distanceSquared(loc) <= 9)
if (MMOUtils.canTarget(attackMeta.getPlayer(), target, InteractionType.OFFENSE_ACTION) && target.getLocation().distanceSquared(loc) <= 9)
attackMeta.applyEffectsAndDamage(nbt, (LivingEntity) target);
cancel();
break;

View File

@ -18,9 +18,9 @@ public class ThunderSpirit implements StaffAttackHandler {
@Override
public void handle(ItemAttackMetadata attackMeta, NBTItem nbt, double range) {
attackMeta.getDamager().getWorld().playSound(attackMeta.getDamager().getLocation(), Sound.ENTITY_WITHER_SHOOT, 2, 2);
attackMeta.getPlayer().getWorld().playSound(attackMeta.getPlayer().getLocation(), Sound.ENTITY_WITHER_SHOOT, 2, 2);
new BukkitRunnable() {
final Location target = getGround(attackMeta.getDamager().getTargetBlock(null, (int) range * 2).getLocation()).add(0, 1.2, 0);
final Location target = getGround(attackMeta.getPlayer().getTargetBlock(null, (int) range * 2).getLocation()).add(0, 1.2, 0);
final double a = random.nextDouble() * Math.PI * 2;
final Location loc = target.clone().add(Math.cos(a) * 4, 10, Math.sin(a) * 4);
final Vector vec = target.toVector().subtract(loc.toVector()).multiply(.015);
@ -36,7 +36,7 @@ public class ThunderSpirit implements StaffAttackHandler {
loc.getWorld().spawnParticle(Particle.FIREWORKS_SPARK, loc, 24, 0, 0, 0, .12);
loc.getWorld().playSound(loc, VersionSound.ENTITY_FIREWORK_ROCKET_BLAST.toSound(), 2, 2);
for (Entity target : MMOUtils.getNearbyChunkEntities(loc))
if (MMOUtils.canTarget(attackMeta.getDamager(), target, InteractionType.OFFENSE_ACTION) && target.getLocation().distanceSquared(loc) <= 9)
if (MMOUtils.canTarget(attackMeta.getPlayer(), target, InteractionType.OFFENSE_ACTION) && target.getLocation().distanceSquared(loc) <= 9)
attackMeta.applyEffectsAndDamage(nbt, (LivingEntity) target);
cancel();
}

View File

@ -14,10 +14,10 @@ public class VoidSpirit implements StaffAttackHandler {
@Override
public void handle(ItemAttackMetadata attackMeta, NBTItem nbt, double range) {
Vector vec = attackMeta.getDamager().getEyeLocation().getDirection();
attackMeta.getDamager().getWorld().playSound(attackMeta.getDamager().getLocation(), Sound.ENTITY_WITHER_SHOOT, 2, 2);
ShulkerBullet shulkerBullet = (ShulkerBullet) attackMeta.getDamager().getWorld().spawnEntity(attackMeta.getDamager().getLocation().add(0, 1, 0), EntityType.valueOf("SHULKER_BULLET"));
shulkerBullet.setShooter(attackMeta.getDamager());
Vector vec = attackMeta.getPlayer().getEyeLocation().getDirection();
attackMeta.getPlayer().getWorld().playSound(attackMeta.getPlayer().getLocation(), Sound.ENTITY_WITHER_SHOOT, 2, 2);
ShulkerBullet shulkerBullet = (ShulkerBullet) attackMeta.getPlayer().getWorld().spawnEntity(attackMeta.getPlayer().getLocation().add(0, 1, 0), EntityType.valueOf("SHULKER_BULLET"));
shulkerBullet.setShooter(attackMeta.getPlayer());
new BukkitRunnable() {
double ti = 0;

View File

@ -15,15 +15,15 @@ public class XRaySpirit implements StaffAttackHandler {
@Override
public void handle(ItemAttackMetadata attackMeta, NBTItem nbt, double range) {
attackMeta.getDamager().getWorld().playSound(attackMeta.getDamager().getLocation(), Sound.BLOCK_FIRE_EXTINGUISH, 2, 2);
attackMeta.getPlayer().getWorld().playSound(attackMeta.getPlayer().getLocation(), Sound.BLOCK_FIRE_EXTINGUISH, 2, 2);
double a = Math.toRadians(attackMeta.getDamager().getEyeLocation().getYaw() + 160);
Location loc = attackMeta.getDamager().getEyeLocation().add(new Vector(Math.cos(a), 0, Math.sin(a)).multiply(.5));
double a = Math.toRadians(attackMeta.getPlayer().getEyeLocation().getYaw() + 160);
Location loc = attackMeta.getPlayer().getEyeLocation().add(new Vector(Math.cos(a), 0, Math.sin(a)).multiply(.5));
MMORayTraceResult trace = MythicLib.plugin.getVersion().getWrapper().rayTrace(attackMeta.getDamager(), range, entity -> MMOUtils.canTarget(attackMeta.getDamager(), entity, InteractionType.OFFENSE_ACTION));
MMORayTraceResult trace = MythicLib.plugin.getVersion().getWrapper().rayTrace(attackMeta.getPlayer(), range, entity -> MMOUtils.canTarget(attackMeta.getPlayer(), entity, InteractionType.OFFENSE_ACTION));
if (trace.hasHit())
attackMeta.applyEffectsAndDamage(nbt, trace.getHit());
trace.draw(loc, attackMeta.getDamager().getEyeLocation().getDirection(), 2, Color.BLACK);
attackMeta.getDamager().getWorld().playSound(attackMeta.getDamager().getLocation(), Sound.ENTITY_ZOMBIE_ATTACK_IRON_DOOR, 0.40f, 2);
trace.draw(loc, attackMeta.getPlayer().getEyeLocation().getDirection(), 2, Color.BLACK);
attackMeta.getPlayer().getWorld().playSound(attackMeta.getPlayer().getLocation(), Sound.ENTITY_ZOMBIE_ATTACK_IRON_DOOR, 0.40f, 2);
}
}

Some files were not shown because too many files have changed in this diff Show More