From 829736ed07d660c075880a51548954dabd0fcbb4 Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Sat, 30 Aug 2014 02:26:07 -0700 Subject: [PATCH 1/9] Fixed purchase info. --- .../src/mineplex/core/cosmetic/ui/page/GadgetPage.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java index 9a6927479..7314c65b0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java @@ -99,9 +99,9 @@ public class GadgetPage extends ShopPageBase else { if (gadget.GetCost(CurrencyType.Coins) > 0 && DonationManager.Get(Player.getName()).GetBalance(CurrencyType.Coins) >= gadget.GetCost(CurrencyType.Coins)) - AddButton(slot, new ShopItem(Material.INK_SACK, (byte)8, "Purchase " + gadget.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, false, false), new GadgetButton(gadget, this)); + AddButton(slot, new ShopItem(Material.INK_SACK, (byte)8, (gadget.GetCost(CurrencyType.Coins) == -2 ? "" : "Purchase ") + gadget.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, false, false), new GadgetButton(gadget, this)); else - setItem(slot, new ShopItem(Material.INK_SACK, (byte)8, "Purchase " + gadget.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false)); + setItem(slot, new ShopItem(Material.INK_SACK, (byte)8, (gadget.GetCost(CurrencyType.Coins) == -2 ? "" : "Purchase ") + gadget.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false)); } } From f6dcebc3dc601158aaececaf7256eb3d63d0af9b Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Sat, 30 Aug 2014 02:33:37 -0700 Subject: [PATCH 2/9] Fixed extra spacing in cosmetic menu. --- .../src/mineplex/core/cosmetic/ui/page/Menu.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java index 0771f34f4..9965f06fa 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java @@ -3,6 +3,7 @@ package mineplex.core.cosmetic.ui.page; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; +import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack; import org.bukkit.entity.Player; import mineplex.core.account.CoreClientManager; @@ -51,7 +52,7 @@ public class Menu extends ShopPageBase else { */ - AddItem(13, new ShopItem(Material.CHEST, C.cGold + treasureChestCount + " Treasure Chests (COMING SOON!)" + ChatColor.RESET, 1, false)); + AddItem(13, new ShopItem(Material.CHEST, ChatColor.RESET + C.cGold + treasureChestCount + " Treasure Chests (COMING SOON!)" + ChatColor.RESET, 1, false)); //} final GemBooster gemBoosterItem = new GemBooster(Shop.getBoosterEnabled(), Plugin.getInventoryManager().Get(Player).getItemCount("Gem Booster")); @@ -115,7 +116,7 @@ public class Menu extends ShopPageBase final Gadget gadget = Plugin.getGadgetManager().getActive(Player, GadgetType.Particle); AddButton(36, - new ShopItem(gadget.GetDisplayMaterial(), gadget.GetDisplayData(), C.mItem + gadget.GetName(), new String[] {}, 1, false, false), + new ShopItem(gadget.GetDisplayMaterial(), gadget.GetDisplayData(), ChatColor.RESET + C.mItem + gadget.GetName(), new String[] {}, 1, false, false), new SingleButton() { @Override @@ -133,7 +134,7 @@ public class Menu extends ShopPageBase final Gadget gadget = Plugin.getGadgetManager().getActive(Player, GadgetType.Item); AddButton(38, - new ShopItem(gadget.GetDisplayMaterial(), gadget.GetDisplayData(), C.mItem + gadget.GetName(), new String[] {}, 1, false, false), + new ShopItem(gadget.GetDisplayMaterial(), gadget.GetDisplayData(), ChatColor.RESET + C.mItem + gadget.GetName(), new String[] {}, 1, false, false), new SingleButton() { @Override @@ -151,7 +152,7 @@ public class Menu extends ShopPageBase final Gadget gadget = Plugin.getGadgetManager().getActive(Player, GadgetType.Morph); AddButton(40, - new ShopItem(gadget.GetDisplayMaterial(), gadget.GetDisplayData(), C.mItem + gadget.GetName(), new String[] {}, 1, false, false), + new ShopItem(gadget.GetDisplayMaterial(), gadget.GetDisplayData(), ChatColor.RESET + C.mItem + gadget.GetName(), new String[] {}, 1, false, false), new SingleButton() { @Override @@ -169,7 +170,7 @@ public class Menu extends ShopPageBase final Mount mount = Plugin.getMountManager().getActive(Player); AddButton(42, - new ShopItem(mount.GetDisplayMaterial(), mount.GetDisplayData(), C.mItem + mount.GetName(), new String[] {}, 1, false, false), + new ShopItem(mount.GetDisplayMaterial(), mount.GetDisplayData(), ChatColor.RESET + C.mItem + mount.GetName(), new String[] {}, 1, false, false), new SingleButton() { @Override @@ -184,7 +185,7 @@ public class Menu extends ShopPageBase if (Plugin.getPetManager().hasActivePet(Player.getName())) { - AddButton(44, new ShopItem(Material.MONSTER_EGG, (byte)Plugin.getPetManager().getActivePet(Player.getName()).getType().getTypeId(), C.mItem + Plugin.getPetManager().getActivePet(Player.getName()).getCustomName(), new String[] {}, 1, false, false), + AddButton(44, new ShopItem(Material.MONSTER_EGG, (byte)Plugin.getPetManager().getActivePet(Player.getName()).getType().getTypeId(), ChatColor.RESET + C.mItem + Plugin.getPetManager().getActivePet(Player.getName()).getCustomName(), new String[] {}, 1, false, false), new SingleButton() { @Override From c8bc697888aef7e7b6532d7f18a0de8d43e6a9d2 Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Sat, 30 Aug 2014 02:37:27 -0700 Subject: [PATCH 3/9] Fixed mounts and gadgets for rank messages...no Purchase. --- .../src/mineplex/core/cosmetic/ui/page/GadgetPage.java | 4 ++-- .../src/mineplex/core/cosmetic/ui/page/MountPage.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java index 7314c65b0..5f37cb486 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java @@ -99,9 +99,9 @@ public class GadgetPage extends ShopPageBase else { if (gadget.GetCost(CurrencyType.Coins) > 0 && DonationManager.Get(Player.getName()).GetBalance(CurrencyType.Coins) >= gadget.GetCost(CurrencyType.Coins)) - AddButton(slot, new ShopItem(Material.INK_SACK, (byte)8, (gadget.GetCost(CurrencyType.Coins) == -2 ? "" : "Purchase ") + gadget.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, false, false), new GadgetButton(gadget, this)); + AddButton(slot, new ShopItem(Material.INK_SACK, (byte)8, (gadget.GetCost(CurrencyType.Coins) < 0 ? "" : "Purchase ") + gadget.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, false, false), new GadgetButton(gadget, this)); else - setItem(slot, new ShopItem(Material.INK_SACK, (byte)8, (gadget.GetCost(CurrencyType.Coins) == -2 ? "" : "Purchase ") + gadget.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false)); + setItem(slot, new ShopItem(Material.INK_SACK, (byte)8, (gadget.GetCost(CurrencyType.Coins) < 0 ? "" : "Purchase ") + gadget.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false)); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MountPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MountPage.java index 8494414d2..ae13f790d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MountPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MountPage.java @@ -71,9 +71,9 @@ public class MountPage extends ShopPageBase else { if (mount.GetCost(CurrencyType.Coins) != -1 && DonationManager.Get(Player.getName()).GetBalance(CurrencyType.Coins) >= mount.GetCost(CurrencyType.Coins)) - AddButton(slot, new ShopItem(mount.GetDisplayMaterial(), mount.GetDisplayData(), "Purchase " + mount.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, false, false), new MountButton(mount, this)); + AddButton(slot, new ShopItem(mount.GetDisplayMaterial(), mount.GetDisplayData(), (mount.GetCost(CurrencyType.Coins) < 0 ? "" : "Purchase ") + mount.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, false, false), new MountButton(mount, this)); else - setItem(slot, new ShopItem(mount.GetDisplayMaterial(), mount.GetDisplayData(), "Purchase " + mount.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false)); + setItem(slot, new ShopItem(mount.GetDisplayMaterial(), mount.GetDisplayData(), (mount.GetCost(CurrencyType.Coins) < 0 ? "" : "Purchase ") + mount.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false)); } AddButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[] { }, 1, false), new SingleButton() From 207de0e67a165456ae1d343c3f1a18fa00a867eb Mon Sep 17 00:00:00 2001 From: Chiss Date: Sat, 30 Aug 2014 20:49:32 +1000 Subject: [PATCH 4/9] fixed MAC kicking players on lillypads --- .../src/mineplex/core/common/util/UtilEnt.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java index 1d7b6eca0..10aead10b 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java @@ -505,6 +505,10 @@ public class UtilEnt if (player.getLocation().add(x, -0.5, z).getBlock().getType() != Material.AIR && !player.getLocation().add(x, -0.5, z).getBlock().isLiquid()) return true; + //Inside a Lillypad + if (player.getLocation().add(x, 0, z).getBlock().getType() == Material.WATER_LILY) + return true; + //Fences/Walls Material beneath = player.getLocation().add(x, -1.5, z).getBlock().getType(); if (player.getLocation().getY() % 0.5 == 0 && From 8198bb31c8a0443a07178c8bff93df6fd656a013 Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Mon, 1 Sep 2014 00:56:32 -0700 Subject: [PATCH 5/9] Added sneaking to player disguise. Did work on DDoSProtectionSwitcher Work on AccountAdministrator to fix rank issues. --- .../core/disguise/DisguiseManager.java | 115 ++++- .../disguise/disguises/DisguisePlayer.java | 19 + .../src/mineplex/core/donation/Donor.java | 8 +- .../mineplex/ddos/DDoSProtectionSwitcher.java | 14 +- .../.externalToolBuilders/CB2.launch | 2 +- .../src/nautilus/game/arcade/Arcade.java | 4 +- Website/LOC.Core/LOC.Core.csproj | 4 - .../Contexts}/IRepository.cs | 0 .../Contexts}/IRepositoryFactory.cs | 0 .../Contexts}/Repository.cs | 14 + .../Contexts}/RepositoryFactory.cs | 0 .../LOC.Website.Common.csproj | 8 +- .../Models/AccountAdministrator.cs | 25 +- .../LOC.Website.Web.Publish.xml | 476 +++++++++--------- Website/LOCWebsite.suo | Bin 474624 -> 474624 bytes 15 files changed, 413 insertions(+), 276 deletions(-) rename Website/{LOC.Core/Data => LOC.Website.Common/Contexts}/IRepository.cs (100%) rename Website/{LOC.Core/Data => LOC.Website.Common/Contexts}/IRepositoryFactory.cs (100%) rename Website/{LOC.Core/Data => LOC.Website.Common/Contexts}/Repository.cs (89%) rename Website/{LOC.Core/Data => LOC.Website.Common/Contexts}/RepositoryFactory.cs (100%) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java index 27b1dd35a..14037083f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java @@ -2,6 +2,7 @@ package mineplex.core.disguise; import java.lang.reflect.Field; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashSet; import java.util.List; @@ -58,6 +59,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable private NautHashMap _entityDisguiseMap = new NautHashMap(); private NautHashMap _addTempList = new NautHashMap(); private HashSet _delTempList = new HashSet(); + private NautHashMap> _disguisePlayerMap = new NautHashMap>(); private Field _attributesA; private Field _soundB; @@ -105,12 +107,44 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable return _spawnPacketMap.get(entity.getEntityId()); } - public void disguise(DisguiseBase disguise) + public void addViewerToDisguise(DisguiseBase disguise, Player player) + { + _disguisePlayerMap.get(disguise).add(player); + + reApplyDisguise(disguise, player); + } + + public void removeViewerToDisguise(DisguiseBase disguise, Player player) + { + _disguisePlayerMap.get(disguise).remove(player); + + EntityPlayer entityPlayer = ((CraftPlayer)player).getHandle(); + entityPlayer.playerConnection.sendPacket(new PacketPlayOutEntityDestroy(disguise.GetEntity().getId())); + + if (disguise.GetEntity() instanceof EntityPlayer) + { + player.hidePlayer(Bukkit.getPlayer(disguise.GetEntity().getName())); + player.showPlayer(Bukkit.getPlayer(disguise.GetEntity().getName())); + } + else + { + entityPlayer.playerConnection.sendPacket(new PacketPlayOutSpawnEntityLiving((net.minecraft.server.v1_7_R4.EntityLiving)disguise.GetEntity())); + } + } + + public void disguise(DisguiseBase disguise, Player...players) { if (!disguise.GetEntity().isAlive()) return; + if (players == null || players.length == 0) + { + players = Bukkit.getOnlinePlayers().toArray(new Player[Bukkit.getOnlinePlayers().size()]); + } + _spawnPacketMap.put(disguise.GetEntityId(), disguise); + _disguisePlayerMap.put(disguise, new HashSet()); + _disguisePlayerMap.get(disguise).addAll(Arrays.asList(players)); reApplyDisguise(disguise); } @@ -120,11 +154,11 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable if (!_spawnPacketMap.containsKey(entity.getEntityId())) return; - _spawnPacketMap.remove(entity.getEntityId()); + DisguiseBase disguise = _spawnPacketMap.remove(entity.getEntityId()); _movePacketMap.remove(entity.getEntityId()); _moveTempMap.remove(entity.getEntityId()); - for (Player player : Bukkit.getOnlinePlayers()) + for (Player player : _disguisePlayerMap.get(disguise)) { if (entity == player) continue; @@ -146,14 +180,16 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable public void reApplyDisguise(final DisguiseBase disguise) { - for (Player player : Bukkit.getOnlinePlayers()) + PacketPlayOutEntityDestroy destroyPacket = new PacketPlayOutEntityDestroy(disguise.GetEntityId()); + + for (Player player : _disguisePlayerMap.get(disguise)) { if (disguise.GetEntity() == ((CraftPlayer)player).getHandle()) continue; EntityPlayer entityPlayer = ((CraftPlayer)player).getHandle(); - entityPlayer.playerConnection.sendPacket(new PacketPlayOutEntityDestroy(disguise.GetEntityId())); + entityPlayer.playerConnection.sendPacket(destroyPacket); } List tempArmor = new ArrayList(); @@ -173,7 +209,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable { public void run() { - for (Player player : Bukkit.getOnlinePlayers()) + for (Player player : _disguisePlayerMap.get(disguise)) { if (disguise.GetEntity() == ((CraftPlayer)player).getHandle()) continue; @@ -189,10 +225,49 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable } }); } + + public void reApplyDisguise(final DisguiseBase disguise, final Player player) + { + PacketPlayOutEntityDestroy destroyPacket = new PacketPlayOutEntityDestroy(disguise.GetEntityId()); + + if (disguise.GetEntity() == ((CraftPlayer)player).getHandle()) + return; + EntityPlayer entityPlayer = ((CraftPlayer)player).getHandle(); + + entityPlayer.playerConnection.sendPacket(destroyPacket); + + List tempArmor = new ArrayList(); + + if (disguise instanceof DisguiseInsentient && disguise.GetEntity() instanceof LivingEntity) + { + if (((DisguiseInsentient)disguise).armorVisible()) + { + for (Packet armorPacket : ((DisguiseInsentient)disguise).getArmorPackets()) + tempArmor.add(armorPacket); + } + } + + final List armorPackets = tempArmor; + + Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(GetPlugin(), new Runnable() + { + public void run() + { + EntityPlayer entityPlayer = ((CraftPlayer)player).getHandle(); + entityPlayer.playerConnection.sendPacket(disguise.GetSpawnPacket()); + + for (Packet packet : armorPackets) + { + entityPlayer.playerConnection.sendPacket(packet); + } + } + }); + } + public void updateDisguise(DisguiseBase disguise) { - for (Player player : Bukkit.getOnlinePlayers()) + for (Player player : _disguisePlayerMap.get(disguise)) { if (disguise.GetEntity() == ((CraftPlayer)player).getHandle()) continue; @@ -265,6 +340,11 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable public void PlayerQuit(PlayerQuitEvent event) { undisguise(event.getPlayer()); + + for (DisguiseBase disguise : _disguisePlayerMap.keySet()) + { + _disguisePlayerMap.get(disguise).remove(event.getPlayer()); + } } @Override @@ -274,7 +354,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable { int entityId = ((PacketPlayOutNamedEntitySpawn)packet).a; - if (_spawnPacketMap.containsKey(entityId)) + if (_spawnPacketMap.containsKey(entityId) && _disguisePlayerMap.get(_spawnPacketMap.get(entityId)).contains(owner)) { packetList.forceProcess(_spawnPacketMap.get(entityId).GetSpawnPacket()); return false; @@ -284,7 +364,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable { int entityId = ((PacketPlayOutSpawnEntity)packet).a; - if (_spawnPacketMap.containsKey(entityId)) + if (_spawnPacketMap.containsKey(entityId) && _disguisePlayerMap.get(_spawnPacketMap.get(entityId)).contains(owner)) { packetList.forceProcess(_spawnPacketMap.get(entityId).GetSpawnPacket()); return false; @@ -307,7 +387,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable e.printStackTrace(); } - if (_spawnPacketMap.containsKey(entityId) && owner.getEntityId() != entityId) + if (_spawnPacketMap.containsKey(entityId) && owner.getEntityId() != entityId && _disguisePlayerMap.get(_spawnPacketMap.get(entityId)).contains(owner)) { // Crash clients with meta to a block id. if (_spawnPacketMap.get(entityId) instanceof DisguiseBlock) @@ -318,7 +398,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable { int entityId = ((PacketPlayOutAnimation)packet).a; - if (_spawnPacketMap.containsKey(entityId) && owner.getEntityId() != entityId) + if (containsSpawnDisguise(owner, entityId) && owner.getEntityId() != entityId) { return false; } @@ -327,7 +407,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable { int entityId = ((PacketPlayOutEntityMetadata)packet).a; - if (_spawnPacketMap.containsKey(entityId) && owner.getEntityId() != entityId) + if (containsSpawnDisguise(owner, entityId) && owner.getEntityId() != entityId) { packetList.forceProcess(_spawnPacketMap.get(entityId).GetMetaDataPacket()); return false; @@ -337,7 +417,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable { int entityId = ((PacketPlayOutEntityEquipment)packet).a; - if (_spawnPacketMap.containsKey(entityId) && _spawnPacketMap.get(entityId) instanceof DisguiseInsentient) + if (containsSpawnDisguise(owner, entityId) && _spawnPacketMap.get(entityId) instanceof DisguiseInsentient) { if (!((DisguiseInsentient)_spawnPacketMap.get(entityId)).armorVisible() && ((PacketPlayOutEntityEquipment)packet).b != 0) { @@ -378,7 +458,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable _movePacketMap.remove(movePacket.a); } - if (!_spawnPacketMap.containsKey(movePacket.a)) + if (!containsSpawnDisguise(owner, movePacket.a)) return true; final PacketPlayOutEntityVelocity velocityPacket = new PacketPlayOutEntityVelocity(); @@ -430,7 +510,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable _movePacketMap.remove(movePacket.a); } - if (!_spawnPacketMap.containsKey(movePacket.a)) + if (!containsSpawnDisguise(owner, movePacket.a)) return true; final PacketPlayOutEntityVelocity velocityPacket = new PacketPlayOutEntityVelocity(); @@ -491,6 +571,11 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable return true; } + private boolean containsSpawnDisguise(Player owner, int entityId) + { + return _spawnPacketMap.containsKey(entityId) && (_disguisePlayerMap.containsKey(_spawnPacketMap.get(entityId)) && _disguisePlayerMap.get(_spawnPacketMap.get(entityId)).contains(owner)); + } + public void PrepAddDisguise(Player caller, EntityType entityType) { _addTempList.put(caller.getName(), entityType); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguisePlayer.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguisePlayer.java index f17553e2b..4e8fcc8b3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguisePlayer.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguisePlayer.java @@ -8,6 +8,7 @@ import net.minecraft.util.com.mojang.authlib.GameProfile; public class DisguisePlayer extends DisguiseHuman { private GameProfile _profile; + private boolean _sneaking; public DisguisePlayer(org.bukkit.entity.Entity entity) { @@ -26,6 +27,24 @@ public class DisguisePlayer extends DisguiseHuman _profile = profile; } + public void setSneaking(boolean sneaking) + { + _sneaking = sneaking; + } + + @Override + public void UpdateDataWatcher() + { + super.UpdateDataWatcher(); + + byte b0 = DataWatcher.getByte(0); + + if (_sneaking) + DataWatcher.watch(0, Byte.valueOf((byte) (b0 | 1 << 1))); + else + DataWatcher.watch(0, Byte.valueOf((byte) (b0 & ~(1 << 1)))); + } + @Override public Packet GetSpawnPacket() { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/Donor.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/Donor.java index 50e9954cc..a1f2ef1dd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/Donor.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/Donor.java @@ -31,7 +31,6 @@ public class Donor _transactions = token.Transactions; _coinTransactions = token.CoinRewards; - if (_salesPackagesOwned == null) { _salesPackagesOwned = new ArrayList(); @@ -42,10 +41,15 @@ public class Donor _unknownSalesPackagesOwned = new ArrayList(); } - if (_unknownSalesPackagesOwned == null) + if (_transactions == null) { _transactions = new ArrayList(); } + + if (_coinTransactions == null) + { + _coinTransactions = new ArrayList(); + } } public int GetGems() diff --git a/Plugins/Mineplex.DDoSProtectionSwitcher/src/mineplex/ddos/DDoSProtectionSwitcher.java b/Plugins/Mineplex.DDoSProtectionSwitcher/src/mineplex/ddos/DDoSProtectionSwitcher.java index fd22fa8fa..67a04c331 100644 --- a/Plugins/Mineplex.DDoSProtectionSwitcher/src/mineplex/ddos/DDoSProtectionSwitcher.java +++ b/Plugins/Mineplex.DDoSProtectionSwitcher/src/mineplex/ddos/DDoSProtectionSwitcher.java @@ -47,8 +47,9 @@ public class DDoSProtectionSwitcher //while (true) //{ - if (_repository.switchToDDOSProt()) - { + //if (_repository.switchToDDOSProt()) + //{ + /* System.out.println("Starting DDoS Protection Switch at " + dateFormat.format(new Date())); DomainRecords records = new ApiGetCall("https://api.dnsmadeeasy.com/V2.0/dns/managed/", 962728, @@ -110,7 +111,7 @@ public class DDoSProtectionSwitcher + idBuilder.toString()).Execute(); System.out.println("Deleted " + recordsToDelete.size() + " records."); } - +*/ // Switching US Bungees switchServer("10.35.74.130", "108.178.20.166", "108.163.222.202", "108.178.20.165", "108.163.222.201"); switchServer("10.35.74.132", "108.163.217.110", "108.178.44.50", "108.163.217.109", "108.178.44.49"); @@ -133,6 +134,7 @@ public class DDoSProtectionSwitcher switchServer("10.32.214.249", "107.6.158.78", "184.154.13.38", "107.6.158.77", "184.154.13.37"); switchServer("10.32.214.247", "184.154.13.118", "108.163.242.98", "184.154.13.117", "108.163.242.97"); + /* // Switching EU Bungees switchServer("10.82.2.202", "107.6.176.194", "107.6.176.34", "107.6.176.193", "107.6.176.33"); switchServer("10.82.2.204", "107.6.176.122", "107.6.176.50", "107.6.176.121", "107.6.176.49"); @@ -142,9 +144,9 @@ public class DDoSProtectionSwitcher switchServer("10.82.2.227", "107.6.176.26", "107.6.176.46", "107.6.176.25", "107.6.176.45"); switchServer("10.82.2.228", "107.6.176.110", "107.6.176.70", "107.6.176.109", "107.6.176.69"); switchServer("10.82.2.226", "107.6.176.138", "107.6.176.234", "107.6.176.137", "107.6.176.233"); - - sendMail(); - } + */ + //sendMail(); + //} int processWaits = 0; diff --git a/Plugins/Nautilus.Core.CraftBukkit/.externalToolBuilders/CB2.launch b/Plugins/Nautilus.Core.CraftBukkit/.externalToolBuilders/CB2.launch index 00db81307..4067ec440 100644 --- a/Plugins/Nautilus.Core.CraftBukkit/.externalToolBuilders/CB2.launch +++ b/Plugins/Nautilus.Core.CraftBukkit/.externalToolBuilders/CB2.launch @@ -10,7 +10,7 @@ - + diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java index 7765d4375..64a59747e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java @@ -30,6 +30,7 @@ import mineplex.core.mount.MountManager; import mineplex.core.npc.NpcManager; import mineplex.core.packethandler.PacketHandler; import mineplex.core.pet.PetManager; +import mineplex.core.playerTracker.PlayerTracker; import mineplex.core.portal.Portal; import mineplex.core.preferences.PreferencesManager; import mineplex.core.projectile.ProjectileManager; @@ -117,7 +118,8 @@ public class Arcade extends JavaPlugin //Arcade Manager _gameManager = new ArcadeManager(this, serverStatusManager, ReadServerConfig(), _clientManager, _donationManager, _damageManager, disguiseManager, creature, teleport, new Blood(this), antistack, portal, packetHandler, preferenceManager, inventoryManager, cosmeticManager, projectileManager, webServerAddress); - + new PlayerTracker(this, serverStatusManager.getCurrentServerName(), serverStatusManager.getUs()); + new MemoryFix(this); //Updates diff --git a/Website/LOC.Core/LOC.Core.csproj b/Website/LOC.Core/LOC.Core.csproj index e83cfeeab..b1fdf484f 100644 --- a/Website/LOC.Core/LOC.Core.csproj +++ b/Website/LOC.Core/LOC.Core.csproj @@ -59,10 +59,6 @@ - - - - diff --git a/Website/LOC.Core/Data/IRepository.cs b/Website/LOC.Website.Common/Contexts/IRepository.cs similarity index 100% rename from Website/LOC.Core/Data/IRepository.cs rename to Website/LOC.Website.Common/Contexts/IRepository.cs diff --git a/Website/LOC.Core/Data/IRepositoryFactory.cs b/Website/LOC.Website.Common/Contexts/IRepositoryFactory.cs similarity index 100% rename from Website/LOC.Core/Data/IRepositoryFactory.cs rename to Website/LOC.Website.Common/Contexts/IRepositoryFactory.cs diff --git a/Website/LOC.Core/Data/Repository.cs b/Website/LOC.Website.Common/Contexts/Repository.cs similarity index 89% rename from Website/LOC.Core/Data/Repository.cs rename to Website/LOC.Website.Common/Contexts/Repository.cs index f9746a6c9..de90ffa75 100644 --- a/Website/LOC.Core/Data/Repository.cs +++ b/Website/LOC.Website.Common/Contexts/Repository.cs @@ -7,6 +7,7 @@ using System.Data.Entity.Validation; using System.Linq; using System.Linq.Expressions; + using LOC.Website.Common; public class Repository : IRepository where TContext : DbContext @@ -56,12 +57,14 @@ catch (DbEntityValidationException ex) { var l = (from err in ex.EntityValidationErrors from ve in err.ValidationErrors select ve.ErrorMessage).ToList(); + Log("ERROR", PREFIX + String.Join("; ", l)); throw new ApplicationException(PREFIX + String.Join("; ", l), ex); // contains the human-readable validation exception } catch (DbUpdateException e) { if (e.InnerException != null && e.InnerException.InnerException != null && !String.IsNullOrEmpty(e.InnerException.InnerException.Message)) { + Log("ERROR", PREFIX + String.Join("; ", e.InnerException.InnerException.Message)); throw new ApplicationException(PREFIX + String.Join("; ", e.InnerException.InnerException.Message), e); // contains the reason } throw; @@ -121,6 +124,17 @@ } } } + + private void Log(string category, string message) + { + Add(new LogEntry + { + Date = DateTime.Now, + Category = category, + Message = message + }); + CommitChanges(); + } } } diff --git a/Website/LOC.Core/Data/RepositoryFactory.cs b/Website/LOC.Website.Common/Contexts/RepositoryFactory.cs similarity index 100% rename from Website/LOC.Core/Data/RepositoryFactory.cs rename to Website/LOC.Website.Common/Contexts/RepositoryFactory.cs diff --git a/Website/LOC.Website.Common/LOC.Website.Common.csproj b/Website/LOC.Website.Common/LOC.Website.Common.csproj index 2f4ed5aca..bcce2c618 100644 --- a/Website/LOC.Website.Common/LOC.Website.Common.csproj +++ b/Website/LOC.Website.Common/LOC.Website.Common.csproj @@ -68,6 +68,12 @@ + + + + + + @@ -95,8 +101,6 @@ - - diff --git a/Website/LOC.Website.Common/Models/AccountAdministrator.cs b/Website/LOC.Website.Common/Models/AccountAdministrator.cs index aed5208f5..67a0492bb 100644 --- a/Website/LOC.Website.Common/Models/AccountAdministrator.cs +++ b/Website/LOC.Website.Common/Models/AccountAdministrator.cs @@ -92,12 +92,14 @@ account.Name = loginToken.Name; } + /* // Expire ranks if ((account.Rank.Name == "ULTRA" || account.Rank.Name == "HERO") && !account.RankPerm && DateTime.Now.CompareTo(account.RankExpire) >= 0) { account.Rank = repository.Where(x => x.Name == "ALL").First(); repository.Attach(account.Rank); } + * */ repository.CommitChanges(); @@ -538,10 +540,12 @@ public string UpdateRank(RankUpdateToken token) { + Rank rank = null; + using (var repository = _repositoryFactory.CreateRepository()) { var account = repository.Where(x => String.Equals(x.Name, token.Name)).Include(x => x.Rank).FirstOrDefault(); - var rank = repository.Where(x => String.Equals(x.Name, token.Rank)).FirstOrDefault(); + rank = repository.Where(x => String.Equals(x.Name, token.Rank)).FirstOrDefault(); if (account == null) return "ALL"; @@ -556,11 +560,10 @@ account.RankExpire = DateTime.Now.AddMonths(1); account.RankPerm = token.Perm; - if ((rank.Name == "HERO" || rank.Name == "ULTRA") && token.Perm == true) - { - repository.Attach(account); - repository.Edit(account); + repository.Edit(account); + if ((rank.Name == "HERO" || rank.Name == "ULTRA") && token.Perm) + { addAccountTransaction(repository, account, "Bacon Brawl Bebe Piggles", 0, 0); addAccountTransaction(repository, account, "Bacon Brawl `Pig`", 0, 0); addAccountTransaction(repository, account, "A Barbarians Life Barbarian Archer", 0, 0); @@ -628,9 +631,17 @@ } repository.CommitChanges(); - - return rank.Name.ToString(); + + _logger.Log("INFO", "TOKEN " + token.Name + "'s rank has been updated to " + token.Rank + " " + (token.Perm ? "Permanently" : "Monthly") + "." + " Rank expire : " + account.RankExpire.ToString()); } + + using (var repository = _repositoryFactory.CreateRepository()) + { + var account = repository.Where(x => String.Equals(x.Name, token.Name)).Include(x => x.Rank).FirstOrDefault(); + _logger.Log("INFO", "ACCOUNT " + account.Name + "'s rank is " + account.Rank.Name + " " + (account.RankPerm ? "Permanently" : "Monthly") + "." + " Rank expire : " + account.RankExpire.ToString()); + } + + return rank.Name.ToString(); } public void RemoveBan(RemovePunishmentToken token) diff --git a/Website/LOC.Website.Web/LOC.Website.Web.Publish.xml b/Website/LOC.Website.Web/LOC.Website.Web.Publish.xml index d6f0e2641..f6af927bc 100644 --- a/Website/LOC.Website.Web/LOC.Website.Web.Publish.xml +++ b/Website/LOC.Website.Web/LOC.Website.Web.Publish.xml @@ -1,11 +1,13 @@  + + @@ -16,18 +18,19 @@ - + - + + - - + + @@ -41,24 +44,27 @@ + + + + - - - + + @@ -69,23 +75,24 @@ - + + - + + - - - + + @@ -93,7 +100,7 @@ - + @@ -101,43 +108,40 @@ - - - + - - + + - + + - + - - - + @@ -148,63 +152,58 @@ - + - - - - + + - - - + - - - + + - + - - - + + - + + - + - + @@ -212,61 +211,62 @@ - + - + - + - - + - + - + + - - + + - + + - - + + - + - - + + - - + + - + + - @@ -282,16 +282,14 @@ - - + - + - @@ -305,25 +303,25 @@ - - + - + + @@ -334,29 +332,30 @@ - - + + - - + + - + + @@ -364,43 +363,41 @@ + - + - - + - + - - - - - + + - + + @@ -411,29 +408,35 @@ - + - + + + + + + - + + @@ -441,95 +444,92 @@ - + - + - + - - - + - + - - + + - + - + - + - - - + + - + + - - + - - + + - + - - + + - + - - - - - + + + + + - + + - @@ -543,50 +543,50 @@ - + - + + - - - + + - + + - + - - + - + @@ -597,73 +597,70 @@ - - - + + - - - + + - + - - + + - + - - + + - + - - + - + - + @@ -674,125 +671,128 @@ - + - + + + + + + - - + - + - + - + + - + - + - + + - - + - + - + - - + + - - + + - + - - + - + - + - - + - - + + - + - - + + - + - - - - - + + + + + - + + - @@ -806,40 +806,40 @@ - + - + + - - + - + + - + - @@ -848,8 +848,8 @@ - + @@ -860,31 +860,29 @@ - - - + + - - - + + - + @@ -892,41 +890,40 @@ - + - - + + - + - - + - + - + @@ -937,119 +934,122 @@ - + - + + + + + + - - + - + + - + - + - + + - - + - + - + - - + + - - + + - + - - + - + - - + - - + + - + - - + + - + - - - - - + + + + + - + \ No newline at end of file diff --git a/Website/LOCWebsite.suo b/Website/LOCWebsite.suo index 3f9f119c206263c33c081bccfa1582d0a37a428c..04d379ca91011a71e544cfdbbbfb9633927c9638 100644 GIT binary patch delta 641 zcmYL`QAkr^6vywq`_Ao}Vs5PkwqUtM18J#589`xY8U|j?deEk;-mIs(L4w69s2+kG z-@^%QNDvk?Xt}npRCLpd3d+FPUJZKaX;EB}V7Shpn-4#}@BjZF4(EJdxZn;K-0_P{ z9p>=?@g{MJbzRk36iKoZC?8S$33I4JEtC35UzRM-xV85s^VuXxJlijC9m3|Q+;C?l zArlH=6DtW;zL8Jr)%L-W{DqsJGE0p=R%h?F{f;`YDao9QG=iD8(2vXS6c2ungNuh| zRCx@;5%A)ULyAkd=Gb^}cYK2+y&%?##bScaS45IX5rQcBC8p>;jrQ%ZSrpuGMM4zFpPS~OV delta 449 zcmZqpBh&ClW z*<=gLzyJULZ(n21C|)!9FpFXPm(7eo%ml>D+rMmP;o+M6$V_SSoDjLq4Nn^ww;$Ng z@+W4xge$GhHXH+eY&75tMc|gGOUet)BkQ_Rh|A|IWx!hRkK;8_$RwW8%+PQ ziq)T!(H&^DE6h35OIEXnO!kP@-TrkotG^hBJy0SLA$f@P3X3OvORll{gB;9y2T5K8sfc(|t Date: Mon, 1 Sep 2014 21:37:39 +1000 Subject: [PATCH 6/9] 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(); From 5d6834633f150b9868d110c65abd51506f947393 Mon Sep 17 00:00:00 2001 From: Chiss Date: Tue, 2 Sep 2014 11:16:17 +1000 Subject: [PATCH 7/9] MineStrike update --- .../game/games/minestrike/MineStrike.java | 152 +++++++++++------- .../game/games/minestrike/ShopManager.java | 50 +++++- .../games/minestrike/items/StrikeItem.java | 44 +++-- .../items/equipment/DefusalKit.java | 8 + .../minestrike/items/equipment/Helmet.java | 10 +- .../minestrike/items/equipment/Kevlar.java | 10 +- .../minestrike/items/grenades/FlashBang.java | 4 +- .../minestrike/items/grenades/Grenade.java | 42 ++++- .../game/games/minestrike/items/guns/Gun.java | 6 + .../game/arcade/managers/GameFlagManager.java | 2 +- 10 files changed, 252 insertions(+), 76 deletions(-) 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 index fe13625ab..953d599da 100644 --- 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 @@ -15,11 +15,14 @@ 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.LivingEntity; 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.EntityRegainHealthEvent; +import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; import org.bukkit.event.entity.ItemDespawnEvent; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.entity.ProjectileHitEvent; @@ -121,7 +124,7 @@ public class MineStrike extends TeamGame private boolean _bombScoreboardFlash = false; - private HashSet _scoped = new HashSet(); + private HashMap _scoped = new HashMap(); //Round Data private String _winText = null; @@ -154,7 +157,7 @@ public class MineStrike extends TeamGame _shopManager = new ShopManager(this); - this.HungerSet = 18; + this.HungerSet = 20; this.ItemDrop = true; @@ -168,7 +171,9 @@ public class MineStrike extends TeamGame "Jumping massively decreases accuracy", "Crouching increases accuracy", "Hold Right-Click to Plant Bomb", - "Hold RIght-Click with Knife to Defuse Bomb", + "Hold Right-Click with knife to Defuse Bomb", + "Left-Click to roll Grenades", + "Right-Click to throw Grenades" }; } @@ -235,13 +240,11 @@ public class MineStrike extends TeamGame 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); + Manager.GetDisguise().disguise(_disguise.get(player)); for (Player other : UtilServer.getPlayers()) { @@ -513,13 +516,16 @@ public class MineStrike extends TeamGame } @EventHandler - public void triggerGrenade(PlayerItemConsumeEvent event) + public void triggerGrenade(PlayerInteractEvent event) { if (_freezeTime > 0) { event.setCancelled(true); return; } + + if (!UtilEvent.isAction(event, ActionType.L) && !UtilEvent.isAction(event, ActionType.R)) + return; if (!IsLive()) return; @@ -531,7 +537,7 @@ public class MineStrike extends TeamGame if (grenade == null) return; - grenade.throwGrenade(event.getPlayer(), this); + grenade.throwGrenade(event.getPlayer(), UtilEvent.isAction(event, ActionType.L), this); event.setCancelled(true); } @@ -729,24 +735,73 @@ public class MineStrike extends TeamGame } } - @EventHandler(priority=EventPriority.HIGHEST) + @EventHandler(priority=EventPriority.HIGH) public void damage(CustomDamageEvent event) { + if (event.GetCause() == DamageCause.FALL) + { + event.AddMod(GetName(), "Fall Reduction", -2, false); + return; + } - + //Knife 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); + //Cancel Non-Knife Melee + if (!UtilGear.isMat(event.GetDamagerPlayer(false).getItemInHand(), Material.IRON_AXE) && + !UtilGear.isMat(event.GetDamagerPlayer(false).getItemInHand(), Material.IRON_SWORD)) + { + event.SetCancelled("Non-Knife"); + } + //Knife Attack + else if (!event.IsCancelled()) + { + Player damager = event.GetDamagerPlayer(false); + if (damager == null) return; + + LivingEntity damagee = event.GetDamageeEntity(); + if (damagee == null) return; + + Vector look = damagee.getLocation().getDirection(); + look.setY(0); + look.normalize(); + + Vector from = damager.getLocation().toVector().subtract(damagee.getLocation().toVector()); + from.setY(0); + from.normalize(); + + Vector check = new Vector(look.getX() * -1, 0, look.getZ() * -1); + + //Backstab + if (check.subtract(from).length() < 0.8) + { + //Damage + event.AddMod(damager.getName(), "Knife", 25 - event.GetDamage(), false); + + //Effect + damagee.getWorld().playSound(damagee.getLocation(), Sound.HURT_FLESH, 1f, 2f); + + event.SetKnockback(false); + } + //Standard + else + { + //Damage + event.AddMod(damager.getName(), "Knife", 6 - event.GetDamage(), false); + + event.GetDamageeEntity().getWorld().playSound(event.GetDamageeEntity().getLocation(), Sound.BAT_HURT, 1f, 1f); + + event.AddKnockback("Knife", 1.2); + } + } } - + return; } + //Gun Bullet bullet = _bullets.remove(event.GetProjectile()); if (bullet == null) return; @@ -754,7 +809,9 @@ public class MineStrike extends TeamGame //Wipe previous data! event.GetCancellers().clear(); event.GetDamageMod().clear(); - event.GetDamageMult().clear(); + + if (!Manager.CanHurt(event.GetDamageePlayer(), event.GetDamagerPlayer(true))) + event.SetCancelled("Team Damage"); event.AddMod(GetName(), bullet.Gun.getName(), bullet.getDamage(event.GetDamageeEntity().getLocation()), true); @@ -1319,11 +1376,17 @@ public class MineStrike extends TeamGame { player.playSound(player.getLocation(), Sound.HORSE_ARMOR, 1f, 2f); Manager.GetCondition().Factory().Blind("Respawn", player, null, 2, 0, false, false, false); + UtilPlayer.message(player, F.main("Game", "You have " + F.elem(C.cGreen + "$" + _shopManager.getMoney(player)) + ".")); } //Give Bomb Player player = UtilAlg.Random(GetTeam(ChatColor.RED).GetPlayers(true)); giveBombToPlayer(player); + + //Update Scoreboard Teams + for (GameTeam team : GetTeamList()) + for (Player teamMember : team.GetPlayers(true)) + GetScoreboard().SetPlayerTeam(teamMember, team.GetName().toUpperCase()); } public void giveMoney() @@ -1514,35 +1577,13 @@ public class MineStrike extends TeamGame player.getWorld().playEffect(player.getLocation(), Effect.BLAZE_SHOOT, 0); } - /* @EventHandler - public void sneakUpdate(UpdateEvent event) + public void healthCancel(EntityRegainHealthEvent event) { - if (!IsLive()) - return; - - if (event.getType() != UpdateType.FAST) - return; - - for (Player player : GetPlayers(true)) - { - if (!player.isSneaking()) - player.setSneaking(true); - } + if (event.getRegainReason() == RegainReason.SATIATED) + event.setCancelled(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) { @@ -1559,7 +1600,7 @@ public class MineStrike extends TeamGame //Enable if (!event.getPlayer().isSneaking()) { - _scoped.add(event.getPlayer()); + _scoped.put(event.getPlayer(), event.getPlayer().getInventory().getHelmet()); Manager.GetCondition().Factory().Slow("Scope", event.getPlayer(), null, 9999, 3, false, false, false, false); event.getPlayer().getInventory().setHelmet(new ItemStack(Material.PUMPKIN)); @@ -1567,11 +1608,7 @@ public class MineStrike extends TeamGame } 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); + removeScope(event.getPlayer()); } } @@ -1586,20 +1623,25 @@ public class MineStrike extends TeamGame for (Player player : GetPlayers(true)) { - if (!_scoped.contains(player)) + if (!_scoped.containsKey(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); + removeScope(player); } } } + + public void removeScope(Player player) + { + ItemStack stack = _scoped.remove(player); + player.getInventory().setHelmet(stack); + Manager.GetCondition().EndCondition(player, null, "Scope"); + + player.getWorld().playSound(player.getEyeLocation(), Sound.GHAST_DEATH, 0.8f, 0.6f); + } @Override @EventHandler @@ -1620,8 +1662,8 @@ public class MineStrike extends TeamGame Scoreboard.WriteBlank(); - Scoreboard.Write(team.GetColor() + C.Bold + team.GetName()); - Scoreboard.Write(getScore(team) + "" + " Wins" + team.GetColor()); + Scoreboard.Write(getScore(team) + " " + team.GetColor() + C.Bold + team.GetName()); + //Scoreboard.Write(team.GetColor() + "" + getScore(team) + "" + " Wins" + team.GetColor()); Scoreboard.Write(team.GetPlayers(true).size() + "" + " Alive" + team.GetColor()); } 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 index e2f0b97fa..b8f71f442 100644 --- 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 @@ -5,6 +5,7 @@ import java.util.HashSet; import mineplex.core.common.util.C; import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTime; @@ -12,6 +13,7 @@ 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.StrikeItemType; 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; @@ -27,6 +29,7 @@ import org.bukkit.Color; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; +import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; import org.bukkit.event.inventory.InventoryClickEvent; @@ -91,11 +94,48 @@ public class ShopManager public void addItem(StrikeItem item, Player player, int slot) { - player.getInventory().setItem(slot, item.getShopItem(getMoney(player))); - + player.getInventory().setItem(slot, item.getShopItem(getMoney(player), hasItem(player, item))); + _shop.get(player).put(slot, item); } + public boolean hasItem(Player player, StrikeItem item) + { + + int count = 0; + for (int i=0 ; i<9 ; i++) + { + if (UtilGear.isMat(player.getInventory().getItem(i), item.getSkin())) + count++; + + if (UtilGear.isMat(player.getInventory().getHelmet(), item.getSkin())) + count++; + + if (UtilGear.isMat(player.getInventory().getChestplate(), item.getSkin())) + count++; + } + + if (count > 0) + { + if (item.getType() == StrikeItemType.PRIMARY_WEAPON || + item.getType() == StrikeItemType.SECONDARY_WEAPON || + item.getType() == StrikeItemType.ARMOR || + item.getType() == StrikeItemType.EQUIPMENT) + return true; + + if (item instanceof Grenade) + { + Grenade grenade = (Grenade)item; + + if (!grenade.canGiveToPlayer(player)) + return true; + } + } + + + return false; + } + public void clearShopInventory(Player player) { _shop.remove(player); @@ -143,6 +183,12 @@ public class ShopManager StrikeItem item = _shop.get(player).get(event.getSlot()); + if (item == null) + return; + + if (hasItem(player, item)) + return; + if (getMoney(player) < item.getCost()) { player.playSound(player.getLocation(), Sound.NOTE_BASS, 1f, 1f); 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 index 9fd09944a..646418cd0 100644 --- 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 @@ -4,7 +4,9 @@ import java.util.ArrayList; import mineplex.core.common.util.C; import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilGear; +import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilPlayer; import mineplex.core.itemstack.ItemStackFactory; import nautilus.game.arcade.game.games.minestrike.MineStrike; @@ -14,6 +16,7 @@ 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.enchantments.Enchantment; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -85,7 +88,7 @@ public abstract class StrikeItem else { ent = player.getWorld().dropItem(player.getEyeLocation(), _stack); - ent.setVelocity(player.getLocation().getDirection().multiply(0.6)); + UtilAction.velocity(ent, player.getLocation().getDirection(), 0.4, false, 0, 0.1, 1, false); } if (this instanceof Gun) @@ -141,7 +144,7 @@ public abstract class StrikeItem public abstract boolean pickup(MineStrike game, Player player); - public ItemStack getShopItem(int money) + public ItemStack getShopItem(int money, boolean alreadyHas) { ArrayList lore = new ArrayList(); @@ -155,24 +158,43 @@ public abstract class StrikeItem for (String cur : getShopItemCustom()) lore.add(C.cWhite + cur); } + + if (alreadyHas) + { + lore.add(" "); + lore.add(C.cYellow + C.Bold + "You already have this!"); + } + else + { + 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"); - - 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); + + String name = getShopItemType() + " " + C.cGreen + getName(); - return ItemStackFactory.Instance.CreateStack(_skin, (byte)0, 1, C.cGreen + getName(), loreArray); + ItemStack item = ItemStackFactory.Instance.CreateStack(_skin, (byte)0, 1, name, loreArray); + + if (alreadyHas) + UtilInv.addDullEnchantment(item); + + return item; } public String[] getShopItemCustom() { return new String[] {}; } + + public String getShopItemType() + { + return ""; + } } 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 index 5e23f5b4d..c23f851e1 100644 --- 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 @@ -1,9 +1,11 @@ package nautilus.game.arcade.game.games.minestrike.items.equipment; +import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.entity.Player; +import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import nautilus.game.arcade.game.games.minestrike.MineStrike; @@ -37,4 +39,10 @@ public class DefusalKit extends StrikeItem player.getWorld().playSound(player.getLocation(), Sound.HORSE_ARMOR, 1.5f, 1f); } + + @Override + public String getShopItemType() + { + return C.cDGreen + C.Bold + "Equipment" + ChatColor.RESET; + } } 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 index e7c7a80ac..0d5c71c09 100644 --- 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 @@ -1,5 +1,6 @@ package nautilus.game.arcade.game.games.minestrike.items.equipment; +import org.bukkit.ChatColor; import org.bukkit.Color; import org.bukkit.Material; import org.bukkit.Sound; @@ -7,6 +8,7 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.LeatherArmorMeta; +import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import nautilus.game.arcade.game.games.minestrike.MineStrike; @@ -19,7 +21,7 @@ public class Helmet extends StrikeItem { super(StrikeItemType.EQUIPMENT, "Helmet", new String[] { - + "Reduces damage from headshots" }, 350, 0, Material.LEATHER_HELMET); } @@ -43,4 +45,10 @@ public class Helmet extends StrikeItem player.getWorld().playSound(player.getLocation(), Sound.HORSE_ARMOR, 1f, 1f); } + + @Override + public String getShopItemType() + { + return C.cDGreen + C.Bold + "Armor" + ChatColor.RESET; + } } 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 index 9e126cb60..db465bfc8 100644 --- 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 @@ -1,5 +1,6 @@ package nautilus.game.arcade.game.games.minestrike.items.equipment; +import org.bukkit.ChatColor; import org.bukkit.Color; import org.bukkit.Material; import org.bukkit.Sound; @@ -7,6 +8,7 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.LeatherArmorMeta; +import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import nautilus.game.arcade.game.games.minestrike.MineStrike; @@ -19,7 +21,7 @@ public class Kevlar extends StrikeItem { super(StrikeItemType.EQUIPMENT, "Kevlar Vest", new String[] { - + "Reduces damage from bullets" }, 650, 0, Material.LEATHER_CHESTPLATE); } @@ -43,4 +45,10 @@ public class Kevlar extends StrikeItem player.getWorld().playSound(player.getLocation(), Sound.HORSE_ARMOR, 1f, 1f); } + + @Override + public String getShopItemType() + { + return C.cDGreen + C.Bold + "Armor" + ChatColor.RESET; + } } 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 index 6ad289664..b43c024ff 100644 --- 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 @@ -25,7 +25,7 @@ public class FlashBang extends Grenade { }, - 300, 0, Material.CARROT_ITEM, 2); + 200, 0, Material.CARROT_ITEM, 2); } @Override @@ -34,7 +34,7 @@ public class FlashBang extends Grenade 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); + UtilFirework.playFirework(ent.getLocation().add(0, 0.5, 0), effect); HashMap players = UtilPlayer.getInRadius(ent.getLocation(), 48); for (Player player : players.keySet()) 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 index 38987d2d3..0c2ef44de 100644 --- 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 @@ -2,6 +2,7 @@ package nautilus.game.arcade.game.games.minestrike.items.grenades; import java.util.ArrayList; +import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; @@ -9,6 +10,7 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.Player; 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.UtilEnt; @@ -53,7 +55,6 @@ public abstract class Grenade extends StrikeItem slot++; } - if (slot > 6) return false; @@ -62,7 +63,32 @@ public abstract class Grenade extends StrikeItem return true; } - public void throwGrenade(Player player, MineStrike game) + public boolean canGiveToPlayer(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; + + return true; + } + + public void throwGrenade(Player player, boolean wasLeftClick, MineStrike game) { player.setItemInHand(null); @@ -70,7 +96,10 @@ public abstract class Grenade extends StrikeItem 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); + if (wasLeftClick) + UtilAction.velocity(ent, player.getLocation().getDirection(), 0.4, false, 0, 0, 2, false); + else + UtilAction.velocity(ent, player.getLocation().getDirection(), 1.2, false, 0, 0.2, 2, false); //Rebound Data _vel = player.getLocation().getDirection(); @@ -135,6 +164,7 @@ public abstract class Grenade extends StrikeItem ent.getWorld().playSound(ent.getLocation(), Sound.ZOMBIE_WOOD, 1f, 2f); } + else { _velHistory.add(ent.getVelocity()); @@ -159,4 +189,10 @@ public abstract class Grenade extends StrikeItem return false; } + + @Override + public String getShopItemType() + { + return C.cDGreen + C.Bold + "Grenade" + ChatColor.RESET; + } } 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 index 88f02d009..873b724aa 100644 --- 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 @@ -358,4 +358,10 @@ public abstract class Gun extends StrikeItem player.setHealth(20); } + + @Override + public String getShopItemType() + { + return C.cDGreen + C.Bold + _gunType.getName() + ChatColor.RESET; + } } 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 2e6434404..dd1d002af 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 @@ -119,7 +119,7 @@ public class GameFlagManager implements Listener { if (!Manager.CanHurt((Player)damagee, (Player)damager)) { - event.SetCancelled("Damage Rules"); + event.SetCancelled("PvP Disabled"); return; } } From 449281501ff6093b9c48d11d9c10352a35593370 Mon Sep 17 00:00:00 2001 From: Chiss Date: Tue, 2 Sep 2014 16:49:15 +1000 Subject: [PATCH 8/9] MineStrike Update --- .../src/mineplex/core/common/Rank.java | 4 +- .../game/games/minestrike/MineStrike.java | 360 +++++++++++------- .../game/games/minestrike/ShopManager.java | 23 +- .../game/games/minestrike/data/Bullet.java | 12 +- .../minestrike/items/equipment/Kevlar.java | 54 --- .../{Helmet.java => armor/Armor.java} | 35 +- .../items/equipment/armor/Helmet.java | 16 + .../items/equipment/armor/Kevlar.java | 16 + .../minestrike/items/grenades/Incendiary.java | 48 +++ .../minestrike/items/grenades/Molotov.java | 6 + .../game/games/minestrike/items/guns/Gun.java | 22 +- .../games/minestrike/items/guns/GunType.java | 21 +- .../games/minestrike/items/guns/Shotgun.java | 2 +- .../minestrike/items/guns/pistol/CZ75.java | 2 +- .../minestrike/items/guns/pistol/Deagle.java | 2 +- .../minestrike/items/guns/pistol/Glock18.java | 2 +- .../minestrike/items/guns/pistol/P2000.java | 2 +- .../minestrike/items/guns/rifle/AK47.java | 2 +- .../minestrike/items/guns/rifle/AWP.java | 2 +- .../minestrike/items/guns/rifle/M4A1.java | 2 +- .../minestrike/items/guns/shotgun/Nova.java | 2 +- .../games/minestrike/items/guns/smg/P90.java | 2 +- 22 files changed, 408 insertions(+), 229 deletions(-) delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/equipment/Kevlar.java rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/equipment/{Helmet.java => armor/Armor.java} (65%) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/equipment/armor/Helmet.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/equipment/armor/Kevlar.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/grenades/Incendiary.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/grenades/Molotov.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java index c9e7b76e2..c448a5b5e 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java @@ -11,8 +11,8 @@ public enum Rank OWNER("Owner", ChatColor.DARK_RED), DEVELOPER("Dev", ChatColor.RED), ADMIN("Admin", ChatColor.RED), - SNR_MODERATOR("Sr.Mod", ChatColor.GRAY), - MODERATOR("Mod", ChatColor.GOLD), + SNR_MODERATOR("Sr.Mod", ChatColor.GOLD), + MODERATOR("Mod", ChatColor.DARK_GREEN), HELPER("Helper", ChatColor.GREEN), MAPDEV("Mapper", ChatColor.BLUE), YOUTUBE("YouTube", ChatColor.RED), 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 index 953d599da..1fe537b7c 100644 --- 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 @@ -1,10 +1,12 @@ package nautilus.game.arcade.game.games.minestrike; +import java.lang.reflect.Field; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Color; import org.bukkit.Effect; @@ -12,13 +14,15 @@ import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftArrow; import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; +import org.bukkit.entity.Arrow; import org.bukkit.entity.Entity; import org.bukkit.entity.Item; import org.bukkit.entity.LivingEntity; 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.EntityRegainHealthEvent; @@ -32,12 +36,13 @@ 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.PlayerTeleportEvent; import org.bukkit.event.player.PlayerToggleSneakEvent; +import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.LeatherArmorMeta; @@ -78,13 +83,16 @@ 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.equipment.armor.Armor; 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.game.games.turfforts.TurfForts.ShredBlockEvent; import nautilus.game.arcade.kit.Kit; +import net.minecraft.server.v1_7_R4.EntityArrow; public class MineStrike extends TeamGame { @@ -95,6 +103,7 @@ public class MineStrike extends TeamGame private int _roundsToWin = 10; private long _roundTime = 120000; + private boolean _bulletInstant = true; //Map Data private ArrayList _bombSites; @@ -104,16 +113,16 @@ public class MineStrike extends TeamGame 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 _bullets = new HashMap(); private HashMap _grenadesThrown = new HashMap(); - + private Bomb _bomb = null; private Item _bombItem = null; private Player _bombHolder = null; @@ -123,7 +132,7 @@ public class MineStrike extends TeamGame private Player _bombPlantedBy; private boolean _bombScoreboardFlash = false; - + private HashMap _scoped = new HashMap(); //Round Data @@ -148,11 +157,11 @@ public class MineStrike extends TeamGame 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", + 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); @@ -212,9 +221,12 @@ public class MineStrike extends TeamGame //Knife event.GetPlayer().getInventory().setItem(2, ItemStackFactory.Instance.CreateStack(Material.IRON_AXE, (byte)0, 1, "Knife")); - + //Sneak disguiseSneak(event.GetPlayer(), team); + + //Armor + giveTeamArmor(event.GetPlayer(), Color.fromRGB(255, 0, 0)); } else if (team.GetColor() == ChatColor.AQUA) { @@ -222,18 +234,21 @@ public class MineStrike extends TeamGame 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); + + //Armor + giveTeamArmor(event.GetPlayer(), Color.fromRGB(0, 0, 255)); } - + //Enter Shop _shopManager.enterShop(event.GetPlayer()); } - + public void disguiseSneak(Player player, GameTeam team) { //Create Disguise @@ -241,11 +256,11 @@ public class MineStrike extends TeamGame { _disguise.put(player, new DisguisePlayer(player, ((CraftPlayer)player).getProfile())); } - + DisguisePlayer disguise = _disguise.get(player); disguise.setSneaking(true); Manager.GetDisguise().disguise(_disguise.get(player)); - + for (Player other : UtilServer.getPlayers()) { if (team.HasPlayer(other)) @@ -266,13 +281,13 @@ public class MineStrike extends TeamGame 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); @@ -286,7 +301,7 @@ public class MineStrike extends TeamGame _shopManager.inventoryClick(event); } - + @EventHandler public void shopUpdate(UpdateEvent event) @@ -296,7 +311,7 @@ public class MineStrike extends TeamGame _shopManager.update(); } - + @EventHandler public void quitClean(PlayerQuitEvent event) { @@ -327,14 +342,14 @@ public class MineStrike extends TeamGame { 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")); @@ -344,7 +359,7 @@ public class MineStrike extends TeamGame 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!"); } @@ -352,7 +367,7 @@ public class MineStrike extends TeamGame { UtilPlayer.message(player, C.cGold + C.Bold + "You picked up the Bomb!"); } - + player.playSound(player.getLocation(), Sound.NOTE_PLING, 1f, 2f); _bombHolder = player; @@ -523,7 +538,7 @@ public class MineStrike extends TeamGame event.setCancelled(true); return; } - + if (!UtilEvent.isAction(event, ActionType.L) && !UtilEvent.isAction(event, ActionType.R)) return; @@ -705,21 +720,60 @@ public class MineStrike extends TeamGame } } - @EventHandler - public void projectileHitSound(ProjectileHitEvent event) + @EventHandler(priority = EventPriority.MONITOR) + public void projectileHitParticle(final ProjectileHitEvent event) { - if (event.getEntity() instanceof Snowball) + if (!(event.getEntity() instanceof Arrow)) + return; + + UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(Manager.GetPlugin(), new Runnable() { - event.getEntity().getWorld().playSound(event.getEntity().getLocation(), Sound.ENDERMAN_HIT, 1f, 1f); - } + public void run() + { + Arrow arrow = (Arrow)event.getEntity(); + + //Particle + UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, arrow.getLocation(), 0, 0, 0, 0, 1); + + //Sound + arrow.getWorld().playSound(event.getEntity().getLocation(), Sound.ENDERMAN_HIT, 1f, 1f); + + //Block Particle + try + { + EntityArrow entityArrow = ((CraftArrow) arrow).getHandle(); + + Field fieldX = EntityArrow.class.getDeclaredField("d"); + Field fieldY = EntityArrow.class.getDeclaredField("e"); + Field fieldZ = EntityArrow.class.getDeclaredField("f"); + + fieldX.setAccessible(true); + fieldY.setAccessible(true); + fieldZ.setAccessible(true); + + int x = fieldX.getInt(entityArrow); + int y = fieldY.getInt(entityArrow); + int z = fieldZ.getInt(entityArrow); + + Block block = arrow.getWorld().getBlockAt(x, y, z); + block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getType()); + } + catch (Exception e) + { + e.printStackTrace(); + } + + arrow.remove(); + } + }, 0); } - + @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()) @@ -743,7 +797,7 @@ public class MineStrike extends TeamGame event.AddMod(GetName(), "Fall Reduction", -2, false); return; } - + //Knife if (event.GetProjectile() == null) { @@ -751,7 +805,7 @@ public class MineStrike extends TeamGame { //Cancel Non-Knife Melee if (!UtilGear.isMat(event.GetDamagerPlayer(false).getItemInHand(), Material.IRON_AXE) && - !UtilGear.isMat(event.GetDamagerPlayer(false).getItemInHand(), Material.IRON_SWORD)) + !UtilGear.isMat(event.GetDamagerPlayer(false).getItemInHand(), Material.IRON_SWORD)) { event.SetCancelled("Non-Knife"); } @@ -760,7 +814,7 @@ public class MineStrike extends TeamGame { Player damager = event.GetDamagerPlayer(false); if (damager == null) return; - + LivingEntity damagee = event.GetDamageeEntity(); if (damagee == null) return; @@ -773,16 +827,16 @@ public class MineStrike extends TeamGame from.normalize(); Vector check = new Vector(look.getX() * -1, 0, look.getZ() * -1); - + //Backstab if (check.subtract(from).length() < 0.8) { //Damage event.AddMod(damager.getName(), "Knife", 25 - event.GetDamage(), false); - + //Effect - damagee.getWorld().playSound(damagee.getLocation(), Sound.HURT_FLESH, 1f, 2f); - + damagee.getWorld().playSound(damagee.getLocation(), Sound.IRONGOLEM_DEATH, 1f, 1f); + event.SetKnockback(false); } //Standard @@ -790,9 +844,9 @@ public class MineStrike extends TeamGame { //Damage event.AddMod(damager.getName(), "Knife", 6 - event.GetDamage(), false); - + event.GetDamageeEntity().getWorld().playSound(event.GetDamageeEntity().getLocation(), Sound.BAT_HURT, 1f, 1f); - + event.AddKnockback("Knife", 1.2); } } @@ -805,22 +859,35 @@ public class MineStrike extends TeamGame Bullet bullet = _bullets.remove(event.GetProjectile()); if (bullet == null) return; - + //Wipe previous data! event.GetCancellers().clear(); event.GetDamageMod().clear(); - + if (!Manager.CanHurt(event.GetDamageePlayer(), event.GetDamagerPlayer(true))) event.SetCancelled("Team Damage"); + + event.AddMod(GetName(), "Negate Arrow", -event.GetDamageInitial(), false); 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)); - + { + //Damage Reduction + if (Armor.isArmor(event.GetDamageePlayer().getInventory().getChestplate())) + { + event.AddMod(GetName(), "Kevlar", -0.25 * bullet.getDamage(event.GetDamageeEntity().getLocation()), false); + } + //Mini-Stun + else + { + event.GetDamageePlayer().setVelocity(new Vector(0,0,0)); + } + } + + event.SetKnockback(false); event.SetIgnoreRate(true); + event.SetIgnoreArmor(true); } @EventHandler @@ -868,21 +935,17 @@ public class MineStrike extends TeamGame return; //Bullets - Iterator bulletIterator = _bullets.keySet().iterator(); + Iterator bulletIterator = _bullets.keySet().iterator(); while (bulletIterator.hasNext()) { - Snowball bullet = bulletIterator.next(); + Entity 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 @@ -1054,10 +1117,10 @@ public class MineStrike extends TeamGame 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.")); @@ -1075,8 +1138,8 @@ public class MineStrike extends TeamGame UtilPlayer.message(player, F.main("Game", _bombDefuser.getName() + " is already defusing the Bomb.")); return; } - - + + _bombDefuser = player; _bombDefuser.setExp(0f); @@ -1156,8 +1219,8 @@ public class MineStrike extends TeamGame Manager.GetExplosion().BlockExplosion(blocks, _bomb.Block.getLocation(), false); */ - - + + HashMap players = UtilPlayer.getInRadius(_bomb.Block.getLocation(), 48); for (Player player : players.keySet()) { @@ -1254,7 +1317,7 @@ public class MineStrike extends TeamGame } } } - + setWinner(teamsAlive.get(0)); } else if (teamsAlive.size() == 0) @@ -1378,11 +1441,11 @@ public class MineStrike extends TeamGame Manager.GetCondition().Factory().Blind("Respawn", player, null, 2, 0, false, false, false); UtilPlayer.message(player, F.main("Game", "You have " + F.elem(C.cGreen + "$" + _shopManager.getMoney(player)) + ".")); } - + //Give Bomb Player player = UtilAlg.Random(GetTeam(ChatColor.RED).GetPlayers(true)); giveBombToPlayer(player); - + //Update Scoreboard Teams for (GameTeam team : GetTeamList()) for (Player teamMember : team.GetPlayers(true)) @@ -1443,10 +1506,10 @@ public class MineStrike extends TeamGame _bombHolder.getInventory().remove(Material.GOLD_SWORD); _bombHolder = null; } - + _bomb = null; _bombItem = null; - + _bombPlanter = null; _bombDefuser = null; _bombPlantedBy = null; @@ -1496,12 +1559,12 @@ public class MineStrike extends TeamGame 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()); @@ -1583,7 +1646,7 @@ public class MineStrike extends TeamGame if (event.getRegainReason() == RegainReason.SATIATED) event.setCancelled(true); } - + @EventHandler(priority = EventPriority.MONITOR) public void scopeUpdate(PlayerToggleSneakEvent event) { @@ -1593,17 +1656,17 @@ public class MineStrike extends TeamGame Gun gun = getGunInHand(event.getPlayer(), null); if (gun == null) return; - + if (!(gun instanceof AWP)) return; - + //Enable if (!event.getPlayer().isSneaking()) { _scoped.put(event.getPlayer(), event.getPlayer().getInventory().getHelmet()); 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 @@ -1611,7 +1674,7 @@ public class MineStrike extends TeamGame removeScope(event.getPlayer()); } } - + @EventHandler public void scopeUpdate(UpdateEvent event) { @@ -1625,7 +1688,7 @@ public class MineStrike extends TeamGame { if (!_scoped.containsKey(player)) continue; - + Gun gun = getGunInHand(player, null); if (gun == null || !(gun instanceof AWP) || !player.isSneaking()) { @@ -1633,14 +1696,14 @@ public class MineStrike extends TeamGame } } } - + public void removeScope(Player player) { ItemStack stack = _scoped.remove(player); player.getInventory().setHelmet(stack); Manager.GetCondition().EndCondition(player, null, "Scope"); - - player.getWorld().playSound(player.getEyeLocation(), Sound.GHAST_DEATH, 0.8f, 0.6f); + + player.getWorld().playSound(player.getEyeLocation(), Sound.GHAST_DEATH, 0.8f, 1f); } @Override @@ -1828,13 +1891,13 @@ public class MineStrike extends TeamGame 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(); @@ -1842,30 +1905,30 @@ public class MineStrike extends TeamGame 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()))); + " " + C.cGreen + C.Bold + "Distance: " + C.cWhite + UtilMath.trim(1, UtilMath.offset2d(target, player.getLocation()))); } else if (_bombHolder != null) { @@ -1877,64 +1940,21 @@ public class MineStrike extends TeamGame { itemMeta.setDisplayName( " " + C.cGreen + C.Bold + "Bomb Planted" + - " " + C.cGreen + C.Bold + "Distance: " + C.cWhite + UtilMath.trim(1, UtilMath.offset2d(target, player.getLocation()))); + " " + 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) { @@ -1951,4 +1971,80 @@ public class MineStrike extends TeamGame Scoreboard.SetPlayerTeam(player, "SPEC"); } + + @EventHandler + public void teleportCancel(PlayerTeleportEvent event) + { + if (!IsLive()) + return; + + if (event.getCause() == TeleportCause.ENDER_PEARL) + event.setCancelled(true); + } + + public boolean isInstantBullets() + { + return _bulletInstant; + } + + @EventHandler + public void debugBullets(PlayerCommandPreprocessEvent event) + { + if (!event.getPlayer().isOp()) + return; + + if (event.getMessage().contains("debugbullets")) + { + _bulletInstant = !_bulletInstant; + + Announce(C.cPurple + C.Bold + "Instant Bullets: " + ChatColor.RESET + _bulletInstant); + + event.setCancelled(true); + } + } + + //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); + } + } + + } 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 index b8f71f442..5b31f7427 100644 --- 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 @@ -15,8 +15,8 @@ import nautilus.game.arcade.game.GameTeam; 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.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.equipment.armor.Helmet; +import nautilus.game.arcade.game.games.minestrike.items.equipment.armor.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.*; @@ -119,7 +119,6 @@ public class ShopManager { if (item.getType() == StrikeItemType.PRIMARY_WEAPON || item.getType() == StrikeItemType.SECONDARY_WEAPON || - item.getType() == StrikeItemType.ARMOR || item.getType() == StrikeItemType.EQUIPMENT) return true; @@ -132,6 +131,24 @@ public class ShopManager } } + if (item instanceof Kevlar) + { + System.out.println("Checking Kevlar"); + + Kevlar armor = (Kevlar)item; + if (armor.isArmor(player.getInventory().getChestplate())) + { + System.out.println("Checking Kevlar TRUE"); + return true; + } + } + + if (item instanceof Helmet) + { + Helmet armor = (Helmet)item; + if (armor.isArmor(player.getInventory().getHelmet())) + return true; + } return false; } 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 index 4ccd6e81d..4ca7d688c 100644 --- 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 @@ -1,27 +1,31 @@ package nautilus.game.arcade.game.games.minestrike.data; +import nautilus.game.arcade.game.games.minestrike.MineStrike; import nautilus.game.arcade.game.games.minestrike.items.guns.Gun; import org.bukkit.Location; -import org.bukkit.entity.Snowball; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilTime; public class Bullet { - public Snowball Bullet; + public Player Shooter; + public Entity Bullet; public Gun Gun; public Location Origin; public long LastSound = System.currentTimeMillis() - 100; - public Bullet(Snowball bullet, Gun gun, Location loc) + public Bullet(Entity bullet, Gun gun, Player shooter, MineStrike game) { Bullet = bullet; Gun = gun; - Origin = loc; + Origin = shooter.getEyeLocation(); + Shooter = shooter; } public boolean isValid() 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 deleted file mode 100644 index db465bfc8..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/equipment/Kevlar.java +++ /dev/null @@ -1,54 +0,0 @@ -package nautilus.game.arcade.game.games.minestrike.items.equipment; - -import org.bukkit.ChatColor; -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.C; -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[] - { - "Reduces damage from bullets" - }, - 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); - } - - @Override - public String getShopItemType() - { - return C.cDGreen + C.Bold + "Armor" + ChatColor.RESET; - } -} 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/armor/Armor.java similarity index 65% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/equipment/Helmet.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/equipment/armor/Armor.java index 0d5c71c09..1d1b64ec3 100644 --- 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/armor/Armor.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.game.games.minestrike.items.equipment; +package nautilus.game.arcade.game.games.minestrike.items.equipment.armor; import org.bukkit.ChatColor; import org.bukkit.Color; @@ -15,15 +15,11 @@ 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 class Armor extends StrikeItem { - public Helmet() + public Armor(String name, String[] desc, int cost, int gemCost, Material skin) { - super(StrikeItemType.EQUIPMENT, "Helmet", new String[] - { - "Reduces damage from headshots" - }, - 350, 0, Material.LEATHER_HELMET); + super(StrikeItemType.ARMOR, name, desc, cost, gemCost, skin); } @Override @@ -39,13 +35,34 @@ public class Helmet extends StrikeItem meta.setColor(color); meta.setDisplayName(getName()); armor.setItemMeta(meta); - player.getInventory().setHelmet(armor); + + if (getSkin() == Material.LEATHER_CHESTPLATE) + player.getInventory().setChestplate(armor); + else + player.getInventory().setHelmet(armor); UtilPlayer.message(player, F.main("Game", "You equipped " + getName() + ".")); player.getWorld().playSound(player.getLocation(), Sound.HORSE_ARMOR, 1f, 1f); } + public static boolean isArmor(ItemStack stack) + { + if (stack == null) + return false; + + try + { + LeatherArmorMeta meta = (LeatherArmorMeta)stack.getItemMeta(); + return (meta.getColor().getBlue() == 100 || meta.getColor().getRed() == 100); + } + catch (Exception e) + { + e.printStackTrace(); + return false; + } + } + @Override public String getShopItemType() { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/equipment/armor/Helmet.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/equipment/armor/Helmet.java new file mode 100644 index 000000000..df3661f47 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/equipment/armor/Helmet.java @@ -0,0 +1,16 @@ +package nautilus.game.arcade.game.games.minestrike.items.equipment.armor; + +import org.bukkit.Material; + + +public class Helmet extends Armor +{ + public Helmet() + { + super("Helmet", new String[] + { + "Reduces damage from headshots" + }, + 350, 0, Material.LEATHER_HELMET); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/equipment/armor/Kevlar.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/equipment/armor/Kevlar.java new file mode 100644 index 000000000..3b0fe5ad6 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/equipment/armor/Kevlar.java @@ -0,0 +1,16 @@ +package nautilus.game.arcade.game.games.minestrike.items.equipment.armor; + +import org.bukkit.Material; + + +public class Kevlar extends Armor +{ + public Kevlar() + { + super("Kevlar", new String[] + { + "Reduces bullet damage by 25%" + }, + 350, 0, Material.LEATHER_CHESTPLATE); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/grenades/Incendiary.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/grenades/Incendiary.java new file mode 100644 index 000000000..06df38081 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/grenades/Incendiary.java @@ -0,0 +1,48 @@ +package nautilus.game.arcade.game.games.minestrike.items.grenades; + +import java.util.HashMap; + +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +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.block.Block; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +public class Incendiary extends Grenade +{ + public Incendiary() + { + super("HE Grenade", new String[] + { + + }, + 300, 0, Material.APPLE, 1); + } + + @Override + public boolean updateCustom(MineStrike game, Entity ent) + { + if (UtilEnt.isGrounded(ent)) + { + createFire(ent.getLocation().getBlock()); + + return true; + } + + return false; + } + + private void createFire(Block block) + { + // TODO Auto-generated method stub + + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/grenades/Molotov.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/grenades/Molotov.java new file mode 100644 index 000000000..44e51979b --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minestrike/items/grenades/Molotov.java @@ -0,0 +1,6 @@ +package nautilus.game.arcade.game.games.minestrike.items.grenades; + +public class Molotov +{ + +} 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 index 873b724aa..d9c98ae03 100644 --- 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 @@ -15,12 +15,13 @@ 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.Arrow; +import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.entity.Snowball; import org.bukkit.event.player.PlayerMoveEvent; @@ -143,16 +144,19 @@ public abstract class Gun extends StrikeItem //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)); + for (Player other : UtilServer.getPlayers()) + if (!player.equals(other)) + UtilParticle.PlayParticle(other, ParticleType.EXPLODE, player.getEyeLocation().add(player.getLocation().getDirection().multiply(1.5)), 0, 0, 0, 0, 1); + + game.registerBullet(fireBullet(player, game)); } - public Bullet fireBullet(Player player) + public Bullet fireBullet(Player player, MineStrike game) { //Shoot - Snowball ball = player.launchProjectile(Snowball.class); - + Entity bullet = player.launchProjectile(Arrow.class); + //COF double cone = getCone(player); @@ -164,12 +168,12 @@ public abstract class Gun extends StrikeItem cof.add(player.getLocation().getDirection()); cof.normalize(); - ball.setVelocity(cof.multiply(_bulletSpeed)); + bullet.setVelocity(cof.multiply(game.isInstantBullets() ? 200 : _bulletSpeed)); //Increase COF _cone = Math.min(_coneMax, _cone + _coneIncreaseRate); - return new Bullet(ball, this, player.getEyeLocation()); + return new Bullet(bullet, this, player, game); } public double getCone(Player player) @@ -272,7 +276,7 @@ public abstract class Gun extends StrikeItem public void soundFire(Location loc) { - loc.getWorld().playSound(loc, _fireSound, 3f, (float)(Math.random() * 0.2 + 0.9)); + loc.getWorld().playSound(loc, _fireSound, _gunType.getVolume(), (float)(Math.random() * 0.2 + 0.9)); } public void soundEmpty(Location loc) 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 index 60601700b..7770c023c 100644 --- 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 @@ -4,25 +4,29 @@ 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), + PISTOL("Pistol", 0.06, 0.04, 0.08, 3f), + SHOTGUN("Shotgun", 0, 0, 0, 3f), + SMG("SMG", 0.08, 0.05, 0.1, 3f), + RIFLE("Rifle", 0.1, 0.06, 0.12, 3.5f), - SNIPER("Sniper Rifle", 0.16, 0.08, 0.16); + SNIPER("Sniper Rifle", 0.16, 0.08, 0.16, 4f); private String _name; private double _movePenalty; private double _sprintPentalty; private double _jumpPenalty; + + private float _volume; - GunType(String name, double move, double sprint, double jump) + GunType(String name, double move, double sprint, double jump, float volume) { _name = name; _movePenalty = move; _sprintPentalty = sprint; _jumpPenalty = jump; + + _volume = volume; } public String getName() @@ -44,4 +48,9 @@ public enum GunType { return _jumpPenalty; } + + public float getVolume() + { + return _volume; + } } 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 index b583067b6..aee4ac52f 100644 --- 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 @@ -50,7 +50,7 @@ public abstract class Shotgun extends Gun 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)); + game.registerBullet(fireBullet(player, game)); } @Override 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 index 15cff6eb6..2df841fd5 100644 --- 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 @@ -19,7 +19,7 @@ public class CZ75 extends Gun 300, 0, //Cost, Gem Cost 12, 1, //Clip Size, Spare Ammo 80, 2700, //ROF, Reload Time - 6, 0.01, 3, //Damage, Dropoff, Bullet Speed + 6, 0.01, 3.5, //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 index e5c197694..776f094c4 100644 --- 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 @@ -19,7 +19,7 @@ public class Deagle extends Gun 800, 0, //Cost, Gem Cost 7, 5, //Clip Size, Spare Ammo 300, 2000, //ROF, Reload Time - 9, 0.01, 3, //Damage, Dropoff, Bullet Speed + 9, 0.01, 3.5, //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 index bd86135cd..b29eef007 100644 --- 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 @@ -19,7 +19,7 @@ public class Glock18 extends Gun 0, 0, //Cost, Gem Cost 20, 6, //Clip Size, Spare Ammo 120, 2000, //ROF, Reload Time - 5, 0.01, 3, //Damage, Dropoff, Bullet Speed + 5, 0.01, 3.5, //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 index fd1a1bd96..332867422 100644 --- 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 @@ -19,7 +19,7 @@ public class P2000 extends Gun 0, 0, //Cost, Gem Cost 13, 4, //Clip Size, Spare Ammo 130, 2200, //ROF, Reload Time - 6, 0.01, 3, //Damage, Dropoff, Bullet Speed + 6, 0.01, 3.5, //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 index cf351e5a2..7dabb85ed 100644 --- 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 @@ -19,7 +19,7 @@ public class AK47 extends Gun 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 + 7.5, 0.005, 4, //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 index 018103381..149f84a72 100644 --- 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 @@ -19,7 +19,7 @@ public class AWP extends Gun 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 + 30, 0.002, 4.3, //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 index ea4e5d34c..afa49b7e9 100644 --- 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 @@ -19,7 +19,7 @@ public class M4A1 extends Gun 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 + 7, 0.005, 4, //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 index 7c4bcf291..14a3c8b84 100644 --- 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 @@ -18,7 +18,7 @@ public class Nova extends Shotgun 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 + 5, 0.02, 3.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 index bd28edd52..df485665e 100644 --- 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 @@ -19,7 +19,7 @@ public class P90 extends Gun 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 + 5, 0.01, 3.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); From d5766d62ae5ac097e601dbe2d335b7f1dea0ec87 Mon Sep 17 00:00:00 2001 From: Chiss Date: Tue, 2 Sep 2014 16:49:45 +1000 Subject: [PATCH 9/9] nerf p90 --- .../game/arcade/game/games/minestrike/items/guns/smg/P90.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index df485665e..ac8441425 100644 --- 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 @@ -19,7 +19,7 @@ public class P90 extends Gun 2350, 5000, //Cost, Gem Cost 50, 2, //Clip Size, Spare Ammo 35, 2800, //ROF, Reload Time - 5, 0.01, 3.5, //Damage, Dropoff, Bullet Speed + 4, 0.02, 3.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);