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

113 lines
3.3 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;
2014-03-21 01:59:56 +01:00
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
2014-03-19 07:51:37 +01:00
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;
2014-03-21 01:59:56 +01:00
public class PerkSeismicSlamCS extends Perk
2014-03-19 07:51:37 +01:00
{
2014-03-21 01:59:56 +01:00
public PerkSeismicSlamCS()
2014-03-19 07:51:37 +01:00
{
2014-03-21 01:59:56 +01:00
super("Ground Pound", new String[]
2014-03-19 07:51:37 +01:00
{
2014-03-21 01:59:56 +01:00
C.cYellow + "Right-Click" + C.cGray + " with Axe to " + C.cGreen + "Ground Pound"
2014-03-19 07:51:37 +01:00
});
}
@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;
2014-03-21 01:59:56 +01:00
if (!event.getPlayer().getItemInHand().getType().toString().contains("_AXE"))
2014-03-19 07:51:37 +01:00
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())
{
2014-03-22 00:44:31 +01:00
if (!(cur instanceof Player))
return;
2014-03-19 07:51:37 +01:00
if (cur.equals(player))
continue;
2014-03-22 00:44:31 +01:00
Player other = (Player)cur;
if (!Manager.GetGame().IsAlive(other))
continue;
if (Manager.GetGame().GetTeam(other).equals(Manager.GetGame().GetTeam(player)))
continue;
2014-03-19 07:51:37 +01:00
2014-03-21 01:59:56 +01:00
//Damage Event
Manager.GetDamage().NewDamageEvent(cur, player, null,
DamageCause.CUSTOM, 8 * targets.get(cur) + 1, false, true, false,
player.getName(), GetName());
2014-03-19 07:51:37 +01:00
//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
2014-03-22 00:44:31 +01:00
player.getWorld().playSound(player.getLocation(), Sound.ZOMBIE_WOOD, 2f, 0.2f);
for (Block cur : UtilBlock.getInRadius(player.getLocation(), 4d).keySet())
if (UtilBlock.airFoliage(cur.getRelative(BlockFace.UP)) && !UtilBlock.airFoliage(cur))
cur.getWorld().playEffect(cur.getLocation(), Effect.STEP_SOUND, cur.getTypeId());
2014-03-19 07:51:37 +01:00
//Inform
UtilPlayer.message(player, F.main("Game", "You used " + F.skill(GetName()) + "."));
}
}