106 lines
2.7 KiB
Java
106 lines
2.7 KiB
Java
|
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.common.util.UtilTime;
|
||
|
import mineplex.core.itemstack.ItemStackFactory;
|
||
|
import mineplex.core.recharge.Recharge;
|
||
|
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"
|
||
|
});
|
||
|
}
|
||
|
|
||
|
@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;
|
||
|
|
||
|
if (!Recharge.Instance.use(player, "Inferno", 4000, true))
|
||
|
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;
|
||
|
}
|
||
|
|
||
|
if (UtilTime.elapsed(_active.get(cur), 1500))
|
||
|
{
|
||
|
_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);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|