2013-08-27 17:14:08 +02:00
|
|
|
package nautilus.game.arcade.kit.perks;
|
|
|
|
|
2013-08-29 08:13:05 +02:00
|
|
|
import org.bukkit.Color;
|
2013-08-27 17:14:08 +02:00
|
|
|
import org.bukkit.Effect;
|
2013-08-29 08:13:05 +02:00
|
|
|
import org.bukkit.FireworkEffect;
|
2013-08-27 17:14:08 +02:00
|
|
|
import org.bukkit.Location;
|
|
|
|
import org.bukkit.Sound;
|
2013-08-29 08:13:05 +02:00
|
|
|
import org.bukkit.FireworkEffect.Type;
|
2013-08-27 17:14:08 +02:00
|
|
|
import org.bukkit.block.Block;
|
|
|
|
import org.bukkit.block.BlockFace;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.event.EventHandler;
|
|
|
|
import org.bukkit.event.block.Action;
|
|
|
|
import org.bukkit.event.player.PlayerInteractEvent;
|
|
|
|
import org.bukkit.util.Vector;
|
|
|
|
|
|
|
|
import mineplex.core.common.util.C;
|
|
|
|
import mineplex.core.common.util.F;
|
|
|
|
import mineplex.core.common.util.UtilBlock;
|
2014-10-25 02:03:45 +02:00
|
|
|
import mineplex.core.common.util.UtilFirework;
|
2013-08-27 17:14:08 +02:00
|
|
|
import mineplex.core.common.util.UtilPlayer;
|
|
|
|
import mineplex.core.recharge.Recharge;
|
|
|
|
import nautilus.game.arcade.kit.Perk;
|
|
|
|
|
|
|
|
public class PerkBlink extends Perk
|
|
|
|
{
|
|
|
|
private String _name = "";
|
|
|
|
private double _range;
|
|
|
|
private long _recharge;
|
|
|
|
|
|
|
|
public PerkBlink(String name, double range, long recharge)
|
|
|
|
{
|
|
|
|
super("Leaper", new String[]
|
|
|
|
{
|
2013-08-29 08:13:05 +02:00
|
|
|
C.cYellow + "Right-Click" + C.cGray + " with Axe to " + C.cGreen + name
|
2013-08-27 17:14:08 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
_name = name;
|
|
|
|
_range = range;
|
|
|
|
_recharge = recharge;
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler
|
2013-09-11 04:22:55 +02:00
|
|
|
public void Blink(PlayerInteractEvent event)
|
2013-08-27 17:14:08 +02:00
|
|
|
{
|
|
|
|
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("_AXE"))
|
|
|
|
return;
|
|
|
|
|
|
|
|
Player player = event.getPlayer();
|
|
|
|
|
|
|
|
if (!Kit.HasKit(player))
|
|
|
|
return;
|
|
|
|
|
2014-04-03 06:48:58 +02:00
|
|
|
if (!Recharge.Instance.use(player, _name, _recharge, true, true))
|
2013-08-27 17:14:08 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
//Smoke Trail
|
|
|
|
Block lastSmoke = player.getLocation().getBlock();
|
|
|
|
|
|
|
|
double curRange = 0;
|
|
|
|
while (curRange <= _range)
|
|
|
|
{
|
|
|
|
Location newTarget = player.getLocation().add(new Vector(0,0.2,0)).add(player.getLocation().getDirection().multiply(curRange));
|
|
|
|
|
|
|
|
if (!UtilBlock.airFoliage(newTarget.getBlock()) ||
|
|
|
|
!UtilBlock.airFoliage(newTarget.getBlock().getRelative(BlockFace.UP)))
|
|
|
|
break;
|
|
|
|
|
|
|
|
//Progress Forwards
|
|
|
|
curRange += 0.2;
|
|
|
|
|
|
|
|
//Smoke Trail
|
|
|
|
if (!lastSmoke.equals(newTarget.getBlock()))
|
2013-08-29 08:13:05 +02:00
|
|
|
{
|
2013-08-27 17:14:08 +02:00
|
|
|
lastSmoke.getWorld().playEffect(lastSmoke.getLocation(), Effect.SMOKE, 4);
|
2013-08-29 08:13:05 +02:00
|
|
|
}
|
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
lastSmoke = newTarget.getBlock();
|
|
|
|
}
|
|
|
|
|
|
|
|
//Modify Range
|
|
|
|
curRange -= 0.4;
|
|
|
|
if (curRange < 0)
|
|
|
|
curRange = 0;
|
|
|
|
|
|
|
|
//Destination
|
|
|
|
Location loc = player.getLocation().add(player.getLocation().getDirection().multiply(curRange).add(new Vector(0, 0.4, 0)));
|
|
|
|
|
|
|
|
if (curRange > 0)
|
2013-08-29 08:13:05 +02:00
|
|
|
{
|
|
|
|
//Firework
|
2014-10-25 02:03:45 +02:00
|
|
|
UtilFirework.playFirework(player.getEyeLocation(), Type.BALL, Color.BLACK, false, false);
|
2013-08-29 08:13:05 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
player.teleport(loc);
|
2013-08-29 08:13:05 +02:00
|
|
|
|
|
|
|
//Firework
|
2014-10-25 02:03:45 +02:00
|
|
|
UtilFirework.playFirework(player.getEyeLocation(), Type.BALL, Color.BLACK, false, false);
|
2013-08-29 08:13:05 +02:00
|
|
|
}
|
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
|
|
|
|
player.setFallDistance(0);
|
|
|
|
|
|
|
|
//Inform
|
|
|
|
UtilPlayer.message(player, F.main("Game", "You used " + F.skill(_name) + "."));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|