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.UtilBlock; import mineplex.core.common.util.UtilMath; 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 PerkInfernoFinn extends Perk { private HashMap _active = new HashMap(); public PerkInfernoFinn() { super("Inferno", new String[] { C.cYellow + "Block" + C.cGray + " with Gold Sword 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("GOLD_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()); } @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, 2, 2, "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); } } @EventHandler public void Refresh(UpdateEvent event) { if (event.getType() != UpdateType.SLOWER) return; for (Player player : UtilServer.getPlayers()) { if (_active.containsKey(player)) continue; if (!Kit.HasKit(player)) continue; player.getInventory().remove(Material.GOLD_SWORD); player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.GOLD_SWORD, (byte)0, 1, "Flaming Sword")); } } }