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

96 lines
2.4 KiB
Java
Raw Normal View History

2014-11-14 04:14:31 +01:00
package nautilus.game.arcade.kit.perks;
import java.util.Iterator;
import java.util.WeakHashMap;
import org.bukkit.Sound;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilServer;
2014-11-14 04:14:31 +01:00
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
2014-11-14 04:14:31 +01:00
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.kit.Perk;
public class PerkWitherArrows extends Perk
{
private WeakHashMap<Arrow, Player> _proj = new WeakHashMap<Arrow, Player>();
public PerkWitherArrows()
{
super("Fire Storm", new String[]
{
C.cYellow + "Hold Block" + C.cGray + " to use " + C.cGreen + "Fire Storm"
});
}
@EventHandler
public void shoot(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
for (Player player : Manager.GetGame().GetPlayers(true))
{
if (!Kit.HasKit(player))
continue;
if (!player.isBlocking())
{
player.setExp((float) Math.min(0.999, player.getExp()+(1f/20f)));
2014-11-14 04:14:31 +01:00
}
else if (player.getExp() > 0)
{
player.setExp((float) Math.max(0, player.getExp()-(1f/20f)));
2014-11-14 04:14:31 +01:00
2014-11-21 06:32:12 +01:00
for (int i=0 ; i<2 ; i++)
2014-11-14 04:14:31 +01:00
{
Arrow arrow = player.getWorld().spawnArrow(
player.getEyeLocation().add(player.getLocation().getDirection()),
2014-11-15 09:31:56 +01:00
player.getLocation().getDirection(), 2, 6);
2014-11-14 04:14:31 +01:00
arrow.setShooter(player);
_proj.put(arrow, player);
}
//Effect
player.getWorld().playSound(player.getLocation(), Sound.FIZZ, 0.1f, 0.5f);
}
}
}
@EventHandler
public void update(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
Iterator<Arrow> arrowIter = _proj.keySet().iterator();
while (arrowIter.hasNext())
{
Arrow arrow = arrowIter.next();
2014-11-15 09:31:56 +01:00
if (!arrow.isValid() || arrow.getTicksLived() > 60 || arrow.getLocation().getY() < 0 || arrow.isOnGround())
2014-11-14 04:14:31 +01:00
{
arrow.remove();
arrowIter.remove();
2014-11-15 09:31:56 +01:00
UtilParticle.PlayParticle(ParticleType.LAVA, arrow.getLocation(), 0, 0, 0, 0, 1,
ViewDist.MAX, UtilServer.getPlayers());
2014-11-14 04:14:31 +01:00
}
else if (arrow.getTicksLived() > 1)
{
UtilParticle.PlayParticle(ParticleType.FLAME, arrow.getLocation(), 0, 0, 0, 0, 1,
ViewDist.MAX, UtilServer.getPlayers());
2014-11-14 04:14:31 +01:00
}
}
}
}