Mineplex2018-withcommit/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkRepel.java

109 lines
3.0 KiB
Java
Raw Normal View History

2014-03-19 07:51:37 +01:00
package nautilus.game.arcade.kit.perks;
import java.util.HashMap;
import org.bukkit.Effect;
import org.bukkit.EntityEffect;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.recharge.Recharge;
import nautilus.game.arcade.kit.Perk;
public class PerkRepel extends Perk
{
public PerkRepel()
{
super("Holy Smite", new String[]
{
C.cYellow + "Right-Click" + C.cGray + " with Sword to " + C.cGreen + "Holy Smite"
});
}
@EventHandler
public void Leap(PlayerInteractEvent event)
{
if (event.isCancelled())
return;
if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK)
return;
if (UtilBlock.usable(event.getClickedBlock()))
return;
if (event.getPlayer().getItemInHand() == null)
return;
if (!event.getPlayer().getItemInHand().getType().toString().contains("_SWORD"))
return;
Player player = event.getPlayer();
if (!Kit.HasKit(player))
return;
if (!Recharge.Instance.use(player, GetName(), 10000, true))
return;
//Action
double range = 6;
HashMap<LivingEntity, Double> targets = UtilEnt.getInRadius(player.getLocation(), range);
for (LivingEntity cur : targets.keySet())
{
if (cur.equals(player))
continue;
if (cur instanceof Player)
{
Player other = (Player)cur;
if (!Manager.GetGame().IsAlive(other))
continue;
if (Manager.GetGame().GetTeam(other).equals(Manager.GetGame().GetTeam(player)))
continue;
}
cur.playEffect(EntityEffect.HURT);
//Velocity
UtilAction.velocity(cur,
UtilAlg.getTrajectory2d(player.getLocation().toVector(), cur.getLocation().toVector()),
1.8 * targets.get(cur), true, 0, 0.4 + 1.0 * targets.get(cur), 1.6, true);
//Condition
Manager.GetCondition().Factory().Falling(GetName(), cur, player, 10, false, true);
//Inform
if (cur instanceof Player)
UtilPlayer.message((Player)cur, F.main("Game", F.name(player.getName()) +" hit you with " + F.skill(GetName()) + "."));
}
//Effect
player.getWorld().playSound(player.getLocation(), Sound.ZOMBIE_UNFECT, 2f, 2f);
for (Block block : UtilBlock.getInRadius(player.getLocation(), 4d).keySet())
UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, block.getLocation().add(0.5, 0.5, 0.5), 0, 0, 0, 0, 1);
//Inform
UtilPlayer.message(player, F.main("Game", "You used " + F.skill(GetName()) + "."));
}
}