diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/Paintball.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/Paintball.java index 57ea34f63..2dd4344b2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/Paintball.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/Paintball.java @@ -7,6 +7,10 @@ import java.util.Iterator; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilGear; +import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; @@ -56,6 +60,7 @@ import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.player.PlayerEvent; +import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; @@ -98,6 +103,7 @@ public class Paintball extends TeamGame private HashMap _doubles = new HashMap(); + @SuppressWarnings("unchecked") public Paintball(ArcadeManager manager) { super(manager, GameType.Paintball, @@ -107,6 +113,7 @@ public class Paintball extends TeamGame new KitRifle(manager), new KitShotgun(manager), new KitMachineGun(manager), + new KitSniper(manager), }, new String[] @@ -162,6 +169,7 @@ public class Paintball extends TeamGame event.setCancelled(true); } + @SuppressWarnings("deprecation") @EventHandler public void Paint(ProjectileHitEvent event) { @@ -265,7 +273,10 @@ public class Paintball extends TeamGame } if (GetKit(damager) instanceof KitSniper) { - count = ((KitSniper) GetKit(damager)).getPaintDamage(damager); + count = ((KitSniper) GetKit(damager)).getPaintDamage(event.GetProjectile()); + + if (count == -1) + count = 1; } } @@ -517,4 +528,22 @@ public class Paintball extends TeamGame for (Player player : GetPlayers(true)) player.removePotionEffect(PotionEffectType.WATER_BREATHING); } + + @EventHandler + public void onHeal(PlayerInteractEvent event) + { + if (!IsLive()) + return; + + if (!UtilEvent.isAction(event, ActionType.R)) + return; + + if (!UtilGear.isMat(event.getItem(), Material.POTION)) + return; + + if (!IsAlive(event.getPlayer()) || UtilPlayer.isSpectator(event.getPlayer())) + event.setCancelled(true); + + UtilInv.Update(event.getPlayer()); + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/PlayerCopy.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/PlayerCopy.java index b072dea9a..787c23296 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/PlayerCopy.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/PlayerCopy.java @@ -2,12 +2,9 @@ package nautilus.game.arcade.game.games.paintball; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilEnt; -import mineplex.core.disguise.disguises.DisguisePlayer; import nautilus.game.arcade.game.Game; import org.bukkit.ChatColor; -import org.bukkit.EntityEffect; -import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Skeleton; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitMachineGun.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitMachineGun.java index 04a62d950..591abb677 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitMachineGun.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitMachineGun.java @@ -1,21 +1,22 @@ package nautilus.game.arcade.game.games.paintball.kits; -import org.bukkit.Color; -import org.bukkit.Material; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.LeatherArmorMeta; -import org.bukkit.inventory.meta.PotionMeta; - import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilInv; +import mineplex.core.itemstack.ItemBuilder; import mineplex.core.itemstack.ItemStackFactory; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.games.paintball.kits.perks.PerkPaintballMachineGun; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.perks.*; + +import org.bukkit.Color; +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.PotionMeta; public class KitMachineGun extends Kit { @@ -40,36 +41,17 @@ public class KitMachineGun extends Kit @Override public void GiveItems(Player player) { - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.DIAMOND_BARDING, (byte)0, 1, "Paintball Machine Gun")); + UtilInv.insert(player, ItemStackFactory.Instance.CreateStack(Material.DIAMOND_BARDING, (byte)0, 1, F.item("Paintball Machine Gun"))); ItemStack potion = new ItemStack(Material.POTION, 3, (short)16429); // 16422 PotionMeta potionMeta = (PotionMeta)potion.getItemMeta(); - potionMeta.setDisplayName("Water Bomb"); + potionMeta.setDisplayName(F.item("Water Bomb")); potion.setItemMeta(potionMeta); - player.getInventory().addItem(potion); - - ItemStack helm = new ItemStack(Material.LEATHER_HELMET); - LeatherArmorMeta metaHelm = (LeatherArmorMeta)helm.getItemMeta(); - metaHelm.setColor(Color.WHITE); - helm.setItemMeta(metaHelm); - player.getInventory().setHelmet(helm); + UtilInv.insert(player, potion); - ItemStack armor = new ItemStack(Material.LEATHER_CHESTPLATE); - LeatherArmorMeta meta = (LeatherArmorMeta)armor.getItemMeta(); - meta.setColor(Color.WHITE); - armor.setItemMeta(meta); - player.getInventory().setChestplate(armor); - - ItemStack legs = new ItemStack(Material.LEATHER_LEGGINGS); - LeatherArmorMeta metaLegs = (LeatherArmorMeta)armor.getItemMeta(); - metaLegs.setColor(Color.WHITE); - legs.setItemMeta(metaLegs); - player.getInventory().setLeggings(legs); - - ItemStack boots = new ItemStack(Material.LEATHER_BOOTS); - LeatherArmorMeta metaBoots = (LeatherArmorMeta)armor.getItemMeta(); - metaBoots.setColor(Color.WHITE); - boots.setItemMeta(metaBoots); - player.getInventory().setBoots(boots); + player.getInventory().setHelmet(new ItemBuilder(Material.LEATHER_HELMET).setUnbreakable(true).setColor(Color.WHITE).build()); + player.getInventory().setChestplate(new ItemBuilder(Material.LEATHER_CHESTPLATE).setUnbreakable(true).setColor(Color.WHITE).build()); + player.getInventory().setLeggings(new ItemBuilder(Material.LEATHER_LEGGINGS).setUnbreakable(true).setColor(Color.WHITE).build()); + player.getInventory().setBoots(new ItemBuilder(Material.LEATHER_BOOTS).setUnbreakable(true).setColor(Color.WHITE).build()); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitRifle.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitRifle.java index ac0f1b480..db88ea43c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitRifle.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitRifle.java @@ -1,22 +1,23 @@ package nautilus.game.arcade.game.games.paintball.kits; -import org.bukkit.Color; -import org.bukkit.Material; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.LeatherArmorMeta; -import org.bukkit.inventory.meta.PotionMeta; -import org.bukkit.potion.PotionEffectType; - import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilInv; +import mineplex.core.itemstack.ItemBuilder; import mineplex.core.itemstack.ItemStackFactory; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.games.paintball.kits.perks.PerkPaintballRifle; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.perks.*; +import nautilus.game.arcade.kit.perks.PerkSpeed; + +import org.bukkit.Color; +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.PotionMeta; public class KitRifle extends Kit { @@ -42,37 +43,17 @@ public class KitRifle extends Kit @Override public void GiveItems(Player player) { - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_BARDING, (byte)0, 1, "Paintball Rifle")); - - //Potion + UtilInv.insert(player, ItemStackFactory.Instance.CreateStack(Material.IRON_BARDING, (byte)0, 1, F.item("Paintball Rifle"))); + ItemStack potion = new ItemStack(Material.POTION, 3, (short)16429); // 16422 PotionMeta potionMeta = (PotionMeta)potion.getItemMeta(); - potionMeta.setDisplayName("Water Bomb"); + potionMeta.setDisplayName(F.item("Water Bomb")); potion.setItemMeta(potionMeta); - player.getInventory().addItem(potion); - - ItemStack helm = new ItemStack(Material.LEATHER_HELMET); - LeatherArmorMeta metaHelm = (LeatherArmorMeta)helm.getItemMeta(); - metaHelm.setColor(Color.WHITE); - helm.setItemMeta(metaHelm); - player.getInventory().setHelmet(helm); + UtilInv.insert(player, potion); - ItemStack armor = new ItemStack(Material.LEATHER_CHESTPLATE); - LeatherArmorMeta meta = (LeatherArmorMeta)armor.getItemMeta(); - meta.setColor(Color.WHITE); - armor.setItemMeta(meta); - player.getInventory().setChestplate(armor); - - ItemStack legs = new ItemStack(Material.LEATHER_LEGGINGS); - LeatherArmorMeta metaLegs = (LeatherArmorMeta)armor.getItemMeta(); - metaLegs.setColor(Color.WHITE); - legs.setItemMeta(metaLegs); - player.getInventory().setLeggings(legs); - - ItemStack boots = new ItemStack(Material.LEATHER_BOOTS); - LeatherArmorMeta metaBoots = (LeatherArmorMeta)armor.getItemMeta(); - metaBoots.setColor(Color.WHITE); - boots.setItemMeta(metaBoots); - player.getInventory().setBoots(boots); + player.getInventory().setHelmet(new ItemBuilder(Material.LEATHER_HELMET).setUnbreakable(true).setColor(Color.WHITE).build()); + player.getInventory().setChestplate(new ItemBuilder(Material.LEATHER_CHESTPLATE).setUnbreakable(true).setColor(Color.WHITE).build()); + player.getInventory().setLeggings(new ItemBuilder(Material.LEATHER_LEGGINGS).setUnbreakable(true).setColor(Color.WHITE).build()); + player.getInventory().setBoots(new ItemBuilder(Material.LEATHER_BOOTS).setUnbreakable(true).setColor(Color.WHITE).build()); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitShotgun.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitShotgun.java index ce2e2db69..65275c0a8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitShotgun.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitShotgun.java @@ -1,21 +1,23 @@ package nautilus.game.arcade.game.games.paintball.kits; -import org.bukkit.Color; -import org.bukkit.Material; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.LeatherArmorMeta; -import org.bukkit.inventory.meta.PotionMeta; - import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilInv; +import mineplex.core.itemstack.ItemBuilder; import mineplex.core.itemstack.ItemStackFactory; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.games.paintball.kits.perks.PerkPaintballShotgun; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.perks.*; +import nautilus.game.arcade.kit.perks.PerkSpeed; + +import org.bukkit.Color; +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.PotionMeta; public class KitShotgun extends Kit { @@ -41,36 +43,17 @@ public class KitShotgun extends Kit @Override public void GiveItems(Player player) { - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.GOLD_BARDING, (byte)0, 1, "Paintball Shotgun")); + UtilInv.insert(player, ItemStackFactory.Instance.CreateStack(Material.GOLD_BARDING, (byte)0, 1, F.item("Paintball Shotgun"))); ItemStack potion = new ItemStack(Material.POTION, 3, (short)16429); // 16422 PotionMeta potionMeta = (PotionMeta)potion.getItemMeta(); - potionMeta.setDisplayName("Water Bomb"); + potionMeta.setDisplayName(F.item("Water Bomb")); potion.setItemMeta(potionMeta); - player.getInventory().addItem(potion); + UtilInv.insert(player, potion); - ItemStack helm = new ItemStack(Material.LEATHER_HELMET); - LeatherArmorMeta metaHelm = (LeatherArmorMeta)helm.getItemMeta(); - metaHelm.setColor(Color.WHITE); - helm.setItemMeta(metaHelm); - player.getInventory().setHelmet(helm); - - ItemStack armor = new ItemStack(Material.LEATHER_CHESTPLATE); - LeatherArmorMeta meta = (LeatherArmorMeta)armor.getItemMeta(); - meta.setColor(Color.WHITE); - armor.setItemMeta(meta); - player.getInventory().setChestplate(armor); - - ItemStack legs = new ItemStack(Material.LEATHER_LEGGINGS); - LeatherArmorMeta metaLegs = (LeatherArmorMeta)armor.getItemMeta(); - metaLegs.setColor(Color.WHITE); - legs.setItemMeta(metaLegs); - player.getInventory().setLeggings(legs); - - ItemStack boots = new ItemStack(Material.LEATHER_BOOTS); - LeatherArmorMeta metaBoots = (LeatherArmorMeta)armor.getItemMeta(); - metaBoots.setColor(Color.WHITE); - boots.setItemMeta(metaBoots); - player.getInventory().setBoots(boots); + player.getInventory().setHelmet(new ItemBuilder(Material.LEATHER_HELMET).setUnbreakable(true).setColor(Color.WHITE).build()); + player.getInventory().setChestplate(new ItemBuilder(Material.LEATHER_CHESTPLATE).setUnbreakable(true).setColor(Color.WHITE).build()); + player.getInventory().setLeggings(new ItemBuilder(Material.LEATHER_LEGGINGS).setUnbreakable(true).setColor(Color.WHITE).build()); + player.getInventory().setBoots(new ItemBuilder(Material.LEATHER_BOOTS).setUnbreakable(true).setColor(Color.WHITE).build()); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitSniper.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitSniper.java index 8075cd4ee..4604ddd0e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitSniper.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/KitSniper.java @@ -2,22 +2,23 @@ package nautilus.game.arcade.game.games.paintball.kits; import mineplex.core.achievement.Achievement; import mineplex.core.common.util.C; +import mineplex.core.common.util.F; import mineplex.core.common.util.UtilInv; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.itemstack.ItemStackFactory; import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.game.games.paintball.kits.perks.PerkPaintballShotgun; import nautilus.game.arcade.game.games.paintball.kits.perks.PerkPaintballSniper; import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.perks.PerkSlow; import org.bukkit.Color; import org.bukkit.Material; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.PotionMeta; public class KitSniper extends Kit { @@ -33,8 +34,7 @@ public class KitSniper extends Kit new Perk[] { - new PerkPaintballShotgun(), - new PerkSlow(0) + new PerkPaintballSniper(), }, EntityType.ZOMBIE, new ItemStack(Material.STONE_HOE)); @@ -51,27 +51,31 @@ public class KitSniper extends Kit } @Override - public void GiveItems(Player player) + public void GiveItems(Player player) { player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.STONE_HOE, (byte)0, 1, C.cWhite + "Paintball Sniper Rifle")); - UtilInv.insert(player, ItemStackFactory.Instance.CreateStack(Material.POTION, (byte) 16429, 1, "Water Bomb")); + ItemStack potion = new ItemStack(Material.POTION, 2, (short)16429); // 16422 + PotionMeta potionMeta = (PotionMeta)potion.getItemMeta(); + potionMeta.setDisplayName(F.item("Water Bomb")); + potion.setItemMeta(potionMeta); + UtilInv.insert(player, potion); - player.getInventory().setHelmet(new ItemBuilder(Material.LEATHER_HELMET).setColor(Color.WHITE).build()); - player.getInventory().setChestplate(new ItemBuilder(Material.LEATHER_CHESTPLATE).setColor(Color.WHITE).build()); - player.getInventory().setLeggings(new ItemBuilder(Material.LEATHER_LEGGINGS).setColor(Color.WHITE).build()); - player.getInventory().setBoots(new ItemBuilder(Material.LEATHER_BOOTS).setColor(Color.WHITE).build()); + player.getInventory().setHelmet(new ItemBuilder(Material.LEATHER_HELMET).setUnbreakable(true).setColor(Color.WHITE).build()); + player.getInventory().setChestplate(new ItemBuilder(Material.LEATHER_CHESTPLATE).setUnbreakable(true).setColor(Color.WHITE).build()); + player.getInventory().setLeggings(new ItemBuilder(Material.LEATHER_LEGGINGS).setUnbreakable(true).setColor(Color.WHITE).build()); + player.getInventory().setBoots(new ItemBuilder(Material.LEATHER_BOOTS).setUnbreakable(true).setColor(Color.WHITE).build()); } - public int getPaintDamage(Player player) + public int getPaintDamage(Projectile proj) { - for (Perk perk : this.GetPerks()) + for (Perk perk : GetPerks()) { if (perk instanceof PerkPaintballSniper) { - return ((PerkPaintballSniper) perk).getPaintDamage(player); + return ((PerkPaintballSniper) perk).getPaintDamage(proj); } } - return 0; + return -1; } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballSniper.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballSniper.java index fd2d18031..71b9bf2b9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballSniper.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/kits/perks/PerkPaintballSniper.java @@ -1,8 +1,10 @@ package nautilus.game.arcade.game.games.paintball.kits.perks; import java.util.HashMap; +import java.util.HashSet; import mineplex.core.common.util.C; +import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilEvent.ActionType; @@ -10,8 +12,11 @@ import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilPlayer; import mineplex.core.recharge.Recharge; import mineplex.core.recharge.RechargedEvent; +import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.condition.Condition.ConditionType; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.kit.Perk; import org.bukkit.ChatColor; @@ -22,18 +27,25 @@ import org.bukkit.entity.Player; import org.bukkit.entity.Projectile; import org.bukkit.entity.Snowball; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.util.Vector; public class PerkPaintballSniper extends Perk { private HashMap _crouching = new HashMap(); + private HashMap _fired = new HashMap(); + private NautHashMap _damage = new NautHashMap(); + + private double _velocity = 8; public PerkPaintballSniper() { super("Sniper Rifle", new String[] { C.cYellow + "Crouch" + C.cGray + " to use " + C.cGreen + "Scope", - C.cYellow + "Right-Click" + C.cGray + " to use " + C.cGreen + "Shotgun" + C.cYellow + "Right-Click" + C.cGray + " to use " + C.cGreen + "Sniper Rifle", + "Experience Bar represents damage." }); } @@ -75,45 +87,63 @@ public class PerkPaintballSniper extends Perk event.setCancelled(true); - if (!Recharge.Instance.use(player, GetName(), 1400, true, false)) + if (!Recharge.Instance.use(player, GetName(), 1000, true, true)) return; - Projectile proj = player.launchProjectile(Manager.GetGame().GetTeam(player).GetColor() == ChatColor.AQUA ? Snowball.class : EnderPearl.class); - - proj.setVelocity(proj.getVelocity().normalize().multiply(4)); + Projectile proj = player.launchProjectile(Manager.GetGame().GetTeam(player).GetColor() == ChatColor.AQUA ? Snowball.class : EnderPearl.class, player.getEyeLocation().getDirection().clone().multiply(_velocity)); + + _fired.put(proj, proj.getVelocity()); + _damage.put(proj, getPaintDamage(player)); //Sound player.getWorld().playSound(player.getLocation(), Sound.CHICKEN_EGG_POP, 0.8f, 1f); + + player.setSneaking(false); + + //Effects + removeEffects(player); } @EventHandler public void onUpdate(UpdateEvent event) { - if (!Manager.GetGame().IsLive()) + if (event.getType() != UpdateType.TICK) return; + if (!Manager.GetGame().IsLive()) + return; + //Cleanup check HashMap copyMap = new HashMap(); copyMap.putAll(_crouching); for (Player player : copyMap.keySet()) { boolean remove = false; + if (!player.isOnline()) + remove = true; + if (!Manager.GetGame().IsAlive(player)) remove = true; - + if (UtilPlayer.isSpectator(player)) remove = true; - + if (!player.isSneaking()) remove = true; + if (!Recharge.Instance.usable(player, GetName())) + remove = true; + if (remove) { - _crouching.remove(player); + if (_crouching.containsKey(player)) + _crouching.remove(player); + + player.setExp(0F); + player.setSneaking(false); // Zoom - if (Manager.GetCondition().HasCondition(player, ConditionType.SLOW, GetName())) - Manager.GetCondition().EndCondition(player, ConditionType.SLOW, GetName()); + removeEffects(player); } } @@ -123,6 +153,9 @@ public class PerkPaintballSniper extends Perk if (UtilPlayer.isSpectator(player)) continue; + if (!Kit.HasKit(player)) + continue; + if (!player.isSneaking()) continue; @@ -132,12 +165,95 @@ public class PerkPaintballSniper extends Perk _crouching.put(player, System.currentTimeMillis()); // Zoom - if (!Manager.GetCondition().HasCondition(player, ConditionType.SLOW, GetName())) - Manager.GetCondition().Factory().Slow(GetName(), player, null, Double.MAX_VALUE, 5, false, false, false, false); - } + addEffects(player); + } + + // Exp check + + for (Player player : Manager.GetGame().GetPlayers(true)) + { + if (UtilPlayer.isSpectator(player)) + continue; + + if (!Kit.HasKit(player)) + continue; + + if (!_crouching.containsKey(player)) + continue; + + player.setExp((float) Math.min(.999F, player.getExp() + .0125)); + } } - public int getPaintDamage(Player player) + @EventHandler + public void updateProjectiles(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + if (!Manager.GetGame().IsLive()) + return; + + HashSet copySet = new HashSet(_fired.keySet()); + for (Projectile proj : copySet) + { + if (!proj.isValid()) + { + _fired.remove(proj); + + if (_damage.containsKey(proj)) + _damage.remove(proj); + + continue; + } + + proj.setVelocity(_fired.get(proj).clone().normalize().multiply(_velocity)); + } + } + + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) + public void removeEffects(GameStateChangeEvent event) + { + if (event.GetState() != GameState.End) + return; + + for (Player player : _crouching.keySet()) + { + removeEffects(player); + } + + _crouching.clear(); + } + + private void removeEffects(Player player) + { + // Zoom + if (Manager.GetCondition().HasCondition(player, ConditionType.SLOW, GetName())) + Manager.GetCondition().EndCondition(player, ConditionType.SLOW, GetName()); + + if (Manager.GetCondition().HasCondition(player, ConditionType.JUMP, GetName())) + Manager.GetCondition().EndCondition(player, ConditionType.JUMP, GetName()); + } + + private void addEffects(Player player) + { + // Zoom + if (!Manager.GetCondition().HasCondition(player, ConditionType.SLOW, GetName())) + Manager.GetCondition().Factory().Slow(GetName(), player, null, Double.MAX_VALUE, 8, false, false, false, false); + +// if (!Manager.GetCondition().HasCondition(player, ConditionType.JUMP, GetName())) +// Manager.GetCondition().Factory().Jump(GetName(), player, null, 9999999, 250, true, false, false); + } + + public int getPaintDamage(Projectile proj) + { + if (!_damage.containsKey(proj)) + return 1; + + return _damage.remove(proj); + } + + private int getPaintDamage(Player player) { if (!_crouching.containsKey(player)) return 1;