Mineplex2018-withcommit/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPaintballMachineGun.java

131 lines
3.6 KiB
Java
Raw Normal View History

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;
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-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-11-02 00:09:07 +01: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"))
2013-11-02 05:42:37 +01:00
player.setExp((float)Math.max(0f, player.getExp() - 0.020f));
2013-11-02 00:09:07 +01:00
}
}
@EventHandler
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();
if (!Kit.HasKit(player))
return;
2013-11-02 00:09:07 +01:00
final GameTeam team = Manager.GetGame().GetTeam(player);
if (team == null)
return;
event.setCancelled(true);
2014-04-03 06:48:58 +02:00
if (!Recharge.Instance.use(player, GetName(), 80, false, false))
return;
2013-11-02 00:09:07 +01:00
ShootPaintball(player, team);
2013-11-02 05:42:37 +01:00
/*
UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable()
2013-11-02 00:09:07 +01:00
{
public void run()
{
ShootPaintball(player, team);
}
}, 2);
2013-11-02 05:42:37 +01:00
*/
2013-11-02 00:09:07 +01:00
}
public void ShootPaintball(Player player, GameTeam team)
{
//Energy
if (player.getExp() >= 0.97)
return;
2013-11-02 05:42:37 +01:00
player.setExp((float) (player.getExp() + 0.025));
2013-11-02 00:09:07 +01:00
//Shoot
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);
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);
Projectile proj = player.launchProjectile(Snowball.class);
proj.setVelocity(proj.getVelocity().multiply(1.6).add(rand));
2013-11-02 00:09:07 +01: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-11-02 05:42:37 +01:00
Projectile proj = player.launchProjectile(EnderPearl.class);
2013-11-02 00:09:07 +01:00
proj.setVelocity(proj.getVelocity().multiply(1.6).add(rand));
//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-11-02 00:09:07 +01:00
}