From 0cbefc1280de364104d6cd7679d6caeefa27c9e9 Mon Sep 17 00:00:00 2001 From: Chiss Date: Sat, 2 Nov 2013 15:42:37 +1100 Subject: [PATCH] Paintball update! --- .../nautilus/game/arcade/ArcadeManager.java | 2 +- .../src/nautilus/game/arcade/game/Game.java | 6 +- .../game/games/paintball/Paintball.java | 84 ++++++++++++++----- .../game/games/paintball/PlayerCopy.java | 3 +- .../game/games/paintball/kits/KitRifle.java | 2 +- .../game/games/paintball/kits/KitShotgun.java | 3 +- .../kit/perks/PerkPaintballMachineGun.java | 9 +- .../arcade/kit/perks/PerkPaintballRifle.java | 3 +- .../kit/perks/PerkPaintballShotgun.java | 5 +- .../game/arcade/managers/GameGemManager.java | 3 + 10 files changed, 82 insertions(+), 38 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java index 092d54add..a581da950 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -474,7 +474,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation ((CraftPlayer)player).getHandle().spectating = false; ((CraftPlayer)player).getHandle().m = true; - GetCondition().EndCondition(player, ConditionType.CLOAK, "Spectator"); + GetCondition().EndCondition(player, ConditionType.CLOAK, null); HubClock(player); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java index f3e98b650..458b0f738 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java @@ -366,7 +366,8 @@ public abstract class Game implements Listener } else { - _scoreboard.registerNewTeam(rank.Name + "SPEC").setPrefix(rank.Color + C.Bold + rank.Name.toUpperCase() + ChatColor.RESET + " " + ChatColor.GRAY); + _scoreboard.registerNewTeam(rank.Name + "SPEC").setPrefix(ChatColor.GRAY + ""); + //_scoreboard.registerNewTeam(rank.Name + "SPEC").setPrefix(rank.Color + C.Bold + rank.Name.toUpperCase() + ChatColor.RESET + " " + ChatColor.GRAY); } } @@ -381,7 +382,8 @@ public abstract class Game implements Listener } else { - _scoreboard.registerNewTeam(rank.Name + team.GetName().toUpperCase()).setPrefix(rank.Color + C.Bold + rank.Name.toUpperCase() + ChatColor.RESET + " " + team.GetColor()); + //_scoreboard.registerNewTeam(rank.Name + team.GetName().toUpperCase()).setPrefix(rank.Color + C.Bold + rank.Name.toUpperCase() + ChatColor.RESET + " " + team.GetColor()); + _scoreboard.registerNewTeam(rank.Name + team.GetName().toUpperCase()).setPrefix(team.GetColor() + ""); } } } 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 c98266403..6f212a638 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 @@ -21,6 +21,7 @@ import org.bukkit.entity.Projectile; import org.bukkit.entity.Snowball; import org.bukkit.entity.ThrownPotion; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityRegainHealthEvent; import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; import org.bukkit.event.entity.ProjectileHitEvent; @@ -77,7 +78,6 @@ public class Paintball extends TeamGame }); } - /* @EventHandler public void CustomTeamGeneration(GameStateChangeEvent event) { @@ -90,21 +90,35 @@ public class Paintball extends TeamGame this.GetTeamList().get(1).SetColor(ChatColor.RED); this.GetTeamList().get(1).SetName("Nether"); } - */ - @EventHandler + @EventHandler(priority = EventPriority.HIGH) + public void ColorArmor(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Prepare) + return; + + for (Player player : GetPlayers(true)) + { + CleanColorArmor(player); + } + + } + + @EventHandler(priority = EventPriority.HIGH) public void RefreshPlayers(GameStateChangeEvent event) { if (event.GetState() != GameState.Live) return; for (Player player : GetPlayers(true)) + { for (Player other : GetPlayers(true)) { other.hidePlayer(player); other.showPlayer(player); } + } } @EventHandler @@ -164,9 +178,6 @@ public class Paintball extends TeamGame @EventHandler public void PaintballDamage(CustomDamageEvent event) { - if (event.IsCancelled()) - return; - if (event.GetProjectile() == null) return; @@ -184,7 +195,16 @@ public class Paintball extends TeamGame Player damager = event.GetDamagerPlayer(true); if (damager == null) return; + + GameTeam damageeTeam = GetTeam(damagee); + if (damageeTeam == null) return; + GameTeam damagerTeam = GetTeam(damager); + if (damagerTeam == null) return; + + if (damagerTeam.equals(damageeTeam)) + return; + //Color Color color = Color.RED; if (event.GetProjectile() instanceof Snowball) @@ -201,21 +221,25 @@ public class Paintball extends TeamGame } //Out - if (Color(damagee, color, count)) + if (Color(damagee, count)) { PlayerOut(damagee); - Announce(GetTeam(damagee).GetColor() + damagee.getName() + ChatColor.RESET + " was painted by " + - GetTeam(damager).GetColor() + damager.getName()); + for (Player player : UtilServer.getPlayers()) + UtilPlayer.message(player, damageeTeam.GetColor() + damagee.getName() + ChatColor.RESET + " was painted by " + + damagerTeam.GetColor() + damager.getName() + ChatColor.RESET + "!"); + + AddGems(damager, 2, "Kill", true); } - //Hit Sound Player player = event.GetDamagerPlayer(true); if (player != null) player.playSound(player.getLocation(), Sound.ORB_PICKUP, 1f, 3f); } + + - public boolean Color(Player player, Color color, int amount) + public boolean Color(Player player, int amount) { //Get Non-Coloured ArrayList nonColored = new ArrayList(); @@ -226,7 +250,7 @@ public class Paintball extends TeamGame LeatherArmorMeta meta = (LeatherArmorMeta)stack.getItemMeta(); - if (meta.getColor().equals(Color.WHITE)) + if (meta.getColor().equals(Color.RED) || meta.getColor().equals(Color.AQUA)) nonColored.add(stack); } @@ -239,7 +263,7 @@ public class Paintball extends TeamGame ItemStack armor = nonColored.remove(UtilMath.r(nonColored.size())); LeatherArmorMeta meta = (LeatherArmorMeta)armor.getItemMeta(); - meta.setColor(color); + meta.setColor(Color.PURPLE); armor.setItemMeta(meta); } @@ -368,17 +392,13 @@ public class Paintball extends TeamGame player.setFlying(false); ((CraftPlayer)player).getHandle().spectating = false; ((CraftPlayer)player).getHandle().m = true; + + //Items + player.getInventory().remove(Material.WATCH); + player.getInventory().remove(Material.COMPASS); //Clean Armor - for (ItemStack stack : player.getInventory().getArmorContents()) - { - if (!(stack.getItemMeta() instanceof LeatherArmorMeta)) - continue; - - LeatherArmorMeta meta = (LeatherArmorMeta)stack.getItemMeta(); - meta.setColor(Color.WHITE); - stack.setItemMeta(meta); - } + CleanColorArmor(player); //Inform UtilPlayer.message(player, F.main("Game", "You have been cleaned!")); @@ -391,7 +411,8 @@ public class Paintball extends TeamGame public void run() { //Remove Invis - Manager.GetCondition().EndCondition(player, ConditionType.CLOAK, null); + if (IsAlive(player)) + Manager.GetCondition().EndCondition(player, ConditionType.CLOAK, null); //Remove Copy copy.remove(); @@ -399,4 +420,21 @@ public class Paintball extends TeamGame }, 4); } } + + public void CleanColorArmor(Player player) + { + Color color = Color.RED; + if (Manager.GetColor(player) != ChatColor.RED) + color = Color.AQUA; + + for (ItemStack stack : player.getInventory().getArmorContents()) + { + if (!(stack.getItemMeta() instanceof LeatherArmorMeta)) + continue; + + LeatherArmorMeta meta = (LeatherArmorMeta)stack.getItemMeta(); + meta.setColor(color); + stack.setItemMeta(meta); + } + } } 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 f38f43124..2266f04b7 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 @@ -29,7 +29,8 @@ public class PlayerCopy //Armor _ent.getEquipment().setArmorContents(owner.getInventory().getArmorContents()); - _ent.setCustomName(C.cWhite + C.Bold + "OUT " + ChatColor.RESET + host.GetTeam(owner).GetColor() + owner.getName()); + + _ent.setCustomName(C.cWhite + C.Bold + C.Scramble + "XX" + ChatColor.RESET + " " + host.GetTeam(owner).GetColor() + owner.getName() + " " + C.cWhite + C.Bold + C.Scramble + "XX"); _ent.setCustomNameVisible(true); //Disguise 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 c1b2301a3..f97d5c5fc 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 @@ -34,7 +34,7 @@ public class KitRifle extends Kit }, EntityType.ZOMBIE, new ItemStack(Material.IRON_BARDING)); - } + } @Override public void GiveItems(Player player) 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 db7237185..2a8fa2660 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,5 +1,6 @@ package nautilus.game.arcade.game.games.paintball.kits; +import org.bukkit.ChatColor; import org.bukkit.Color; import org.bukkit.Material; import org.bukkit.entity.EntityType; @@ -24,7 +25,7 @@ public class KitShotgun extends Kit new String[] { "Pump action paintball shotgun.", - C.cGold + "4 Hit Kill" + C.cGold + "8 Pellets, 4 Pellet Hits Kill" }, new Perk[] diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPaintballMachineGun.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPaintballMachineGun.java index 17350f6b9..eddad2dfd 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPaintballMachineGun.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPaintballMachineGun.java @@ -44,7 +44,7 @@ public class PerkPaintballMachineGun extends Perk continue; if (Recharge.Instance.usable(player, "Cool")) - player.setExp((float)Math.max(0f, player.getExp() - 0.015f)); + player.setExp((float)Math.max(0f, player.getExp() - 0.020f)); } } @@ -76,6 +76,7 @@ public class PerkPaintballMachineGun extends Perk ShootPaintball(player, team); + /* UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(Manager.GetPlugin(), new Runnable() { public void run() @@ -83,6 +84,7 @@ public class PerkPaintballMachineGun extends Perk ShootPaintball(player, team); } }, 2); + */ } public void ShootPaintball(Player player, GameTeam team) @@ -90,7 +92,7 @@ public class PerkPaintballMachineGun extends Perk //Energy if (player.getExp() >= 0.97) return; - player.setExp((float) (player.getExp() + 0.03)); + player.setExp((float) (player.getExp() + 0.025)); //Shoot Vector rand = new Vector(Math.random() - 0.5, Math.random() - 0.5, Math.random() - 0.5); @@ -114,8 +116,7 @@ public class PerkPaintballMachineGun extends Perk //proj.setVelocity(player.getLocation().getDirection().multiply(1.6).add(rand)); //proj.setShooter(player); - //Projectile proj = player.launchProjectile(EnderPearl.class); - Projectile proj = player.launchProjectile(Snowball.class); + Projectile proj = player.launchProjectile(EnderPearl.class); proj.setVelocity(proj.getVelocity().multiply(1.6).add(rand)); //Sound diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPaintballRifle.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPaintballRifle.java index 7e39d73a4..e160f1635 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPaintballRifle.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPaintballRifle.java @@ -75,8 +75,7 @@ public class PerkPaintballRifle extends Perk } else { - //Projectile proj = player.launchProjectile(EnderPearl.class); - Projectile proj = player.launchProjectile(Snowball.class); + Projectile proj = player.launchProjectile(EnderPearl.class); proj.setVelocity(proj.getVelocity().multiply(2)); //Sound diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPaintballShotgun.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPaintballShotgun.java index e0ed9d954..5c729e194 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPaintballShotgun.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPaintballShotgun.java @@ -68,7 +68,7 @@ public class PerkPaintballShotgun extends Perk if (!Recharge.Instance.use(player, GetName(), 1400, true)) return; - for (int i=0 ; i<6 ; i++) + for (int i=0 ; i<8 ; i++) { Vector rand = new Vector(Math.random() - 0.5, Math.random() - 0.5, Math.random() - 0.5); rand.multiply(0.4); @@ -83,8 +83,7 @@ public class PerkPaintballShotgun extends Perk } else { - //Projectile proj = player.launchProjectile(EnderPearl.class); - Projectile proj = player.launchProjectile(Snowball.class); + Projectile proj = player.launchProjectile(EnderPearl.class); proj.setVelocity(proj.getVelocity().multiply(1).add(rand)); //Sound diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameGemManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameGemManager.java index d0144e130..4bd2d0a3c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameGemManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameGemManager.java @@ -97,6 +97,9 @@ public class GameGemManager implements Listener if (event.GetState() != PlayerState.OUT) return; + if (event.GetGame().GetType() == GameType.Paintball) + return; + RewardGems(event.GetGame(), event.GetPlayer(), false); }