2013-10-04 23:49:05 +02:00
|
|
|
package nautilus.game.arcade.kit.perks;
|
|
|
|
|
|
|
|
import org.bukkit.ChatColor;
|
|
|
|
import org.bukkit.Material;
|
|
|
|
import org.bukkit.Sound;
|
|
|
|
import org.bukkit.entity.EnderPearl;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.entity.Projectile;
|
|
|
|
import org.bukkit.entity.Snowball;
|
|
|
|
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;
|
2013-11-02 00:09:07 +01:00
|
|
|
import mineplex.core.common.util.UtilServer;
|
|
|
|
import mineplex.core.recharge.Recharge;
|
|
|
|
import mineplex.core.updater.UpdateType;
|
|
|
|
import mineplex.core.updater.event.UpdateEvent;
|
2013-10-04 23:49:05 +02:00
|
|
|
import nautilus.game.arcade.game.GameTeam;
|
|
|
|
import nautilus.game.arcade.kit.Perk;
|
|
|
|
|
|
|
|
public class PerkPaintballMachineGun extends Perk
|
|
|
|
{
|
|
|
|
public PerkPaintballMachineGun()
|
|
|
|
{
|
2013-11-02 00:09:07 +01:00
|
|
|
super("Machine Gun", new String[]
|
2013-10-04 23:49:05 +02:00
|
|
|
{
|
2013-11-02 00:09:07 +01:00
|
|
|
C.cYellow + "Right-Click" + C.cGray + " to use " + C.cGreen + "Machine Gun",
|
|
|
|
"Experience Bar represents weapon overheating."
|
2013-10-04 23:49:05 +02:00
|
|
|
});
|
|
|
|
}
|
2013-11-02 00:09:07 +01:00
|
|
|
|
2013-10-04 23:49:05 +02:00
|
|
|
@EventHandler
|
2013-11-02 00:09:07 +01:00
|
|
|
public void WeaponCooldown(UpdateEvent event)
|
|
|
|
{
|
|
|
|
if (event.getType() != UpdateType.TICK)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (Player player : UtilServer.getPlayers())
|
|
|
|
{
|
|
|
|
if (!Kit.HasKit(player))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (Recharge.Instance.usable(player, "Cool"))
|
|
|
|
player.setExp((float)Math.max(0f, player.getExp() - 0.015f));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler
|
2013-10-04 23:49:05 +02:00
|
|
|
public void Shoot(PlayerInteractEvent event)
|
|
|
|
{
|
|
|
|
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() != Material.DIAMOND_BARDING)
|
|
|
|
return;
|
|
|
|
|
2013-11-02 00:09:07 +01:00
|
|
|
final Player player = event.getPlayer();
|
2013-10-04 23:49:05 +02:00
|
|
|
|
|
|
|
if (!Kit.HasKit(player))
|
|
|
|
return;
|
|
|
|
|
2013-11-02 00:09:07 +01:00
|
|
|
final GameTeam team = Manager.GetGame().GetTeam(player);
|
2013-10-04 23:49:05 +02:00
|
|
|
if (team == null)
|
|
|
|
return;
|
|
|
|
|
|
|
|
event.setCancelled(true);
|
|
|
|
|
2013-11-02 00:09:07 +01:00
|
|
|
ShootPaintball(player, team);
|
|
|
|
|
|
|
|
UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(Manager.GetPlugin(), new Runnable()
|
|
|
|
{
|
|
|
|
public void run()
|
|
|
|
{
|
|
|
|
ShootPaintball(player, team);
|
|
|
|
}
|
|
|
|
}, 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void ShootPaintball(Player player, GameTeam team)
|
|
|
|
{
|
|
|
|
//Energy
|
|
|
|
if (player.getExp() >= 0.97)
|
|
|
|
return;
|
|
|
|
player.setExp((float) (player.getExp() + 0.03));
|
|
|
|
|
|
|
|
//Shoot
|
2013-10-04 23:49:05 +02:00
|
|
|
Vector rand = new Vector(Math.random() - 0.5, Math.random() - 0.5, Math.random() - 0.5);
|
2013-11-02 00:09:07 +01:00
|
|
|
rand.multiply(0.25);
|
2013-10-04 23:49:05 +02:00
|
|
|
|
|
|
|
if (team.GetColor() == ChatColor.AQUA)
|
|
|
|
{
|
2013-11-02 00:09:07 +01:00
|
|
|
//Projectile proj = player.getWorld().spawn(player.getEyeLocation().add(player.getLocation().getDirection()), Snowball.class);
|
|
|
|
//proj.setVelocity(player.getLocation().getDirection().multiply(1.6).add(rand));
|
|
|
|
//proj.setShooter(player);
|
|
|
|
|
2013-10-04 23:49:05 +02:00
|
|
|
Projectile proj = player.launchProjectile(Snowball.class);
|
|
|
|
proj.setVelocity(proj.getVelocity().multiply(1.6).add(rand));
|
2013-11-02 00:09:07 +01:00
|
|
|
|
2013-10-04 23:49:05 +02:00
|
|
|
//Sound
|
|
|
|
player.getWorld().playSound(player.getLocation(), Sound.CHICKEN_EGG_POP, 1.5f, 2f);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-11-02 00:09:07 +01:00
|
|
|
//Projectile proj = player.getWorld().spawn(player.getEyeLocation().add(player.getLocation().getDirection()), EnderPearl.class);
|
|
|
|
//proj.setVelocity(player.getLocation().getDirection().multiply(1.6).add(rand));
|
|
|
|
//proj.setShooter(player);
|
2013-10-04 23:49:05 +02:00
|
|
|
|
2013-11-02 00:09:07 +01:00
|
|
|
//Projectile proj = player.launchProjectile(EnderPearl.class);
|
|
|
|
Projectile proj = player.launchProjectile(Snowball.class);
|
|
|
|
proj.setVelocity(proj.getVelocity().multiply(1.6).add(rand));
|
|
|
|
|
2013-10-04 23:49:05 +02:00
|
|
|
//Sound
|
|
|
|
player.getWorld().playSound(player.getLocation(), Sound.CHICKEN_EGG_POP, 1.5f, 1.75f);
|
|
|
|
}
|
|
|
|
|
2013-11-02 00:09:07 +01:00
|
|
|
Recharge.Instance.useForce(player, "Cool", 250);
|
2013-10-04 23:49:05 +02:00
|
|
|
}
|
2013-11-02 00:09:07 +01:00
|
|
|
}
|