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 eca5842fd..31310033c 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 @@ -33,7 +33,6 @@ import org.bukkit.craftbukkit.v1_7_R4.CraftWorld; public class UtilEnt { - private static int entityIdCount = 455000; //Custom Entity Names private static HashMap _nameMap = new HashMap(); @@ -574,6 +573,30 @@ public class UtilEnt public static int getNewEntityId() { - return entityIdCount++; + return getNewEntityId(true); } + + /** + * Use false if you don't want to modify the next entityid to be used. + * + * Normally you want true if you want a unique entityid to use. + **/ + public static int getNewEntityId(boolean modifynumber) + { + try + { + Field field = net.minecraft.server.v1_7_R4.Entity.class.getDeclaredField("entityCount"); + field.setAccessible(true); + int entityId = field.getInt(null); + if (modifynumber) { + field.set(null, entityId+1); + } + return entityId; + } + catch (Exception ex) + { + ex.printStackTrace(); + } + return -1; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/itemstack/ComplexItemLayout.java b/Plugins/Mineplex.Core/src/mineplex/core/itemstack/ComplexItemLayout.java deleted file mode 100644 index 7338d1e1f..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/itemstack/ComplexItemLayout.java +++ /dev/null @@ -1,113 +0,0 @@ -package mineplex.core.itemstack; - -import java.util.ArrayList; -import java.util.HashMap; - -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; - -public class ComplexItemLayout -{ - - private int _invSize = 0; - private HashMap> placing = new HashMap>(); - - public ComplexItemLayout(String... strings) - { - _invSize = strings.length * 9; - for (int row = 0; row < strings.length; row++) - { - final String string = strings[row]; - char[] cArray = string.toCharArray(); - int entries = 0; - for (int i = 0; i < cArray.length; i++) - { - entries++; - if (cArray[i] == '(') - { - for (; i < cArray.length; i++) - { - if (cArray[i] == ')') - { - break; - } - else - { - if (!placing.containsKey(cArray[i])) - { - placing.put(cArray[i], new ArrayList()); - } - placing.get(cArray[i]).add((row * 9) + i); - } - if (i + 1 >= cArray.length) - { - throw new IllegalArgumentException("String '" + string + "' does not have a enclosing ) after the ("); - - } - } - } - else - { - if (!placing.containsKey(cArray[i])) - { - placing.put(cArray[i], new ArrayList()); - } - placing.get(cArray[i]).add((row * 9) + i); - } - } - if (entries != 9) - throw new IllegalArgumentException("String '" + string + "' does not 9 entries but instead has " + entries - + " entries"); - } - } - - public ItemStack[] generate(char toReplace, ArrayList items, boolean replaceExistingItems) - { - return generate(toReplace, items.toArray(new ItemStack[0]), replaceExistingItems); - } - - public ItemStack[] generate(ItemStack[] existingItems, char toReplace, ItemStack[] items, boolean replaceExistingItems) - { - ArrayList list = placing.get(toReplace); - for (int i = 0; i < list.size(); i++) - { - if (i < items.length && i < existingItems.length) - { - ItemStack item = existingItems[list.get(i)]; - if (replaceExistingItems || item == null || item.getType() == Material.AIR) - { - existingItems[list.get(i)] = items[i]; - } - } - } - return existingItems; - } - - public ItemStack[] generate(char toReplace, ItemStack[] items, boolean replaceExistingItems) - { - return generate(new ItemStack[this._invSize], toReplace, items, replaceExistingItems); - } - - public ItemStack[] generate(ItemStack[] existingItems, char toReplace, ItemStack item, boolean replaceExistingItems) - { - ArrayList list = placing.get(toReplace); - for (int i = 0; i < list.size(); i++) - { - if (i < existingItems.length) - { - ItemStack checkItem = existingItems[list.get(i)]; - if (replaceExistingItems || checkItem == null || checkItem.getType() == Material.AIR) - { - existingItems[list.get(i)] = item; - } - } - } - return existingItems; - } - - public ItemStack[] generate(char toReplace, ItemStack item, boolean replaceExistingItems) - { - return generate(new ItemStack[this._invSize], toReplace, item, replaceExistingItems); - } - -} diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/Longshot.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/Longshot.java index 43e143944..aed909b2c 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/Longshot.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/Longshot.java @@ -1,10 +1,6 @@ package mineplex.minecraft.game.classcombat.Skill.Ranger; -import java.util.HashMap; -import java.util.Iterator; - import org.bukkit.*; -import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.entity.Projectile; import org.bukkit.event.*; @@ -13,92 +9,75 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.core.updater.UpdateType; import mineplex.core.common.util.UtilMath; import mineplex.minecraft.game.classcombat.Skill.Skill; import mineplex.minecraft.game.classcombat.Skill.SkillFactory; -import org.bukkit.event.player.*; + +import org.bukkit.metadata.FixedMetadataValue; public class Longshot extends Skill { - private HashMap _arrows = new HashMap(); - public Longshot(SkillFactory skills, String name, ClassType classType, SkillType skillType, int cost, int levels) - { - super(skills, name, classType, skillType, cost, levels); + public Longshot(SkillFactory skills, String name, ClassType classType, SkillType skillType, int cost, int levels) + { + super(skills, name, classType, skillType, cost, levels); - SetDesc(new String[] - { - "Arrows do an additional 1 damage", - "for every #4#-0.5 Blocks they travelled,", - "however, their base damage is", - "reduced by 3.", - "", - "Maximum of #5#5 additional damage." - }); - } + SetDesc(new String[] + { + "Arrows do an additional 1 damage", "for every #4#-0.5 Blocks they travelled,", + "however, their base damage is", "reduced by 3.", "", "Maximum of #5#5 additional damage." + }); + } - @EventHandler - public void ShootBow(EntityShootBowEvent event) - { - if (!(event.getEntity() instanceof Player)) - return; - - int level = getLevel((Player)event.getEntity()); - if (level == 0) return; - - //Save - _arrows.put(event.getProjectile(), event.getProjectile().getLocation()); - } + @EventHandler + public void ShootBow(EntityShootBowEvent event) + { + if (!(event.getEntity() instanceof Player)) + return; - @EventHandler(priority = EventPriority.HIGH) - public void Damage(CustomDamageEvent event) - { - if (event.IsCancelled()) - return; - - if (event.GetCause() != DamageCause.PROJECTILE) - return; + int level = getLevel((Player) event.getEntity()); + if (level == 0) + return; - Projectile projectile = event.GetProjectile(); - if (projectile == null) return; + // Save + event.getProjectile().setMetadata("ShotFrom", + new FixedMetadataValue(this.Factory.GetPlugin(), event.getProjectile().getLocation())); + } - if (!_arrows.containsKey(projectile)) - return; - - Player damager = event.GetDamagerPlayer(true); - if (damager == null) return; - - int level = getLevel(damager); - - Location loc = _arrows.remove(projectile); - double length = UtilMath.offset(loc, projectile.getLocation()); - - //Damage - double damage = Math.min(5 + 5 * level, (length / (4 - 0.5 * level)) - 3); - - event.AddMod(damager.getName(), GetName(), damage, damage > 0); - } - - @EventHandler - public void Clean(UpdateEvent event) - { - if (event.getType() != UpdateType.SEC) - return; - - for (Iterator arrowIterator = _arrows.keySet().iterator(); arrowIterator.hasNext();) - { - Entity arrow = arrowIterator.next(); - - if (arrow.isDead() || !arrow.isValid()) - arrowIterator.remove(); - } - } - - @Override - public void Reset(Player player) - { - - } + @EventHandler(priority = EventPriority.HIGH) + public void Damage(CustomDamageEvent event) + { + if (event.IsCancelled()) + return; + + if (event.GetCause() != DamageCause.PROJECTILE) + return; + + Projectile projectile = event.GetProjectile(); + if (projectile == null) + return; + + if (!projectile.hasMetadata("ShotFrom")) + return; + + Player damager = event.GetDamagerPlayer(true); + if (damager == null) + return; + + int level = getLevel(damager); + + Location loc = (Location) projectile.getMetadata("ShotFrom").get(0).value(); + double length = UtilMath.offset(loc, projectile.getLocation()); + + // Damage + double damage = Math.min(5 + 5 * level, (length / (4 - 0.5 * level)) - 3); + + event.AddMod(damager.getName(), GetName(), damage, damage > 0); + } + + @Override + public void Reset(Player player) + { + + } } diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/page/SkillPage.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/page/SkillPage.java index 38a184ef9..091b24437 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/page/SkillPage.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/page/SkillPage.java @@ -311,7 +311,8 @@ public class SkillPage extends ShopPageBase itemLore.add(""); itemLore.add(C.cYellow + "Item Token Cost: " + C.cWhite + item.getTokenCost()); - itemLore.add(C.cYellow + "Item Tokens Remaining: " + C.cWhite + clientClass.GetSavingCustomBuild().ItemTokens + "/" + CustomBuildToken.MAX_ITEM_TOKENS); + itemLore.add(C.cYellow + "Item Tokens Remaining: " + C.cWhite + clientClass.GetSavingCustomBuild().ItemTokens + "/" + + (CustomBuildToken.MAX_ITEM_TOKENS - (_pvpClass.GetType() == ClassType.Assassin || _pvpClass.GetType() == ClassType.Ranger ? 0 : 2))); itemLore.add(""); if (clientClass.GetSavingCustomBuild().ItemTokens >= item.getTokenCost()) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/HideSeek.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/HideSeek.java index ebf0bf3a5..c776df703 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/HideSeek.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/HideSeek.java @@ -50,7 +50,6 @@ import org.bukkit.event.vehicle.VehicleExitEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.FireworkMeta; -import mineplex.core.antihack.AntiHack; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilBlock; @@ -67,11 +66,12 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.packethandler.IPacketHandler; +import mineplex.core.packethandler.PacketInfo; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.combat.DeathMessageType; -import mineplex.minecraft.game.core.condition.Condition.ConditionType; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; @@ -91,1397 +91,1445 @@ import nautilus.game.arcade.stats.BadHiderStatTracker; import nautilus.game.arcade.stats.HunterKillerStatTracker; import nautilus.game.arcade.stats.HunterOfTheYearStatTracker; import nautilus.game.arcade.stats.MeowStatTracker; - import net.minecraft.server.v1_7_R4.EntityCreature; import net.minecraft.server.v1_7_R4.Navigation; +import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntity; @SuppressWarnings("deprecation") public class HideSeek extends TeamGame { - public static class MeowEvent extends PlayerEvent - { - private static final HandlerList handlers = new HandlerList(); - - public static HandlerList getHandlerList() - { - return handlers; - } - - @Override - public HandlerList getHandlers() - { - return getHandlerList(); - } - - public MeowEvent(Player who) - { - super(who); - } - } - - public static class PlayerChangeFormEvent extends PlayerEvent - { - private static final HandlerList handlers = new HandlerList(); - - public static HandlerList getHandlerList() - { - return handlers; - } - - @Override - public HandlerList getHandlers() - { - return getHandlerList(); - } - - private final Form _form; - - public PlayerChangeFormEvent(Player who, Form form) - { - super(who); - - _form = form; - } - - public Form getForm() - { - return _form; - } - } - - public static class PlayerSolidifyEvent extends PlayerEvent - { - private static final HandlerList handlers = new HandlerList(); - - public static HandlerList getHandlerList() - { - return handlers; - } - - @Override - public HandlerList getHandlers() - { - return getHandlerList(); - } - - public PlayerSolidifyEvent(Player who) - { - super(who); - } - } - - private GameTeam _hiders; - private GameTeam _seekers; - - private long _hideTime = 20000; - private long _gameTime = 360000; - - private boolean _started = false; - - private HashMap _arrowHits = new HashMap(); - - private HashMap _forms = new HashMap(); - private HashMap _infested = new HashMap(); - private HashSet _infestDeny = new HashSet(); - - private HashMap _mobs = new HashMap(); - - private ArrayList _allowedBlocks; - private ArrayList _allowedEnts; - - public HideSeek(ArcadeManager manager) - { - super(manager, GameType.HideSeek, - - new Kit[] - { - new KitHiderSwapper(manager), - new KitHiderQuick(manager), - new KitHiderShocker(manager), - new KitHiderTeleporter(manager), - new NullKit(manager), - new KitSeekerLeaper(manager), - new KitSeekerTNT(manager), - new KitSeekerRadar(manager), - }, - - new String[] - { - C.cAqua + "Hiders" + C.cWhite + " Run and Hide from Seekers", - C.cAqua + "Hiders" + C.cWhite + " Disguise as Blocks or Animals", - C.cAqua + "Hiders" + C.cWhite + " Shoot Seekers for Axe Upgrades", - C.cAqua + "Hiders" + C.cWhite + " Right-Click with Axe for Speed Boost", - C.cRed + "Seekers" + C.cWhite + " Find and kill the Hiders!", - }); - - this.DamageSelf = false; - this.DeathOut = false; - this.HungerSet = 20; - this.PrepareFreeze = false; - - _allowedBlocks = new ArrayList(); - _allowedBlocks.add(Material.TNT); - _allowedBlocks.add(Material.BOOKSHELF); - _allowedBlocks.add(Material.WORKBENCH); - _allowedBlocks.add(Material.FURNACE); - _allowedBlocks.add(Material.MELON_BLOCK); - _allowedBlocks.add(Material.CAULDRON); - _allowedBlocks.add(Material.FLOWER_POT); - _allowedBlocks.add(Material.ANVIL); - _allowedBlocks.add(Material.HAY_BLOCK); - _allowedBlocks.add(Material.CAKE_BLOCK); - - _allowedEnts = new ArrayList(); - _allowedEnts.add(EntityType.PIG); - _allowedEnts.add(EntityType.COW); - _allowedEnts.add(EntityType.CHICKEN); - _allowedEnts.add(EntityType.SHEEP); - - Manager.GetExplosion().SetRegenerate(true); - Manager.GetExplosion().SetTNTSpread(false); - Manager.getCosmeticManager().setHideParticles(true); - - registerStatTrackers( - new HunterKillerStatTracker(this), - new MeowStatTracker(this), - new HunterKillerStatTracker(this), - new HunterOfTheYearStatTracker(this), - new BadHiderStatTracker(this) - ); - } - - public Material GetItemEquivilent(Material mat) - { - if (mat == Material.CAULDRON) return Material.CAULDRON_ITEM; - if (mat == Material.FLOWER_POT) return Material.FLOWER_POT_ITEM; - if (mat == Material.CAKE_BLOCK) return Material.CAKE; - - return mat; - } - - @Override - public void ParseData() - { - int i = 0; - - for (ArrayList locs : WorldData.GetAllCustomLocs().values()) - { - for (Location loc : locs) - { - if (Math.random() > 0.25) - continue; - - if (loc.getBlock().getRelative(BlockFace.UP).getType() != Material.AIR) - continue; - - loc.getBlock().setType(Material.AIR); - i++; - } - } - - System.out.println("Removed " + i + " Random Blocks."); - - for (Location loc : WorldData.GetDataLocs("BLACK")) - loc.getBlock().setType(Material.FENCE); - - } - - @EventHandler - public void CustomTeamGeneration(GameStateChangeEvent event) - { - if (event.GetState() != GameState.Recruit) - return; - - _hiders = GetTeamList().get(0); - _hiders.SetColor(ChatColor.AQUA); - _hiders.SetName("Hiders"); - - _seekers = GetTeamList().get(1); - _seekers.SetColor(ChatColor.RED); - _seekers.SetName("Hunters"); - - RestrictKits(); - } - - @Override - public void RestrictKits() - { - for (Kit kit : GetKits()) - { - for (GameTeam team : GetTeamList()) - { - if (team.GetColor() == ChatColor.RED) - { - if (kit.GetName().contains("Hider")) - team.GetRestrictedKits().add(kit); - } - else - { - if (kit.GetName().contains("Hunter")) - team.GetRestrictedKits().add(kit); - } - } - } - } - - @EventHandler - public void MoveKits(GameStateChangeEvent event) - { - if (event.GetState() != GameState.Prepare) - return; - - for (int i=0 ; i _arrowHits = new HashMap(); + + private HashMap _forms = new HashMap(); + private HashMap _infested = new HashMap(); + private HashSet _infestDeny = new HashSet(); + + private HashMap _mobs = new HashMap(); + + private ArrayList _allowedBlocks; + private ArrayList _allowedEnts; + private IPacketHandler _preventSpawnSent = new IPacketHandler() + { + + @Override + public void handle(PacketInfo packetInfo) + { + if (packetInfo.getPacket() instanceof PacketPlayOutSpawnEntity) + { + Form form = _forms.get(packetInfo.getPlayer()); + if (form != null && form instanceof BlockForm + && ((BlockForm) form).getEntityId() == ((PacketPlayOutSpawnEntity) packetInfo.getPacket()).a) + { + packetInfo.setCancelled(true); + } + } + } + + }; + + public HideSeek(ArcadeManager manager) + { + super(manager, GameType.HideSeek, + + new Kit[] + { + new KitHiderSwapper(manager), new KitHiderQuick(manager), new KitHiderShocker(manager), + new KitHiderTeleporter(manager), new NullKit(manager), new KitSeekerLeaper(manager), + new KitSeekerTNT(manager), new KitSeekerRadar(manager), + }, + + new String[] + { + C.cAqua + "Hiders" + C.cWhite + " Run and Hide from Seekers", + C.cAqua + "Hiders" + C.cWhite + " Disguise as Blocks or Animals", + C.cAqua + "Hiders" + C.cWhite + " Shoot Seekers for Axe Upgrades", + C.cAqua + "Hiders" + C.cWhite + " Right-Click with Axe for Speed Boost", + C.cRed + "Seekers" + C.cWhite + " Find and kill the Hiders!", + }); + + this.DamageSelf = false; + this.DeathOut = false; + this.HungerSet = 20; + this.PrepareFreeze = false; + + _allowedBlocks = new ArrayList(); + _allowedBlocks.add(Material.TNT); + _allowedBlocks.add(Material.BOOKSHELF); + _allowedBlocks.add(Material.WORKBENCH); + _allowedBlocks.add(Material.FURNACE); + _allowedBlocks.add(Material.MELON_BLOCK); + _allowedBlocks.add(Material.CAULDRON); + _allowedBlocks.add(Material.FLOWER_POT); + _allowedBlocks.add(Material.ANVIL); + _allowedBlocks.add(Material.HAY_BLOCK); + _allowedBlocks.add(Material.CAKE_BLOCK); + + _allowedEnts = new ArrayList(); + _allowedEnts.add(EntityType.PIG); + _allowedEnts.add(EntityType.COW); + _allowedEnts.add(EntityType.CHICKEN); + _allowedEnts.add(EntityType.SHEEP); + + Manager.GetExplosion().SetRegenerate(true); + Manager.GetExplosion().SetTNTSpread(false); + Manager.getCosmeticManager().setHideParticles(true); + + registerStatTrackers(new HunterKillerStatTracker(this), new MeowStatTracker(this), new HunterKillerStatTracker(this), + new HunterOfTheYearStatTracker(this), new BadHiderStatTracker(this)); + } + + @EventHandler + public void onGameEndStart(GameStateChangeEvent event) + { + if (event.GetState() == GameState.Prepare) + { + this.getArcadeManager().getPacketHandler().addPacketHandler(_preventSpawnSent); + } + else if (event.GetState() == GameState.End) + { + this.getArcadeManager().getPacketHandler().removePacketHandler(_preventSpawnSent); + } + } + + public Material GetItemEquivilent(Material mat) + { + if (mat == Material.CAULDRON) + return Material.CAULDRON_ITEM; + if (mat == Material.FLOWER_POT) + return Material.FLOWER_POT_ITEM; + if (mat == Material.CAKE_BLOCK) + return Material.CAKE; + + return mat; + } + + @Override + public void ParseData() + { + int i = 0; + + for (ArrayList locs : WorldData.GetAllCustomLocs().values()) + { + for (Location loc : locs) + { + if (Math.random() > 0.25) + continue; + + if (loc.getBlock().getRelative(BlockFace.UP).getType() != Material.AIR) + continue; + + loc.getBlock().setType(Material.AIR); + i++; + } + } + + System.out.println("Removed " + i + " Random Blocks."); + + for (Location loc : WorldData.GetDataLocs("BLACK")) + loc.getBlock().setType(Material.FENCE); + + } + + @EventHandler + public void CustomTeamGeneration(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Recruit) + return; + + _hiders = GetTeamList().get(0); + _hiders.SetColor(ChatColor.AQUA); + _hiders.SetName("Hiders"); + + _seekers = GetTeamList().get(1); + _seekers.SetColor(ChatColor.RED); + _seekers.SetName("Hunters"); + + RestrictKits(); + } + + @Override + public void RestrictKits() + { + for (Kit kit : GetKits()) + { + for (GameTeam team : GetTeamList()) + { + if (team.GetColor() == ChatColor.RED) + { + if (kit.GetName().contains("Hider")) + team.GetRestrictedKits().add(kit); + } + else + { + if (kit.GetName().contains("Hunter")) + team.GetRestrictedKits().add(kit); + } + } + } + } + + @EventHandler + public void MoveKits(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Prepare) + return; + + for (int i = 0; i < WorldData.GetDataLocs("RED").size() && i < 3; i++) + { + if (GetKits().length <= 5 + i) + continue; + + this.CreatureAllowOverride = true; + Entity ent = GetKits()[5 + i].SpawnEntity(WorldData.GetDataLocs("RED").get(i)); + this.CreatureAllowOverride = false; + + Manager.GetLobby().AddKitLocation(ent, GetKits()[5 + i], WorldData.GetDataLocs("RED").get(i)); + } + } + + public void GiveItems() + { + for (Player player : _hiders.GetPlayers(true)) + { + // Axe + player.getInventory().setItem(0, + ItemStackFactory.Instance.CreateStack(Material.WOOD_AXE, (byte) 0, 1, C.cGreen + "Speed Axe")); + + // Bow + ItemStack bow = ItemStackFactory.Instance.CreateStack(Material.BOW, (byte) 0, 1, C.cYellow + C.Bold + "Shoot Hunters" + + C.cWhite + C.Bold + " - " + C.cGreen + C.Bold + "Upgrades Axe"); + bow.addEnchantment(Enchantment.ARROW_INFINITE, 1); + player.getInventory().setItem(1, bow); + player.getInventory().setItem(28, ItemStackFactory.Instance.CreateStack(Material.ARROW)); + + // Meower + player.getInventory().setItem( + 4, + ItemStackFactory.Instance.CreateStack(Material.SUGAR, (byte) 0, 1, C.cYellow + C.Bold + "Meow" + C.cWhite + + C.Bold + " - " + C.cGreen + C.Bold + "+0.25 Gems")); + + // Firework + ItemStack firework = ItemStackFactory.Instance.CreateStack(Material.FIREWORK, (byte) 0, 5, C.cYellow + C.Bold + + "Firework" + C.cWhite + C.Bold + " - " + C.cGreen + C.Bold + "+2 Gems"); + FireworkMeta metaData = (FireworkMeta) firework.getItemMeta(); + metaData.setPower(1); + metaData.addEffect(FireworkEffect.builder().flicker(true).withColor(Color.AQUA).with(Type.BALL_LARGE).trail(true) + .build()); + firework.setItemMeta(metaData); + player.getInventory().setItem(5, firework); + + // Recharges + Recharge.Instance.useForce(player, "Meow", 15000); + Recharge.Instance.useForce(player, "Firework", 15000); + } + } + + @EventHandler + public void InitialDisguise(PlayerPrepareTeleportEvent event) + { + if (_hiders.HasPlayer(event.GetPlayer().getName(), true)) + { + if (GetKit(event.GetPlayer()) instanceof KitHider) + { + Form form = new BlockForm(this, event.GetPlayer(), _allowedBlocks.get(UtilMath.r(_allowedBlocks.size()))); + + _forms.put(event.GetPlayer(), form); + + form.Apply(); + + Bukkit.getPluginManager().callEvent(new PlayerChangeFormEvent(event.GetPlayer(), form)); + } + } + } + + @EventHandler + public void ChangeDisguise(PlayerInteractEvent event) + { + if (event.getClickedBlock() == null) + return; + + Player player = event.getPlayer(); + + if (!UtilGear.isMat(player.getItemInHand(), Material.SLIME_BALL)) + return; + + if (!_allowedBlocks.contains(event.getClickedBlock().getType())) + { + UtilPlayer.message( + player, + F.main("Game", + "You cannot morph into " + + F.elem(ItemStackFactory.Instance + .GetName(event.getClickedBlock().getType(), (byte) 0, false) + " Block") + ".")); + return; + } + + if (!Recharge.Instance.use(player, "Change Form", 6000, true, false)) + return; + + if (!(GetKit(player) instanceof KitHiderSwapper)) + UtilInv.remove(player, Material.SLIME_BALL, (byte) 0, 1); + + // Remove Old + _forms.get(player).Remove(); + + Form form = new BlockForm(this, player, event.getClickedBlock().getType()); + + // Set New + _forms.put(player, form); + + form.Apply(); + + Bukkit.getPluginManager().callEvent(new PlayerChangeFormEvent(player, form)); + } + + @EventHandler + public void ChangeDisguise(PlayerInteractEntityEvent event) + { + if (event.getRightClicked() == null) + return; + + Player player = event.getPlayer(); + + if (!UtilGear.isMat(player.getItemInHand(), Material.SLIME_BALL)) + return; + + if (!_allowedEnts.contains(event.getRightClicked().getType())) + { + UtilPlayer.message(player, + F.main("Game", "You cannot morph into " + F.elem(UtilEnt.getName(event.getRightClicked())) + ".")); + return; + } + + if (!Recharge.Instance.use(player, "Change Form", 6000, true, false)) + return; + + if (!(GetKit(player) instanceof KitHiderSwapper)) + UtilInv.remove(player, Material.SLIME_BALL, (byte) 0, 1); + + // Remove Old + _forms.get(player).Remove(); + + Form form = new CreatureForm(this, player, event.getRightClicked().getType()); + + // Set New + _forms.put(player, form); + + Bukkit.getPluginManager().callEvent(new PlayerChangeFormEvent(player, form)); + } + + @EventHandler + public void ChangeDisguise(CustomDamageEvent event) + { + Player player = event.GetDamagerPlayer(false); + if (player == null) + return; + + if (!UtilGear.isMat(player.getItemInHand(), Material.SLIME_BALL)) + return; - Form form = new CreatureForm(this, player, event.GetDamageeEntity().getType()); + if (!_allowedEnts.contains(event.GetDamageeEntity().getType())) + { + UtilPlayer.message(player, + F.main("Game", "You cannot morph into " + F.elem(UtilEnt.getName(event.GetDamageeEntity())) + ".")); + return; + } - //Set New - _forms.put(player, form); + if (!Recharge.Instance.use(player, "Change Form", 6000, true, false)) + return; + + if (!(GetKit(player) instanceof KitHiderSwapper)) + UtilInv.remove(player, Material.SLIME_BALL, (byte) 0, 1); - Bukkit.getPluginManager().callEvent(new PlayerChangeFormEvent(player, form)); - } + // Remove Old + _forms.get(player).Remove(); - @EventHandler - public void FallingBlockBreak(ItemSpawnEvent event) - { - if (event.getEntity().getItemStack().getType() == Material.getMaterial(175)) - return; + Form form = new CreatureForm(this, player, event.GetDamageeEntity().getType()); - event.setCancelled(true); + // Set New + _forms.put(player, form); - for (Form form : _forms.values()) - if (form instanceof BlockForm) - ((BlockForm)form).FallingBlockCheck(); - } + Bukkit.getPluginManager().callEvent(new PlayerChangeFormEvent(player, form)); + } - @EventHandler - public void FallingBlockLand(EntityChangeBlockEvent event) - { - if (event.getEntity() instanceof FallingBlock) - { - event.setCancelled(true); - event.getEntity().remove(); + @EventHandler + public void FallingBlockBreak(ItemSpawnEvent event) + { + if (event.getEntity().getItemStack().getType() == Material.getMaterial(175)) + return; - for (Form form : _forms.values()) - if (form instanceof BlockForm) - ((BlockForm)form).FallingBlockCheck(); - } - } - - @EventHandler - public void FallingBlockUpdate(UpdateEvent event) - { - if (event.getType() != UpdateType.TICK) - return; - - if (!InProgress()) - return; - - for (Form form : _forms.values()) - if (form instanceof BlockForm) - ((BlockForm)form).FallingBlockCheck(); - } + event.setCancelled(true); - @EventHandler - public void SolidifyUpdate(UpdateEvent event) - { - if (!IsLive()) - return; - - if (event.getType() != UpdateType.TICK) - return; + for (Form form : _forms.values()) + if (form instanceof BlockForm) + ((BlockForm) form).FallingBlockCheck(); + } - for (Form form : _forms.values()) - if (form instanceof BlockForm) - ((BlockForm)form).SolidifyUpdate(); - } - - @EventHandler - public void SolidBlockDamage(BlockDamageEvent event) - { - if (!_seekers.HasPlayer(event.getPlayer())) - return; - - for (Form form : _forms.values()) - { - if (!(form instanceof BlockForm)) - continue; - - if (((BlockForm)form).GetBlock() == null) - continue; - - if (!((BlockForm)form).GetBlock().equals(event.getBlock())) - continue; - - //Damage Event - Manager.GetDamage().NewDamageEvent(form.Player, event.getPlayer(), null, - DamageCause.CUSTOM, 4, true, true, false, - event.getPlayer().getName(), null); - - ((BlockForm)form).SolidifyRemove(); - } - } - - @EventHandler - public void FallingBlockDamage(EntityDamageEvent event) - { - if (!(event instanceof EntityDamageByEntityEvent)) - return; - - if (!(event.getEntity() instanceof FallingSand)) - return; - - if (event.getEntity().getVehicle() == null) - return; - - if (!(event.getEntity().getVehicle() instanceof LivingEntity)) - return; - - LivingEntity damagee = (LivingEntity)event.getEntity().getVehicle(); - - EntityDamageByEntityEvent eventEE = (EntityDamageByEntityEvent)event; - - LivingEntity damager = null; - Projectile proj = null; - - if (eventEE.getDamager() instanceof Projectile) - { - proj = (Projectile)eventEE.getDamager(); - damager = (LivingEntity)proj.getShooter(); - } - else if (eventEE.getDamager() instanceof LivingEntity) - { - damager = (LivingEntity)eventEE.getDamager(); - } - - //Damage Event - Manager.GetDamage().NewDamageEvent(damagee, damager, proj, - event.getCause(), event.getDamage(), true, false, false, - null, null); - - event.setCancelled(true); - } - - @EventHandler - public void AnimalSpawn(GameStateChangeEvent event) - { - if (event.GetState() != GameState.Prepare) - return; - - this.CreatureAllowOverride = true; - - for (Location loc : WorldData.GetDataLocs("WHITE")) - _mobs.put(loc.getWorld().spawn(loc, Sheep.class), loc); - - for (Location loc : WorldData.GetDataLocs("PINK")) - _mobs.put(loc.getWorld().spawn(loc, Pig.class), loc); + @EventHandler + public void FallingBlockLand(EntityChangeBlockEvent event) + { + if (event.getEntity() instanceof FallingBlock) + { + event.setCancelled(true); + event.getEntity().remove(); - for (Location loc : WorldData.GetDataLocs("YELLOW")) - _mobs.put(loc.getWorld().spawn(loc, Chicken.class), loc); + for (Form form : _forms.values()) + if (form instanceof BlockForm) + ((BlockForm) form).FallingBlockCheck(); + } + } - for (Location loc : WorldData.GetDataLocs("BROWN")) - _mobs.put(loc.getWorld().spawn(loc, Cow.class), loc); + @EventHandler + public void FallingBlockUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; - this.CreatureAllowOverride = false; - } + if (!InProgress()) + return; - @EventHandler(priority = EventPriority.LOW) - public void AnimalDamage(CustomDamageEvent event) - { - if (event.GetDamageePlayer() == null && !(event.GetDamageeEntity() instanceof Slime)) - event.SetCancelled("Animal Damage"); + for (Form form : _forms.values()) + if (form instanceof BlockForm) + ((BlockForm) form).FallingBlockCheck(); + } - if (event.GetDamagerEntity(false) != null && event.GetDamagerEntity(false) instanceof Slime) - event.SetCancelled("Slime Attack"); - } + @EventHandler + public void SolidifyUpdate(UpdateEvent event) + { + if (!IsLive()) + return; - @EventHandler - public void AnimalReturn(UpdateEvent event) - { - if (event.getType() != UpdateType.SEC) - return; + if (event.getType() != UpdateType.TICK) + return; - for (Creature ent : _mobs.keySet()) - { - if (UtilMath.offset(ent.getLocation(), _mobs.get(ent)) < 5) - continue; + for (Form form : _forms.values()) + if (form instanceof BlockForm) + ((BlockForm) form).SolidifyUpdate(); + } - Location loc = _mobs.get(ent).add(UtilAlg.getTrajectory(_mobs.get(ent), ent.getLocation()).multiply(Math.random() * 3)); + @EventHandler + public void SolidBlockDamage(BlockDamageEvent event) + { + if (!_seekers.HasPlayer(event.getPlayer())) + return; + + for (Form form : _forms.values()) + { + if (!(form instanceof BlockForm)) + continue; + + if (((BlockForm) form).GetBlock() == null) + continue; + + if (!((BlockForm) form).GetBlock().equals(event.getBlock())) + continue; + + // Damage Event + Manager.GetDamage().NewDamageEvent(form.Player, event.getPlayer(), null, DamageCause.CUSTOM, 4, true, true, false, + event.getPlayer().getName(), null); + + ((BlockForm) form).SolidifyRemove(); + } + } + + @EventHandler + public void FallingBlockDamage(EntityDamageEvent event) + { + if (!(event instanceof EntityDamageByEntityEvent)) + return; + + if (!(event.getEntity() instanceof FallingSand)) + return; + + if (event.getEntity().getVehicle() == null) + return; + + if (!(event.getEntity().getVehicle() instanceof LivingEntity)) + return; + + LivingEntity damagee = (LivingEntity) event.getEntity().getVehicle(); + + EntityDamageByEntityEvent eventEE = (EntityDamageByEntityEvent) event; + + LivingEntity damager = null; + Projectile proj = null; + + if (eventEE.getDamager() instanceof Projectile) + { + proj = (Projectile) eventEE.getDamager(); + damager = (LivingEntity) proj.getShooter(); + } + else if (eventEE.getDamager() instanceof LivingEntity) + { + damager = (LivingEntity) eventEE.getDamager(); + } + + // Damage Event + Manager.GetDamage().NewDamageEvent(damagee, damager, proj, event.getCause(), event.getDamage(), true, false, false, null, + null); + + event.setCancelled(true); + } + + @EventHandler + public void AnimalSpawn(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Prepare) + return; + + this.CreatureAllowOverride = true; - EntityCreature ec = ((CraftCreature)ent).getHandle(); - Navigation nav = ec.getNavigation(); - nav.a(loc.getX(), loc.getY(), loc.getZ(), 1f); - } - } - - @EventHandler - public void AttackSeeker(CustomDamageEvent event) - { - if (event.GetDamagerPlayer(true) == null) - return; - - if (!_hiders.HasPlayer(event.GetDamagerPlayer(true))) - return; - - if (event.GetDamageInitial() > 1) - return; - - event.AddMod("H&S", "Negate", -event.GetDamageInitial(), false); - event.AddMod("H&S", "Attack", event.GetDamageInitial(), true); - } - - @EventHandler - public void ArrowShoot(EntityShootBowEvent event) - { - if (!(event.getEntity() instanceof Player)) - return; - - Player shooter = (Player)event.getEntity(); - - if (!_hiders.HasPlayer(shooter)) - return; - - Arrow arrow = shooter.getWorld().spawnArrow( - shooter.getEyeLocation().add(shooter.getLocation().getDirection().multiply(1.5)), - shooter.getLocation().getDirection(), (float) event.getProjectile().getVelocity().length(), 0f); - arrow.setShooter(shooter); - - event.setCancelled(true); - } - - @EventHandler - public void ArrowHit(CustomDamageEvent event) - { - if (event.IsCancelled()) - return; - - if (event.GetProjectile() == null) - return; - - Player damagee = event.GetDamageePlayer(); - if (damagee == null) return; - - if (!_seekers.HasPlayer(damagee)) - return; - - Player damager = event.GetDamagerPlayer(true); - if (damager == null) return; - - if (!_hiders.HasPlayer(damager)) - return; - - event.AddMod("Hide & Seek", "Negate", -event.GetDamageInitial(), false); - event.AddMod("Hide & Seek", "Damage Set", 2, false); - event.AddKnockback("Hide & Seek", 2); - - Powerup(damager); - } - - public void Powerup(Player player) - { - int count = 1; - if (_arrowHits.containsKey(player)) - count += _arrowHits.get(player); - - _arrowHits.put(player, count); - - if (count == 4) - { - player.getInventory().remove(Material.WOOD_AXE); - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.STONE_AXE, (byte)0, 1, C.cGreen + "Super Axe")); - - //Sound - player.playSound(player.getLocation(), Sound.LEVEL_UP, 1f, 1f); - - //Inform - UtilPlayer.message(player, F.main("Game", "You upgraded to " + F.elem("Super Axe") + "!")); - } - else if (count == 8) - { - player.getInventory().remove(Material.STONE_AXE); - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_AXE, (byte)0, 1, C.cGreen + "Ultra Axe")); - - //Sound - player.playSound(player.getLocation(), Sound.LEVEL_UP, 1f, 1f); - - //Inform - UtilPlayer.message(player, F.main("Game", "You upgraded to " + F.elem("Ultra Axe") + "!")); - } - else if (count == 12) - { - player.getInventory().remove(Material.IRON_AXE); - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.DIAMOND_AXE, (byte)0, 1, C.cGreen + "Hyper Axe")); + for (Location loc : WorldData.GetDataLocs("WHITE")) + _mobs.put(loc.getWorld().spawn(loc, Sheep.class), loc); - //Sound - player.playSound(player.getLocation(), Sound.LEVEL_UP, 1f, 1f); + for (Location loc : WorldData.GetDataLocs("PINK")) + _mobs.put(loc.getWorld().spawn(loc, Pig.class), loc); - //Inform - UtilPlayer.message(player, F.main("Game", "You upgraded to " + F.elem("Hyper Axe") + "!")); - } - else if (count < 12) - { - //Sound - player.playSound(player.getLocation(), Sound.ORB_PICKUP, 1f, 1f); - } - } + for (Location loc : WorldData.GetDataLocs("YELLOW")) + _mobs.put(loc.getWorld().spawn(loc, Chicken.class), loc); - @EventHandler - public void UseBoost(PlayerInteractEvent event) - { - Player player = event.getPlayer(); + for (Location loc : WorldData.GetDataLocs("BROWN")) + _mobs.put(loc.getWorld().spawn(loc, Cow.class), loc); - if (!UtilEvent.isAction(event, ActionType.R)) - return; + this.CreatureAllowOverride = false; + } + + @EventHandler(priority = EventPriority.LOW) + public void AnimalDamage(CustomDamageEvent event) + { + if (event.GetDamageePlayer() == null && !(event.GetDamageeEntity() instanceof Slime)) + event.SetCancelled("Animal Damage"); - if (player.getItemInHand() == null) - return; + if (event.GetDamagerEntity(false) != null && event.GetDamagerEntity(false) instanceof Slime) + event.SetCancelled("Slime Attack"); + } - if (!player.getItemInHand().getType().toString().contains("_AXE")) - return; - - if (!_hiders.HasPlayer(player)) - return; - - if (!Recharge.Instance.use(player, "Axe Boost", 16000, true, true)) - return; + @EventHandler + public void AnimalReturn(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + return; - if (UtilGear.isMat(player.getItemInHand(), Material.WOOD_AXE)) - { - Manager.GetCondition().Factory().Speed("Boost", player, player, 4, 0, false, false, false); + for (Creature ent : _mobs.keySet()) + { + if (UtilMath.offset(ent.getLocation(), _mobs.get(ent)) < 5) + continue; - //Inform - UtilPlayer.message(player, F.main("Game", "You used " + F.elem("Basic Boost") + "!")); - - //Sound - player.getWorld().playSound(player.getLocation(), Sound.BLAZE_BREATH, 1f, 1f); - } - else if (UtilGear.isMat(player.getItemInHand(), Material.STONE_AXE)) - { - Manager.GetCondition().Factory().Speed("Boost", player, player, 4, 1, false, false, false); - - //Inform - UtilPlayer.message(player, F.main("Game", "You used " + F.elem("Ultra Boost") + "!")); - - //Sound - player.getWorld().playSound(player.getLocation(), Sound.BLAZE_BREATH, 1f, 1f); - } - else if (UtilGear.isMat(player.getItemInHand(), Material.IRON_AXE)) - { - Manager.GetCondition().Factory().Speed("Boost", player, player, 4, 1, false, false, false); - Manager.GetCondition().Factory().Regen("Boost", player, player, 4, 0, false, false, false); - - //Inform - UtilPlayer.message(player, F.main("Game", "You used " + F.elem("Mega Boost") + "!")); - - //Sound - player.getWorld().playSound(player.getLocation(), Sound.BLAZE_BREATH, 1f, 1f); - } - else if (UtilGear.isMat(player.getItemInHand(), Material.DIAMOND_AXE)) - { - Manager.GetCondition().Factory().Speed("Boost", player, player, 4, 2, false, false, false); - Manager.GetCondition().Factory().Regen("Boost", player, player, 4, 1, false, false, false); - - //Inform - UtilPlayer.message(player, F.main("Game", "You used " + F.elem("Hyper Boost") + "!")); - - //Sound - player.getWorld().playSound(player.getLocation(), Sound.BLAZE_BREATH, 1f, 1f); - } - } - - @EventHandler - public void UseMeow(PlayerInteractEvent event) - { - Player player = event.getPlayer(); - - if (!UtilEvent.isAction(event, ActionType.R)) - return; - - if (!UtilGear.isMat(player.getItemInHand(), Material.SUGAR)) - return; - - event.setCancelled(true); - - if (!Recharge.Instance.use(player, "Meow", 5000, true, true)) - return; - - player.getWorld().playSound(player.getLocation(), Sound.CAT_MEOW, 1f, 1f); - - this.AddGems(player, 0.25, "Meows", true); - - UtilParticle.PlayParticle(ParticleType.NOTE, player.getLocation().add(0, 0.75, 0), 0.4f, 0.4f, 0.4f, 0, 6); - - Bukkit.getPluginManager().callEvent(new MeowEvent(event.getPlayer())); - } - - @EventHandler - public void UseFirework(PlayerInteractEvent event) - { - Player player = event.getPlayer(); - - if (!UtilEvent.isAction(event, ActionType.R_BLOCK)) - return; - - if (!UtilGear.isMat(player.getItemInHand(), Material.FIREWORK)) - return; - - if (!Recharge.Instance.use(player, "Firework", 15000, true, true)) - { - event.setCancelled(true); - return; - } - - this.AddGems(player, 2, "Fireworks", true); - } - - @EventHandler - public void HiderTimeGems(UpdateEvent event) - { - if (GetState() != GameState.Live) - return; - - if (event.getType() != UpdateType.SEC) - return; - - for (Player player : _hiders.GetPlayers(true)) - { - this.AddGems(player, 0.05, "Seconds Alive", true); - } - } - - @EventHandler - public void UpdateSeekers(UpdateEvent event) - { - if (!IsLive()) - return; - - if (event.getType() != UpdateType.FAST) - return; - - int req = Math.max(1, GetPlayers(true).size()/5); - - while (_seekers.GetPlayers(true).size() < req && _hiders.GetPlayers(true).size() > 0) - { - Player player = _hiders.GetPlayers(true).get(UtilMath.r(_hiders.GetPlayers(true).size())); - SetSeeker(player, true); - } - } - - @EventHandler - public void WaterDamage(UpdateEvent event) - { - if (!IsLive()) - return; - - if (event.getType() != UpdateType.FAST) - return; - } - - @EventHandler - public void WorldWaterDamage(UpdateEvent event) - { - if (!IsLive()) - return; - - if (event.getType() != UpdateType.SEC) - return; - - for (Player player : _hiders.GetPlayers(true)) - if (player.getLocation().getBlock().getTypeId() == 8 || player.getLocation().getBlock().getTypeId() == 9) - { - //Damage Event - Manager.GetDamage().NewDamageEvent(player, null, null, - DamageCause.DROWNING, 2, false, false, false, - "Water", "Water Damage"); - - player.getWorld().playSound(player.getLocation(), - Sound.SPLASH, 0.8f, - 1f + (float) Math.random() / 2); - } - } - - @EventHandler - public void PlayerDeath(PlayerQuitEvent event) - { - Form form = _forms.remove(event.getPlayer()); - if (form != null) - form.Remove(); - } - - @EventHandler - public void PlayerDeath(PlayerDeathEvent event) - { - if (_hiders.HasPlayer(event.getEntity())) - SetSeeker(event.getEntity(), false); - } - - public void SetSeeker(Player player, boolean forced) - { - GameTeam pastTeam = GetTeam(player); - if (pastTeam != null && pastTeam.equals(_hiders)) - pastTeam.SetPlacement(player, PlayerState.OUT); - - SetPlayerTeam(player, _seekers, true); - - Manager.GetDisguise().undisguise(player); - - //Remove Form - Form form = _forms.remove(player); - if (form != null) - form.Remove(); - - //Kit - SetKit(player, GetKits()[5], false); - GetKits()[5].ApplyKit(player); - - //Refresh - for (Player other : UtilServer.getPlayers()) - { - other.hidePlayer(player); - other.showPlayer(player); - } - - if (forced) - { - AddGems(player, 10, "Forced Seeker", false); - - Announce(F.main("Game", F.elem(_hiders.GetColor() + player.getName()) + " was moved to " + - F.elem(C.cRed + C.Bold + "Hunters") + ".")); - - player.getWorld().strikeLightningEffect(player.getLocation()); - - player.damage(1000); - } - - UtilPlayer.message(player, C.cRed + C.Bold + "You are now a Hunter!"); - - player.eject(); - player.leaveVehicle(); - player.teleport(_seekers.GetSpawn()); - } - - @Override - public void EndCheck() - { - if (!IsLive()) - return; - - if (GetPlayers(true).isEmpty()) - { - SetState(GameState.End); - return; - } - - if (_hiders.GetPlayers(true).isEmpty()) - { - ArrayList places = _hiders.GetPlacements(true); - - AnnounceEnd(_hiders.GetPlacements(true)); - - //Gems - if (places.size() >= 1) - AddGems(places.get(0), 20, "1st Place", false); - - if (places.size() >= 2) - AddGems(places.get(1), 15, "2nd Place", false); - - if (places.size() >= 3) - AddGems(places.get(2), 10, "3rd Place", false); - - for (Player player : GetPlayers(false)) - if (player.isOnline()) - AddGems(player, 10, "Participation", false); - - SetState(GameState.End); - } - } - - @Override - public double GetKillsGems(Player killer, Player killed, boolean assist) - { - if (_hiders.HasPlayer(killed)) - { - if (!assist) - return 4; - else - return 1; - } - - if (!assist) - return 1; - - return 0; - } - - @EventHandler - public void AnnounceHideTime(GameStateChangeEvent event) - { - if (event.GetState() != GameState.Live) - return; - - Announce(C.cAqua + C.Bold + "Hiders have 20 Seconds to hide!"); - } - - - - @EventHandler - public void Timer(UpdateEvent event) - { - if (GetState() != GameState.Live) - return; - - if (event.getType() != UpdateType.TICK) - return; - - //Hide Time - if (!_started) - { - long timeLeft = _hideTime - (System.currentTimeMillis() - GetStateTime()); - - if (timeLeft <= 0) - { - _started = true; - - //Hider Items - GiveItems(); - - //Remove Barrier - for (Location loc : WorldData.GetDataLocs("BLACK")) - loc.getBlock().setType(Material.AIR); - - Announce(C.cRed + C.Bold + "The Hunters have been released!"); - } - } - //Seek Time - else - { - long timeLeft = _gameTime - (System.currentTimeMillis() - GetStateTime() - _hideTime); - - if (timeLeft <= 0) - { - WriteScoreboard(); - - AnnounceEnd(_hiders); - - for (Player player : _hiders.GetPlayers(true)) - AddGems(player, 10, "Winning Team", false); - - for (Player player : GetPlayers(false)) - if (player.isOnline()) - AddGems(player, 10, "Participation", false); - - SetState(GameState.End); - } - } - } - - @Override - @EventHandler - public void ScoreboardUpdate(UpdateEvent event) - { - if (event.getType() != UpdateType.FAST) - return; - - WriteScoreboard(); - } - - private void WriteScoreboard() - { - //Wipe Last - Scoreboard.Reset(); - - for (GameTeam team : this.GetTeamList()) - { - Scoreboard.WriteBlank(); - Scoreboard.Write(team.GetPlayers(true).size() + " " + team.GetColor() + team.GetName()); - } - - - if (!_started) - { - long timeLeft = _hideTime - (System.currentTimeMillis() - GetStateTime()); - - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellow + C.Bold + "Hide Time"); - Scoreboard.Write(UtilTime.MakeStr(Math.max(0, timeLeft), 0)); - } - else - { - long timeLeft = _gameTime - (System.currentTimeMillis() - GetStateTime() - _hideTime); - - Scoreboard.WriteBlank(); - Scoreboard.Write(C.cYellow + C.Bold + "Seek Time"); - Scoreboard.Write(UtilTime.MakeStr(Math.max(0, timeLeft), 0)); - } - - Scoreboard.Draw(); - } - - @Override - public GameTeam ChooseTeam(Player player) - { - if (CanJoinTeam(_seekers)) - return _seekers; - - return _hiders; - } - - @Override - public boolean CanJoinTeam(GameTeam team) - { - if (team.GetColor() == ChatColor.RED) - { - return team.GetSize() < Math.max(1, GetPlayers(true).size()/5); - } - - return true; - } - - @Override - public boolean CanThrowTNT(Location location) - { - for (Location loc : _seekers.GetSpawns()) - if (UtilMath.offset(loc, location) < 24) - return false; - - return true; - } - - @Override - public DeathMessageType GetDeathMessageType() - { - return DeathMessageType.Detailed; - } - - @EventHandler - public void UsableCancel(PlayerInteractEvent event) - { - if (event.getClickedBlock() == null) - return; - - if (UtilBlock.usable(event.getClickedBlock())) - event.setCancelled(true); - } - - public GameTeam getHiders() - { - return _hiders; - } - - public GameTeam getSeekers() - { - return _seekers; - } - - @EventHandler - public void InfestDisguise(PlayerInteractEvent event) - { - if (event.getClickedBlock() == null) - return; - - final Player player = event.getPlayer(); - - final Block block = event.getClickedBlock(); - - if (!UtilGear.isMat(player.getItemInHand(), Material.MAGMA_CREAM)) - return; - - if (!_allowedBlocks.contains(block.getType())) - { - UtilPlayer.message(player, F.main("Game", "You cannot infest " + F.elem(ItemStackFactory.Instance.GetName(block.getType(), (byte)0, false) + " Block") + ".")); - return; - } - - if (block.getRelative(BlockFace.UP).getType() != Material.AIR || _infested.values().contains(block.getRelative(BlockFace.UP))) - { - UtilPlayer.message(player, F.main("Game", "You can only infest blocks with air above them.")); - return; - } - - if (IsInfesting(player) || _infestDeny.contains(player)) - { - UtilPlayer.message(player, F.main("Game", "You are already infesting something.")); - return; - } - - if (!Recharge.Instance.use(player, "Infest", 8000, true, true)) - return; - - //Cloak - InfestStart(player); - - //Data - final InfestedData data = new InfestedData(block); - - //Teleport - player.teleport(block.getLocation().add(0.5, 0, 0.5)); - - //Fake Block - UtilServer.getServer().getScheduler().runTaskLater(Manager.GetPlugin(), new Runnable() - { - @Override - public void run() - { - if (block.getType() == Material.AIR) - { - player.sendBlockChange(block.getLocation(), 36, (byte)0); - for (Player other : UtilServer.getPlayers()) - if (!other.equals(player)) - other.sendBlockChange(block.getLocation(), data.Material, data.Data); - } - } - - }, 5); - - - _infested.put(player, data); - } - - @EventHandler - public void InfestDisguise(PlayerInteractEntityEvent event) - { - if (event.getRightClicked() == null) - return; - - Player player = event.getPlayer(); - - if (!UtilGear.isMat(player.getItemInHand(), Material.MAGMA_CREAM)) - return; - - if (!_allowedEnts.contains(event.getRightClicked().getType())) - { - UtilPlayer.message(player, F.main("Game", "You cannot infest " + F.elem(UtilEnt.getName(event.getRightClicked())) + ".")); - return; - } - - if (IsInfesting(player) || _infestDeny.contains(player)) - { - UtilPlayer.message(player, F.main("Game", "You are already infesting something.")); - return; - } - - if (!Recharge.Instance.use(player, "Infest", 8000, true, true)) - return; - - //Cloak - InfestStart(player); - - //Infest - event.getRightClicked().setPassenger(player); - } - - @EventHandler - public void InfestDisguise(CustomDamageEvent event) - { - Player player = event.GetDamagerPlayer(false); - if (player == null) return; - - if (!UtilGear.isMat(player.getItemInHand(), Material.MAGMA_CREAM)) - return; - - if (!_allowedEnts.contains(event.GetDamageeEntity().getType())) - { - UtilPlayer.message(player, F.main("Game", "You cannot morph into " + F.elem(UtilEnt.getName(event.GetDamageeEntity())) + ".")); - return; - } - - if (IsInfesting(player) || _infestDeny.contains(player)) - { - UtilPlayer.message(player, F.main("Game", "You are already infesting something.")); - return; - } - - if (!Recharge.Instance.use(player, "Infest", 8000, true, true)) - return; - - //Cloak - InfestStart(player); - - //Infest - event.GetDamageeEntity().setPassenger(player); - } - - @EventHandler(priority = EventPriority.LOW) - public void InfectDamageShuffleUp(CustomDamageEvent event) - { - if (event.GetDamageePlayer() == null) - { - if (event.GetDamageeEntity().getPassenger() != null && event.GetDamageeEntity().getPassenger() instanceof LivingEntity) - { - LivingEntity passenger = (LivingEntity) event.GetDamageeEntity().getPassenger(); - - //Leave - event.GetDamageeEntity().eject(); - passenger.leaveVehicle(); - - //End - InfestEnd(passenger); - - //Damage Event - Manager.GetDamage().NewDamageEvent(passenger, event.GetDamagerEntity(true), null, - DamageCause.CUSTOM, 4, true, true, false, - UtilEnt.getName(event.GetDamagerEntity(true)), null); - } - } - } - - @EventHandler - public void InfestBlockDamage(BlockDamageEvent event) - { - if (!_seekers.HasPlayer(event.getPlayer())) - return; - - for (Player player : _infested.keySet()) - { - if (!_infested.get(player).Block.equals(event.getBlock())) - continue; - - //Damage Event - Manager.GetDamage().NewDamageEvent(player, event.getPlayer(), null, - DamageCause.CUSTOM, 4, true, true, false, - event.getPlayer().getName(), null); - - //Remove - _infested.remove(player).restore(); - - //End - InfestEnd(player); - } - } - - @EventHandler - public void InfestLeave(VehicleExitEvent event) - { - InfestEnd(event.getExited()); - } - - @EventHandler - public void InfestLeave(UpdateEvent event) - { - if (event.getType() != UpdateType.TICK) - return; - - //Block Leave - Iterator infestIterator = _infested.keySet().iterator(); - while (infestIterator.hasNext()) - { - Player player = infestIterator.next(); - - InfestedData data = _infested.get(player); - - //Update - if (data.Block.getType() == Material.AIR) - { - player.sendBlockChange(data.Block.getLocation(), 36, (byte)0); - for (Player other : UtilServer.getPlayers()) - if (!other.equals(player)) - other.sendBlockChange(data.Block.getLocation(), data.Material, data.Data); - } - - if (!player.getLocation().getBlock().equals(data.Block)) - { - //End - InfestEnd(player); - - //Restore Block - data.restore(); - - infestIterator.remove(); - } - } - - //Invisible - for (Player player : GetPlayers(true)) - { - if (!(GetKit(player) instanceof KitHiderTeleporter)) - continue; - - if (_infested.containsKey(player) || player.getVehicle() != null) - Manager.GetCondition().Factory().Cloak("Infest", player, player, 1.9, false, false); - } - } - - public void InfestStart(LivingEntity ent) - { - UtilParticle.PlayParticle(ParticleType.SLIME, ent.getLocation().add(0, 0.6, 0), 0.3f, 0.3f, 0.3f, 0, 24); - ent.getWorld().playSound(ent.getLocation(), Sound.SLIME_ATTACK, 2f, 1f); - ent.getWorld().playSound(ent.getLocation(), Sound.SLIME_ATTACK, 2f, 1f); - - Manager.GetCondition().Factory().Cloak("Infest", ent, ent, 1.9, false, false); - - //Gets rid of timer, not needed until end - Recharge.Instance.recharge((Player)ent, "Infest"); - - _infestDeny.add(ent); - } - - public void InfestEnd(LivingEntity ent) - { - Manager.GetCondition().EndCondition(ent, null, "Infest"); - - ent.getWorld().playSound(ent.getLocation(), Sound.SLIME_ATTACK, 2f, 0.6f); - - if (ent instanceof Player) - { - Recharge.Instance.recharge((Player)ent, "Infest"); - Recharge.Instance.use((Player)ent, "Infest", 8000, true, true); - _infestDeny.remove(ent); - } - } - - public boolean IsInfesting(LivingEntity ent) - { - if (_infested.containsKey(ent)) - return true; - - return ent.getVehicle() != null; - } + Location loc = _mobs.get(ent).add( + UtilAlg.getTrajectory(_mobs.get(ent), ent.getLocation()).multiply(Math.random() * 3)); + + EntityCreature ec = ((CraftCreature) ent).getHandle(); + Navigation nav = ec.getNavigation(); + nav.a(loc.getX(), loc.getY(), loc.getZ(), 1f); + } + } + + @EventHandler + public void AttackSeeker(CustomDamageEvent event) + { + if (event.GetDamagerPlayer(true) == null) + return; + + if (!_hiders.HasPlayer(event.GetDamagerPlayer(true))) + return; + + if (event.GetDamageInitial() > 1) + return; + + event.AddMod("H&S", "Negate", -event.GetDamageInitial(), false); + event.AddMod("H&S", "Attack", event.GetDamageInitial(), true); + } + + @EventHandler + public void ArrowShoot(EntityShootBowEvent event) + { + if (!(event.getEntity() instanceof Player)) + return; + + Player shooter = (Player) event.getEntity(); + + if (!_hiders.HasPlayer(shooter)) + return; + + Arrow arrow = shooter.getWorld().spawnArrow( + shooter.getEyeLocation().add(shooter.getLocation().getDirection().multiply(1.5)), + shooter.getLocation().getDirection(), (float) event.getProjectile().getVelocity().length(), 0f); + arrow.setShooter(shooter); + + event.setCancelled(true); + } + + @EventHandler + public void ArrowHit(CustomDamageEvent event) + { + if (event.IsCancelled()) + return; + + if (event.GetProjectile() == null) + return; + + Player damagee = event.GetDamageePlayer(); + if (damagee == null) + return; + + if (!_seekers.HasPlayer(damagee)) + return; + + Player damager = event.GetDamagerPlayer(true); + if (damager == null) + return; + + if (!_hiders.HasPlayer(damager)) + return; + + event.AddMod("Hide & Seek", "Negate", -event.GetDamageInitial(), false); + event.AddMod("Hide & Seek", "Damage Set", 2, false); + event.AddKnockback("Hide & Seek", 2); + + Powerup(damager); + } + + public void Powerup(Player player) + { + int count = 1; + if (_arrowHits.containsKey(player)) + count += _arrowHits.get(player); + + _arrowHits.put(player, count); + + if (count == 4) + { + player.getInventory().remove(Material.WOOD_AXE); + player.getInventory().addItem( + ItemStackFactory.Instance.CreateStack(Material.STONE_AXE, (byte) 0, 1, C.cGreen + "Super Axe")); + + // Sound + player.playSound(player.getLocation(), Sound.LEVEL_UP, 1f, 1f); + + // Inform + UtilPlayer.message(player, F.main("Game", "You upgraded to " + F.elem("Super Axe") + "!")); + } + else if (count == 8) + { + player.getInventory().remove(Material.STONE_AXE); + player.getInventory().addItem( + ItemStackFactory.Instance.CreateStack(Material.IRON_AXE, (byte) 0, 1, C.cGreen + "Ultra Axe")); + + // Sound + player.playSound(player.getLocation(), Sound.LEVEL_UP, 1f, 1f); + + // Inform + UtilPlayer.message(player, F.main("Game", "You upgraded to " + F.elem("Ultra Axe") + "!")); + } + else if (count == 12) + { + player.getInventory().remove(Material.IRON_AXE); + player.getInventory().addItem( + ItemStackFactory.Instance.CreateStack(Material.DIAMOND_AXE, (byte) 0, 1, C.cGreen + "Hyper Axe")); + + // Sound + player.playSound(player.getLocation(), Sound.LEVEL_UP, 1f, 1f); + + // Inform + UtilPlayer.message(player, F.main("Game", "You upgraded to " + F.elem("Hyper Axe") + "!")); + } + else if (count < 12) + { + // Sound + player.playSound(player.getLocation(), Sound.ORB_PICKUP, 1f, 1f); + } + } + + @EventHandler + public void UseBoost(PlayerInteractEvent event) + { + Player player = event.getPlayer(); + + if (!UtilEvent.isAction(event, ActionType.R)) + return; + + if (player.getItemInHand() == null) + return; + + if (!player.getItemInHand().getType().toString().contains("_AXE")) + return; + + if (!_hiders.HasPlayer(player)) + return; + + if (!Recharge.Instance.use(player, "Axe Boost", 16000, true, true)) + return; + + if (UtilGear.isMat(player.getItemInHand(), Material.WOOD_AXE)) + { + Manager.GetCondition().Factory().Speed("Boost", player, player, 4, 0, false, false, false); + + // Inform + UtilPlayer.message(player, F.main("Game", "You used " + F.elem("Basic Boost") + "!")); + + // Sound + player.getWorld().playSound(player.getLocation(), Sound.BLAZE_BREATH, 1f, 1f); + } + else if (UtilGear.isMat(player.getItemInHand(), Material.STONE_AXE)) + { + Manager.GetCondition().Factory().Speed("Boost", player, player, 4, 1, false, false, false); + + // Inform + UtilPlayer.message(player, F.main("Game", "You used " + F.elem("Ultra Boost") + "!")); + + // Sound + player.getWorld().playSound(player.getLocation(), Sound.BLAZE_BREATH, 1f, 1f); + } + else if (UtilGear.isMat(player.getItemInHand(), Material.IRON_AXE)) + { + Manager.GetCondition().Factory().Speed("Boost", player, player, 4, 1, false, false, false); + Manager.GetCondition().Factory().Regen("Boost", player, player, 4, 0, false, false, false); + + // Inform + UtilPlayer.message(player, F.main("Game", "You used " + F.elem("Mega Boost") + "!")); + + // Sound + player.getWorld().playSound(player.getLocation(), Sound.BLAZE_BREATH, 1f, 1f); + } + else if (UtilGear.isMat(player.getItemInHand(), Material.DIAMOND_AXE)) + { + Manager.GetCondition().Factory().Speed("Boost", player, player, 4, 2, false, false, false); + Manager.GetCondition().Factory().Regen("Boost", player, player, 4, 1, false, false, false); + + // Inform + UtilPlayer.message(player, F.main("Game", "You used " + F.elem("Hyper Boost") + "!")); + + // Sound + player.getWorld().playSound(player.getLocation(), Sound.BLAZE_BREATH, 1f, 1f); + } + } + + @EventHandler + public void UseMeow(PlayerInteractEvent event) + { + Player player = event.getPlayer(); + + if (!UtilEvent.isAction(event, ActionType.R)) + return; + + if (!UtilGear.isMat(player.getItemInHand(), Material.SUGAR)) + return; + + event.setCancelled(true); + + if (!Recharge.Instance.use(player, "Meow", 5000, true, true)) + return; + + player.getWorld().playSound(player.getLocation(), Sound.CAT_MEOW, 1f, 1f); + + this.AddGems(player, 0.25, "Meows", true); + + UtilParticle.PlayParticle(ParticleType.NOTE, player.getLocation().add(0, 0.75, 0), 0.4f, 0.4f, 0.4f, 0, 6); + + Bukkit.getPluginManager().callEvent(new MeowEvent(event.getPlayer())); + } + + @EventHandler + public void UseFirework(PlayerInteractEvent event) + { + Player player = event.getPlayer(); + + if (!UtilEvent.isAction(event, ActionType.R_BLOCK)) + return; + + if (!UtilGear.isMat(player.getItemInHand(), Material.FIREWORK)) + return; + + if (!Recharge.Instance.use(player, "Firework", 15000, true, true)) + { + event.setCancelled(true); + return; + } + + this.AddGems(player, 2, "Fireworks", true); + } + + @EventHandler + public void HiderTimeGems(UpdateEvent event) + { + if (GetState() != GameState.Live) + return; + + if (event.getType() != UpdateType.SEC) + return; + + for (Player player : _hiders.GetPlayers(true)) + { + this.AddGems(player, 0.05, "Seconds Alive", true); + } + } + + @EventHandler + public void UpdateSeekers(UpdateEvent event) + { + if (!IsLive()) + return; + + if (event.getType() != UpdateType.FAST) + return; + + int req = Math.max(1, GetPlayers(true).size() / 5); + + while (_seekers.GetPlayers(true).size() < req && _hiders.GetPlayers(true).size() > 0) + { + Player player = _hiders.GetPlayers(true).get(UtilMath.r(_hiders.GetPlayers(true).size())); + SetSeeker(player, true); + } + } + + @EventHandler + public void WaterDamage(UpdateEvent event) + { + if (!IsLive()) + return; + + if (event.getType() != UpdateType.FAST) + return; + } + + @EventHandler + public void WorldWaterDamage(UpdateEvent event) + { + if (!IsLive()) + return; + + if (event.getType() != UpdateType.SEC) + return; + + for (Player player : _hiders.GetPlayers(true)) + if (player.getLocation().getBlock().getTypeId() == 8 || player.getLocation().getBlock().getTypeId() == 9) + { + // Damage Event + Manager.GetDamage().NewDamageEvent(player, null, null, DamageCause.DROWNING, 2, false, false, false, "Water", + "Water Damage"); + + player.getWorld().playSound(player.getLocation(), Sound.SPLASH, 0.8f, 1f + (float) Math.random() / 2); + } + } + + @EventHandler + public void PlayerDeath(PlayerQuitEvent event) + { + Form form = _forms.remove(event.getPlayer()); + if (form != null) + form.Remove(); + } + + @EventHandler + public void PlayerDeath(PlayerDeathEvent event) + { + if (_hiders.HasPlayer(event.getEntity())) + SetSeeker(event.getEntity(), false); + } + + public void SetSeeker(Player player, boolean forced) + { + GameTeam pastTeam = GetTeam(player); + if (pastTeam != null && pastTeam.equals(_hiders)) + pastTeam.SetPlacement(player, PlayerState.OUT); + + SetPlayerTeam(player, _seekers, true); + + Manager.GetDisguise().undisguise(player); + + // Remove Form + Form form = _forms.remove(player); + if (form != null) + form.Remove(); + + // Kit + SetKit(player, GetKits()[5], false); + GetKits()[5].ApplyKit(player); + + // Refresh + for (Player other : UtilServer.getPlayers()) + { + other.hidePlayer(player); + other.showPlayer(player); + } + + if (forced) + { + AddGems(player, 10, "Forced Seeker", false); + + Announce(F.main("Game", + F.elem(_hiders.GetColor() + player.getName()) + " was moved to " + F.elem(C.cRed + C.Bold + "Hunters") + ".")); + + player.getWorld().strikeLightningEffect(player.getLocation()); + + player.damage(1000); + } + + UtilPlayer.message(player, C.cRed + C.Bold + "You are now a Hunter!"); + + player.eject(); + player.leaveVehicle(); + player.teleport(_seekers.GetSpawn()); + } + + @Override + public void EndCheck() + { + if (!IsLive()) + return; + + if (GetPlayers(true).isEmpty()) + { + SetState(GameState.End); + return; + } + + if (_hiders.GetPlayers(true).isEmpty()) + { + ArrayList places = _hiders.GetPlacements(true); + + AnnounceEnd(_hiders.GetPlacements(true)); + + // Gems + if (places.size() >= 1) + AddGems(places.get(0), 20, "1st Place", false); + + if (places.size() >= 2) + AddGems(places.get(1), 15, "2nd Place", false); + + if (places.size() >= 3) + AddGems(places.get(2), 10, "3rd Place", false); + + for (Player player : GetPlayers(false)) + if (player.isOnline()) + AddGems(player, 10, "Participation", false); + + SetState(GameState.End); + } + } + + @Override + public double GetKillsGems(Player killer, Player killed, boolean assist) + { + if (_hiders.HasPlayer(killed)) + { + if (!assist) + return 4; + else + return 1; + } + + if (!assist) + return 1; + + return 0; + } + + @EventHandler + public void AnnounceHideTime(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Live) + return; + + Announce(C.cAqua + C.Bold + "Hiders have 20 Seconds to hide!"); + } + + @EventHandler + public void Timer(UpdateEvent event) + { + if (GetState() != GameState.Live) + return; + + if (event.getType() != UpdateType.TICK) + return; + + // Hide Time + if (!_started) + { + long timeLeft = _hideTime - (System.currentTimeMillis() - GetStateTime()); + + if (timeLeft <= 0) + { + _started = true; + + // Hider Items + GiveItems(); + + // Remove Barrier + for (Location loc : WorldData.GetDataLocs("BLACK")) + loc.getBlock().setType(Material.AIR); + + Announce(C.cRed + C.Bold + "The Hunters have been released!"); + } + } + // Seek Time + else + { + long timeLeft = _gameTime - (System.currentTimeMillis() - GetStateTime() - _hideTime); + + if (timeLeft <= 0) + { + WriteScoreboard(); + + AnnounceEnd(_hiders); + + for (Player player : _hiders.GetPlayers(true)) + AddGems(player, 10, "Winning Team", false); + + for (Player player : GetPlayers(false)) + if (player.isOnline()) + AddGems(player, 10, "Participation", false); + + SetState(GameState.End); + } + } + } + + @Override + @EventHandler + public void ScoreboardUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + WriteScoreboard(); + } + + private void WriteScoreboard() + { + // Wipe Last + Scoreboard.Reset(); + + for (GameTeam team : this.GetTeamList()) + { + Scoreboard.WriteBlank(); + Scoreboard.Write(team.GetPlayers(true).size() + " " + team.GetColor() + team.GetName()); + } + + if (!_started) + { + long timeLeft = _hideTime - (System.currentTimeMillis() - GetStateTime()); + + Scoreboard.WriteBlank(); + Scoreboard.Write(C.cYellow + C.Bold + "Hide Time"); + Scoreboard.Write(UtilTime.MakeStr(Math.max(0, timeLeft), 0)); + } + else + { + long timeLeft = _gameTime - (System.currentTimeMillis() - GetStateTime() - _hideTime); + + Scoreboard.WriteBlank(); + Scoreboard.Write(C.cYellow + C.Bold + "Seek Time"); + Scoreboard.Write(UtilTime.MakeStr(Math.max(0, timeLeft), 0)); + } + + Scoreboard.Draw(); + } + + @Override + public GameTeam ChooseTeam(Player player) + { + if (CanJoinTeam(_seekers)) + return _seekers; + + return _hiders; + } + + @Override + public boolean CanJoinTeam(GameTeam team) + { + if (team.GetColor() == ChatColor.RED) + { + return team.GetSize() < Math.max(1, GetPlayers(true).size() / 5); + } + + return true; + } + + @Override + public boolean CanThrowTNT(Location location) + { + for (Location loc : _seekers.GetSpawns()) + if (UtilMath.offset(loc, location) < 24) + return false; + + return true; + } + + @Override + public DeathMessageType GetDeathMessageType() + { + return DeathMessageType.Detailed; + } + + @EventHandler + public void UsableCancel(PlayerInteractEvent event) + { + if (event.getClickedBlock() == null) + return; + + if (UtilBlock.usable(event.getClickedBlock())) + event.setCancelled(true); + } + + public GameTeam getHiders() + { + return _hiders; + } + + public GameTeam getSeekers() + { + return _seekers; + } + + @EventHandler + public void InfestDisguise(PlayerInteractEvent event) + { + if (event.getClickedBlock() == null) + return; + + final Player player = event.getPlayer(); + + final Block block = event.getClickedBlock(); + + if (!UtilGear.isMat(player.getItemInHand(), Material.MAGMA_CREAM)) + return; + + if (!_allowedBlocks.contains(block.getType())) + { + UtilPlayer.message( + player, + F.main("Game", + "You cannot infest " + + F.elem(ItemStackFactory.Instance.GetName(block.getType(), (byte) 0, false) + " Block") + + ".")); + return; + } + + if (block.getRelative(BlockFace.UP).getType() != Material.AIR + || _infested.values().contains(block.getRelative(BlockFace.UP))) + { + UtilPlayer.message(player, F.main("Game", "You can only infest blocks with air above them.")); + return; + } + + if (IsInfesting(player) || _infestDeny.contains(player)) + { + UtilPlayer.message(player, F.main("Game", "You are already infesting something.")); + return; + } + + if (!Recharge.Instance.use(player, "Infest", 8000, true, true)) + return; + + // Cloak + InfestStart(player); + + // Data + final InfestedData data = new InfestedData(block); + + // Teleport + player.teleport(block.getLocation().add(0.5, 0, 0.5)); + + // Fake Block + UtilServer.getServer().getScheduler().runTaskLater(Manager.GetPlugin(), new Runnable() + { + @Override + public void run() + { + if (block.getType() == Material.AIR) + { + player.sendBlockChange(block.getLocation(), 36, (byte) 0); + for (Player other : UtilServer.getPlayers()) + if (!other.equals(player)) + other.sendBlockChange(block.getLocation(), data.Material, data.Data); + } + } + + }, 5); + + _infested.put(player, data); + } + + @EventHandler + public void InfestDisguise(PlayerInteractEntityEvent event) + { + if (event.getRightClicked() == null) + return; + + Player player = event.getPlayer(); + + if (!UtilGear.isMat(player.getItemInHand(), Material.MAGMA_CREAM)) + return; + + if (!_allowedEnts.contains(event.getRightClicked().getType())) + { + UtilPlayer.message(player, + F.main("Game", "You cannot infest " + F.elem(UtilEnt.getName(event.getRightClicked())) + ".")); + return; + } + + if (IsInfesting(player) || _infestDeny.contains(player)) + { + UtilPlayer.message(player, F.main("Game", "You are already infesting something.")); + return; + } + + if (!Recharge.Instance.use(player, "Infest", 8000, true, true)) + return; + + // Cloak + InfestStart(player); + + // Infest + event.getRightClicked().setPassenger(player); + } + + @EventHandler + public void InfestDisguise(CustomDamageEvent event) + { + Player player = event.GetDamagerPlayer(false); + if (player == null) + return; + + if (!UtilGear.isMat(player.getItemInHand(), Material.MAGMA_CREAM)) + return; + + if (!_allowedEnts.contains(event.GetDamageeEntity().getType())) + { + UtilPlayer.message(player, + F.main("Game", "You cannot morph into " + F.elem(UtilEnt.getName(event.GetDamageeEntity())) + ".")); + return; + } + + if (IsInfesting(player) || _infestDeny.contains(player)) + { + UtilPlayer.message(player, F.main("Game", "You are already infesting something.")); + return; + } + + if (!Recharge.Instance.use(player, "Infest", 8000, true, true)) + return; + + // Cloak + InfestStart(player); + + // Infest + event.GetDamageeEntity().setPassenger(player); + } + + @EventHandler(priority = EventPriority.LOW) + public void InfectDamageShuffleUp(CustomDamageEvent event) + { + if (event.GetDamageePlayer() == null) + { + if (event.GetDamageeEntity().getPassenger() != null + && event.GetDamageeEntity().getPassenger() instanceof LivingEntity) + { + LivingEntity passenger = (LivingEntity) event.GetDamageeEntity().getPassenger(); + + // Leave + event.GetDamageeEntity().eject(); + passenger.leaveVehicle(); + + // End + InfestEnd(passenger); + + // Damage Event + Manager.GetDamage().NewDamageEvent(passenger, event.GetDamagerEntity(true), null, DamageCause.CUSTOM, 4, true, + true, false, UtilEnt.getName(event.GetDamagerEntity(true)), null); + } + } + } + + @EventHandler + public void InfestBlockDamage(BlockDamageEvent event) + { + if (!_seekers.HasPlayer(event.getPlayer())) + return; + + for (Player player : _infested.keySet()) + { + if (!_infested.get(player).Block.equals(event.getBlock())) + continue; + + // Damage Event + Manager.GetDamage().NewDamageEvent(player, event.getPlayer(), null, DamageCause.CUSTOM, 4, true, true, false, + event.getPlayer().getName(), null); + + // Remove + _infested.remove(player).restore(); + + // End + InfestEnd(player); + } + } + + @EventHandler + public void InfestLeave(VehicleExitEvent event) + { + InfestEnd(event.getExited()); + } + + @EventHandler + public void InfestLeave(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + // Block Leave + Iterator infestIterator = _infested.keySet().iterator(); + while (infestIterator.hasNext()) + { + Player player = infestIterator.next(); + + InfestedData data = _infested.get(player); + + // Update + if (data.Block.getType() == Material.AIR) + { + player.sendBlockChange(data.Block.getLocation(), 36, (byte) 0); + for (Player other : UtilServer.getPlayers()) + if (!other.equals(player)) + other.sendBlockChange(data.Block.getLocation(), data.Material, data.Data); + } + + if (!player.getLocation().getBlock().equals(data.Block)) + { + // End + InfestEnd(player); + + // Restore Block + data.restore(); + + infestIterator.remove(); + } + } + + // Invisible + for (Player player : GetPlayers(true)) + { + if (!(GetKit(player) instanceof KitHiderTeleporter)) + continue; + + if (_infested.containsKey(player) || player.getVehicle() != null) + Manager.GetCondition().Factory().Cloak("Infest", player, player, 1.9, false, false); + } + } + + public void InfestStart(LivingEntity ent) + { + UtilParticle.PlayParticle(ParticleType.SLIME, ent.getLocation().add(0, 0.6, 0), 0.3f, 0.3f, 0.3f, 0, 24); + ent.getWorld().playSound(ent.getLocation(), Sound.SLIME_ATTACK, 2f, 1f); + ent.getWorld().playSound(ent.getLocation(), Sound.SLIME_ATTACK, 2f, 1f); + + Manager.GetCondition().Factory().Cloak("Infest", ent, ent, 1.9, false, false); + + // Gets rid of timer, not needed until end + Recharge.Instance.recharge((Player) ent, "Infest"); + + _infestDeny.add(ent); + } + + public void InfestEnd(LivingEntity ent) + { + Manager.GetCondition().EndCondition(ent, null, "Infest"); + + ent.getWorld().playSound(ent.getLocation(), Sound.SLIME_ATTACK, 2f, 0.6f); + + if (ent instanceof Player) + { + Recharge.Instance.recharge((Player) ent, "Infest"); + Recharge.Instance.use((Player) ent, "Infest", 8000, true, true); + _infestDeny.remove(ent); + } + } + + public boolean IsInfesting(LivingEntity ent) + { + if (_infested.containsKey(ent)) + return true; + + return ent.getVehicle() != null; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/forms/BlockForm.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/forms/BlockForm.java index 92509d0e5..6caed67e4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/forms/BlockForm.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/forms/BlockForm.java @@ -4,6 +4,7 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.MapUtil; import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; @@ -13,6 +14,15 @@ import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.recharge.Recharge; import nautilus.game.arcade.game.games.hideseek.HideSeek; import nautilus.game.arcade.game.games.hideseek.kits.KitHiderQuick; +import net.minecraft.server.v1_7_R4.DataWatcher; +import net.minecraft.server.v1_7_R4.EntityPlayer; +import net.minecraft.server.v1_7_R4.Packet; +import net.minecraft.server.v1_7_R4.PacketPlayOutAttachEntity; +import net.minecraft.server.v1_7_R4.PacketPlayOutEntityDestroy; +import net.minecraft.server.v1_7_R4.PacketPlayOutEntityTeleport; +import net.minecraft.server.v1_7_R4.PacketPlayOutRelEntityMove; +import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntity; +import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityLiving; import org.bukkit.Bukkit; import org.bukkit.Effect; @@ -23,234 +33,321 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity; import org.bukkit.craftbukkit.v1_7_R4.entity.CraftFallingSand; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; +import org.bukkit.entity.EntityType; import org.bukkit.entity.FallingBlock; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; public class BlockForm extends Form { - private Material _mat; + private Material _mat; - private Block _block; + private Block _block; + private int _entityId; - private Location _loc; + private Location _loc; + private int _selfEntityId1; + private int _selfEntityId2; + private Location _lastSaw; + private Vector _sawDiff = new Vector(); - public BlockForm(HideSeek host, Player player, Material mat) - { - super(host, player); + public BlockForm(HideSeek host, Player player, Material mat) + { + super(host, player); - _mat = mat; - _loc = player.getLocation(); - - System.out.println("Block Form: " + _mat + " " + _mat.getId()); + _mat = mat; + _loc = player.getLocation(); + _selfEntityId1 = UtilEnt.getNewEntityId(); + _selfEntityId2 = UtilEnt.getNewEntityId(); + System.out.println("Block Form: " + _mat + " " + _mat.getId()); + } - Apply(); - } - - @Override - public void Apply() - { - //Remove Old - if (Player.getPassenger() != null) - { - Recharge.Instance.useForce(Player, "PassengerChange", 100); + @Override + public void Apply() + { + // Remove Old + if (Player.getPassenger() != null) + { + Recharge.Instance.useForce(Player, "PassengerChange", 100); - Player.getPassenger().remove(); - Player.eject(); - } + Player.getPassenger().remove(); + Player.eject(); + } - ((CraftEntity)Player).getHandle().getDataWatcher().watch(0, Byte.valueOf((byte) 32)); + EntityPlayer player = ((CraftPlayer) Player).getHandle(); + player.getDataWatcher().watch(0, Byte.valueOf((byte) 32)); - //Player > Chicken - DisguiseChicken disguise = new DisguiseChicken(Player); - disguise.setBaby(); - disguise.setSoundDisguise(new DisguiseCat(Player)); - Host.Manager.GetDisguise().disguise(disguise); + // Player > Chicken + DisguiseChicken disguise = new DisguiseChicken(Player); + disguise.setBaby(); + disguise.setSoundDisguise(new DisguiseCat(Player)); + Host.Manager.GetDisguise().disguise(disguise); - //Apply Falling Block - FallingBlockCheck(); + // Apply Falling Block + FallingBlockCheck(); - //Inform - String blockName = F.elem(ItemStackFactory.Instance.GetName(_mat, (byte)0, false)); - if (!blockName.contains("Block")) - UtilPlayer.message(Player, F.main("Game", C.cWhite + "You are now a " + F.elem(ItemStackFactory.Instance.GetName(_mat, (byte)0, false) + " Block") + "!")); - else - UtilPlayer.message(Player, F.main("Game", C.cWhite + "You are now a " + F.elem(ItemStackFactory.Instance.GetName(_mat, (byte)0, false)) + "!")); + PacketPlayOutSpawnEntityLiving packet1 = new PacketPlayOutSpawnEntityLiving(); + packet1.a = _selfEntityId1; + packet1.b = EntityType.SILVERFISH.getTypeId(); + packet1.c = (int) Math.floor(_lastSaw.getX() * 32); + packet1.d = (int) Math.floor(_lastSaw.getY() * 32); + packet1.e = (int) Math.floor(_lastSaw.getZ() * 32); + DataWatcher watcher = new DataWatcher(null); + watcher.a(0, (byte) 32); + watcher.a(1, 0); + packet1.l = watcher; + player.playerConnection.sendPacket(packet1); - //Give Item - Player.getInventory().setItem(8, new ItemStack(Host.GetItemEquivilent(_mat))); - UtilInv.Update(Player); + PacketPlayOutSpawnEntity packet2 = new PacketPlayOutSpawnEntity(player, 70, _mat.getId()); + packet2.a = _selfEntityId2; + player.playerConnection.sendPacket(packet2); - //Sound - Player.playSound(Player.getLocation(), Sound.ZOMBIE_UNFECT, 2f, 2f); - } + PacketPlayOutAttachEntity packet3 = new PacketPlayOutAttachEntity(); - @Override - public void Remove() - { - SolidifyRemove(); + packet3.b = _selfEntityId2; + packet3.c = _selfEntityId1; + player.playerConnection.sendPacket(packet3); - Host.Manager.GetDisguise().undisguise(Player); + // Inform + String blockName = F.elem(ItemStackFactory.Instance.GetName(_mat, (byte) 0, false)); + if (!blockName.contains("Block")) + UtilPlayer.message( + Player, + F.main("Game", + C.cWhite + "You are now a " + + F.elem(ItemStackFactory.Instance.GetName(_mat, (byte) 0, false) + " Block") + "!")); + else + UtilPlayer.message( + Player, + F.main("Game", C.cWhite + "You are now a " + F.elem(ItemStackFactory.Instance.GetName(_mat, (byte) 0, false)) + + "!")); - //Remove FB - if (Player.getPassenger() != null) - { - Recharge.Instance.useForce(Player, "PassengerChange", 100); + // Give Item + Player.getInventory().setItem(8, new ItemStack(Host.GetItemEquivilent(_mat))); + UtilInv.Update(Player); - Player.getPassenger().remove(); - Player.eject(); - } + // Sound + Player.playSound(Player.getLocation(), Sound.ZOMBIE_UNFECT, 2f, 2f); + } - ((CraftEntity)Player).getHandle().getDataWatcher().watch(0, Byte.valueOf((byte) 0)); - } + @Override + public void Remove() + { + SolidifyRemove(); - public void SolidifyUpdate() - { - if (!Player.isSprinting()) - ((CraftEntity)Player).getHandle().getDataWatcher().watch(0, Byte.valueOf((byte) 32)); - - //Not a Block - if (_block == null) - { - //Moved - if (!_loc.getBlock().equals(Player.getLocation().getBlock())) - { - Player.setExp(0); - _loc = Player.getLocation(); - } - //Unmoved - else - { - double hideBoost = 0.025; - if (Host.GetKit(Player) instanceof KitHiderQuick) - hideBoost = 0.1; + Host.Manager.GetDisguise().undisguise(Player); - Player.setExp((float) Math.min(0.999f, Player.getExp() + hideBoost)); + // Remove FB + if (Player.getPassenger() != null) + { + Recharge.Instance.useForce(Player, "PassengerChange", 100); - //Set Block - if (Player.getExp() >= 0.999f) - { - Block block = Player.getLocation().getBlock(); + Player.getPassenger().remove(); + Player.eject(); - //Not Able - if (block.getType() != Material.AIR || !UtilBlock.solid(block.getRelative(BlockFace.DOWN))) - { - UtilPlayer.message(Player, F.main("Game", "You cannot become a Solid Block here.")); - Player.setExp(0f); - return; - } + ((CraftPlayer) Player).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityDestroy(new int[] + { + _selfEntityId1, _selfEntityId2 + })); + } - Bukkit.getPluginManager().callEvent(new HideSeek.PlayerSolidifyEvent(Player)); + ((CraftEntity) Player).getHandle().getDataWatcher().watch(0, Byte.valueOf((byte) 0)); + } - //Set Block - _block = block; + public void SolidifyUpdate() + { + if (!Player.isSprinting()) + ((CraftEntity) Player).getHandle().getDataWatcher().watch(0, Byte.valueOf((byte) 32)); - //Effect - Player.playEffect(Player.getLocation(), Effect.STEP_SOUND, _mat); - //block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, _mat); + // Not a Block + if (_block == null) + { + // Moved + if (!_loc.getBlock().equals(Player.getLocation().getBlock())) + { + Player.setExp(0); + _loc = Player.getLocation(); + } + // Unmoved + else + { + double hideBoost = 0.025; + if (Host.GetKit(Player) instanceof KitHiderQuick) + hideBoost = 0.1; - //Display - SolidifyVisual(); + Player.setExp((float) Math.min(0.999f, Player.getExp() + hideBoost)); - //Invisible - //Host.Manager.GetCondition().Factory().Cloak("Disguised as Block", Player, Player, 60000, false, false); + // Set Block + if (Player.getExp() >= 0.999f) + { + Block block = Player.getLocation().getBlock(); - //Sound - Player.playSound(Player.getLocation(), Sound.NOTE_PLING, 1f, 2f); - } - } - } - //Is a Block - else - { - //Moved - if (!_loc.getBlock().equals(Player.getLocation().getBlock())) - { - SolidifyRemove(); - } - //Send Packets - else - { - SolidifyVisual(); - } - } - } + // Not Able + if (block.getType() != Material.AIR || !UtilBlock.solid(block.getRelative(BlockFace.DOWN))) + { + UtilPlayer.message(Player, F.main("Game", "You cannot become a Solid Block here.")); + Player.setExp(0f); + return; + } - public void SolidifyRemove() - { - if (_block != null) - { - MapUtil.QuickChangeBlockAt(_block.getLocation(), 0, (byte)0); - _block = null; - } + Bukkit.getPluginManager().callEvent(new HideSeek.PlayerSolidifyEvent(Player)); - Player.setExp(0f); + // Set Block + _block = block; - //Host.Manager.GetCondition().EndCondition(Player, null, "Disguised as Block"); + // Effect + Player.playEffect(Player.getLocation(), Effect.STEP_SOUND, _mat); + // block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, _mat); - //Inform - Player.playSound(Player.getLocation(), Sound.NOTE_PLING, 1f, 0.5f); + // Display + SolidifyVisual(); - FallingBlockCheck(); - } + // Invisible + // Host.Manager.GetCondition().Factory().Cloak("Disguised as Block", Player, Player, 60000, false, false); - @SuppressWarnings("deprecation") - public void SolidifyVisual() - { - if (_block == null) - return; + // Sound + Player.playSound(Player.getLocation(), Sound.NOTE_PLING, 1f, 2f); + } + } + } + // Is a Block + else + { + // Moved + if (!_loc.getBlock().equals(Player.getLocation().getBlock())) + { + SolidifyRemove(); + } + // Send Packets + else + { + SolidifyVisual(); + } + } + } - //Remove Old - if (Player.getPassenger() != null) - { - Recharge.Instance.useForce(Player, "PassengerChange", 100); + public void SolidifyRemove() + { + if (_block != null) + { + MapUtil.QuickChangeBlockAt(_block.getLocation(), 0, (byte) 0); + _block = null; + } - Player.getPassenger().remove(); - Player.eject(); - } + Player.setExp(0f); - //Others - for (Player other : UtilServer.getPlayers()) - other.sendBlockChange(Player.getLocation(), _mat, (byte)0); + // Host.Manager.GetCondition().EndCondition(Player, null, "Disguised as Block"); - //Self - Player.sendBlockChange(Player.getLocation(), 36, (byte)0); + // Inform + Player.playSound(Player.getLocation(), Sound.NOTE_PLING, 1f, 0.5f); - FallingBlockCheck(); - } + FallingBlockCheck(); + } - public void FallingBlockCheck() - { - //Block Form (Hide Falling) - if (_block != null) - return; + @SuppressWarnings("deprecation") + public void SolidifyVisual() + { + if (_block == null) + return; - //Recreate Falling - if (Player.getPassenger() == null || !Player.getPassenger().isValid()) - { - if (!Recharge.Instance.use(Player, "PassengerChange", 100, false, false)) - return; + // Remove Old + if (Player.getPassenger() != null) + { + Recharge.Instance.useForce(Player, "PassengerChange", 100); - //Falling Block - FallingBlock block = Player.getWorld().spawnFallingBlock(Player.getEyeLocation(), _mat, (byte)0); - - //No Arrow Collision - ((CraftFallingSand)block).getHandle().spectating = true; - - Player.setPassenger(block); - } + Player.getPassenger().remove(); + Player.eject(); + } - //Ensure Falling doesnt Despawn - else - { - ((CraftFallingSand)Player.getPassenger()).getHandle().ticksLived = 1; - Player.getPassenger().setTicksLived(1); - } + // Others + for (Player other : UtilServer.getPlayers()) + if (!other.equals(Player)) + other.sendBlockChange(Player.getLocation(), _mat, (byte) 0); - } + // Self + Player.sendBlockChange(Player.getLocation(), 36, (byte) 0); - public Block GetBlock() - { - return _block; - } + FallingBlockCheck(); + } + + public void FallingBlockCheck() + { + + EntityPlayer player = ((CraftPlayer) Player).getHandle(); + + // Block Form (Hide Falling) + if (_block == null) + { + // Recreate Falling + if (Player.getPassenger() == null || !Player.getPassenger().isValid()) + { + if (Recharge.Instance.use(Player, "PassengerChange", 100, false, false)) + { + _entityId = UtilEnt.getNewEntityId(false); + // Falling Block + FallingBlock block = Player.getWorld().spawnFallingBlock(Player.getEyeLocation(), _mat, (byte) 0); + + // No Arrow Collision + ((CraftFallingSand) block).getHandle().spectating = true; + + Player.setPassenger(block); + } + } + + // Ensure Falling doesnt Despawn + else + { + ((CraftFallingSand) Player.getPassenger()).getHandle().ticksLived = 1; + Player.getPassenger().setTicksLived(1); + } + } + + if (_lastSaw == null || _lastSaw.getWorld() != Player.getWorld()) + { + _lastSaw = Player.getLocation(); + } + this._sawDiff.add(Player.getLocation().subtract(_lastSaw).toVector()); + _lastSaw = Player.getLocation(); + + int x = (int) Math.floor(_sawDiff.getX() * 32); + int y = (int) Math.floor(_sawDiff.getY() * 32); + int z = (int) Math.floor(_sawDiff.getZ() * 32); + if (x != 0 || y != 0 || z != 0) + { + Packet packet; + if (x >= -128 && x <= 127 && y >= -128 && y <= 127 && z >= -128 && z <= 127) + { + _sawDiff.subtract(new Vector(x / 32D, y / 32D, z / 32D)); + PacketPlayOutRelEntityMove relMove = new PacketPlayOutRelEntityMove(); + relMove.a = this._selfEntityId1; + relMove.b = (byte) x; + relMove.c = (byte) y; + relMove.d = (byte) z; + packet = relMove; + } + else + { + _sawDiff = new Vector(); + PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(); + teleportPacket.a = _selfEntityId1; + teleportPacket.b = (int) Math.floor(32 * _lastSaw.getX()); + teleportPacket.c = (int) Math.floor(32 * _lastSaw.getY()); + teleportPacket.d = (int) Math.floor(32 * _lastSaw.getZ()); + packet = teleportPacket; + } + player.playerConnection.sendPacket(packet); + } + } + + public Block GetBlock() + { + return _block; + } + + public int getEntityId() + { + return _entityId; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/KitManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/KitManager.java index 8ae7ad5d9..0f12dafde 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/KitManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/KitManager.java @@ -3,11 +3,8 @@ package nautilus.game.arcade.game.games.searchanddestroy; import java.util.ArrayList; import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.game.games.searchanddestroy.kits.bow.KitBow; -import nautilus.game.arcade.game.games.searchanddestroy.kits.bow.KitPinner; -import nautilus.game.arcade.game.games.searchanddestroy.kits.bow.KitPunch; -import nautilus.game.arcade.game.games.searchanddestroy.kits.bow.KitSniper; -import nautilus.game.arcade.game.games.searchanddestroy.kits.bow.KitStitcher; +import nautilus.game.arcade.game.games.searchanddestroy.kits.bow.*; +import nautilus.game.arcade.game.games.searchanddestroy.kits.trooper.*; import nautilus.game.arcade.kit.Kit; public class KitManager @@ -36,7 +33,7 @@ public class KitManager public KitManager(SearchAndDestroy search) { ArcadeManager man = search.getArcadeManager(); - { + { // Register bow kits ArrayList children1 = new ArrayList(); ArrayList children2 = new ArrayList(); ArrayList children3 = new ArrayList(); @@ -49,11 +46,11 @@ public class KitManager _kits.add(bow3); UpgradeKit bow4 = new UpgradeKit(bow2, new KitSniper(man), new ArrayList(), 46, 29, 37); _kits.add(bow4); - UpgradeKit bow5 = new UpgradeKit(bow2, new KitBow(man), new ArrayList(), 48, 29, 39); + UpgradeKit bow5 = new UpgradeKit(bow2, new KitSharpshooter(man), new ArrayList(), 48, 29, 39); _kits.add(bow5); UpgradeKit bow6 = new UpgradeKit(bow3, new KitPinner(man), new ArrayList(), 50, 33, 41); _kits.add(bow6); - UpgradeKit bow7 = new UpgradeKit(bow3, new KitBow(man), new ArrayList(), 52, 33, 43); + UpgradeKit bow7 = new UpgradeKit(bow3, new KitThunderstorm(man), new ArrayList(), 52, 33, 43); _kits.add(bow7); children1.add(bow2); children1.add(bow3); @@ -64,6 +61,34 @@ public class KitManager } + { // Register sword kits + ArrayList children1 = new ArrayList(); + ArrayList children2 = new ArrayList(); + ArrayList children3 = new ArrayList(); + + UpgradeKit sword1 = new UpgradeKit(null, new KitTrooper(man), children1, 4); + _kits.add(sword1); + UpgradeKit sword2 = new UpgradeKit(sword1, new KitTrooper(man), children2, 20, 12); + _kits.add(sword2); + UpgradeKit sword3 = new UpgradeKit(sword1, new KitTrooper(man), children3, 24, 14); + _kits.add(sword3); + UpgradeKit sword4 = new UpgradeKit(sword2, new KitTrooper(man), new ArrayList(), 46, 29, 37); + _kits.add(sword4); + UpgradeKit sword5 = new UpgradeKit(sword2, new KitTrooper(man), new ArrayList(), 48, 29, 39); + _kits.add(sword5); + UpgradeKit sword6 = new UpgradeKit(sword3, new KitTrooper(man), new ArrayList(), 50, 33, 41); + _kits.add(sword6); + UpgradeKit sword7 = new UpgradeKit(sword3, new KitTrooper(man), new ArrayList(), 52, 33, 43); + _kits.add(sword7); + children1.add(sword2); + children1.add(sword3); + children2.add(sword4); + children2.add(sword5); + children3.add(sword6); + children3.add(sword7); + + } + } public Kit[] get_kits() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/bow/KitPinner.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/bow/KitPinner.java index e9a53a2a4..59cb1f9fc 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/bow/KitPinner.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/bow/KitPinner.java @@ -1,30 +1,19 @@ package nautilus.game.arcade.game.games.searchanddestroy.kits.bow; -import java.util.Iterator; - -import mineplex.core.common.util.NautHashMap; import mineplex.core.itemstack.ItemBuilder; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.games.castlesiege.kits.KitHuman; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.perks.PerkPinned; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.EntityType; -import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; -import org.bukkit.util.Vector; public class KitPinner extends KitHuman { @@ -33,56 +22,11 @@ public class KitPinner extends KitHuman { super(manager, "Pinner", KitAvailability.Hide, new String[] { - "Your arrows have been enchanted with gravity magic.", "As such, the player will find it hard to lift", - "their body and move around for a few seconds." - }, new Perk[0], EntityType.SKELETON, new ItemStack(Material.OBSIDIAN)); - } - - private NautHashMap _secondsPinned = new NautHashMap(); - - @EventHandler - public void onSecond(UpdateEvent event) - { - if (event.getType() != UpdateType.FASTER) - { - return; - } - - Iterator itel = _secondsPinned.keySet().iterator(); - while (itel.hasNext()) - { - LivingEntity entity = itel.next(); - if (entity.isDead() || (entity instanceof Player && !Manager.IsAlive((Player) entity))) + "Your arrows enchanted with gravity magic.", "Victims find it hard to lift", "Their bodies are sluggish" + }, new Perk[] { - itel.remove(); - continue; - } - entity.setVelocity(entity.getVelocity().add(new Vector(0, -1, 0))); - if (_secondsPinned.get(entity) <= 1) - { - itel.remove(); - } - else - { - _secondsPinned.put(entity, _secondsPinned.get(entity) - 1); - } - } - } - - @EventHandler(ignoreCancelled = true) - public void onDamage(CustomDamageEvent event) - { - if (event.GetCause() == DamageCause.PROJECTILE) - { - Player player = event.GetDamagerPlayer(true); - if (player != null && this.HasKit(player)) - { - LivingEntity entity = event.GetDamageeEntity(); - entity.setVelocity(entity.getVelocity().add(new Vector(0, -1, 0))); - entity.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 40, 1), true); - _secondsPinned.put(entity, 8); - } - } + new PerkPinned() + }, EntityType.SKELETON, new ItemStack(Material.OBSIDIAN)); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/bow/KitPunch.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/bow/KitPunch.java index 5d387ffd5..bc34be770 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/bow/KitPunch.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/bow/KitPunch.java @@ -6,6 +6,7 @@ import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.games.castlesiege.kits.KitHuman; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.perks.PerkKnockbackArrow; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -26,20 +27,10 @@ public class KitPunch extends KitHuman { "Your bow is super stretchy", "Your arrows are huge", "What does this mean?", "Your arrows will knock em flying!" - }, new Perk[0], EntityType.SKELETON, new ItemStack(Material.FENCE)); - } - - @EventHandler(ignoreCancelled = true) - public void onDamage(CustomDamageEvent event) - { - if (event.GetCause() == DamageCause.PROJECTILE) - { - Player player = event.GetDamagerPlayer(true); - if (player != null && this.HasKit(player)) + }, new Perk[] { - event.AddKnockback("Punch", 2.5D); - } - } + new PerkKnockbackArrow(2.5D) + }, EntityType.SKELETON, new ItemStack(Material.FENCE)); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/bow/KitSharpshooter.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/bow/KitSharpshooter.java new file mode 100644 index 000000000..ca8e93455 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/bow/KitSharpshooter.java @@ -0,0 +1,41 @@ +package nautilus.game.arcade.game.games.searchanddestroy.kits.bow; + +import mineplex.core.itemstack.ItemBuilder; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.castlesiege.kits.KitHuman; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.perks.PerkSharpshooter; + +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.PlayerInventory; + +public class KitSharpshooter extends KitHuman +{ + public KitSharpshooter(ArcadeManager manager) + { + super(manager, "Sharpshooter", KitAvailability.Hide, new String[] + { + "Each consecutive arrow hit deals an additional 2 damage.", + "Max of +6. Missing an arrow resets the count to 0." + }, new Perk[] + { + new PerkSharpshooter() + }, EntityType.SKELETON, new ItemStack(Material.FLINT)); + } + + @Override + public void GiveItems(Player player) + { + PlayerInventory inv = player.getInventory(); + inv.addItem(new ItemBuilder(Material.BLAZE_POWDER).setTitle(ChatColor.GOLD + "Fuse").build()); + inv.addItem(new ItemBuilder(Material.BOW).setUnbreakable(true).addEnchantment(Enchantment.ARROW_INFINITE, 1).build()); + inv.setItem(9, new ItemStack(Material.ARROW, 1)); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/bow/KitSniper.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/bow/KitSniper.java index 11b74ae49..5bf9d2726 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/bow/KitSniper.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/bow/KitSniper.java @@ -6,6 +6,7 @@ import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.games.castlesiege.kits.KitHuman; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.perks.PerkSniper; import org.bukkit.ChatColor; import org.bukkit.Location; @@ -31,37 +32,10 @@ public class KitSniper extends KitHuman super(manager, "Sniper", KitAvailability.Hide, new String[] { "Arrows do 0.1 damage per block travelled.", "Shoot from afar to score major damage!" - }, new Perk[0], EntityType.SKELETON, new ItemStack(Material.ARROW)); - } - - @EventHandler - public void onShoot(ProjectileLaunchEvent event) - { - Projectile entity = event.getEntity(); - if (entity instanceof Arrow && entity.getShooter() instanceof Player && HasKit((Player) entity.getShooter())) - { - entity.setMetadata("ShotFrom", - new FixedMetadataValue(Manager.GetPlugin(), ((Player) entity.getShooter()).getLocation())); - } - } - - @EventHandler(ignoreCancelled = true) - public void onDamage(CustomDamageEvent event) - { - if (event.GetCause() == DamageCause.PROJECTILE) - { - Entity entity = event.GetProjectile(); - if (entity != null && entity.hasMetadata("ShotFrom")) + }, new Perk[] { - // TODO Remove orig damage - event.AddMod("AntiNormal", "AntiNormal", -event.GetDamageInitial(), false); - event.AddMod( - "Sniper", - "Sniper", - event.GetDamageeEntity().getLocation().distance((Location) entity.getMetadata("ShotFrom").get(0).value()) / 10, - true); - } - } + new PerkSniper() + }, EntityType.SKELETON, new ItemStack(Material.ARROW)); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/bow/KitStitcher.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/bow/KitStitcher.java index 8ecc6e31b..4aae8730f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/bow/KitStitcher.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/bow/KitStitcher.java @@ -1,91 +1,31 @@ package nautilus.game.arcade.game.games.searchanddestroy.kits.bow; -import java.util.Iterator; - -import mineplex.core.common.util.NautHashMap; import mineplex.core.itemstack.ItemBuilder; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.games.castlesiege.kits.KitHuman; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.perks.PerkRangedBleeding; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.EntityType; -import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; public class KitStitcher extends KitHuman { - - private NautHashMap _secondsBleeding = new NautHashMap(); - public KitStitcher(ArcadeManager manager) { super(manager, "Stitcher", KitAvailability.Hide, new String[] { - "Your arrows tend to hit people in tender places.", - "Its only logical they are going to start bleeding isn't it?" - }, new Perk[0], EntityType.SKELETON, new ItemStack(Material.INK_SACK, 1, (short) 14)); - } - - @EventHandler - public void onSecond(UpdateEvent event) - { - if (event.getType() != UpdateType.SEC) - { - return; - } - - Iterator itel = _secondsBleeding.keySet().iterator(); - while (itel.hasNext()) - { - LivingEntity entity = itel.next(); - if (entity.isDead() || (entity instanceof Player && !Manager.IsAlive((Player) entity))) + "People bleed when your arrows hit them","1 heart per second, 2 seconds per arrow." + }, new Perk[] { - itel.remove(); - continue; - } - Manager.GetDamage().NewDamageEvent(entity, null, null, DamageCause.CUSTOM, 2, false, true, true, "Bleed", - "Stitcher Bleeding"); - if (_secondsBleeding.get(entity) <= 1) - { - itel.remove(); - } - else - { - _secondsBleeding.put(entity, _secondsBleeding.get(entity) - 1); - } - } - } - - @EventHandler(ignoreCancelled = true) - public void onDamage(CustomDamageEvent event) - { - if (event.GetCause() == DamageCause.PROJECTILE) - { - Player player = event.GetDamagerPlayer(true); - if (player != null && this.HasKit(player)) - { - LivingEntity entity = event.GetDamageeEntity(); - if (!_secondsBleeding.containsKey(entity)) - { - _secondsBleeding.put(entity, 2); - } - else - { - _secondsBleeding.put(entity, _secondsBleeding.get(entity) + 2); - } - } - } + new PerkRangedBleeding() + }, EntityType.SKELETON, new ItemStack(Material.INK_SACK, 1, (short) 14)); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/bow/KitThunderstorm.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/bow/KitThunderstorm.java new file mode 100644 index 000000000..b42682ee8 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/bow/KitThunderstorm.java @@ -0,0 +1,41 @@ +package nautilus.game.arcade.game.games.searchanddestroy.kits.bow; + +import mineplex.core.itemstack.ItemBuilder; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.castlesiege.kits.KitHuman; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.perks.PerkBarrage; + +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.PlayerInventory; + +public class KitThunderstorm extends KitHuman +{ + public KitThunderstorm(ArcadeManager manager) + { + super(manager, "Thunderstorm", KitAvailability.Hide, new String[] + { + "Chargeup your bow to release a barrage of arrows." + "The longer you charge your bow" + + "The more arrows are added to the barrage." + }, new Perk[] + { + new PerkBarrage(10, 400, false, false, true) + }, EntityType.SKELETON, new ItemStack(Material.ARROW, 16)); + } + + @Override + public void GiveItems(Player player) + { + PlayerInventory inv = player.getInventory(); + inv.addItem(new ItemBuilder(Material.BLAZE_POWDER).setTitle(ChatColor.GOLD + "Fuse").build()); + inv.addItem(new ItemBuilder(Material.BOW).setUnbreakable(true).addEnchantment(Enchantment.ARROW_INFINITE, 1).build()); + inv.setItem(9, new ItemStack(Material.ARROW, 1)); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/rogue/KitRogue.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/rogue/KitRogue.java new file mode 100644 index 000000000..8cdd55ccd --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/rogue/KitRogue.java @@ -0,0 +1,29 @@ +package nautilus.game.arcade.game.games.searchanddestroy.kits.rogue; + +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +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 KitRogue extends Kit +{ + + public KitRogue(ArcadeManager manager) + { + super(manager, "Rogue", KitAvailability.Free, new String[] + {}, new Perk[0], EntityType.ZOMBIE, new ItemStack(Material.WOOD_SWORD)); + // TODO Auto-generated constructor stub + } + + @Override + public void GiveItems(Player player) + { + + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/trooper/KitAssault.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/trooper/KitAssault.java new file mode 100644 index 000000000..03161f8cf --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/trooper/KitAssault.java @@ -0,0 +1,33 @@ +package nautilus.game.arcade.game.games.searchanddestroy.kits.trooper; + +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.PlayerInventory; + +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 KitAssault extends Kit +{ + + public KitAssault(ArcadeManager manager) + { + super(manager, "Assault", KitAvailability.Free, new String[] + { + "Bulls Charge ability.", "Temperary speed boost when activated.", "When attacking with the boost on", + "The victim is stunned and slows down" + }, new Perk[0], EntityType.ZOMBIE, new ItemStack(Material.IRON_SWORD)); + } + + @Override + public void GiveItems(Player player) + { + PlayerInventory inv = player.getInventory(); + inv.addItem(new ItemStack(Material.IRON_SWORD)); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/trooper/KitTrooper.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/trooper/KitTrooper.java new file mode 100644 index 000000000..7cba47ada --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/trooper/KitTrooper.java @@ -0,0 +1,33 @@ +package nautilus.game.arcade.game.games.searchanddestroy.kits.trooper; + +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.PlayerInventory; + +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 KitTrooper extends Kit +{ + + public KitTrooper(ArcadeManager manager) + { + super(manager, "Trooper", KitAvailability.Free, new String[] + { + "Full iron armor and 2 golden apples" + }, new Perk[0], EntityType.ZOMBIE, new ItemStack(Material.IRON_SWORD)); + } + + @Override + public void GiveItems(Player player) + { + PlayerInventory inv = player.getInventory(); + inv.addItem(new ItemStack(Material.IRON_SWORD)); + inv.addItem(new ItemStack(Material.GOLDEN_APPLE, 2)); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBarrage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBarrage.java index 0e55f9e15..7471b9dfc 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBarrage.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBarrage.java @@ -30,237 +30,259 @@ import nautilus.game.arcade.kit.Perk; public class PerkBarrage extends Perk { - private WeakHashMap _charge = new WeakHashMap(); - private WeakHashMap _chargeLast = new WeakHashMap(); + private WeakHashMap _charge = new WeakHashMap(); + private WeakHashMap _chargeLast = new WeakHashMap(); - private HashSet _firing = new HashSet(); - private HashSet _arrows = new HashSet(); + private HashSet _firing = new HashSet(); + private HashSet _arrows = new HashSet(); - private int _max; - private long _tick; - private boolean _remove; - private boolean _noDelay; - - public PerkBarrage(int max, long tick, boolean remove, boolean noDelay) - { - super("Barrage", new String[] - { - C.cYellow + "Charge" + C.cGray + " your Bow to use " + C.cGreen + "Barrage" - }); - - _max = max; - _tick = tick; - _remove = remove; - _noDelay = noDelay; - } + private int _max; + private long _tick; + private boolean _remove; + private boolean _noDelay; + private boolean _useExp; - @EventHandler - public void BarrageDrawBow(PlayerInteractEvent event) - { - Player player = event.getPlayer(); + public PerkBarrage(int max, long tick, boolean remove, boolean noDelay) + { + this(max, tick, remove, noDelay, false); + } - if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) - return; + public PerkBarrage(int max, long tick, boolean remove, boolean noDelay, boolean useExpAndBar) + { + super("Barrage", new String[] + { + C.cYellow + "Charge" + C.cGray + " your Bow to use " + C.cGreen + "Barrage" + }); + _useExp = useExpAndBar; + _max = max; + _tick = tick; + _remove = remove; + _noDelay = noDelay; + } - if (player.getItemInHand() == null || player.getItemInHand().getType() != Material.BOW) - return; + @EventHandler + public void BarrageDrawBow(PlayerInteractEvent event) + { + Player player = event.getPlayer(); - if (!Kit.HasKit(player)) - return; + if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) + return; - if (!player.getInventory().contains(Material.ARROW)) - return; + if (player.getItemInHand() == null || player.getItemInHand().getType() != Material.BOW) + return; - if (event.getClickedBlock() != null) - if (UtilBlock.usable(event.getClickedBlock())) - return; + if (!Kit.HasKit(player)) + return; - //Start Charge - _charge.put(player, 0); - _chargeLast.put(player, System.currentTimeMillis()); - _firing.remove(player); - } + if (!player.getInventory().contains(Material.ARROW)) + return; - @EventHandler - public void BarrageCharge(UpdateEvent event) - { - if (event.getType() != UpdateType.TICK) - return; + if (event.getClickedBlock() != null) + if (UtilBlock.usable(event.getClickedBlock())) + return; - for (Player cur : UtilServer.getPlayers()) - { - //Not Charging - if (!_charge.containsKey(cur)) - continue; + // Start Charge + _charge.put(player, 0); + _chargeLast.put(player, System.currentTimeMillis()); + _firing.remove(player); + } - if (_firing.contains(cur)) - continue; + @EventHandler + public void BarrageCharge(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; - //Max Charge - if (_charge.get(cur) >= _max) - continue; + for (Player cur : UtilServer.getPlayers()) + { + // Not Charging + if (!_charge.containsKey(cur)) + continue; - //Charge Interval - if (_charge.get(cur) == 0) - { - if (!UtilTime.elapsed(_chargeLast.get(cur), 1000)) - continue; - } - else - { - if (!UtilTime.elapsed(_chargeLast.get(cur), _tick)) - continue; - } + if (_firing.contains(cur)) + continue; - //No Longer Holding Bow - if (cur.getItemInHand() == null || cur.getItemInHand().getType() != Material.BOW) - { - _charge.remove(cur); - _chargeLast.remove(cur); - continue; - } + // Max Charge + if (_charge.get(cur) >= _max) + continue; - //Increase Charge - _charge.put(cur, _charge.get(cur) + 1); - _chargeLast.put(cur, System.currentTimeMillis()); + // Charge Interval + if (_charge.get(cur) == 0) + { + if (!UtilTime.elapsed(_chargeLast.get(cur), 1000)) + continue; + } + else + { + if (!UtilTime.elapsed(_chargeLast.get(cur), _tick)) + continue; + } - //Effect - cur.playSound(cur.getLocation(), Sound.CLICK, 1f, 1f + (0.1f * _charge.get(cur))); - } - } + // No Longer Holding Bow + if (cur.getItemInHand() == null || cur.getItemInHand().getType() != Material.BOW) + { + if (_useExp) + { + cur.setLevel(_charge.get(cur)); + } + _charge.remove(cur); + _chargeLast.remove(cur); + continue; + } - @EventHandler(priority = EventPriority.HIGH) - public void BarrageFireBow(EntityShootBowEvent event) - { - if (event.isCancelled()) - return; - - if (!Manager.GetGame().IsLive()) - return; - - if (!(event.getEntity() instanceof Player)) - return; + // Increase Charge + _charge.put(cur, _charge.get(cur) + 1); - if (!(event.getProjectile() instanceof Arrow)) - return; + if (_useExp) + { + cur.setLevel(_charge.get(cur)); + } + _chargeLast.put(cur, System.currentTimeMillis()); - Player player = (Player)event.getEntity(); + // Effect + cur.playSound(cur.getLocation(), Sound.CLICK, 1f, 1f + (0.1f * _charge.get(cur))); + } + } - if (!_charge.containsKey(player)) - return; + @EventHandler(priority = EventPriority.HIGH) + public void BarrageFireBow(EntityShootBowEvent event) + { + if (event.isCancelled()) + return; - //Start Barrage - _firing.add(player); - _chargeLast.put(player, System.currentTimeMillis()); - } + if (!Manager.GetGame().IsLive()) + return; - @EventHandler - public void BarrageArrows(UpdateEvent event) - { - if (event.getType() != UpdateType.TICK) - return; + if (!(event.getEntity() instanceof Player)) + return; - HashSet remove = new HashSet(); + if (!(event.getProjectile() instanceof Arrow)) + return; - for (Player cur : _firing) - { - if (!_charge.containsKey(cur) || !_chargeLast.containsKey(cur)) - { - remove.add(cur); - continue; - } + Player player = (Player) event.getEntity(); - if (cur.getItemInHand() == null || cur.getItemInHand().getType() != Material.BOW) - { - remove.add(cur); - continue; - } + if (!_charge.containsKey(player)) + return; - int arrows = _charge.get(cur); - if (arrows <= 0) - { - remove.add(cur); - continue; - } + // Start Barrage + _firing.add(player); + _chargeLast.put(player, System.currentTimeMillis()); + } - _charge.put(cur, arrows-1); + @EventHandler + public void BarrageArrows(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; - //Fire Arrow - Vector random = new Vector((Math.random()-0.5)/10, (Math.random()-0.5)/10, (Math.random()-0.5)/10); - Projectile arrow = cur.launchProjectile(Arrow.class); - arrow.setVelocity(cur.getLocation().getDirection().add(random).multiply(3)); - _arrows.add(arrow); - cur.getWorld().playSound(cur.getLocation(), Sound.SHOOT_ARROW, 1f, 1f); - } + HashSet remove = new HashSet(); - for (Player cur : remove) - { - _charge.remove(cur); - _chargeLast.remove(cur); - _firing.remove(cur); - } - } - - @EventHandler(priority = EventPriority.HIGH) - public void BarrageDamageTime(CustomDamageEvent event) - { - if (!_noDelay) - return; - - if (event.GetProjectile() == null) - return; + for (Player cur : _firing) + { + if (!_charge.containsKey(cur) || !_chargeLast.containsKey(cur)) + { + remove.add(cur); + continue; + } - if (event.GetDamagerPlayer(true) == null) - return; + if (cur.getItemInHand() == null || cur.getItemInHand().getType() != Material.BOW) + { + remove.add(cur); + continue; + } - if (!(event.GetProjectile() instanceof Arrow)) - return; + int arrows = _charge.get(cur); + if (arrows <= 0) + { + remove.add(cur); + continue; + } - Player damager = event.GetDamagerPlayer(true); + _charge.put(cur, arrows - 1); + if (_useExp) + { + cur.setLevel(_charge.get(cur)); + } - if (!Kit.HasKit(damager)) - return; + // Fire Arrow + Vector random = new Vector((Math.random() - 0.5) / 10, (Math.random() - 0.5) / 10, (Math.random() - 0.5) / 10); + Projectile arrow = cur.launchProjectile(Arrow.class); + arrow.setVelocity(cur.getLocation().getDirection().add(random).multiply(3)); + _arrows.add(arrow); + cur.getWorld().playSound(cur.getLocation(), Sound.SHOOT_ARROW, 1f, 1f); + } - event.SetCancelled("Barrage Cancel"); - - event.GetProjectile().remove(); - - //Damage Event - Manager.GetDamage().NewDamageEvent(event.GetDamageeEntity(), damager, null, - DamageCause.THORNS, event.GetDamage(), true, true, false, - damager.getName(), GetName()); - } + for (Player cur : remove) + { + if (_useExp) + { + cur.setLevel(0); + } + _charge.remove(cur); + _chargeLast.remove(cur); + _firing.remove(cur); + } + } - @EventHandler - public void BarrageProjectileHit(ProjectileHitEvent event) - { - if (_remove) - if (_arrows.remove(event.getEntity())) - event.getEntity().remove(); - } + @EventHandler(priority = EventPriority.HIGH) + public void BarrageDamageTime(CustomDamageEvent event) + { + if (!_noDelay) + return; - @EventHandler - public void BarrageClean(UpdateEvent event) - { - if (event.getType() != UpdateType.SEC) - return; + if (event.GetProjectile() == null) + return; - for (Iterator arrowIterator = _arrows.iterator(); arrowIterator.hasNext();) - { - Projectile arrow = arrowIterator.next(); + if (event.GetDamagerPlayer(true) == null) + return; - if (arrow.isDead() || !arrow.isValid()) - arrowIterator.remove(); - } - } + if (!(event.GetProjectile() instanceof Arrow)) + return; - @EventHandler - public void Quit(PlayerQuitEvent event) - { - Player player = event.getPlayer(); + Player damager = event.GetDamagerPlayer(true); - _charge.remove(player); - _chargeLast.remove(player); - _firing.remove(player); - } + if (!Kit.HasKit(damager)) + return; + + event.SetCancelled("Barrage Cancel"); + + event.GetProjectile().remove(); + + // Damage Event + Manager.GetDamage().NewDamageEvent(event.GetDamageeEntity(), damager, null, DamageCause.THORNS, event.GetDamage(), true, + true, false, damager.getName(), GetName()); + } + + @EventHandler + public void BarrageProjectileHit(ProjectileHitEvent event) + { + if (_remove) + if (_arrows.remove(event.getEntity())) + event.getEntity().remove(); + } + + @EventHandler + public void BarrageClean(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + return; + + for (Iterator arrowIterator = _arrows.iterator(); arrowIterator.hasNext();) + { + Projectile arrow = arrowIterator.next(); + + if (arrow.isDead() || !arrow.isValid()) + arrowIterator.remove(); + } + } + + @EventHandler + public void Quit(PlayerQuitEvent event) + { + Player player = event.getPlayer(); + + _charge.remove(player); + _chargeLast.remove(player); + _firing.remove(player); + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPinned.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPinned.java new file mode 100644 index 000000000..f43c615c4 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkPinned.java @@ -0,0 +1,76 @@ +package nautilus.game.arcade.kit.perks; + +import java.util.Iterator; + +import mineplex.core.common.util.NautHashMap; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.kit.Perk; + +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.bukkit.util.Vector; + +public class PerkPinned extends Perk +{ + + public PerkPinned() + { + super("Pinned", new String[] + { + "Gravity is suddenly much stronger", "You also have a hard time moving" + }); + } + + private NautHashMap _secondsPinned = new NautHashMap(); + + @EventHandler + public void onSecond(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTER) + { + return; + } + + Iterator itel = _secondsPinned.keySet().iterator(); + while (itel.hasNext()) + { + LivingEntity entity = itel.next(); + if (entity.isDead() || (entity instanceof Player && !Manager.IsAlive((Player) entity))) + { + itel.remove(); + continue; + } + entity.setVelocity(entity.getVelocity().add(new Vector(0, -1, 0))); + if (_secondsPinned.get(entity) <= 1) + { + itel.remove(); + } + else + { + _secondsPinned.put(entity, _secondsPinned.get(entity) - 1); + } + } + } + + @EventHandler(ignoreCancelled = true) + public void onDamage(CustomDamageEvent event) + { + if (event.GetCause() == DamageCause.PROJECTILE) + { + Player player = event.GetDamagerPlayer(true); + if (player != null && this.Kit.HasKit(player)) + { + LivingEntity entity = event.GetDamageeEntity(); + entity.setVelocity(entity.getVelocity().add(new Vector(0, -1, 0))); + entity.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 40, 1), true); + _secondsPinned.put(entity, 8); + } + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkRangedBleeding.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkRangedBleeding.java new file mode 100644 index 000000000..817bcb027 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkRangedBleeding.java @@ -0,0 +1,80 @@ +package nautilus.game.arcade.kit.perks; + +import java.util.Iterator; + +import mineplex.core.common.util.NautHashMap; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.kit.Perk; + +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +public class PerkRangedBleeding extends Perk +{ + + public PerkRangedBleeding() + { + super("Bleeding", new String[] + { + "After being hit by a arrow", "You will bleed for a few seconds" + }); + } + + @EventHandler + public void onSecond(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } + + Iterator itel = _secondsBleeding.keySet().iterator(); + while (itel.hasNext()) + { + LivingEntity entity = itel.next(); + if (entity.isDead() || (entity instanceof Player && !Manager.IsAlive((Player) entity))) + { + itel.remove(); + continue; + } + Manager.GetDamage().NewDamageEvent(entity, null, null, DamageCause.CUSTOM, 2, false, true, true, "Bleed", + "Stitcher Bleeding"); + if (_secondsBleeding.get(entity) <= 1) + { + itel.remove(); + } + else + { + _secondsBleeding.put(entity, _secondsBleeding.get(entity) - 1); + } + } + } + + private NautHashMap _secondsBleeding = new NautHashMap(); + + @EventHandler(ignoreCancelled = true) + public void onDamage(CustomDamageEvent event) + { + if (event.GetCause() == DamageCause.PROJECTILE) + { + Player player = event.GetDamagerPlayer(true); + if (player != null && Kit.HasKit(player)) + { + LivingEntity entity = event.GetDamageeEntity(); + if (!_secondsBleeding.containsKey(entity)) + { + _secondsBleeding.put(entity, 4); + } + else + { + _secondsBleeding.put(entity, _secondsBleeding.get(entity) + 4); + } + } + } + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSharpshooter.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSharpshooter.java new file mode 100644 index 000000000..161bc476b --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSharpshooter.java @@ -0,0 +1,121 @@ +package nautilus.game.arcade.kit.perks; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.WeakHashMap; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.kit.Perk; + +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + +public class PerkSharpshooter extends Perk +{ + private WeakHashMap _hitCount = new WeakHashMap(); + private HashMap _arrows = new HashMap(); + + public PerkSharpshooter() + { + super("Sharpshooter", new String[] + { + "Consecutive arrow hits deal an", "additional 2 damage.", "", "Stacks up to 6 times", "", + "Missing an arrow resets the bonus.", + }); + } + + @EventHandler + public void ShootBow(EntityShootBowEvent event) + { + if (!(event.getEntity() instanceof Player)) + return; + + if (!Kit.HasKit((Player) event.getEntity())) + return; + + // Store + _arrows.put(event.getProjectile(), (Player) event.getEntity()); + } + + @EventHandler(priority = EventPriority.HIGH) + public void Damage(CustomDamageEvent event) + { + if (event.IsCancelled()) + return; + + if (event.GetCause() != DamageCause.PROJECTILE) + return; + + Projectile projectile = event.GetProjectile(); + if (projectile == null) + return; + + if (!_arrows.containsKey(projectile)) + return; + + Player player = _arrows.remove(projectile); + + if (_hitCount.containsKey(player)) + { + // Damage + event.AddMod(player.getName(), GetName(), _hitCount.get(player) * 2, true); + + int limit = Math.min(6, _hitCount.get(player) + 1); + + _hitCount.put(player, limit); + + // Inform + UtilPlayer.message( + (Entity) projectile.getShooter(), + GetName() + ": " + F.elem(_hitCount.get(player) + " Consecutive Hits") + C.cGray + " (" + + F.skill("+" + (limit * 2) + " Damage") + C.cGray + ")"); + } + else + { + _hitCount.put(player, 1); + } + + projectile.remove(); + } + + @EventHandler + public void Clean(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + HashSet remove = new HashSet(); + + Iteratoritel = this._hitCount.keySet().iterator(); + while (itel.hasNext()) { + Player p = itel.next(); + if (!Kit.HasKit(p) || !this.Manager.IsAlive(p)) { + itel.remove(); + } + } + + for (Entity cur : _arrows.keySet()) + if (cur.isDead() || !cur.isValid() || cur.isOnGround()) + remove.add(cur); + + for (Entity cur : remove) + { + Player player = _arrows.remove(cur); + + if (player != null) + if (_hitCount.remove(player) != null) + UtilPlayer.message(player, GetName() + ": " + F.elem("0 Consecutive Hits")); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSniper.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSniper.java new file mode 100644 index 000000000..5cb2def94 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkSniper.java @@ -0,0 +1,69 @@ +package nautilus.game.arcade.kit.perks; + +import mineplex.core.common.util.UtilMath; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.kit.Perk; + +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.metadata.FixedMetadataValue; + +public class PerkSniper extends Perk +{ + public PerkSniper() + { + super("Sniper", new String[] + { + "The further your arrow travels", "The more damage it does!" + }); + } + + @EventHandler + public void ShootBow(EntityShootBowEvent event) + { + if (!(event.getEntity() instanceof Player)) + return; + + if (!Kit.HasKit((Player) event.getEntity())) + return; + + // Save + event.getProjectile().setMetadata("ShotFrom", + new FixedMetadataValue(this.Manager.GetPlugin(), event.getProjectile().getLocation())); + } + + @EventHandler(priority = EventPriority.HIGH) + public void Damage(CustomDamageEvent event) + { + if (event.IsCancelled()) + return; + + if (event.GetCause() != DamageCause.PROJECTILE) + return; + + Projectile projectile = event.GetProjectile(); + if (projectile == null) + return; + + if (!projectile.hasMetadata("ShotFrom")) + return; + + Player damager = event.GetDamagerPlayer(true); + if (damager == null) + return; + + Location loc = (Location) projectile.getMetadata("ShotFrom").get(0).value(); + double length = UtilMath.offset(loc, projectile.getLocation()); + + length /= 13; + // Damage + double damage = Math.max(event.GetDamageInitial(), Math.pow(length, length)); + + event.AddMod(damager.getName(), "Sniper", damage, damage > 0); + } +}