2013-08-31 05:15:16 +02:00
|
|
|
package nautilus.game.arcade.kit.perks;
|
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
|
|
|
import org.bukkit.Material;
|
|
|
|
import org.bukkit.Sound;
|
|
|
|
import org.bukkit.entity.Item;
|
|
|
|
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;
|
|
|
|
import mineplex.core.common.util.UtilMath;
|
|
|
|
import mineplex.core.common.util.UtilPlayer;
|
|
|
|
import mineplex.core.common.util.UtilServer;
|
|
|
|
import mineplex.core.itemstack.ItemStackFactory;
|
|
|
|
import mineplex.core.updater.UpdateType;
|
|
|
|
import mineplex.core.updater.event.UpdateEvent;
|
|
|
|
import nautilus.game.arcade.kit.Perk;
|
|
|
|
|
|
|
|
public class PerkInferno extends Perk
|
|
|
|
{
|
|
|
|
private HashMap<Player, Long> _active = new HashMap<Player, Long>();
|
|
|
|
|
|
|
|
public PerkInferno()
|
|
|
|
{
|
|
|
|
super("Inferno", new String[]
|
|
|
|
{
|
|
|
|
C.cYellow + "Hold Block" + C.cGray + " to use " + C.cGreen + "Inferno"
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2013-09-03 11:18:56 +02:00
|
|
|
@EventHandler
|
|
|
|
public void EnergyUpdate(UpdateEvent event)
|
|
|
|
{
|
|
|
|
if (event.getType() != UpdateType.TICK)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (Player player : Manager.GetGame().GetPlayers(true))
|
|
|
|
{
|
|
|
|
if (!Kit.HasKit(player))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
player.setExp((float) Math.min(0.999, player.getExp()+0.015));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-31 05:15:16 +02:00
|
|
|
@EventHandler
|
|
|
|
public void Activate(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().getType().toString().contains("_SWORD"))
|
|
|
|
return;
|
|
|
|
|
|
|
|
Player player = event.getPlayer();
|
|
|
|
|
|
|
|
if (!Kit.HasKit(player))
|
|
|
|
return;
|
|
|
|
|
|
|
|
_active.put(player, System.currentTimeMillis());
|
|
|
|
|
|
|
|
UtilPlayer.message(player, F.main("Skill", "You used " + F.skill("Inferno") + "."));
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void Update(UpdateEvent event)
|
|
|
|
{
|
|
|
|
if (event.getType() != UpdateType.TICK)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (Player cur : UtilServer.getPlayers())
|
|
|
|
{
|
|
|
|
if (!_active.containsKey(cur))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!cur.isBlocking())
|
|
|
|
{
|
|
|
|
_active.remove(cur);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2013-09-05 05:55:42 +02:00
|
|
|
cur.setExp(cur.getExp()-0.035f);
|
2013-09-03 11:18:56 +02:00
|
|
|
|
|
|
|
if (cur.getExp() <= 0)
|
2013-08-31 05:15:16 +02:00
|
|
|
{
|
|
|
|
_active.remove(cur);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Fire
|
|
|
|
Item fire = cur.getWorld().dropItem(cur.getEyeLocation(), ItemStackFactory.Instance.CreateStack(Material.FIRE));
|
|
|
|
Manager.GetFire().Add(fire, cur, 0.7, 0, 0.5, 1, "Inferno");
|
|
|
|
|
|
|
|
fire.teleport(cur.getEyeLocation());
|
|
|
|
double x = 0.07 - (UtilMath.r(14)/100d);
|
|
|
|
double y = 0.07 - (UtilMath.r(14)/100d);
|
|
|
|
double z = 0.07 - (UtilMath.r(14)/100d);
|
|
|
|
fire.setVelocity(cur.getLocation().getDirection().add(new Vector(x,y,z)).multiply(1.6));
|
|
|
|
|
|
|
|
//Effect
|
|
|
|
cur.getWorld().playSound(cur.getLocation(), Sound.GHAST_FIREBALL, 0.1f, 1f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|