diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoweapons/effects/Effects.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoweapons/effects/Effects.java index 6dbe214..e794b11 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoweapons/effects/Effects.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoweapons/effects/Effects.java @@ -6,6 +6,7 @@ import com.google.common.collect.ImmutableList; import com.willfp.ecoweapons.effects.effects.EffectArrowStorm; import com.willfp.ecoweapons.effects.effects.EffectRailgun; import com.willfp.ecoweapons.effects.effects.EffectStrikeLightning; +import com.willfp.ecoweapons.effects.effects.EffectWarp; import lombok.experimental.UtilityClass; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -23,6 +24,7 @@ public class Effects { public static final Effect STRIKE_LIGHTNING = new EffectStrikeLightning(); public static final Effect RAILGUN = new EffectRailgun(); public static final Effect ARROW_STORM = new EffectArrowStorm(); + public static final Effect WARP = new EffectWarp(); /** * Get effect matching name. diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoweapons/effects/effects/EffectWarp.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoweapons/effects/effects/EffectWarp.java new file mode 100644 index 0000000..f2914f0 --- /dev/null +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoweapons/effects/effects/EffectWarp.java @@ -0,0 +1,59 @@ +package com.willfp.ecoweapons.effects.effects; + +import com.willfp.eco.core.config.interfaces.JSONConfig; +import com.willfp.ecoweapons.effects.Effect; +import org.bukkit.Location; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.util.RayTraceResult; +import org.jetbrains.annotations.NotNull; + +public class EffectWarp extends Effect { + public EffectWarp() { + super("warp"); + } + + @Override + public void handleMeleeAttack(@NotNull final Player player, + @NotNull final LivingEntity victim, + @NotNull final EntityDamageByEntityEvent event, + @NotNull final JSONConfig args) { + handle(player, victim.getLocation(), args); + } + + @Override + public void handleProjectileHitEntity(@NotNull final Player player, + @NotNull final LivingEntity victim, + @NotNull final Projectile projectile, + @NotNull final ProjectileHitEvent event, + @NotNull final JSONConfig args) { + handle(player, victim.getLocation(), args); + } + + @Override + public void handleProjectileHit(@NotNull final Player player, + @NotNull final Projectile projectile, + @NotNull final ProjectileHitEvent event, + @NotNull final JSONConfig args) { + handle(player, projectile.getLocation(), args); + } + + @Override + public void handleAltClick(@NotNull final Player player, + @NotNull final RayTraceResult blockRay, + @NotNull final RayTraceResult entityRay, + @NotNull final PlayerInteractEvent event, + @NotNull final JSONConfig args) { + handle(player, blockRay.getHitPosition().toLocation(player.getWorld()), args); + } + + private void handle(@NotNull final Player player, + @NotNull final Location location, + @NotNull final JSONConfig args) { + player.teleport(location); + } +}