2013-09-02 06:40:06 +02:00
|
|
|
package nautilus.game.arcade.kit.perks;
|
|
|
|
|
|
|
|
import org.bukkit.Effect;
|
|
|
|
import org.bukkit.Material;
|
|
|
|
import org.bukkit.Sound;
|
|
|
|
import org.bukkit.block.Block;
|
|
|
|
import org.bukkit.entity.LivingEntity;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.event.EventHandler;
|
|
|
|
import org.bukkit.event.block.Action;
|
|
|
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
|
|
|
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.UtilAction;
|
|
|
|
import mineplex.core.common.util.UtilBlock;
|
|
|
|
import mineplex.core.common.util.UtilEnt;
|
|
|
|
import mineplex.core.common.util.UtilInv;
|
|
|
|
import mineplex.core.common.util.UtilPlayer;
|
|
|
|
import mineplex.core.itemstack.ItemStackFactory;
|
|
|
|
import mineplex.core.projectile.IThrown;
|
|
|
|
import mineplex.core.projectile.ProjectileUser;
|
|
|
|
import mineplex.core.recharge.Recharge;
|
|
|
|
import mineplex.core.updater.UpdateType;
|
|
|
|
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
|
|
|
import nautilus.game.arcade.kit.Perk;
|
|
|
|
|
|
|
|
public class PerkInkBlast extends Perk implements IThrown
|
|
|
|
{
|
|
|
|
public PerkInkBlast()
|
|
|
|
{
|
2013-09-04 00:13:59 +02:00
|
|
|
super("Ink Shotgun", new String[]
|
2013-09-02 06:40:06 +02:00
|
|
|
{
|
2013-09-04 00:13:59 +02:00
|
|
|
C.cYellow + "Right-Click" + C.cGray + " with Axe to use " + C.cGreen + "Ink Shotgun"
|
2013-09-02 06:40:06 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void ShootWeb(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() == 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, GetName(), 6000, true, true))
|
2013-09-02 06:40:06 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
event.setCancelled(true);
|
|
|
|
|
|
|
|
UtilInv.Update(player);
|
|
|
|
|
2014-10-31 00:35:47 +01:00
|
|
|
for (int i=0 ; i<6 ; i++)
|
2013-09-02 06:40:06 +02:00
|
|
|
{
|
|
|
|
org.bukkit.entity.Item ent = player.getWorld().dropItem(player.getEyeLocation(), ItemStackFactory.Instance.CreateStack(Material.INK_SACK));
|
|
|
|
|
|
|
|
Vector random = new Vector(Math.random() - 0.5, Math.random() - 0.5, Math.random() - 0.5);
|
|
|
|
random.normalize();
|
2013-09-04 00:13:59 +02:00
|
|
|
random.multiply(0.2);
|
2013-09-02 06:40:06 +02:00
|
|
|
|
2014-10-31 00:35:47 +01:00
|
|
|
UtilAction.velocity(ent, player.getLocation().getDirection().add(random), 1 + 0.4 * Math.random(), false, 0, 0.2, 10, false);
|
2013-09-02 06:40:06 +02:00
|
|
|
|
|
|
|
Manager.GetProjectile().AddThrow(ent, player, this, -1, true, true, true,
|
|
|
|
null, 1f, 1f,
|
|
|
|
Effect.SMOKE, 4, UpdateType.TICK,
|
|
|
|
2d);
|
|
|
|
}
|
|
|
|
|
|
|
|
//Inform
|
|
|
|
UtilPlayer.message(player, F.main("Game", "You used " + F.skill(GetName()) + "."));
|
|
|
|
|
|
|
|
//Effect
|
|
|
|
player.getWorld().playSound(player.getLocation(), Sound.EXPLODE, 1.5f, 0.75f);
|
|
|
|
player.getWorld().playSound(player.getLocation(), Sound.SPLASH, 0.75f, 1f);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void Collide(LivingEntity target, Block block, ProjectileUser data)
|
|
|
|
{
|
|
|
|
Explode(data);
|
|
|
|
|
|
|
|
if (target == null)
|
|
|
|
return;
|
|
|
|
|
|
|
|
//Damage Event
|
|
|
|
Manager.GetDamage().NewDamageEvent(target, data.GetThrower(), null,
|
|
|
|
DamageCause.PROJECTILE, 2.5, true, true, false,
|
|
|
|
UtilEnt.getName(data.GetThrower()), GetName());
|
|
|
|
|
2014-08-09 11:55:05 +02:00
|
|
|
Manager.GetCondition().Factory().Blind(GetName(), target, data.GetThrower(), 1.5, 0, false, false, false);
|
2013-09-02 06:40:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void Idle(ProjectileUser data)
|
|
|
|
{
|
|
|
|
Explode(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void Expire(ProjectileUser data)
|
|
|
|
{
|
|
|
|
Explode(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Explode(ProjectileUser data)
|
|
|
|
{
|
|
|
|
data.GetThrown().getWorld().playSound(data.GetThrown().getLocation(), Sound.EXPLODE, 0.75f, 1.25f);
|
|
|
|
data.GetThrown().remove();
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void Knockback(CustomDamageEvent event)
|
|
|
|
{
|
|
|
|
if (event.GetReason() == null || !event.GetReason().contains(GetName()))
|
|
|
|
return;
|
|
|
|
|
2014-10-31 00:35:47 +01:00
|
|
|
event.AddKnockback(GetName(), 3);
|
2013-09-02 06:40:06 +02:00
|
|
|
}
|
|
|
|
}
|