From 05623b7522e8d4a88587a1d72853350245a16d28 Mon Sep 17 00:00:00 2001 From: Chiss Date: Mon, 1 Sep 2014 21:37:39 +1000 Subject: [PATCH] Initial MineStrike push fixed frames being breakable in games --- .../core/achievement/Achievement.java | 2 +- .../core/disguise/DisguiseManager.java | 2 + .../core/gadget/gadgets/MorphPumpkinKing.java | 1 + .../mineplex/core/mount/types/MountCart.java | 8 + .../nautilus/game/arcade/ArcadeManager.java | 5 +- .../src/nautilus/game/arcade/GameFactory.java | 4 +- .../src/nautilus/game/arcade/game/Game.java | 26 + .../game/games/minestrike/MineStrike.java | 1912 +++++++++++++++++ .../game/games/minestrike/ShopManager.java | 259 +++ .../game/games/minestrike/data/Bomb.java | 86 + .../game/games/minestrike/data/Bullet.java | 47 + .../games/minestrike/items/StrikeItem.java | 178 ++ .../minestrike/items/StrikeItemType.java | 10 + .../items/equipment/DefusalKit.java | 40 + .../minestrike/items/equipment/Helmet.java | 46 + .../minestrike/items/equipment/Kevlar.java | 46 + .../minestrike/items/grenades/FlashBang.java | 80 + .../minestrike/items/grenades/Grenade.java | 162 ++ .../items/grenades/HighExplosive.java | 55 + .../minestrike/items/grenades/Smoke.java | 36 + .../game/games/minestrike/items/guns/Gun.java | 361 ++++ .../games/minestrike/items/guns/GunType.java | 47 + .../games/minestrike/items/guns/Shotgun.java | 74 + .../minestrike/items/guns/pistol/CZ75.java | 27 + .../minestrike/items/guns/pistol/Deagle.java | 27 + .../minestrike/items/guns/pistol/Glock18.java | 27 + .../minestrike/items/guns/pistol/P2000.java | 27 + .../minestrike/items/guns/rifle/AK47.java | 27 + .../minestrike/items/guns/rifle/AWP.java | 27 + .../minestrike/items/guns/rifle/M4A1.java | 27 + .../minestrike/items/guns/shotgun/Nova.java | 26 + .../games/minestrike/items/guns/smg/P90.java | 27 + .../game/games/minestrike/kits/KitPlayer.java | 50 + .../sneakyassassins/SneakyAssassins.java | 19 - .../game/arcade/game/games/spleef/Spleef.java | 6 +- .../game/arcade/managers/GameFlagManager.java | 8 +- .../game/arcade/managers/GameManager.java | 2 +- .../arcade/managers/GamePlayerManager.java | 1 - 38 files changed, 3785 insertions(+), 30 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/MineStrike.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/ShopManager.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/data/Bomb.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/data/Bullet.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/StrikeItem.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/StrikeItemType.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/equipment/DefusalKit.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/equipment/Helmet.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/equipment/Kevlar.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/grenades/FlashBang.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/grenades/Grenade.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/grenades/HighExplosive.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/grenades/Smoke.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/Gun.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/GunType.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/Shotgun.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/pistol/CZ75.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/pistol/Deagle.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/pistol/Glock18.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/pistol/P2000.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/rifle/AK47.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/rifle/AWP.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/rifle/M4A1.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/shotgun/Nova.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/smg/P90.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/kits/KitPlayer.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java index 1f22634d8..bc8213cae 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java @@ -23,7 +23,7 @@ public enum Achievement BRIDGES_SNIPER("Sniper", 600, new String[] {"The Bridges.Sniper"}, - new String[] {"Kill an enemy with Bow before Bridges fall"}, + new String[] {"Kill an enemy with Archery before Bridges fall"}, new int[] {1}, AchievementCategory.BRIDGES), diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java index 14037083f..d725eb237 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java @@ -543,6 +543,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable }); } } + /* else if (packet instanceof PacketPlayOutNamedSoundEffect) { try @@ -567,6 +568,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable e.printStackTrace(); } } + */ return true; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphPumpkinKing.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphPumpkinKing.java index d1ed0a3f6..4cfc27555 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphPumpkinKing.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphPumpkinKing.java @@ -62,6 +62,7 @@ public class MorphPumpkinKing extends MorphGadget { this.RemoveArmor(player); Manager.getDisguiseManager().undisguise(player); + player.getInventory().setHelmet(null); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountCart.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountCart.java index 1892b4cc9..d72168ac4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountCart.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountCart.java @@ -7,6 +7,7 @@ import org.bukkit.Sound; import org.bukkit.entity.Minecart; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityTargetEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; @@ -170,4 +171,11 @@ public class MountCart extends Mount } } } + + @EventHandler + public void cancelBreak(EntityDamageEvent event) + { + if (GetActive().values().contains(event.getEntity())) + event.setCancelled(true); + } } 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 c577e8e82..a7c1aa048 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -647,8 +647,9 @@ public class ArcadeManager extends MiniPlugin implements IRelation // Arrows go bye bye. ((CraftPlayer) player).getHandle().p(0); - GetCondition().EndCondition(player, ConditionType.CLOAK, null); - + //Remove all conditions + GetCondition().EndCondition(player, null, null); + HubClock(player); GetDisguise().undisguise(player); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameFactory.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameFactory.java index 4181d7e65..6108fa4b3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameFactory.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameFactory.java @@ -26,7 +26,7 @@ import nautilus.game.arcade.game.games.halloween.Halloween; import nautilus.game.arcade.game.games.hideseek.HideSeek; import nautilus.game.arcade.game.games.micro.Micro; import nautilus.game.arcade.game.games.milkcow.MilkCow; -//import nautilus.game.arcade.game.games.minestrike.MineStrike; +import nautilus.game.arcade.game.games.minestrike.MineStrike; import nautilus.game.arcade.game.games.mineware.MineWare; import nautilus.game.arcade.game.games.quiver.Quiver; import nautilus.game.arcade.game.games.quiver.QuiverTeams; @@ -79,7 +79,7 @@ public class GameFactory else if (gameType == GameType.Halloween) return new Halloween(_manager); else if (gameType == GameType.HideSeek) return new HideSeek(_manager); else if (gameType == GameType.Micro) return new Micro(_manager); - //else if (gameType == GameType.MineStrike) return new MineStrike(_manager); + else if (gameType == GameType.MineStrike) return new MineStrike(_manager); else if (gameType == GameType.MineWare) return new MineWare(_manager); else if (gameType == GameType.MilkCow) return new MilkCow(_manager); else if (gameType == GameType.Paintball) return new Paintball(_manager); 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 78ed62c1d..75d7af6cf 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 @@ -6,6 +6,7 @@ import mineplex.core.common.util.*; import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.UpdateType; import mineplex.minecraft.game.core.combat.DeathMessageType; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.ArcadeFormat; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; @@ -37,10 +38,14 @@ import org.bukkit.Location; import org.bukkit.Sound; import org.bukkit.block.BlockFace; import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; +import org.bukkit.entity.Hanging; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.hanging.HangingBreakEvent; +import org.bukkit.event.hanging.HangingPlaceEvent; import org.bukkit.event.player.PlayerLoginEvent; import org.bukkit.scoreboard.Objective; import org.bukkit.util.Vector; @@ -1147,4 +1152,25 @@ public abstract class Game implements Listener { return _statTrackers; } + + @EventHandler + public void onHangingBreak(HangingBreakEvent event) + { + event.setCancelled(true); + } + + @EventHandler + public void onHangingPlace(HangingPlaceEvent event) + { + event.setCancelled(true); + } + + @EventHandler + public void onDamageHanging(EntityDamageEvent event) + { + if (event.getEntity() instanceof Hanging) + { + event.setCancelled(true); + } + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/MineStrike.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/MineStrike.java new file mode 100644 index 000000000..fe13625ab --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/MineStrike.java @@ -0,0 +1,1912 @@ +package nautilus.game.arcade.game.games.minestrike; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; + +import org.bukkit.ChatColor; +import org.bukkit.Color; +import org.bukkit.Effect; +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Item; +import org.bukkit.entity.Painting; +import org.bukkit.entity.Player; +import org.bukkit.entity.Snowball; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.ItemDespawnEvent; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.painting.PaintingBreakEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerDropItemEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerItemConsumeEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.event.player.PlayerPickupItemEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerToggleSneakEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.inventory.meta.LeatherArmorMeta; +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.UtilAlg; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilGear; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilWorld; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilTime; +import mineplex.core.disguise.disguises.DisguisePlayer; +import mineplex.core.itemstack.ItemStackFactory; +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.combat.event.CombatDeathEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.events.PlayerKitGiveEvent; +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.TeamGame; +import nautilus.game.arcade.game.GameTeam.PlayerState; +import nautilus.game.arcade.game.games.minestrike.data.Bomb; +import nautilus.game.arcade.game.games.minestrike.data.Bullet; +import nautilus.game.arcade.game.games.minestrike.items.StrikeItem; +import nautilus.game.arcade.game.games.minestrike.items.grenades.Grenade; +import nautilus.game.arcade.game.games.minestrike.items.guns.Gun; +import nautilus.game.arcade.game.games.minestrike.items.guns.pistol.Glock18; +import nautilus.game.arcade.game.games.minestrike.items.guns.pistol.P2000; +import nautilus.game.arcade.game.games.minestrike.items.guns.rifle.AWP; +import nautilus.game.arcade.game.games.minestrike.kits.KitPlayer; +import nautilus.game.arcade.kit.Kit; + +public class MineStrike extends TeamGame +{ + //Managers + private ShopManager _shopManager; + + //Data + private int _roundsToWin = 10; + private long _roundTime = 120000; + + + //Map Data + private ArrayList _bombSites; + + //Ongoing Data + private HashMap _gunsEquipped = new HashMap(); + private HashMap _grenadesEquipped = new HashMap(); + + private HashMap _score = new HashMap(); + + private HashMap _disguise = new HashMap(); + + //Round Data (wiped at end of each round) + private HashMap _gunsDropped = new HashMap(); + private HashMap _grenadesDropped = new HashMap(); + + private HashMap _bullets = new HashMap(); + private HashMap _grenadesThrown = new HashMap(); + + private Bomb _bomb = null; + private Item _bombItem = null; + private Player _bombHolder = null; + + private Player _bombPlanter; + private Player _bombDefuser; + private Player _bombPlantedBy; + + private boolean _bombScoreboardFlash = false; + + private HashSet _scoped = new HashSet(); + + //Round Data + private String _winText = null; + private boolean _roundOver = false; + private int _freezeTime = 0; + + //Money Data + private boolean _bombPlanted = false; + private boolean _ctWonLast = false; + private int _winStreak = 0; + + + public MineStrike(ArcadeManager manager) + { + super(manager, GameType.MineStrike, + + new Kit[] + { + new KitPlayer(manager), + }, + + new String[] + { + C.cAqua + "SWAT" + C.cWhite + " Defend the Bomb Sites", + C.cAqua + "SWAT" + C.cWhite + " Kill the Terrorists", + " ", + C.cRed + "Al'Jaha" + C.cWhite + " Plant the Bomb at Bomb Site", + C.cRed + "Al'Jaha" + C.cWhite + " Kill the Counter-Terrorists", + }); + + _shopManager = new ShopManager(this); + + this.HungerSet = 18; + + this.ItemDrop = true; + + this.InventoryClick = true; + + this._help = new String[] + { + "Tap Crouch when close to an ally to Boost", + "Moving decreases accuracy", + "Sprinting heavily decreases accuracy", + "Jumping massively decreases accuracy", + "Crouching increases accuracy", + "Hold Right-Click to Plant Bomb", + "Hold RIght-Click with Knife to Defuse Bomb", + }; + } + + @Override + public void ParseData() + { + _bombSites = WorldData.GetDataLocs("RED"); + } + + @EventHandler + public void CustomTeamGeneration(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Recruit) + return; + + this.GetTeamList().get(0).SetColor(ChatColor.AQUA); + this.GetTeamList().get(0).SetName("SWAT"); + + this.GetTeamList().get(1).SetColor(ChatColor.RED); + this.GetTeamList().get(1).SetName("Al'Jaha"); + } + + @EventHandler + public void giveStartEquipment(PlayerKitGiveEvent event) + { + GameTeam team = GetTeam(event.GetPlayer()); + if (team == null) + return; + + if (team.GetColor() == ChatColor.RED) + { + //Pistol + Gun gun = new Glock18(); + registerGun(gun, event.GetPlayer()); + gun.giveToPlayer(event.GetPlayer()); + + //Knife + event.GetPlayer().getInventory().setItem(2, ItemStackFactory.Instance.CreateStack(Material.IRON_AXE, (byte)0, 1, "Knife")); + + //Sneak + disguiseSneak(event.GetPlayer(), team); + } + else if (team.GetColor() == ChatColor.AQUA) + { + //Pistol + Gun gun = new P2000(); + registerGun(gun, event.GetPlayer()); + gun.giveToPlayer(event.GetPlayer()); + + //Knife + event.GetPlayer().getInventory().setItem(2, ItemStackFactory.Instance.CreateStack(Material.IRON_SWORD, (byte)0, 1, "Knife")); + + //Sneak + disguiseSneak(event.GetPlayer(), team); + } + + //Enter Shop + _shopManager.enterShop(event.GetPlayer()); + } + + public void disguiseSneak(Player player, GameTeam team) + { + //Create Disguise + if (!_disguise.containsKey(player)) + { + _disguise.put(player, new DisguisePlayer(player, ((CraftPlayer)player).getProfile())); + + //Enable Disguise + Manager.GetDisguise().disguise(_disguise.get(player)); + } + + DisguisePlayer disguise = _disguise.get(player); + disguise.setSneaking(true); + + for (Player other : UtilServer.getPlayers()) + { + if (team.HasPlayer(other)) + { + Manager.GetDisguise().removeViewerToDisguise(disguise, other); + } + else + { + Manager.GetDisguise().addViewerToDisguise(disguise, other); + } + } + } + + public void giveTeamArmor(Player player, Color color) + { + ItemStack armor = new ItemStack(Material.LEATHER_CHESTPLATE); + LeatherArmorMeta meta = (LeatherArmorMeta)armor.getItemMeta(); + meta.setColor(color); + armor.setItemMeta(meta); + player.getInventory().setChestplate(armor); + + ItemStack legs = new ItemStack(Material.LEATHER_LEGGINGS); + LeatherArmorMeta metaLegs = (LeatherArmorMeta)legs.getItemMeta(); + metaLegs.setColor(color); + legs.setItemMeta(metaLegs); + player.getInventory().setLeggings(legs); + + ItemStack boots = new ItemStack(Material.LEATHER_BOOTS); + LeatherArmorMeta metaBoots = (LeatherArmorMeta)boots.getItemMeta(); + metaBoots.setColor(color); + boots.setItemMeta(metaBoots); + player.getInventory().setBoots(boots); + } + + @EventHandler + public void shopInventoryClick(InventoryClickEvent event) + { + _shopManager.inventoryClick(event); + } + + + + @EventHandler + public void shopUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + return; + + _shopManager.update(); + } + + @EventHandler + public void quitClean(PlayerQuitEvent event) + { + _shopManager.leaveShop(event.getPlayer(), false, true); + _disguise.remove(event.getPlayer()); + _scoped.remove(event.getPlayer()); + dropInventory(event.getPlayer()); + } + + @EventHandler + public void giveBombInitial(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Prepare) + return; + + UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(Manager.GetPlugin(), new Runnable() + { + public void run() + { + Player player = UtilAlg.Random(GetTeam(ChatColor.RED).GetPlayers(true)); + + giveBombToPlayer(player); + } + }, 40); + } + + public void giveBombToPlayer(Player player) + { + if (player == null) + return; + + GameTeam team = GetTeam(player); + if (team == null) + return; + + if (team.GetColor() != ChatColor.RED) + return; + + //Bomb + player.getInventory().setItem(8, ItemStackFactory.Instance.CreateStack(Material.GOLD_SWORD, (byte)0, 1, C.cGold + C.Bold + "C4 Explosive")); + + //Inform + if (!IsLive() || _freezeTime > 0) + { + for (Player other : team.GetPlayers(false)) + if (!other.equals(player)) + UtilPlayer.message(other, C.cGold + C.Bold + player.getName() + " has the Bomb!"); + + UtilPlayer.message(player, C.cGold + C.Bold + "You have the Bomb!"); + UtilPlayer.message(player, C.cGold + C.Bold + "Hold Right-Click to place at a Bomb Site!"); + } + else + { + UtilPlayer.message(player, C.cGold + C.Bold + "You picked up the Bomb!"); + } + + player.playSound(player.getLocation(), Sound.NOTE_PLING, 1f, 2f); + _bombHolder = player; + + if (_bombItem != null) + { + _bombItem.remove(); + _bombItem = null; + } + } + + public void registerGun(Gun gun, Player player) + { + _gunsEquipped.put(gun, player); + } + + public void deregisterGun(Gun gun) + { + _gunsEquipped.remove(gun); + } + + public void registerGrenade(Grenade grenade, Player player) + { + _grenadesEquipped.put(grenade, player); + } + + public void deregisterGrenade(Grenade grenade) + { + _grenadesEquipped.remove(grenade); + } + + public void registerDroppedGun(Entity ent, Gun gun) + { + _gunsDropped.put(ent, gun); + } + + public void deregisterDroppedGun(Gun gun) + { + Iterator entIterator = _gunsDropped.keySet().iterator(); + + while (entIterator.hasNext()) + if (gun.equals(_gunsDropped.get(entIterator.next()))) + entIterator.remove(); + } + + public void registerDroppedGrenade(Entity ent, Grenade grenade) + { + _grenadesDropped.put(ent, grenade); + } + + public void deregisterDroppedGrenade(Grenade grenade) + { + Iterator entIterator = _grenadesDropped.keySet().iterator(); + + while (entIterator.hasNext()) + if (grenade.equals(_grenadesDropped.get(entIterator.next()))) + entIterator.remove(); + } + + public void registerBullet(Bullet bullet) + { + _bullets.put(bullet.Bullet, bullet); + + UtilEnt.ghost(bullet.Bullet, false, true); + } + + public void registerThrownGrenade(Entity ent, Grenade grenade) + { + _grenadesThrown.put(ent, grenade); + } + + public Gun getGunInHand(Player player, ItemStack overrideStack) + { + ItemStack stack = player.getItemInHand(); + if (overrideStack != null) + stack = overrideStack; + + for (Gun gun : _gunsEquipped.keySet()) + { + if (!_gunsEquipped.get(gun).equals(player)) + continue; + + if (!gun.isStack(stack)) + continue; + + return gun; + } + + return null; + } + + public Grenade getGrenadeInHand(Player player, ItemStack overrideStack) + { + ItemStack stack = player.getItemInHand(); + if (overrideStack != null) + stack = overrideStack; + + for (Grenade grenade : _grenadesEquipped.keySet()) + { + if (!_grenadesEquipped.get(grenade).equals(player)) + continue; + + if (!grenade.isStack(stack)) + continue; + + return grenade; + } + + return null; + } + + + + @EventHandler + public void triggerShoot(PlayerInteractEvent event) + { + if (_freezeTime > 0) + return; + + if (!IsLive()) + return; + + if (!IsAlive(event.getPlayer())) + return; + + if (!UtilEvent.isAction(event, ActionType.R)) + return; + + //Players get between 150 and 250. 200 is norm. For some reason it doesnt go outside 150-250 bounds. + //Announce("Since Last: " + (System.currentTimeMillis() - last), false); + //last = System.currentTimeMillis(); + + Gun gun = getGunInHand(event.getPlayer(), null); + if (gun == null) + return; + + gun.shoot(event.getPlayer(), this); + event.setCancelled(true); + } + + @EventHandler + public void triggerReload(PlayerInteractEvent event) + { + if (_freezeTime > 0) + return; + + if (!IsLive()) + return; + + if (!IsAlive(event.getPlayer())) + return; + + if (!UtilEvent.isAction(event, ActionType.L)) + return; + + Gun gun = getGunInHand(event.getPlayer(), null); + if (gun == null) + return; + + gun.reload(event.getPlayer()); + event.setCancelled(true); + } + + @EventHandler + public void triggerGrenade(PlayerItemConsumeEvent event) + { + if (_freezeTime > 0) + { + event.setCancelled(true); + return; + } + + if (!IsLive()) + return; + + if (!IsAlive(event.getPlayer())) + return; + + Grenade grenade = getGrenadeInHand(event.getPlayer(), null); + if (grenade == null) + return; + + grenade.throwGrenade(event.getPlayer(), this); + event.setCancelled(true); + } + + @EventHandler + public void triggerDrop(PlayerDropItemEvent event) + { + if (!InProgress()) + return; + + //Without this, the event is cancelled in pre-game by managers + //Which results in the item staying in your hand, even if i set to null here. + event.setCancelled(false); + + //Guns + Gun gun = getGunInHand(event.getPlayer(), event.getItemDrop().getItemStack()); + if (gun != null) + { + gun.drop(this, event.getPlayer(), false); + event.getItemDrop().remove(); + return; + } + + //Grenades + Grenade grenade = getGrenadeInHand(event.getPlayer(), event.getItemDrop().getItemStack()); + if (grenade != null) + { + grenade.drop(this, event.getPlayer(), false); + event.getItemDrop().remove(); + return; + } + + //Bomb + if (event.getItemDrop().getItemStack().getType() == Material.GOLD_SWORD) + { + _bombItem = event.getItemDrop(); + _bombHolder = null; + return; + } + + event.setCancelled(true); + } + + @EventHandler(priority = EventPriority.LOWEST) + public void deathDrop(PlayerDeathEvent event) + { + dropInventory(event.getEntity()); + } + + public void dropInventory(Player player) + { + if (!InProgress()) + return; + + for (int i=0 ; i<9 ; i++) + { + ItemStack stack = player.getInventory().getItem(i); + + if (stack == null || stack.getType() == Material.AIR) + continue; + + HashSet toDrop = new HashSet(); + + //Guns + for (StrikeItem item : _gunsEquipped.keySet()) + { + if (!_gunsEquipped.get(item).equals(player)) + continue; + + toDrop.add(item); + } + + //Grenades + for (StrikeItem item : _grenadesEquipped.keySet()) + { + if (!_grenadesEquipped.get(item).equals(player)) + continue; + + toDrop.add(item); + } + + for (StrikeItem item : toDrop) + { + item.drop(this, player, true); + } + + //Bomb + if (stack.getType() == Material.GOLD_SWORD) + { + _bombItem = player.getWorld().dropItemNaturally(player.getEyeLocation(), stack); + _bombItem.setPickupDelay(40); + _bombHolder = null; + } + } + + UtilInv.Clear(player); + } + + @EventHandler + public void triggerPickup(PlayerPickupItemEvent event) + { + if (!InProgress()) + return; + + if (event.getItem().getTicksLived() < 10) + return; + + if (UtilMath.offset(event.getItem(), event.getPlayer()) > 1) + return; + + if (!IsAlive(event.getPlayer())) + return; + + //Guns + Gun gun = _gunsDropped.get(event.getItem()); + if (gun != null) + { + gun.pickup(this, event.getPlayer()); + } + + //Grenades + Grenade grenade = _grenadesDropped.get(event.getItem()); + if (grenade != null) + { + grenade.pickup(this, event.getPlayer()); + } + + //Bomb + if (_bombItem != null && _bombItem.equals(event.getItem())) + { + giveBombToPlayer(event.getPlayer()); + } + } + + @EventHandler + public void rechargeWeapons(RechargedEvent event) + { + for (Gun gun : _gunsEquipped.keySet()) + { + if (_gunsEquipped.get(gun).equals(event.GetPlayer())) + { + gun.reloadEvent(event); + } + } + } + + @EventHandler + public void coneOfFireIncrease(PlayerMoveEvent event) + { + Gun gun = getGunInHand(event.getPlayer(), null); + if (gun != null) + { + gun.moveEvent(event); + } + } + + @EventHandler + public void coneOfFireReduction(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + for (Gun gun : _gunsEquipped.keySet()) + { + gun.reduceCone(); + } + } + + @EventHandler + public void projectileHitSound(ProjectileHitEvent event) + { + if (event.getEntity() instanceof Snowball) + { + event.getEntity().getWorld().playSound(event.getEntity().getLocation(), Sound.ENDERMAN_HIT, 1f, 1f); + } + } + + @EventHandler(priority = EventPriority.MONITOR) + public void bulletFlybySound(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + for (Player player : UtilServer.getPlayers()) + { + for (Entity ent : _bullets.keySet()) + { + if (UtilMath.offset(player.getEyeLocation(), ent.getLocation()) < 4) + { + if (_bullets.get(ent).bulletSound()) + { + player.playSound(ent.getLocation(), Sound.BAT_IDLE, (float)(0.2 + UtilMath.offset(player.getEyeLocation(), ent.getLocation()) / 4d), 1f); + } + } + } + } + } + + @EventHandler(priority=EventPriority.HIGHEST) + public void damage(CustomDamageEvent event) + { + + + if (event.GetProjectile() == null) + { + if (event.IsCancelled()) + return; + + if (event.GetDamagerPlayer(false) != null) + { + event.GetDamageeEntity().getWorld().playSound(event.GetDamageeEntity().getLocation(), Sound.BAT_HURT, 1f, 1f); + } + + return; + } + + Bullet bullet = _bullets.remove(event.GetProjectile()); + if (bullet == null) + return; + + //Wipe previous data! + event.GetCancellers().clear(); + event.GetDamageMod().clear(); + event.GetDamageMult().clear(); + + event.AddMod(GetName(), bullet.Gun.getName(), bullet.getDamage(event.GetDamageeEntity().getLocation()), true); + + event.SetKnockback(false); + + if (event.GetDamageePlayer() != null) + event.GetDamageePlayer().setVelocity(new Vector(0,0,0)); + + event.SetIgnoreRate(true); + } + + @EventHandler + public void killReward(CombatDeathEvent event) + { + Game game = Manager.GetGame(); + if (game == null) return; + + if (!(event.GetEvent().getEntity() instanceof Player)) + return; + + Player killed = (Player)event.GetEvent().getEntity(); + + if (event.GetLog().GetKiller() != null) + { + Player killer = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName()); + + if (killer == null || killer.equals(killed)) + return; + + if (GetTeam(killed).equals(GetTeam(killer))) + return; + + int amount = 300; + + if (event.GetLog().GetLastDamager().GetReason().contains("AWP")) + amount = 100; + + else if (event.GetLog().GetLastDamager().GetReason().contains("Nova")) + amount = 900; + + else if (event.GetLog().GetLastDamager().GetReason().contains("Knife")) + amount = 1500; + + _shopManager.addMoney(killer, amount, "kill with " + event.GetLog().GetLastDamager().GetReason()); + } + } + + + + @EventHandler + public void updateBulletsGrenades(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + //Bullets + Iterator bulletIterator = _bullets.keySet().iterator(); + + while (bulletIterator.hasNext()) + { + Snowball bullet = bulletIterator.next(); + + if (!bullet.isValid() || bullet.getTicksLived() > 200) + { + bulletIterator.remove(); + bullet.remove(); + } + else + { + //UtilParticle.PlayParticle(ParticleType.CRIT, bullet.getLocation(), 0, 0, 0, 0, 1); + } + } + + //Grenades + Iterator grenadeIterator = _grenadesThrown.keySet().iterator(); + + while (grenadeIterator.hasNext()) + { + Entity grenadeItem = grenadeIterator.next(); + + UtilParticle.PlayParticle(ParticleType.CRIT, grenadeItem.getLocation(), 0, 0, 0, 0, 1); + + //Expired + if (!grenadeItem.isValid() || grenadeItem.getTicksLived() > 400) + { + grenadeItem.remove(); + grenadeIterator.remove(); + continue; + } + + //Completed + Grenade grenade = _grenadesThrown.get(grenadeItem); + if (grenade.update(this, grenadeItem)) + { + grenadeItem.remove(); + grenadeIterator.remove(); + } + } + } + + public void dropSlotItem(Player player, int slot) + { + for (Gun gun : _gunsEquipped.keySet()) + { + if (!_gunsEquipped.get(gun).equals(player)) + continue; + + if (gun.isStack(player.getInventory().getItem(slot))) + { + gun.drop(this, player, false); + player.getInventory().setItem(slot, null); + return; + } + } + } + + @EventHandler + public void plantBomb(PlayerInteractEvent event) + { + Player player = event.getPlayer(); + + if (!UtilGear.isMat(player.getItemInHand(), Material.GOLD_SWORD)) + return; + + if (!UtilEnt.isGrounded(player)) + { + UtilPlayer.message(player, F.main("Game", "You can only plant Bomb on the ground!")); + event.setCancelled(true); + return; + } + + //Should never occur with 1 Bomb + if (_bombPlanter != null) + { + UtilPlayer.message(player, F.main("Game", "Someone else is planting Bomb...")); + event.setCancelled(true); + return; + } + + //Check Bomb Sites + boolean near = false; + for (Location loc : _bombSites) + { + if (UtilMath.offset(player.getLocation(), loc) < 5) + { + near = true; + break; + } + } + + //Too Far + if (!near) + { + UtilPlayer.message(player, F.main("Game", "You can only plant Bomb at a bomb site!")); + event.setCancelled(true); + return; + } + + _bombPlanter = player; + _bombPlanter.setExp(0f); + + UtilPlayer.message(player, F.main("Game", "You are placing the Bomb.")); + } + + @EventHandler + public void plantBombUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + if (_bombPlanter == null) + return; + + if (!_bombPlanter.isBlocking()) + { + _bombPlanter.setExp(0f); + _bombPlanter = null; + + return; + } + + _bombPlanter.setExp(Math.min(_bombPlanter.getExp() + 0.017f, 0.99999f)); + + if (Math.random() > 0.90) + _bombPlanter.getWorld().playSound(_bombPlanter.getLocation(), Sound.NOTE_PLING, 1f, 3f); + + if (_bombPlanter.getExp() >= 0.98f) + { + _bomb = new Bomb(_bombPlanter); + + _shopManager.addMoney(_bombPlanter, 300, "planting the bomb"); + + Announce(C.cRed + C.Bold + _bombPlanter.getName() + " has planted the bomb!"); + + _bombPlantedBy = _bombPlanter; + + _bombPlanter.setExp(0f); + _bombPlanter.setItemInHand(null); + _bombPlanter = null; + _bombHolder = null; + + } + } + + @EventHandler + public void plantDefuseBombRestrictMovement(PlayerMoveEvent event) + { + if (_bombPlanter != null && _bombPlanter.equals(event.getPlayer())) + if (UtilMath.offset(event.getFrom(), event.getTo()) > 0) + event.setTo(event.getFrom()); + + if (_bombDefuser != null && _bombDefuser.equals(event.getPlayer())) + if (UtilMath.offset(event.getFrom(), event.getTo()) > 0) + event.setTo(event.getFrom()); + } + + @EventHandler + public void defuseKitMessage(PlayerInteractEvent event) + { + Player player = event.getPlayer(); + + if (!UtilGear.isMat(player.getItemInHand(), Material.SHEARS)) + return; + + UtilPlayer.message(player, F.main("Game", F.elem(C.cGreen + "Right-Click") + " with your " + F.elem("Knife") + " to defuse bombs.")); + } + + @EventHandler + public void defuseBomb(PlayerInteractEvent event) + { + Player player = event.getPlayer(); + + if (!UtilGear.isMat(player.getItemInHand(), Material.IRON_SWORD)) + return; + + if (!UtilEvent.isAction(event, ActionType.R_BLOCK)) + { + if (_bomb != null && event.getClickedBlock() == null && _bomb.isBlock(event.getClickedBlock())) + { + UtilPlayer.message(player, F.main("Game", "Hold Right-Click to defuse the Bomb!")); + return; + } + + return; + } + + if (_bomb == null || event.getClickedBlock() == null || !_bomb.isBlock(event.getClickedBlock())) + { + UtilPlayer.message(player, F.main("Game", "You must be looking at the Bomb to defuse.")); + return; + } + + if (!UtilEnt.isGrounded(player)) + { + UtilPlayer.message(player, F.main("Game", "You can only defuse Bomb while on the ground!")); + return; + } + + if (_bombDefuser != null) + { + UtilPlayer.message(player, F.main("Game", _bombDefuser.getName() + " is already defusing the Bomb.")); + return; + } + + + + _bombDefuser = player; + _bombDefuser.setExp(0f); + + UtilPlayer.message(player, F.main("Game", "You are defusing the Bomb.")); + } + + @EventHandler + public void defuseBombUpdate(UpdateEvent event) + { + if (!IsLive()) + return; + + if (event.getType() != UpdateType.TICK) + return; + + if (_bombDefuser == null) + return; + + if (!_bombDefuser.isBlocking()) + { + _bombDefuser.setExp(0f); + _bombDefuser = null; + return; + } + + //Kit or Not? + float defuseRate = 0.005f; + if (UtilGear.isMat(_bombDefuser.getInventory().getItem(8), Material.SHEARS)) + defuseRate = 0.01f; + + _bombDefuser.setExp(Math.min(_bombDefuser.getExp() + defuseRate, 0.99999f)); + + if (Math.random() > 0.95) + _bombDefuser.getWorld().playSound(_bombDefuser.getLocation(), Sound.PISTON_RETRACT, 1f, (float)(Math.random() + 1f)); + + if (_bombDefuser.getExp() >= 0.98f) + { + _bomb.defuse(); + + _winText = _bombDefuser.getName() + " defused the bomb!"; + + _bomb = null; + _bombDefuser.setExp(0f); + _bombDefuser = null; + + setWinner(GetTeam(ChatColor.AQUA)); + } + } + + @EventHandler + public void bombUpdate(UpdateEvent event) + { + if (!IsLive()) + return; + + if (event.getType() != UpdateType.TICK) + return; + + if (_bomb == null) + return; + + if (!_bomb.update()) + return; + + /* + Set blocks = UtilBlock.getInRadius(_bomb.Block.getLocation(), 10d).keySet(); + + Iterator blockIterator = blocks.iterator(); + while (blockIterator.hasNext()) + { + Block block = blockIterator.next(); + + if (block.getY() < 2) + blockIterator.remove(); + } + + Manager.GetExplosion().BlockExplosion(blocks, _bomb.Block.getLocation(), false); + */ + + + HashMap players = UtilPlayer.getInRadius(_bomb.Block.getLocation(), 48); + for (Player player : players.keySet()) + { + if (!IsAlive(player)) + continue; + + // Damage Event + Manager.GetDamage().NewDamageEvent(player, null, null, + DamageCause.CUSTOM, 1 + (players.get(player) * 40), + true, true, false, null, "C4 Explosion"); + } + + + _bomb = null; + + _winText = _bombPlantedBy.getName() + " destroyed the bomb site!"; + + setWinner(GetTeam(ChatColor.RED)); + } + + @EventHandler + public void bombItemUpdate(UpdateEvent event) + { + if (!InProgress()) + return; + + if (event.getType() != UpdateType.SEC) + return; + + if (_bombItem == null) + return; + + UtilParticle.PlayParticle(ParticleType.HAPPY_VILLAGER, _bombItem.getLocation().add(0.0, 0.2, 0.0), 0, 0, 0, 0, 1); + } + + public int getScore(GameTeam team) + { + if (!_score.containsKey(team)) + _score.put(team, 0); + + return _score.get(team); + } + + public void addScore(GameTeam team) + { + _score.put(team, getScore(team) + 1); + } + + @EventHandler + public void roundTimerUpdate(UpdateEvent event) + { + if (!IsLive()) + return; + + if (event.getType() != UpdateType.TICK) + return; + + if (_bomb != null) + return; + + if (UtilTime.elapsed(GetStateTime(), _roundTime)) + { + _winText = "Bomb sites were successfully defended!"; + drawScoreboard(); + setWinner(GetTeam(ChatColor.AQUA)); + } + } + + @EventHandler + public void roundPlayerCheck(UpdateEvent event) + { + if (!IsLive()) + return; + + if (event.getType() != UpdateType.TICK) + return; + + ArrayList teamsAlive = new ArrayList(); + + for (GameTeam team : this.GetTeamList()) + if (team.GetPlayers(true).size() > 0) + teamsAlive.add(team); + + if (teamsAlive.size() == 1) + { + //Bomb Planted - CT cannot win without defusing + if (_bomb != null) + { + if (teamsAlive.size() > 0) + { + if (teamsAlive.get(0).GetColor() == ChatColor.AQUA) + { + return; + } + } + } + + setWinner(teamsAlive.get(0)); + } + else if (teamsAlive.size() == 0) + { + if (_bomb == null) + { + _winText = "Bomb sites were successfully defended!"; + setWinner(GetTeam(ChatColor.AQUA)); + } + else + { + _winText = "Bomb site will be destroyed!"; + setWinner(GetTeam(ChatColor.RED)); + } + } + } + + public void setWinner(GameTeam winner) + { + if (_roundOver) + return; + + _roundOver = true; + + String winnerLine = C.Bold + "The round was a draw!"; + ChatColor color = ChatColor.GRAY; + if (winnerLine != null) + { + winnerLine= winner.GetColor() + C.Bold + winner.GetName() + " has won the round!"; + addScore(winner); + drawScoreboard(); + color = winner.GetColor(); + } + + //Record Streak for Money + if (winner.GetColor() == ChatColor.RED) + { + _winStreak++; + + if (_ctWonLast) + { + _ctWonLast = false; + _winStreak = 0; + } + } + else + { + _winStreak++; + + if (!_ctWonLast) + { + _ctWonLast = true; + _winStreak = 0; + } + } + + //Announce + Announce("", false); + Announce(color + "===================================", false); + Announce("", false); + Announce(winnerLine, false); + if (_winText != null) + Announce(_winText, false); + Announce("", false); + Announce(color + "===================================", false); + + for (Player player : UtilServer.getPlayers()) + player.playSound(player.getLocation(), Sound.LEVEL_UP, 1f, 1f); + + //Check for total game win + EndCheck(); + + //Next Round (if not over) + if (IsLive()) + { + UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(Manager.GetPlugin(), new Runnable() + { + public void run() + { + restartRound(); + } + }, 100); + } + } + + public void restartRound() + { + giveMoney(); + + //Clean + resetGame(); + + //Teleport to Spawn + for (GameTeam team : GetTeamList()) + team.SpawnTeleport(false); + + //Revive Dead Players + for (Player player : GetPlayers(false)) + if (!IsAlive(player)) + { + SetPlayerState(player, PlayerState.IN); + + GameTeam team = GetTeam(player); + + //Teleport + team.SpawnTeleport(player); + + Manager.Clear(player); + UtilInv.Clear(player); + + ValidateKit(player, GetTeam(player)); + + if (GetKit(player) != null) + GetKit(player).ApplyKit(player); + } + + //Prepare Sound + for (Player player : GetPlayers(false)) + { + player.playSound(player.getLocation(), Sound.HORSE_ARMOR, 1f, 2f); + Manager.GetCondition().Factory().Blind("Respawn", player, null, 2, 0, false, false, false); + } + + //Give Bomb + Player player = UtilAlg.Random(GetTeam(ChatColor.RED).GetPlayers(true)); + giveBombToPlayer(player); + } + + public void giveMoney() + { + if (_ctWonLast) + { + int ctMoney = 3250; + int tMoney = 1400 + (Math.min(4,_winStreak) * 500); + + if (_bombPlanted) + { + ctMoney += 250; + tMoney += 800; + } + + //Award + for (Player player : GetTeam(ChatColor.RED).GetPlayers(false)) + _shopManager.addMoney(player, tMoney, "losing the round"); + + for (Player player : GetTeam(ChatColor.AQUA).GetPlayers(false)) + _shopManager.addMoney(player, ctMoney, "winning the round"); + } + else + { + int tMoney = 3250; + int ctMoney = 1400 + (Math.min(4,_winStreak) * 500); + + //Award + for (Player player : GetTeam(ChatColor.RED).GetPlayers(false)) + _shopManager.addMoney(player, tMoney, "winning the round"); + + for (Player player : GetTeam(ChatColor.AQUA).GetPlayers(false)) + _shopManager.addMoney(player, ctMoney, "losing the round"); + } + } + + public void resetGame() + { + //General + _roundOver = false; + SetStateTime(System.currentTimeMillis()); + _freezeTime = 10; + _winText = null; + + //Bomb + if (_bomb != null) + _bomb.clean(); + + if (_bombItem != null) + _bombItem.remove(); + + if (_bombHolder != null) + { + _bombHolder.getInventory().remove(Material.GOLD_SWORD); + _bombHolder = null; + } + + _bomb = null; + _bombItem = null; + + _bombPlanter = null; + _bombDefuser = null; + _bombPlantedBy = null; + _bombPlanted = false; + + //Dropped Guns + for (Entity ent : _gunsDropped.keySet()) + ent.remove(); + _gunsDropped.clear(); + + //Dropped Grenades + for (Entity ent : _grenadesDropped.keySet()) + ent.remove(); + _grenadesDropped.clear(); + + //Thrown Grenades + for (Entity ent : _grenadesThrown.keySet()) + ent.remove(); + _grenadesThrown.clear(); + + //Bullets + for (Entity ent : _bullets.keySet()) + ent.remove(); + _bullets.clear(); + + //Restock Ammo + for (Gun gun : _gunsEquipped.keySet()) + gun.restockAmmo(_gunsEquipped.get(gun)); + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void specToTeam(PlayerJoinEvent event) + { + if (GetState() == GameState.Recruit) + return; + + //Target Team + GameTeam targetTeam = null; + if (GetTeamList().get(0).GetPlayers(false).size() < GetTeamList().get(1).GetPlayers(false).size()) + targetTeam = GetTeamList().get(0); + else if (GetTeamList().get(0).GetPlayers(false).size() > GetTeamList().get(1).GetPlayers(false).size()) + targetTeam = GetTeamList().get(1); + else if (Math.random() > 0.5) + targetTeam = GetTeamList().get(1); + else + targetTeam = GetTeamList().get(0); + + SetPlayerTeam(event.getPlayer(), targetTeam, false); + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void quitLeaveTeam(PlayerQuitEvent event) + { + GameTeam team = GetTeam(event.getPlayer()); + + if (team != null) + { + team.RemovePlayer(event.getPlayer()); + } + } + + @EventHandler + public void restartFreezeCountdown(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + return; + + if (_freezeTime <= 0) + return; + + _freezeTime--; + + for (Player player : UtilServer.getPlayers()) + { + if (_freezeTime > 0) + player.playSound(player.getLocation(), Sound.NOTE_STICKS, 1f, 1f); + else + player.playSound(player.getLocation(), Sound.NOTE_SNARE_DRUM, 1f, 1f); + } + } + + @EventHandler + public void restartPlayerFreeze(PlayerMoveEvent event) + { + if (_freezeTime <= 0) + return; + + if (UtilMath.offset2d(event.getFrom(), event.getTo()) <= 0) + return; + + event.getFrom().setPitch(event.getTo().getPitch()); + event.getFrom().setYaw(event.getTo().getYaw()); + + event.setTo(event.getFrom()); + } + + @EventHandler + public void boostClimb(PlayerToggleSneakEvent event) + { + if (!IsLive()) + return; + + Player player = event.getPlayer(); + + boolean nearOther = false; + for (Player other : GetPlayers(true)) + { + if (player.equals(other)) + continue; + + if (UtilMath.offset(player, other) < 1 && other.getLocation().getY() <= player.getLocation().getY()) + { + nearOther = true; + break; + } + } + + if (!nearOther) + return; + + if (!Recharge.Instance.use(player, "Boost", 1500, false, false)) + return; + + UtilAction.velocity(event.getPlayer(), new Vector(0,1,0), 0.6, false, 0, 0, 1, true); + + Recharge.Instance.useForce(player, "Boost", 1500); + + player.getWorld().playEffect(player.getLocation(), Effect.BLAZE_SHOOT, 0); + } + + /* + @EventHandler + public void sneakUpdate(UpdateEvent event) + { + if (!IsLive()) + return; + + if (event.getType() != UpdateType.FAST) + return; + + for (Player player : GetPlayers(true)) + { + if (!player.isSneaking()) + player.setSneaking(true); + } + } + + @EventHandler(priority = EventPriority.MONITOR) + public void sneakUpdate(PlayerToggleSneakEvent event) + { + if (!IsLive()) + return; + + event.getPlayer().setSneaking(true); + } + */ + + + + @EventHandler(priority = EventPriority.MONITOR) + public void scopeUpdate(PlayerToggleSneakEvent event) + { + if (!IsLive()) + return; + + Gun gun = getGunInHand(event.getPlayer(), null); + if (gun == null) + return; + + if (!(gun instanceof AWP)) + return; + + //Enable + if (!event.getPlayer().isSneaking()) + { + _scoped.add(event.getPlayer()); + Manager.GetCondition().Factory().Slow("Scope", event.getPlayer(), null, 9999, 3, false, false, false, false); + event.getPlayer().getInventory().setHelmet(new ItemStack(Material.PUMPKIN)); + + event.getPlayer().getWorld().playSound(event.getPlayer().getEyeLocation(), Sound.GHAST_DEATH, 0.8f, 1f); + } + else + { + _scoped.remove(event.getPlayer()); + Manager.GetCondition().EndCondition(event.getPlayer(), null, "Scope"); + event.getPlayer().getInventory().setHelmet(null); + + event.getPlayer().getWorld().playSound(event.getPlayer().getEyeLocation(), Sound.GHAST_DEATH, 0.8f, 0.6f); + } + } + + @EventHandler + public void scopeUpdate(UpdateEvent event) + { + if (!IsLive()) + return; + + if (event.getType() != UpdateType.TICK) + return; + + for (Player player : GetPlayers(true)) + { + if (!_scoped.contains(player)) + continue; + + Gun gun = getGunInHand(player, null); + if (gun == null || !(gun instanceof AWP) || !player.isSneaking()) + { + _scoped.remove(player); + Manager.GetCondition().EndCondition(player, null, "Scope"); + player.getInventory().setHelmet(null); + + player.getWorld().playSound(player.getEyeLocation(), Sound.GHAST_DEATH, 0.8f, 0.6f); + } + } + } + + @Override + @EventHandler + public void ScoreboardUpdate(UpdateEvent event) + { + if (event != null && event.getType() != UpdateType.FAST) + return; + + drawScoreboard(); + } + + public void drawScoreboard() + { + Scoreboard.Reset(); + + for (GameTeam team : this.GetTeamList()) + { + + Scoreboard.WriteBlank(); + + Scoreboard.Write(team.GetColor() + C.Bold + team.GetName()); + Scoreboard.Write(getScore(team) + "" + " Wins" + team.GetColor()); + Scoreboard.Write(team.GetPlayers(true).size() + "" + " Alive" + team.GetColor()); + + } + + Scoreboard.WriteBlank(); + Scoreboard.Write(C.cGold + C.Bold + "Playing To"); + Scoreboard.Write(_roundsToWin + " Wins"); + + if (InProgress()) + { + Scoreboard.WriteBlank(); + + if (_bomb == null) + { + Scoreboard.Write(C.cGold + C.Bold + "Time Left"); + Scoreboard.Write(UtilTime.MakeStr(_roundTime - (System.currentTimeMillis() - this.GetStateTime()), 1)); + } + else + { + if (_bombScoreboardFlash) + Scoreboard.Write(C.cRed + C.Bold + "Bomb Active"); + else + Scoreboard.Write(C.cWhite + C.Bold + "Bomb Active"); + + _bombScoreboardFlash = !_bombScoreboardFlash; + } + } + + + Scoreboard.Draw(); + } + + @Override + public void EndCheck() + { + endCheckScore(); + endCheckPlayer(); + } + + public void endCheckScore() + { + if (!IsLive()) + return; + + for (GameTeam team : GetTeamList()) + { + if (getScore(team) >= _roundsToWin) + { + //Announce + AnnounceEnd(team); + + for (GameTeam other : GetTeamList()) + { + if (WinnerTeam != null && other.equals(WinnerTeam)) + { + for (Player player : other.GetPlayers(false)) + AddGems(player, 10, "Winning Team", false); + } + + for (Player player : other.GetPlayers(false)) + if (player.isOnline()) + AddGems(player, 10, "Participation", false); + } + + //End + SetState(GameState.End); + } + } + } + + public void endCheckPlayer() + { + if (!IsLive()) + return; + + ArrayList teamsAlive = new ArrayList(); + + for (GameTeam team : this.GetTeamList()) + if (team.GetPlayers(false).size() > 0) + teamsAlive.add(team); + + if (teamsAlive.size() <= 1) + { + //Announce + if (teamsAlive.size() > 0) + AnnounceEnd(teamsAlive.get(0)); + + for (GameTeam team : GetTeamList()) + { + if (WinnerTeam != null && team.equals(WinnerTeam)) + { + for (Player player : team.GetPlayers(false)) + AddGems(player, 10, "Winning Team", false); + } + + for (Player player : team.GetPlayers(false)) + if (player.isOnline()) + AddGems(player, 10, "Participation", false); + } + + //End + SetState(GameState.End); + } + } + + //Cleans entities that may not have been removed due to unloaded chunks + @EventHandler + public void clean(UpdateEvent event) + { + if (!IsLive()) + return; + + if (event.getType() != UpdateType.SEC) + return; + + for (Entity ent : WorldData.World.getEntities()) + { + if (ent instanceof Player) + continue; + + if (ent instanceof Painting) + continue; + + if (_gunsDropped.containsKey(ent)) + continue; + + if (_grenadesDropped.containsKey(ent)) + continue; + + if (_grenadesThrown.containsKey(ent)) + continue; + + if (_bullets.containsKey(ent)) + continue; + + if (_bombItem != null && _bombItem.equals(ent)) + continue; + + ent.remove(); + } + } + + @SuppressWarnings("deprecation") + @EventHandler(priority=EventPriority.LOWEST) + public void damagePainting(PaintingBreakEvent event) + { + event.setCancelled(true); + } + + @EventHandler + public void entityExpire(ItemDespawnEvent event) + { + if (_gunsDropped.containsKey(event.getEntity())) + event.setCancelled(true); + + else if (_grenadesDropped.containsKey(event.getEntity())) + event.setCancelled(true); + + else if (_grenadesThrown.containsKey(event.getEntity())) + event.setCancelled(true); + + else if (_bombItem != null && _bombItem.equals(event.getEntity())) + event.setCancelled(true); + } + + @EventHandler + public void terroristCompass(UpdateEvent event) + { + if (!IsLive()) + return; + + Location target = null; + if (_bombItem != null) + target = _bombItem.getLocation(); + else if (_bombHolder != null) + target = _bombHolder.getLocation(); + else if (_bomb != null) + target = _bomb.Block.getLocation(); + + for (Player player : GetTeam(ChatColor.RED).GetPlayers(true)) + { + //Has Bomb + if (player.getInventory().contains(Material.GOLD_SWORD)) + continue; + + //Error - Random Loc + if (target == null) + target = player.getLocation().add(Math.random() - 0.5, Math.random() - 0.5, Math.random() - 0.5); + + //Set Target + player.setCompassTarget(target); + + ItemStack stack = new ItemStack(Material.COMPASS); + + //Text + ItemMeta itemMeta = stack.getItemMeta(); + + if (_bombItem != null) + { + itemMeta.setDisplayName( + " " + C.cGreen + C.Bold + "Bomb Dropped" + + " " + C.cGreen + C.Bold + "Distance: " + C.cWhite + UtilMath.trim(1, UtilMath.offset2d(target, player.getLocation()))); + } + else if (_bombHolder != null) + { + itemMeta.setDisplayName( + " " + C.cGreen + C.Bold + "Bomb Holder: " + C.cWhite + _bombHolder.getName() + + " " + C.cGreen + C.Bold + "Distance: " + C.cWhite + UtilMath.trim(1, UtilMath.offset2d(target, player.getLocation()))); + } + else if (_bomb != null) + { + itemMeta.setDisplayName( + " " + C.cGreen + C.Bold + "Bomb Planted" + + " " + C.cGreen + C.Bold + "Distance: " + C.cWhite + UtilMath.trim(1, UtilMath.offset2d(target, player.getLocation()))); + } + else + { + itemMeta.setDisplayName( + " " + C.cGreen + C.Bold + "Bomb Not Found");; + } + + stack.setItemMeta(itemMeta); + + //Set + player.getInventory().setItem(8, stack); + } + } + + //Cleans entities that may not have been removed due to unloaded chunks + @EventHandler + public void debug(PlayerCommandPreprocessEvent event) + { + if (!event.getPlayer().isOp()) + return; + + if (event.getMessage().contains("debugplayer")) + { + Announce(C.Bold + "PLAYER DEBUG:"); + + for (Player player : UtilServer.getPlayers()) + { + GameTeam team = GetTeam(player); + + Announce(player.getName() + " " + + (team != null ? team.GetColor() + team.GetName() : C.cGray + "No Team") + " " + + (IsAlive(player) ? C.cGreen + "ALIVE" : C.cRed + "DEAD") + " " + + C.cGray + UtilWorld.locToStrClean(player.getLocation()) + ); + } + + event.setCancelled(true); + } + + if (event.getMessage().contains("debugteam")) + { + Announce(C.Bold + "TEAM DEBUG:"); + + for (GameTeam team : GetTeamList()) + for (Player player : team.GetPlayers(false)) + { + Announce(player.getName() + " " + + (team != null ? team.GetColor() + team.GetName() : C.cGray + "No Team") + " " + + (IsAlive(player) ? C.cGreen + "ALIVE" : C.cRed + "DEAD") + " " + + C.cGray + UtilWorld.locToStrClean(player.getLocation()) + ); + } + + event.setCancelled(true); + } + } + + @Override + public void SetSpectator(Player player) + { + Manager.Clear(player); + + player.setVelocity(new Vector(0,1,0)); + player.setGameMode(GameMode.CREATIVE); + player.setFlying(true); + player.setFlySpeed(0.1f); + ((CraftPlayer)player).getHandle().spectating = true; + ((CraftPlayer)player).getHandle().k = false; + + Manager.GetCondition().Factory().Cloak("Spectator", player, player, 7777, true, true); + + Scoreboard.SetPlayerTeam(player, "SPEC"); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/ShopManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/ShopManager.java new file mode 100644 index 000000000..e2f0b97fa --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/ShopManager.java @@ -0,0 +1,259 @@ +package nautilus.game.arcade.game.games.minestrike; + +import java.util.HashMap; +import java.util.HashSet; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.recharge.Recharge; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.minestrike.items.StrikeItem; +import nautilus.game.arcade.game.games.minestrike.items.equipment.DefusalKit; +import nautilus.game.arcade.game.games.minestrike.items.equipment.Helmet; +import nautilus.game.arcade.game.games.minestrike.items.equipment.Kevlar; +import nautilus.game.arcade.game.games.minestrike.items.grenades.*; +import nautilus.game.arcade.game.games.minestrike.items.guns.Gun; +import nautilus.game.arcade.game.games.minestrike.items.guns.pistol.*; +import nautilus.game.arcade.game.games.minestrike.items.guns.rifle.*; +import nautilus.game.arcade.game.games.minestrike.items.guns.shotgun.*; +import nautilus.game.arcade.game.games.minestrike.items.guns.smg.*; + +import org.bukkit.ChatColor; +import org.bukkit.Color; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.InventoryClickEvent; + +public class ShopManager +{ + private MineStrike Host; + + private HashMap> _shop = new HashMap>(); + private HashMap _money = new HashMap(); + private HashSet _inShop = new HashSet(); + + public ShopManager(MineStrike host) + { + Host = host; + } + + public void enterShop(Player player) + { + GameTeam team = Host.GetTeam(player); + if (team == null) + return; + + clearShopInventory(player); + + _shop.put(player, new HashMap()); + + int slot; + + //Pistols + slot = 9; + //addItem(team.GetColor() == ChatColor.RED ? new Glock18() : new USP(), player, slot++); + addItem(new CZ75(), player, slot++); + addItem(new Deagle(), player, slot++); + + //Shotgun + slot = 18; + addItem(new Nova(), player, slot++); + + //SMG + addItem(new P90(), player, slot++); + + //Rifles + slot = 27; + addItem(team.GetColor() == ChatColor.RED ? new AK47() : new M4A1(), player, slot++); + addItem(new AWP(), player, slot++); + + //Grenades + addItem(new FlashBang(), player, 15); + addItem(new HighExplosive(), player, 16); + addItem(new Smoke(), player, 17); + + //Gear + if (team.GetColor() == ChatColor.AQUA) + addItem(new DefusalKit(), player, 26); + + //Equipment + addItem(new Helmet(), player, 34); + addItem(new Kevlar(), player, 35); + + _inShop.add(player); + } + + public void addItem(StrikeItem item, Player player, int slot) + { + player.getInventory().setItem(slot, item.getShopItem(getMoney(player))); + + _shop.get(player).put(slot, item); + } + + public void clearShopInventory(Player player) + { + _shop.remove(player); + + for (int i=9 ; i<36 ; i++) + player.getInventory().setItem(i, null); + } + + public int getMoney(Player player) + { + if (!_money.containsKey(player)) + _money.put(player, 800); + + return _money.get(player); + } + + public void addMoney(Player player, int amount, String reason) + { + _money.put(player, Math.min(16000, getMoney(player) + amount)); + + UtilPlayer.message(player, F.main("Game", "Received " + F.elem(C.cDGreen + "$" + amount) + " for " + reason + ".")); + } + + public void inventoryClick(InventoryClickEvent event) + { + event.setCancelled(true); + + Player player = UtilPlayer.searchExact(event.getWhoClicked().getName()); + if (player == null) + return; + + GameTeam team = Host.GetTeam(player); + if (team == null) + return; + + if (!_shop.containsKey(player)) + return; + + if (!_shop.get(player).containsKey(event.getSlot())) + return; + + //Prevent accidently buying multi + if (!Recharge.Instance.use(player, "Shop Purchase", 120, false, false)) + return; + + StrikeItem item = _shop.get(player).get(event.getSlot()); + + if (getMoney(player) < item.getCost()) + { + player.playSound(player.getLocation(), Sound.NOTE_BASS, 1f, 1f); + return; + } + + //Gun + if (item instanceof Gun) + { + Gun gun = (Gun)item; + Host.dropSlotItem(player, gun.getSlot()); + gun.giveToPlayer(player); + Host.registerGun(gun, player); + } + + //Grenade + else if (item instanceof Grenade) + { + Grenade grenade = (Grenade)item; + + if (!grenade.giveToPlayer(player)) + { + player.playSound(player.getLocation(), Sound.NOTE_BASS, 1f, 1f); + return; + } + + Host.registerGrenade(grenade, player); + } + + else if (item instanceof Helmet) + { + ((Helmet)item).giveToPlayer(player, (team.GetColor() == ChatColor.RED) ? Color.fromRGB(100, 0, 0) : Color.fromRGB(0, 0, 100)); + } + + else if (item instanceof Kevlar) + { + ((Kevlar)item).giveToPlayer(player, (team.GetColor() == ChatColor.RED) ? Color.fromRGB(100, 0, 0) : Color.fromRGB(0, 0, 100)); + } + + else if (item instanceof DefusalKit) + { + item.giveToPlayer(player, 8); + } + + _money.put(player, getMoney(player) - item.getCost()); + + enterShop(player); + } + + public void leaveShop(Player player, boolean showShopItem, boolean wipeMoney) + { + _shop.remove(player); + + _inShop.remove(player); + clearShopInventory(player); + + if (wipeMoney) + _money.remove(player); + + if (showShopItem) + { + player.getInventory().setItem(22, + ItemStackFactory.Instance.CreateStack(Material.PAPER, (byte)0, 1, C.cRed + "Cannot Purchase Gear", + new String[] + { + C.cWhite + "", + C.cWhite + "You can only purchase gear when", + C.cWhite + "you are near your spawn point in", + C.cWhite + "the first 45 seconds of the round!", + })); + } + } + + public boolean isBuyTime() + { + return !UtilTime.elapsed(Host.GetStateTime(), 45000) && Host.InProgress(); + } + + public void update() + { + for (Player player : Host.GetPlayers(true)) + { + GameTeam team = Host.GetTeam(player); + + if (team == null) + { + leaveShop(player, false, false); + continue; + } + + //Near Shop? + boolean nearShop = false; + for (Location loc : team.GetSpawns()) + { + if (UtilMath.offset(player.getLocation(), loc) < 5) + { + nearShop = true; + break; + } + } + + //Leave Shop + if (_inShop.contains(player) && (!nearShop || !isBuyTime())) + { + leaveShop(player, true, false); + } + //Enter Shop + else if (!_inShop.contains(player) && (nearShop && isBuyTime())) + { + enterShop(player); + } + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/data/Bomb.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/data/Bomb.java new file mode 100644 index 000000000..a590c1e48 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/data/Bomb.java @@ -0,0 +1,86 @@ +package nautilus.game.arcade.game.games.minestrike.data; + +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilParticle.ParticleType; + +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; + +public class Bomb +{ + public long BombTime = 45000; + + public Block Block; + public long StartTime; + public long LastBeep; + + public long MinBeepTime = 40; + public long StartBeepTime = 2000; + + public Player Planter; + + public Bomb(Player planter) + { + Planter = planter; + + Block = planter.getLocation().getBlock(); + Block.setType(Material.DAYLIGHT_DETECTOR); + + StartTime = System.currentTimeMillis(); + } + + public boolean update() + { + double scale = (double)(System.currentTimeMillis() - StartTime)/(double)BombTime; + + long beepDuration = MinBeepTime + (long)(StartBeepTime * (1-scale)); + float volume = 1f + 4f*(float)scale; + + if (UtilTime.elapsed(LastBeep, beepDuration)) + { + Block.getWorld().playSound(Block.getLocation(), Sound.ANVIL_BREAK, volume, 1f); + UtilParticle.PlayParticle(ParticleType.HAPPY_VILLAGER, Block.getLocation().add(0.5, 0.5, 0.5), 0, 0, 0, 0, 1); + + LastBeep = System.currentTimeMillis(); + } + + if (UtilTime.elapsed(StartTime, BombTime)) + { + Block.setType(Material.AIR); + + //Effect + UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, Block.getLocation(), 10f, 10f, 10f, 0, 30); + + for (int i=0 ; i<3 ; i++) + Block.getWorld().playSound(Block.getLocation(), Sound.ANVIL_LAND, 20f, (float)(Math.random() * 0.5 + 0.5)); + + return true; + } + + return false; + } + + public boolean isBlock(Block block) + { + if (block == null) + return false; + + return block.equals(Block); + } + + public void defuse() + { + Block.setType(Material.AIR); + + //Effect + UtilParticle.PlayParticle(ParticleType.CLOUD, Block.getLocation().add(0.5, 0.5, 0.5), 0, 0, 0, 0, 1); + } + + public void clean() + { + Block.setType(Material.AIR); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/data/Bullet.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/data/Bullet.java new file mode 100644 index 000000000..4ccd6e81d --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/data/Bullet.java @@ -0,0 +1,47 @@ +package nautilus.game.arcade.game.games.minestrike.data; + +import nautilus.game.arcade.game.games.minestrike.items.guns.Gun; + +import org.bukkit.Location; +import org.bukkit.entity.Snowball; + +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilTime; + +public class Bullet +{ + public Snowball Bullet; + public Gun Gun; + public Location Origin; + + public long LastSound = System.currentTimeMillis() - 100; + + + public Bullet(Snowball bullet, Gun gun, Location loc) + { + Bullet = bullet; + Gun = gun; + Origin = loc; + } + + public boolean isValid() + { + return Bullet.isValid(); + } + + public double getDamage(Location destination) + { + return Gun.getDamage() * (1 - (Gun.getDropOff() * UtilMath.offset(Origin, destination))); + } + + public boolean bulletSound() + { + if (UtilTime.elapsed(LastSound, 250)) + { + LastSound = System.currentTimeMillis(); + return true; + } + + return false; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/StrikeItem.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/StrikeItem.java new file mode 100644 index 000000000..9fd09944a --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/StrikeItem.java @@ -0,0 +1,178 @@ +package nautilus.game.arcade.game.games.minestrike.items; + +import java.util.ArrayList; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilGear; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.itemstack.ItemStackFactory; +import nautilus.game.arcade.game.games.minestrike.MineStrike; +import nautilus.game.arcade.game.games.minestrike.items.grenades.Grenade; +import nautilus.game.arcade.game.games.minestrike.items.guns.Gun; + +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +public abstract class StrikeItem +{ + private StrikeItemType _type; + private String _name; + private String[] _desc; + private int _cost; + private int _gemCost; + private Material _skin; + + private ItemStack _stack = null; + + public StrikeItem(StrikeItemType type, String name, String[] desc, int cost, int gemCost, Material skin) + { + _type = type; + _name = name; + _desc = desc; + _cost = cost; + _gemCost = gemCost; + _skin = skin; + + //Make Stack + _stack = new ItemStack(skin); + fixStackName(); + } + + public StrikeItemType getType() + { + return _type; + } + + public String getName() + { + return _name; + } + + public String[] getDesc() + { + return _desc; + } + + public int getCost() + { + return _cost; + } + + public int getGemCost() + { + return _gemCost; + } + + public Material getSkin() + { + return _skin; + } + + public void drop(MineStrike game, Player player, boolean natural) + { + Entity ent; + + if (natural) + { + ent = player.getWorld().dropItemNaturally(player.getEyeLocation(), _stack); + } + else + { + ent = player.getWorld().dropItem(player.getEyeLocation(), _stack); + ent.setVelocity(player.getLocation().getDirection().multiply(0.6)); + } + + if (this instanceof Gun) + { + game.deregisterGun((Gun)this); + game.registerDroppedGun(ent, (Gun)this); + } + + else if (this instanceof Grenade) + { + game.deregisterGrenade((Grenade)this); + game.registerDroppedGrenade(ent, (Grenade)this); + } + } + + public ItemStack getStack() + { + return _stack; + } + + public void setStack(ItemStack stack) + { + _stack = stack; + } + + public boolean isHolding(Player player) + { + return UtilGear.isMat(player.getItemInHand(), _skin); + } + + public boolean isStack(ItemStack stack) + { + return UtilGear.isMat(stack, _skin); + } + + public void giveToPlayer(Player player, int slot) + { + fixStackName(); + + player.getInventory().setItem(slot, getStack()); + + UtilPlayer.message(player, F.main("Game", "You equipped " + getName() + ".")); + + player.getWorld().playSound(player.getLocation(), Sound.ITEM_PICKUP, 1.5f, 1f); + } + + public void fixStackName() + { + ItemMeta meta = _stack.getItemMeta(); + meta.setDisplayName(C.Bold + getName()); + _stack.setItemMeta(meta); + } + + public abstract boolean pickup(MineStrike game, Player player); + + public ItemStack getShopItem(int money) + { + ArrayList lore = new ArrayList(); + + for (String cur : _desc) + lore.add(C.cWhite + cur); + + //Custom (Gun Stats) + if (getShopItemCustom().length > 0) + { + lore.add(" "); + for (String cur : getShopItemCustom()) + lore.add(C.cWhite + cur); + } + + + lore.add(" "); + lore.add(C.cYellow + C.Bold + "Cost: " + ChatColor.RESET + "$" + _cost); + lore.add(" "); + lore.add(C.cYellow + C.Bold + "Money: " + ChatColor.RESET + "$" + money); + lore.add(" "); + lore.add((money >= _cost) ? C.cGreen + C.Bold + "Click to Purchase" : C.cRed + C.Bold + "Not enough Money"); + + + String[] loreArray = new String[lore.size()]; + loreArray = lore.toArray(loreArray); + + return ItemStackFactory.Instance.CreateStack(_skin, (byte)0, 1, C.cGreen + getName(), loreArray); + } + + public String[] getShopItemCustom() + { + return new String[] {}; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/StrikeItemType.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/StrikeItemType.java new file mode 100644 index 000000000..5f0c2cf1c --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/StrikeItemType.java @@ -0,0 +1,10 @@ +package nautilus.game.arcade.game.games.minestrike.items; + +public enum StrikeItemType +{ + PRIMARY_WEAPON, + SECONDARY_WEAPON, + GRENADE, + EQUIPMENT, + ARMOR +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/equipment/DefusalKit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/equipment/DefusalKit.java new file mode 100644 index 000000000..5e23f5b4d --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/equipment/DefusalKit.java @@ -0,0 +1,40 @@ +package nautilus.game.arcade.game.games.minestrike.items.equipment; + +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import nautilus.game.arcade.game.games.minestrike.MineStrike; +import nautilus.game.arcade.game.games.minestrike.items.StrikeItem; +import nautilus.game.arcade.game.games.minestrike.items.StrikeItemType; + +public class DefusalKit extends StrikeItem +{ + public DefusalKit() + { + super(StrikeItemType.EQUIPMENT, "Defusal Kit", new String[] + { + "Halves the time it takes to defuse." + }, + 400, 0, Material.SHEARS); + } + + @Override + public boolean pickup(MineStrike game, Player player) + { + return false; + } + + public void giveToPlayer(Player player, int slot) + { + fixStackName(); + + player.getInventory().setItem(slot, getStack()); + + UtilPlayer.message(player, F.main("Game", "You equipped " + getName() + ".")); + + player.getWorld().playSound(player.getLocation(), Sound.HORSE_ARMOR, 1.5f, 1f); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/equipment/Helmet.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/equipment/Helmet.java new file mode 100644 index 000000000..e7c7a80ac --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/equipment/Helmet.java @@ -0,0 +1,46 @@ +package nautilus.game.arcade.game.games.minestrike.items.equipment; + +import org.bukkit.Color; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.LeatherArmorMeta; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import nautilus.game.arcade.game.games.minestrike.MineStrike; +import nautilus.game.arcade.game.games.minestrike.items.StrikeItem; +import nautilus.game.arcade.game.games.minestrike.items.StrikeItemType; + +public class Helmet extends StrikeItem +{ + public Helmet() + { + super(StrikeItemType.EQUIPMENT, "Helmet", new String[] + { + + }, + 350, 0, Material.LEATHER_HELMET); + } + + @Override + public boolean pickup(MineStrike game, Player player) + { + return false; + } + + public void giveToPlayer(Player player, Color color) + { + ItemStack armor = new ItemStack(getSkin()); + LeatherArmorMeta meta = (LeatherArmorMeta)armor.getItemMeta(); + meta.setColor(color); + meta.setDisplayName(getName()); + armor.setItemMeta(meta); + player.getInventory().setHelmet(armor); + + UtilPlayer.message(player, F.main("Game", "You equipped " + getName() + ".")); + + player.getWorld().playSound(player.getLocation(), Sound.HORSE_ARMOR, 1f, 1f); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/equipment/Kevlar.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/equipment/Kevlar.java new file mode 100644 index 000000000..9e126cb60 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/equipment/Kevlar.java @@ -0,0 +1,46 @@ +package nautilus.game.arcade.game.games.minestrike.items.equipment; + +import org.bukkit.Color; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.LeatherArmorMeta; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import nautilus.game.arcade.game.games.minestrike.MineStrike; +import nautilus.game.arcade.game.games.minestrike.items.StrikeItem; +import nautilus.game.arcade.game.games.minestrike.items.StrikeItemType; + +public class Kevlar extends StrikeItem +{ + public Kevlar() + { + super(StrikeItemType.EQUIPMENT, "Kevlar Vest", new String[] + { + + }, + 650, 0, Material.LEATHER_CHESTPLATE); + } + + @Override + public boolean pickup(MineStrike game, Player player) + { + return false; + } + + public void giveToPlayer(Player player, Color color) + { + ItemStack armor = new ItemStack(getSkin()); + LeatherArmorMeta meta = (LeatherArmorMeta)armor.getItemMeta(); + meta.setColor(color); + meta.setDisplayName(getName()); + armor.setItemMeta(meta); + player.getInventory().setChestplate(armor); + + UtilPlayer.message(player, F.main("Game", "You equipped " + getName() + ".")); + + player.getWorld().playSound(player.getLocation(), Sound.HORSE_ARMOR, 1f, 1f); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/grenades/FlashBang.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/grenades/FlashBang.java new file mode 100644 index 000000000..6ad289664 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/grenades/FlashBang.java @@ -0,0 +1,80 @@ +package nautilus.game.arcade.game.games.minestrike.items.grenades; + +import java.util.HashMap; + +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import nautilus.game.arcade.game.games.minestrike.MineStrike; + +import org.bukkit.Color; +import org.bukkit.FireworkEffect; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.FireworkEffect.Type; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; + +public class FlashBang extends Grenade +{ + public FlashBang() + { + super("Flash Bang", new String[] + { + + }, + 300, 0, Material.CARROT_ITEM, 2); + } + + @Override + public boolean updateCustom(MineStrike game, Entity ent) + { + if (ent.getTicksLived() > 40) + { + FireworkEffect effect = FireworkEffect.builder().flicker(true).withColor(Color.WHITE).with(Type.BALL_LARGE).trail(false).build(); + UtilFirework.playFirework(ent.getLocation(), effect); + + HashMap players = UtilPlayer.getInRadius(ent.getLocation(), 48); + for (Player player : players.keySet()) + { + if (!game.IsAlive(player)) + continue; + + //Line of Sight + Location loc = player.getEyeLocation(); + + boolean sight = true; + while (UtilMath.offset(loc, ent.getLocation()) > 0.5) + { + if (UtilBlock.solid(loc.getBlock())) + { + sight = false; + break; + } + + loc.add(UtilAlg.getTrajectory(loc, ent.getLocation()).multiply(0.2)); + } + + if (!sight) + continue; + + //Calculate if player is looking away + Location eyeToGrenade = player.getEyeLocation().add(UtilAlg.getTrajectory(player.getEyeLocation(), ent.getLocation())); + double flashIntensity = 2 - UtilMath.offset(player.getEyeLocation().add(player.getLocation().getDirection()), eyeToGrenade); + + //Duration + double duration = (2 + (3 * (players.get(player)))) * flashIntensity; + duration += 1; + + //Blind + game.Manager.GetCondition().Factory().Blind(getName(), player, _thrower, duration, 0, false, false, false); + } + + return true; + } + + return false; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/grenades/Grenade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/grenades/Grenade.java new file mode 100644 index 000000000..38987d2d3 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/grenades/Grenade.java @@ -0,0 +1,162 @@ +package nautilus.game.arcade.game.games.minestrike.items.grenades; + +import java.util.ArrayList; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilPlayer; +import nautilus.game.arcade.game.games.minestrike.MineStrike; +import nautilus.game.arcade.game.games.minestrike.items.StrikeItem; +import nautilus.game.arcade.game.games.minestrike.items.StrikeItemType; + +public abstract class Grenade extends StrikeItem +{ + protected Player _thrower = null; + + protected Vector _vel; + protected Location _lastLoc; + protected ArrayList _velHistory = new ArrayList(); + + protected int _limit; + + public Grenade(String name, String[] desc, int cost, int gemCost, Material skin, int limit) + { + super(StrikeItemType.GRENADE, name, desc, cost, gemCost, skin); + + _limit = limit; + } + + public boolean giveToPlayer(Player player) + { + int slot = 3; + + int alreadyHas = 0; + + while (player.getInventory().getItem(slot) != null && player.getInventory().getItem(slot).getType() != Material.AIR && slot <= 6) + { + if (player.getInventory().getItem(slot).getType() == getSkin()) + { + alreadyHas++; + + if (alreadyHas >= _limit) + return false; + } + + slot++; + } + + + if (slot > 6) + return false; + + giveToPlayer(player, slot); + + return true; + } + + public void throwGrenade(Player player, MineStrike game) + { + player.setItemInHand(null); + + _thrower = player; + + Entity ent = player.getWorld().dropItem(player.getEyeLocation().add(player.getLocation().getDirection()), getStack()); + + UtilAction.velocity(ent, player.getLocation().getDirection(), 1.2, false, 0, 0.2, 2, false); + + //Rebound Data + _vel = player.getLocation().getDirection(); + _velHistory.add(_vel); + _lastLoc = ent.getLocation(); + + UtilPlayer.message(player, F.main("Game", "You threw " + getName() + ".")); + + game.registerThrownGrenade(ent, this); + game.deregisterGrenade(this); + } + + public boolean update(MineStrike game, Entity ent) + { + //Invalid + if (!ent.isValid()) + return true; + + //Rebound Off Blocks + rebound(ent); + + //Custom + if (updateCustom(game, ent)) + return true; + + return false; + } + + public void rebound(Entity ent) + { + if (UtilEnt.isGrounded(ent) || ent.getVelocity().length() < 0.1 || ent.getTicksLived() < 4) + return; + + /* + * What we must do here, is record the velocity every tick. + * Then when it collides, we get the velocity from a few ticks before and apply it, reversing the direction of collision. + * We record history because as soon as it collides the collision direction is set to 0. + */ + + //X Rebound + if ((_vel.getX() > 0 && ent.getLocation().getX() - _lastLoc.getX() <= 0) || + (_vel.getX() < 0 && ent.getLocation().getX() - _lastLoc.getX() >= 0)) + { + _vel = _velHistory.get(0); + _vel.setX(-_vel.getX()); + _vel.multiply(0.75); + + ent.setVelocity(_vel); + + ent.getWorld().playSound(ent.getLocation(), Sound.ZOMBIE_WOOD, 1f, 2f); + } + + //Z Rebound + else if ((_vel.getZ() > 0 && ent.getLocation().getZ() - _lastLoc.getZ() <= 0) || + (_vel.getZ() < 0 && ent.getLocation().getZ() - _lastLoc.getZ() >= 0)) + { + _vel = _velHistory.get(0); + _vel.setZ(-_vel.getZ()); + _vel.multiply(0.75); + + ent.setVelocity(_vel); + + ent.getWorld().playSound(ent.getLocation(), Sound.ZOMBIE_WOOD, 1f, 2f); + } + else + { + _velHistory.add(ent.getVelocity()); + + while (_velHistory.size() > 4) + _velHistory.remove(0); + } + + _lastLoc = ent.getLocation(); + } + + public abstract boolean updateCustom(MineStrike game, Entity ent); + + @Override + public boolean pickup(MineStrike game, Player player) + { + if (giveToPlayer(player)) + { + game.registerGrenade(this, player); + game.deregisterDroppedGrenade(this); + } + + return false; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/grenades/HighExplosive.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/grenades/HighExplosive.java new file mode 100644 index 000000000..920cbd0c9 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/grenades/HighExplosive.java @@ -0,0 +1,55 @@ +package nautilus.game.arcade.game.games.minestrike.items.grenades; + +import java.util.HashMap; + +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilPlayer; +import nautilus.game.arcade.game.games.minestrike.MineStrike; + +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +public class HighExplosive extends Grenade +{ + public HighExplosive() + { + super("HE Grenade", new String[] + { + + }, + 300, 0, Material.APPLE, 1); + } + + @Override + public boolean updateCustom(MineStrike game, Entity ent) + { + if (ent.getTicksLived() > 40) + { + UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, + ent.getLocation(), 0, 0, 0, 0, 1); + ent.getWorld().playSound(ent.getLocation(), + Sound.EXPLODE, 3f, 0.8f); + + HashMap players = UtilPlayer.getInRadius( + ent.getLocation(), 8); + for (Player player : players.keySet()) + { + if (!game.IsAlive(player)) + continue; + + // Damage Event + game.Manager.GetDamage().NewDamageEvent(player, _thrower, null, + DamageCause.CUSTOM, 1 + (players.get(player) * 18), + true, true, false, _thrower.getName(), getName()); + } + + return true; + } + + return false; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/grenades/Smoke.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/grenades/Smoke.java new file mode 100644 index 000000000..9248d1747 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/grenades/Smoke.java @@ -0,0 +1,36 @@ +package nautilus.game.arcade.game.games.minestrike.items.grenades; + +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import nautilus.game.arcade.game.games.minestrike.MineStrike; + +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Entity; + +public class Smoke extends Grenade +{ + public Smoke() + { + super("Smoke Grenade", new String[] + { + + }, + 300, 0, Material.POTATO_ITEM, 1); + } + + @Override + public boolean updateCustom(MineStrike game, Entity ent) + { + if (ent.getTicksLived() > 60) + { + UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, ent.getLocation(), 0, 0, 0, 0, 1); + + ent.getWorld().playSound(ent.getLocation(), Sound.FIZZ, 0.1f, 0.1f); + + return false; + } + + return ent.getTicksLived() > 360; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/Gun.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/Gun.java new file mode 100644 index 000000000..88f02d009 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/Gun.java @@ -0,0 +1,361 @@ +package nautilus.game.arcade.game.games.minestrike.items.guns; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilServer; +import mineplex.core.recharge.Recharge; +import mineplex.core.recharge.RechargedEvent; +import nautilus.game.arcade.game.games.minestrike.MineStrike; +import nautilus.game.arcade.game.games.minestrike.data.Bullet; +import nautilus.game.arcade.game.games.minestrike.items.StrikeItem; +import nautilus.game.arcade.game.games.minestrike.items.StrikeItemType; +import nautilus.game.arcade.game.games.minestrike.items.guns.rifle.AWP; + +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.entity.Snowball; +import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.util.Vector; + +public abstract class Gun extends StrikeItem +{ + protected GunType _gunType; + protected int _slot; + + //Stats + protected int _clipSize; + protected int _clipReserve; + protected long _fireRate; + protected long _reloadTime; + protected double _damage; + protected double _dropOffPerBlock; + protected double _bulletSpeed; + protected Sound _fireSound; + + protected double _coneMin; + protected double _coneMax; + protected double _coneReduceRate; + protected double _coneIncreaseRate; + + + //Active Data + protected int _loadedAmmo; + protected int _reserveAmmo; + protected double _cone; + protected double _lastMove; + protected long _lastMoveTime; + + public Gun(StrikeItemType type, GunType gunType, String name, String[] desc, + int cost, int gemCost, + int clipSize, int clipReserve, + long fireRate, long reloadTime, + double damage, double dropOffPerBlock, double bulletSpeed, + double coneMin, double coneMax, + double coneIncrease, double coneReduce, + Material skin, Sound sound) + { + super(type, name, desc, cost, gemCost, skin); + + _gunType = gunType; + + if (type == StrikeItemType.PRIMARY_WEAPON) + _slot = 0; + else + _slot = 1; + + _clipSize = clipSize; + _clipReserve = clipReserve; + _fireRate = fireRate; + _reloadTime = reloadTime; + _damage = damage; + _dropOffPerBlock = dropOffPerBlock; + _bulletSpeed = bulletSpeed; + + _fireSound = sound; + + _coneMin = coneMin; + _coneMax = coneMax; + _coneIncreaseRate = coneIncrease; + _coneReduceRate = coneReduce; + _cone = _coneMin; + + _loadedAmmo = clipSize; + _reserveAmmo = clipReserve * clipSize; + + updateWeaponName(null); + } + + public void shoot(final Player player, final MineStrike game) + { + //Standard (300) RPM + shootOnce(player, game); + + //600RPM + if (_fireRate <= 100 && _fireRate > 50) + { + UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(game.Manager.GetPlugin(), new Runnable() + { + public void run() + { + shootOnce(player, game); + } + }, 2); + } + + //1200RPM + if (_fireRate <= 50) + { + for (int i=1 ; i<4 ; i++) + { + UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(game.Manager.GetPlugin(), new Runnable() + { + public void run() + { + shootOnce(player, game); + } + }, i); + } + } + } + + public void shootOnce(Player player, MineStrike game) + { + //Check Ammo + if (!ammoCheck(player)) + return; + + if (!Recharge.Instance.use(player, getName() + " Shoot", _fireRate, false, false)) + return; + + //Use Ammo + _loadedAmmo--; + updateWeaponName(player); + + //Effect + soundFire(player.getLocation()); + UtilParticle.PlayParticle(ParticleType.CLOUD, player.getEyeLocation().add(player.getLocation().getDirection().multiply(1.5)), 0, 0, 0, 0, 1); + + game.registerBullet(fireBullet(player)); + } + + public Bullet fireBullet(Player player) + { + //Shoot + Snowball ball = player.launchProjectile(Snowball.class); + + //COF + double cone = getCone(player); + + //Calc + Vector cof = new Vector(Math.random() - 0.5, (Math.random() - 0.2) * (5d/8d), Math.random() - 0.5); + cof.normalize(); + cof.multiply(cone); + + cof.add(player.getLocation().getDirection()); + cof.normalize(); + + ball.setVelocity(cof.multiply(_bulletSpeed)); + + //Increase COF + _cone = Math.min(_coneMax, _cone + _coneIncreaseRate); + + return new Bullet(ball, this, player.getEyeLocation()); + } + + public double getCone(Player player) + { + double cone = _cone; + + //Move Penalty + if (!UtilTime.elapsed(_lastMoveTime, 75)) + cone += _lastMove * _gunType.getMovePenalty(); + + //Sprint Penalty + if (player.isSprinting()) + cone += _gunType.getSprintPenalty(); + + //Airborne Penalty + else if (!UtilEnt.isGrounded(player)) + cone += _gunType.getJumpPenalty(); + + //Crouch + else if (player.isSneaking() && _gunType != GunType.SNIPER) + cone = cone * 0.8; + + + //Sniper Zoomed + if (_gunType == GunType.SNIPER) + { + if (player.isSneaking()) + { + cone -= _cone; + } + } + + return cone; + } + + public boolean ammoCheck(Player player) + { + if (_loadedAmmo > 0) + return true; + + //Sound + if (Recharge.Instance.use(player, getName() + " Ammo Tick", 200, false, false)) + soundEmpty(player.getLocation()); + + return false; + } + + public void reload(Player player) + { + if (_loadedAmmo == _clipSize) + return; + + int ammo = _reserveAmmo + _loadedAmmo; + + if (ammo == 0) + { + UtilPlayer.message(player, F.main("Gun", "You have no ammo for " + F.name(getName()) + ".")); + return; + } + + _loadedAmmo = Math.min(ammo, _clipSize); + _reserveAmmo = Math.max(0, ammo - _clipSize); + + //Recharge + Recharge.Instance.useForce(player, getName() + " Shoot", _reloadTime); + Recharge.Instance.use(player, getName() + " Reload", _reloadTime, false, true); + + //Sound + soundReload(player.getLocation()); + + //Update + updateWeaponName(player); + } + + @Override + public void fixStackName() + { + updateWeaponName(null); + } + + public void updateWeaponName(Player player) + { + ItemMeta meta = getStack().getItemMeta(); + meta.setDisplayName(C.Bold + getName() + ChatColor.RESET + " " + C.cGreen + _loadedAmmo + ChatColor.RESET + " / " + C.cYellow + _reserveAmmo); + getStack().setItemMeta(meta); + + if (player != null) + player.getInventory().setItem(_slot, getStack()); + } + + public double getDamage() + { + return _damage; + } + + public double getDropOff() + { + return _dropOffPerBlock; + } + + public void soundFire(Location loc) + { + loc.getWorld().playSound(loc, _fireSound, 3f, (float)(Math.random() * 0.2 + 0.9)); + } + + public void soundEmpty(Location loc) + { + loc.getWorld().playSound(loc, Sound.NOTE_STICKS, 1f, 2f); + loc.getWorld().playSound(loc, Sound.NOTE_STICKS, 1f, 2f); + loc.getWorld().playSound(loc, Sound.NOTE_STICKS, 1f, 2f); + } + + public void soundReload(Location loc) + { + loc.getWorld().playSound(loc, Sound.PISTON_RETRACT, 1f, 0.8f); + } + + public void soundReloaded(Location loc) + { + loc.getWorld().playSound(loc, Sound.PISTON_EXTEND, 1f, 1.6f); + } + + public void soundRefire(Location loc) + { + + } + + public void giveToPlayer(Player player) + { + giveToPlayer(player, _slot); + } + + public int getSlot() + { + return _slot; + } + + public void moveEvent(PlayerMoveEvent event) + { + double dist = UtilMath.offset(event.getFrom(), event.getTo()); + + _lastMove = dist; + _lastMoveTime = System.currentTimeMillis(); + } + + public void reduceCone() + { + _cone = Math.max(_coneMin, _cone - (_coneReduceRate / 20d)); + } + + public void reloadEvent(RechargedEvent event) + { + if (!isHolding(event.GetPlayer())) + return; + + if (event.GetAbility().equals(getName() + " Shoot")) + { + soundRefire(event.GetPlayer().getEyeLocation()); + } + else if (event.GetAbility().equals(getName() + " Reload")) + { + soundReloaded(event.GetPlayer().getEyeLocation()); + } + } + + @Override + public boolean pickup(MineStrike game, Player player) + { + if (player.getInventory().getItem(_slot) != null && player.getInventory().getItem(_slot).getType() != Material.AIR) + return false; + + giveToPlayer(player); + + game.registerGun(this, player); + game.deregisterDroppedGun(this); + + return true; + } + + public void restockAmmo(Player player) + { + _loadedAmmo = _clipSize; + _reserveAmmo = _clipReserve * _clipSize; + + updateWeaponName(player); + + player.setHealth(20); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/GunType.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/GunType.java new file mode 100644 index 000000000..60601700b --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/GunType.java @@ -0,0 +1,47 @@ +package nautilus.game.arcade.game.games.minestrike.items.guns; + +public enum GunType +{ + + + PISTOL("Pistol", 0.06, 0.04, 0.08), + SHOTGUN("Shotgun", 0, 0, 0), + SMG("SMG", 0.08, 0.05, 0.1), + RIFLE("Rifle", 0.1, 0.06, 0.12), + + SNIPER("Sniper Rifle", 0.16, 0.08, 0.16); + + private String _name; + + private double _movePenalty; + private double _sprintPentalty; + private double _jumpPenalty; + + GunType(String name, double move, double sprint, double jump) + { + _name = name; + _movePenalty = move; + _sprintPentalty = sprint; + _jumpPenalty = jump; + } + + public String getName() + { + return _name; + } + + public double getMovePenalty() + { + return _movePenalty; + } + + public double getSprintPenalty() + { + return _sprintPentalty; + } + + public double getJumpPenalty() + { + return _jumpPenalty; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/Shotgun.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/Shotgun.java new file mode 100644 index 000000000..b583067b6 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/Shotgun.java @@ -0,0 +1,74 @@ +package nautilus.game.arcade.game.games.minestrike.items.guns; + +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.recharge.Recharge; +import nautilus.game.arcade.game.games.minestrike.MineStrike; +import nautilus.game.arcade.game.games.minestrike.items.StrikeItemType; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.player.PlayerMoveEvent; + +public abstract class Shotgun extends Gun +{ + private int _pellets; + + public Shotgun(StrikeItemType type, String name, String[] desc, + int cost, int gemCost, + int clipSize, int spareAmmo, + long fireRate, long reloadTime, double damage, + double dropOffPerBlock, double bulletSpeed, double coneMin, + double coneMax, double coneIncrease, double coneReduce, + Material skin, Sound sound, int pellets) + { + super(type, GunType.SHOTGUN, name, desc, cost, gemCost, clipSize, spareAmmo, fireRate, reloadTime, damage, + dropOffPerBlock, bulletSpeed, coneMin, coneMax, coneIncrease, + coneReduce, skin, sound); + + _pellets = pellets; + } + + @Override + public void shoot(Player player, MineStrike game) + { + //Check Ammo + if (!ammoCheck(player)) + return; + + if (!Recharge.Instance.use(player, getName() + " Shoot", _fireRate, false, false)) + return; + + //Use Ammo + _loadedAmmo--; + updateWeaponName(player); + + //Effect + soundFire(player.getLocation()); + UtilParticle.PlayParticle(ParticleType.CLOUD, player.getEyeLocation().add(player.getLocation().getDirection().multiply(1.5)), 0, 0, 0, 0, 1); + + for (int i=0 ; i<_pellets ; i++) + game.registerBullet(fireBullet(player)); + } + + @Override + public void soundRefire(Location loc) + { + loc.getWorld().playSound(loc, Sound.PISTON_RETRACT, 0.8f, 1.2f); + loc.getWorld().playSound(loc, Sound.PISTON_RETRACT, 0.8f, 1.2f); + } + + @Override + public double getCone(Player player) + { + return _cone; + } + + @Override + public void moveEvent(PlayerMoveEvent event) + { + + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/pistol/CZ75.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/pistol/CZ75.java new file mode 100644 index 000000000..15cff6eb6 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/pistol/CZ75.java @@ -0,0 +1,27 @@ +package nautilus.game.arcade.game.games.minestrike.items.guns.pistol; + + +import org.bukkit.Material; +import org.bukkit.Sound; + +import nautilus.game.arcade.game.games.minestrike.items.StrikeItemType; +import nautilus.game.arcade.game.games.minestrike.items.guns.Gun; +import nautilus.game.arcade.game.games.minestrike.items.guns.GunType; + +public class CZ75 extends Gun +{ + public CZ75() + { + super(StrikeItemType.SECONDARY_WEAPON, GunType.PISTOL, "CZ75-Auto", new String[] + { + + }, + 300, 0, //Cost, Gem Cost + 12, 1, //Clip Size, Spare Ammo + 80, 2700, //ROF, Reload Time + 6, 0.01, 3, //Damage, Dropoff, Bullet Speed + 0, 0.15, //COF Min, COF Max + 0.06, 0.4, //COF Inc per Bullet, COF Dec per Second + Material.IRON_HOE, Sound.ENDERMAN_DEATH); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/pistol/Deagle.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/pistol/Deagle.java new file mode 100644 index 000000000..e5c197694 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/pistol/Deagle.java @@ -0,0 +1,27 @@ +package nautilus.game.arcade.game.games.minestrike.items.guns.pistol; + + +import org.bukkit.Material; +import org.bukkit.Sound; + +import nautilus.game.arcade.game.games.minestrike.items.StrikeItemType; +import nautilus.game.arcade.game.games.minestrike.items.guns.Gun; +import nautilus.game.arcade.game.games.minestrike.items.guns.GunType; + +public class Deagle extends Gun +{ + public Deagle() + { + super(StrikeItemType.SECONDARY_WEAPON, GunType.PISTOL, "Desert Eagle", new String[] + { + + }, + 800, 0, //Cost, Gem Cost + 7, 5, //Clip Size, Spare Ammo + 300, 2000, //ROF, Reload Time + 9, 0.01, 3, //Damage, Dropoff, Bullet Speed + 0, 0.2, //COF Min, COF Max + 0.12, 0.2, //COF Inc per Bullet, COF Dec per Second + Material.GOLD_HOE, Sound.BAT_DEATH); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/pistol/Glock18.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/pistol/Glock18.java new file mode 100644 index 000000000..bd86135cd --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/pistol/Glock18.java @@ -0,0 +1,27 @@ +package nautilus.game.arcade.game.games.minestrike.items.guns.pistol; + + +import org.bukkit.Material; +import org.bukkit.Sound; + +import nautilus.game.arcade.game.games.minestrike.items.StrikeItemType; +import nautilus.game.arcade.game.games.minestrike.items.guns.Gun; +import nautilus.game.arcade.game.games.minestrike.items.guns.GunType; + +public class Glock18 extends Gun +{ + public Glock18() + { + super(StrikeItemType.SECONDARY_WEAPON, GunType.PISTOL, "Glock 18", new String[] + { + + }, + 0, 0, //Cost, Gem Cost + 20, 6, //Clip Size, Spare Ammo + 120, 2000, //ROF, Reload Time + 5, 0.01, 3, //Damage, Dropoff, Bullet Speed + 0, 0.15, //COF Min, COF Max + 0.08, 0.3, //COF Inc per Bullet, COF Dec per Second + Material.STONE_HOE, Sound.BAT_LOOP); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/pistol/P2000.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/pistol/P2000.java new file mode 100644 index 000000000..fd1a1bd96 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/pistol/P2000.java @@ -0,0 +1,27 @@ +package nautilus.game.arcade.game.games.minestrike.items.guns.pistol; + + +import org.bukkit.Material; +import org.bukkit.Sound; + +import nautilus.game.arcade.game.games.minestrike.items.StrikeItemType; +import nautilus.game.arcade.game.games.minestrike.items.guns.Gun; +import nautilus.game.arcade.game.games.minestrike.items.guns.GunType; + +public class P2000 extends Gun +{ + public P2000() + { + super(StrikeItemType.SECONDARY_WEAPON, GunType.PISTOL, "P2000", new String[] + { + + }, + 0, 0, //Cost, Gem Cost + 13, 4, //Clip Size, Spare Ammo + 130, 2200, //ROF, Reload Time + 6, 0.01, 3, //Damage, Dropoff, Bullet Speed + 0, 0.15, //COF Min, COF Max + 0.08, 0.3, //COF Inc per Bullet, COF Dec per Second + Material.WOOD_HOE, Sound.GHAST_SCREAM2); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/rifle/AK47.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/rifle/AK47.java new file mode 100644 index 000000000..cf351e5a2 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/rifle/AK47.java @@ -0,0 +1,27 @@ +package nautilus.game.arcade.game.games.minestrike.items.guns.rifle; + + +import org.bukkit.Material; +import org.bukkit.Sound; + +import nautilus.game.arcade.game.games.minestrike.items.StrikeItemType; +import nautilus.game.arcade.game.games.minestrike.items.guns.Gun; +import nautilus.game.arcade.game.games.minestrike.items.guns.GunType; + +public class AK47 extends Gun +{ + public AK47() + { + super(StrikeItemType.PRIMARY_WEAPON, GunType.RIFLE, "AK-47", new String[] + { + + }, + 2700, 5000, //Cost, Gem Cost + 30, 3, //Clip Size, Spare Ammo + 80, 3600, //ROF, Reload Time + 7.5, 0.005, 3.5, //Damage, Dropoff, Bullet Speed + 0, 0.25, //COF Min, COF Max + 0.050, 0.4, //COF Inc per Bullet, COF Dec per Second + Material.WOOD_SPADE, Sound.BURP); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/rifle/AWP.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/rifle/AWP.java new file mode 100644 index 000000000..018103381 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/rifle/AWP.java @@ -0,0 +1,27 @@ +package nautilus.game.arcade.game.games.minestrike.items.guns.rifle; + + +import org.bukkit.Material; +import org.bukkit.Sound; + +import nautilus.game.arcade.game.games.minestrike.items.StrikeItemType; +import nautilus.game.arcade.game.games.minestrike.items.guns.Gun; +import nautilus.game.arcade.game.games.minestrike.items.guns.GunType; + +public class AWP extends Gun +{ + public AWP() + { + super(StrikeItemType.PRIMARY_WEAPON, GunType.SNIPER, "AWP", new String[] + { + + }, + 4750, 5000, //Cost, Gem Cost + 10, 3, //Clip Size, Spare Ammo + 1500, 3600, //ROF, Reload Time + 30, 0.002, 4.4, //Damage, Dropoff, Bullet Speed + 0.05, 0.05, //COF Min, COF Max + 0, 0, //COF Inc per Bullet, COF Dec per Second + Material.GOLD_SPADE, Sound.DRINK); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/rifle/M4A1.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/rifle/M4A1.java new file mode 100644 index 000000000..ea4e5d34c --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/rifle/M4A1.java @@ -0,0 +1,27 @@ +package nautilus.game.arcade.game.games.minestrike.items.guns.rifle; + + +import org.bukkit.Material; +import org.bukkit.Sound; + +import nautilus.game.arcade.game.games.minestrike.items.StrikeItemType; +import nautilus.game.arcade.game.games.minestrike.items.guns.Gun; +import nautilus.game.arcade.game.games.minestrike.items.guns.GunType; + +public class M4A1 extends Gun +{ + public M4A1() + { + super(StrikeItemType.PRIMARY_WEAPON, GunType.RIFLE, "M4A4", new String[] + { + + }, + 2900, 5000, //Cost, Gem Cost + 30, 3, //Clip Size, Spare Ammo + 80, 3600, //ROF, Reload Time + 7, 0.005, 3.5, //Damage, Dropoff, Bullet Speed + 0, 0.2, //COF Min, COF Max + 0.048, 0.4, //COF Inc per Bullet, COF Dec per Second + Material.STONE_SPADE, Sound.BAT_TAKEOFF); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/shotgun/Nova.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/shotgun/Nova.java new file mode 100644 index 000000000..7c4bcf291 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/shotgun/Nova.java @@ -0,0 +1,26 @@ +package nautilus.game.arcade.game.games.minestrike.items.guns.shotgun; + + +import org.bukkit.Material; +import org.bukkit.Sound; + +import nautilus.game.arcade.game.games.minestrike.items.StrikeItemType; +import nautilus.game.arcade.game.games.minestrike.items.guns.Shotgun; + +public class Nova extends Shotgun +{ + public Nova() + { + super(StrikeItemType.PRIMARY_WEAPON, "Nova", new String[] + { + + }, + 1200, 5000, //Cost, Gem Cost + 8, 4, //Clip Size, Spare Ammo + 1000, 4000, //ROF, Reload Time + 5, 0.02, 2.5, //Damage, Dropoff, Bullet Speed + 0.15, 0.15, //COF Min, COF Max + 0, 0, //COF Inc per Bullet, COF Dec per Second + Material.GOLD_AXE, Sound.BLAZE_DEATH, 9); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/smg/P90.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/smg/P90.java new file mode 100644 index 000000000..bd28edd52 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/guns/smg/P90.java @@ -0,0 +1,27 @@ +package nautilus.game.arcade.game.games.minestrike.items.guns.smg; + + +import org.bukkit.Material; +import org.bukkit.Sound; + +import nautilus.game.arcade.game.games.minestrike.items.StrikeItemType; +import nautilus.game.arcade.game.games.minestrike.items.guns.Gun; +import nautilus.game.arcade.game.games.minestrike.items.guns.GunType; + +public class P90 extends Gun +{ + public P90() + { + super(StrikeItemType.PRIMARY_WEAPON, GunType.SMG, "P90", new String[] + { + + }, + 2350, 5000, //Cost, Gem Cost + 50, 2, //Clip Size, Spare Ammo + 35, 2800, //ROF, Reload Time + 5, 0.01, 2.5, //Damage, Dropoff, Bullet Speed + 0, 0.2, //COF Min, COF Max + 0.03, 0.4, //COF Inc per Bullet, COF Dec per Second + Material.STONE_AXE, Sound.CREEPER_DEATH); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/kits/KitPlayer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/kits/KitPlayer.java new file mode 100644 index 000000000..ddf568901 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/kits/KitPlayer.java @@ -0,0 +1,50 @@ +package nautilus.game.arcade.game.games.minestrike.kits; + +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemStackFactory; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; + +public class KitPlayer extends Kit +{ + public KitPlayer(ArcadeManager manager) + { + super(manager, "Player", KitAvailability.Free, + new String[] + { + C.cGreen + "Right-Click" + C.cWhite + " - " + C.cYellow + "Fire Gun", + C.cGreen + "Left-Click" + C.cWhite + " - " + C.cYellow + "Reload Gun", + C.cGreen + "Crouch" + C.cWhite + " - " + C.cYellow + "Sniper Scope", + "", + C.cGreen + "Hold Right-Click with Bomb" + C.cWhite + " - " + C.cRed + "Plant Bomb", + C.cGreen + "Hold Right-Click with Knife" + C.cWhite + " - " + C.cAqua + "Defuse Bomb", + }, + new Perk[] + { + + }, + EntityType.PLAYER, + new ItemStack(Material.AIR)); + + } + + @Override + public void GiveItems(Player player) + { + + } + + @Override + public void SpawnCustom(LivingEntity ent) + { + + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sneakyassassins/SneakyAssassins.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sneakyassassins/SneakyAssassins.java index 8f4f677ae..96fadfe96 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sneakyassassins/SneakyAssassins.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sneakyassassins/SneakyAssassins.java @@ -278,18 +278,6 @@ public class SneakyAssassins extends SoloGame event.setCancelled(true); } - @EventHandler(ignoreCancelled = true) - public void onHangingBreak(HangingBreakEvent event) - { - event.setCancelled(true); - } - - @EventHandler(ignoreCancelled = true) - public void onHangingPlace(HangingPlaceEvent event) - { - event.setCancelled(true); - } - @EventHandler(ignoreCancelled = true) public void onPlayerInteractHanging(PlayerInteractEntityEvent event) { @@ -297,13 +285,6 @@ public class SneakyAssassins extends SoloGame event.setCancelled(true); } - @EventHandler(ignoreCancelled = true) - public void onDamageHanging(EntityDamageEvent event) - { - if (event.getEntity() instanceof Hanging) - event.setCancelled(true); - } - @EventHandler(ignoreCancelled = true) public void onWitherEffectDamager(CustomDamageEvent event) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/spleef/Spleef.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/spleef/Spleef.java index 3ded0d662..0f071935c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/spleef/Spleef.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/spleef/Spleef.java @@ -187,10 +187,12 @@ public class Spleef extends SoloGame public void BlockFade(Block block, Player player, boolean slowDamage) { + if (block.getTypeId() == 7) + return; + //Prevent Super Hunger from Bow if (Recharge.Instance.use(player, GetName() + " Hunger", 50, false, false)) - if (block.getTypeId() != 7) - UtilPlayer.hunger(player, 1); + UtilPlayer.hunger(player, 1); if (!slowDamage) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java index be864a7a1..2e6434404 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java @@ -253,7 +253,7 @@ public class GameFlagManager implements Listener } @EventHandler(priority = EventPriority.LOWEST) - public void InventoryOpen(InventoryClickEvent event) + public void InventoryClick(InventoryClickEvent event) { Game game = Manager.GetGame(); if (game == null) @@ -262,6 +262,10 @@ public class GameFlagManager implements Listener if (!game.InProgress()) return; + Player player = UtilPlayer.searchExact(event.getWhoClicked().getName()); + if (player != null && !game.IsAlive(player)) + return; + if (game.InventoryClick) return; @@ -560,7 +564,7 @@ public class GameFlagManager implements Listener final Player player = event.getEntity(); //Visual - Manager.GetCondition().Factory().Blind("Ghost", player, player, 1.5, 0, false, false, false); + Manager.GetCondition().Factory().Blind("Ghost", player, player, 2, 0, false, false, false); player.setFireTicks(0); player.setFallDistance(0); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java index fc421c197..2b553928e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java @@ -108,7 +108,7 @@ public class GameManager implements Listener System.out.println("Game Load Expired."); game.SetState(GameState.Dead); } - } + } else if (game.GetState() == GameState.Recruit) { //Stop Countdown! diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GamePlayerManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GamePlayerManager.java index 2a36516a6..189399c12 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GamePlayerManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GamePlayerManager.java @@ -68,7 +68,6 @@ public class GamePlayerManager implements Listener event.GetLog().SetKillerColor(Manager.GetColor(player)+""); } - if (event.GetEvent().getEntity() instanceof Player) { Player player = (Player)event.GetEvent().getEntity();