From 3212b75e4e14ea760388020d3e8e8dd17011c4bf Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 12 Mar 2016 09:35:44 -0500 Subject: [PATCH] - Finally finished all of chiss' changes --- .../game/games/minecraftleague/DataLoc.java | 22 +- .../minecraftleague/MinecraftLeague.java | 323 ++++++++++-------- .../minecraftleague/data/DefenderAI.java | 171 ++++++++++ .../minecraftleague/data/OreGenerator.java | 39 +++ .../minecraftleague/data/TeamCrystal.java | 243 +------------ .../games/minecraftleague/data/TeamTower.java | 17 + .../minecraftleague/data/TeamTowerBase.java | 272 +++++++++++++++ .../minecraftleague/data/TowerManager.java | 181 ++++++++++ .../variation/VariationManager.java | 11 +- .../variation/VariationType.java | 12 +- .../variation/wither/WitherVariation.java | 18 +- .../variation/wither/data/TeamAltar.java | 70 ++-- .../wither/data/WitherMinionManager.java | 12 +- .../wither/data/WitherPathfinder.java | 58 ++-- 14 files changed, 978 insertions(+), 471 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/DefenderAI.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/OreGenerator.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamTower.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamTowerBase.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TowerManager.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/DataLoc.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/DataLoc.java index bc0270002..3eb439b3e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/DataLoc.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/DataLoc.java @@ -1,22 +1,26 @@ package nautilus.game.arcade.game.games.minecraftleague; - public enum DataLoc { //Base - RED_CRYSTAL("RED"), - BLUE_CRYSTAL("BLUE"), - VARIANT_ID("ORANGE"), - RED_BEACON("PINK"), - BLUE_BEACON("CYAN"), + RED_CRYSTAL("RED CRYSTAL"), + RED_TOWER("RED TOWER"), + BLUE_CRYSTAL("BLUE CRYSTAL"), + BLUE_TOWER("BLUE TOWER"), + VARIANT_BASE("GAMEMODE "), + //RED_BEACON("PINK"), + /*BLUE_*/BEACON("CYAN"), SKELETON_SPAWNER("BROWN"), - MAP_DIAMOND("LIGHT_BLUE"), - MAP_IRON("SILVER"), + //MAP_DIAMOND("LIGHT_BLUE"), + //MAP_IRON("SILVER"), + RED_ORE("15"), + BLUE_ORE("14"), //Wither WITHER_WAYPOINT("PURPLE"), + TOWER_WAYPOINT("$team$ TOWER $number$"), WITHER_SKELETON("BLACK"), - BLUE_ALTAR("GREEN"), + BLUE_ALTAR("LIME"), RED_ALTAR("YELLOW") ; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java index 99bb4dbf1..172ea19bd 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/MinecraftLeague.java @@ -2,7 +2,6 @@ package nautilus.game.arcade.game.games.minecraftleague; import java.util.ArrayList; import java.util.List; -import java.util.Random; import java.util.concurrent.ConcurrentHashMap; import mineplex.core.common.util.C; @@ -12,6 +11,7 @@ import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilItem; +import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; @@ -35,8 +35,9 @@ import nautilus.game.arcade.game.games.minecraftleague.data.BlockProtection; import nautilus.game.arcade.game.games.minecraftleague.data.OreDeposit; import nautilus.game.arcade.game.games.minecraftleague.data.PlayerRespawnPoint; import nautilus.game.arcade.game.games.minecraftleague.data.Spawner; -import nautilus.game.arcade.game.games.minecraftleague.data.TeamBeacon; import nautilus.game.arcade.game.games.minecraftleague.data.TeamCrystal; +import nautilus.game.arcade.game.games.minecraftleague.data.TeamTowerBase; +import nautilus.game.arcade.game.games.minecraftleague.data.TowerManager; import nautilus.game.arcade.game.games.minecraftleague.data.map.ItemMapManager; import nautilus.game.arcade.game.games.minecraftleague.kit.KitPlayer; import nautilus.game.arcade.game.games.minecraftleague.variation.ExtraScoreboardData; @@ -94,11 +95,10 @@ import com.google.common.base.Objects; public class MinecraftLeague extends TeamGame { - private ConcurrentHashMap _crystals = new ConcurrentHashMap(); private ConcurrentHashMap _customRespawns = new ConcurrentHashMap(); //private ConcurrentHashMap _maps = new ConcurrentHashMap(); private ConcurrentHashMap> _gear = new ConcurrentHashMap>(); - private ConcurrentHashMap _beacons = new ConcurrentHashMap(); + //private ConcurrentHashMap _beacons = new ConcurrentHashMap(); private ConcurrentHashMap _blockLock = new ConcurrentHashMap(); private ConcurrentHashMap _spawnAllow = new ConcurrentHashMap(); private List _spawners = new ArrayList(); @@ -116,6 +116,9 @@ public class MinecraftLeague extends TeamGame private VariationManager _vman; private FreezeManager _freeze; + private TowerManager _tower; + + private final CreatureType[] _passive = new CreatureType[] {CreatureType.CHICKEN, CreatureType.COW, CreatureType.PIG, CreatureType.RABBIT, CreatureType.SHEEP}; public MinecraftLeague(ArcadeManager manager) { @@ -179,6 +182,7 @@ public class MinecraftLeague extends TeamGame _vman = new VariationManager(this); _freeze = new FreezeManager(); + _tower = new TowerManager(this); Bukkit.getPluginManager().registerEvents(_freeze, manager.getPlugin()); } @@ -363,14 +367,25 @@ public class MinecraftLeague extends TeamGame return ret; } - public int getMapVariantID() + public List getMapVariantIDS() { - return WorldData.GetDataLocs(DataLoc.VARIANT_ID.getKey()).size(); + List ids = new ArrayList(); + for (String s : WorldData.GetAllCustomLocs().keySet()) + { + if (s.contains(DataLoc.VARIANT_BASE.getKey())) + ids.add(s); + } + return ids; } - public TeamCrystal getCrystal(GameTeam team) + public TeamTowerBase getActiveTower(GameTeam team) { - return _crystals.get(team); + return _tower.getVulnerable(team); + } + + public TowerManager getTowerManager() + { + return _tower; } public FreezeManager getFreezeManager() @@ -385,29 +400,25 @@ public class MinecraftLeague extends TeamGame @Override public void ParseData() - { - Location redLoc = WorldData.GetDataLocs(DataLoc.RED_CRYSTAL.getKey()).get(0); - Location blueLoc = WorldData.GetDataLocs(DataLoc.BLUE_CRYSTAL.getKey()).get(0); + { + _tower.parseTowers(WorldData); - _crystals.put(GetTeam(ChatColor.RED), new TeamCrystal(this, GetTeam(ChatColor.RED), redLoc)); - _crystals.put(GetTeam(ChatColor.AQUA), new TeamCrystal(this, GetTeam(ChatColor.AQUA), blueLoc)); - - _beacons.put(GetTeam(ChatColor.RED), new TeamBeacon(GetTeam(ChatColor.RED), WorldData.GetDataLocs(DataLoc.RED_BEACON.getKey()).get(0).getBlock(), redLoc)); - _beacons.put(GetTeam(ChatColor.AQUA), new TeamBeacon(GetTeam(ChatColor.AQUA), WorldData.GetDataLocs(DataLoc.BLUE_BEACON.getKey()).get(0).getBlock(), blueLoc)); + //_beacons.put(GetTeam(ChatColor.RED), new TeamBeacon(GetTeam(ChatColor.RED), WorldData.GetDataLocs(DataLoc.RED_BEACON.getKey()).get(0).getBlock(), redLoc)); + //_beacons.put(GetTeam(ChatColor.AQUA), new TeamBeacon(GetTeam(ChatColor.AQUA), WorldData.GetDataLocs(DataLoc.BLUE_BEACON.getKey()).get(0).getBlock(), blueLoc)); for (Location loc : WorldData.GetDataLocs(DataLoc.SKELETON_SPAWNER.getKey())) { _spawners.add(new Spawner(this, loc, EntityType.SKELETON)); } - for (Location loc : WorldData.GetDataLocs(DataLoc.MAP_DIAMOND.getKey())) + /*for (Location loc : WorldData.GetDataLocs(DataLoc.MAP_DIAMOND.getKey())) { Ore.add(new OreDeposit(loc, Material.DIAMOND_ORE, new int[] {0, 255, 255})); } for (Location loc : WorldData.GetDataLocs(DataLoc.MAP_IRON.getKey())) { Ore.add(new OreDeposit(loc, Material.IRON_ORE, new int[] {190, 190, 190})); - } + }*/ MapManager = new ItemMapManager(this, WorldData.World, WorldData.MinX, WorldData.MinZ, WorldData.MaxX, WorldData.MaxZ); @@ -456,8 +467,8 @@ public class MinecraftLeague extends TeamGame GameTeam red = GetTeam(ChatColor.RED); GameTeam blue = GetTeam(ChatColor.AQUA); - TeamCrystal redc = _crystals.get(red); - TeamCrystal bluec = _crystals.get(blue); + TeamCrystal redc = (TeamCrystal) _tower.getTeamTowers(red).getLast(); + TeamCrystal bluec = (TeamCrystal) _tower.getTeamTowers(blue).getLast(); _liveTime = Math.max(System.currentTimeMillis() - GetStateTime(), 0); @@ -507,54 +518,16 @@ public class MinecraftLeague extends TeamGame player.teleport(GetTeam(player).GetSpawn()); } - public enum EditType + public boolean handleCommand(Player caller) { - SPAWN, KILL, DAMAGE, STATUS; - } - - public boolean handleCommand(EditType type, GameTeam target, Player caller, Double damage) - { - TeamCrystal crystal = null; - if (target != null) - crystal = _crystals.get(target); - - if (type == EditType.SPAWN) + for (GameTeam team : GetTeamList()) { - if (crystal == null) - return false; - if (crystal.Alive) - return false; - crystal.handleDebug(caller, null, false); + TeamTowerBase tower = _tower.getVulnerable(team); + UtilPlayer.message(caller, team.GetColor() + team.GetName()); + UtilPlayer.message(caller, C.cGray + "Health: " + tower.getHealth()); + UtilPlayer.message(caller, C.cGray + "Alive: " + tower.Alive); } - if (type == EditType.KILL) - { - if (crystal == null) - return false; - if (!crystal.Alive) - return false; - crystal.handleDebug(caller, null, true); - } - if (type == EditType.DAMAGE) - { - if (crystal == null) - return false; - if (!crystal.Alive) - return false; - if (damage == null) - return false; - crystal.handleDebug(caller, damage, false); - } - if (type == EditType.STATUS) - { - for (GameTeam team : _crystals.keySet()) - { - TeamCrystal cr = _crystals.get(team); - UtilPlayer.message(caller, team.GetColor() + team.GetName()); - UtilPlayer.message(caller, C.cGray + "Health: " + cr.getHealth()); - UtilPlayer.message(caller, C.cGray + "Alive: " + cr.Alive); - } - } - + return true; } @@ -563,12 +536,7 @@ public class MinecraftLeague extends TeamGame if (!_gear.containsKey(player)) return; List items = _gear.get(player); - if (items.get(0) == null) - UtilInv.insert(player, new ItemStack(Material.AIR)); - else - UtilInv.insert(player, getNewItemStack(items.get(0))); - - for (int i = 1; i < items.size(); i++) + for (int i = 0; i < 4; i++) { ItemStack item; if (items.get(i) != null) @@ -576,7 +544,7 @@ public class MinecraftLeague extends TeamGame else item = new ItemStack(Material.AIR); - switch(i) + switch(i + 1) { case 1: player.getInventory().setHelmet(getNewItemStack(item)); @@ -592,6 +560,13 @@ public class MinecraftLeague extends TeamGame break; } } + for (int i = 4; i < items.size(); i++) + { + if (items.get(i) == null) + UtilInv.insert(player, new ItemStack(Material.AIR)); + else + UtilInv.insert(player, getNewItemStack(items.get(i))); + } _gear.remove(player); } @@ -703,10 +678,7 @@ public class MinecraftLeague extends TeamGame if (event.getType() == UpdateType.FASTEST) { - for (TeamCrystal crystal : _crystals.values()) - { - crystal.update(); - } + _tower.update(); /*for (TeamMap map : _maps.values()) { @@ -718,10 +690,10 @@ public class MinecraftLeague extends TeamGame spawner.update(); } - for (TeamBeacon beacon : _beacons.values()) + /*for (TeamBeacon beacon : _beacons.values()) { beacon.update(); - } + }*/ if (!OverTime) { @@ -759,14 +731,16 @@ public class MinecraftLeague extends TeamGame player.setFireTicks(-1); player.setFoodLevel(20); } - if (player.getInventory().getType() == InventoryType.BEACON) + if (player.getOpenInventory().getType() == InventoryType.BEACON) player.closeInventory(); + if (player.getFireTicks() > 20 * 3) + player.setFireTicks(20 * 3); } } } @EventHandler - public void crystalDmg(EntityDamageEvent event) + public void towerDmg(EntityDamageEvent event) { if (!InProgress()) return; @@ -774,15 +748,16 @@ public class MinecraftLeague extends TeamGame if (event.getEntity().getType() != EntityType.ENDER_CRYSTAL) return; - for (TeamCrystal cryst : _crystals.values()) - { - if (cryst.isEntity(event.getEntity())) - event.setCancelled(true); - } + for (GameTeam team : GetTeamList()) + for (TeamTowerBase tower : _tower.getTeamTowers(team)) + { + if (tower.isEntity(event.getEntity())) + event.setCancelled(true); + } } @EventHandler - public void crystalDmg(EntityDamageByEntityEvent event) + public void towerDmg(EntityDamageByEntityEvent event) { if (!IsLive()) return; @@ -790,14 +765,15 @@ public class MinecraftLeague extends TeamGame if (event.getEntity().getType() != EntityType.ENDER_CRYSTAL) return; - TeamCrystal crystal = null; - for (TeamCrystal cryst : _crystals.values()) + TeamTowerBase tower = null; + for (GameTeam team : GetTeamList()) + for (TeamTowerBase tow : _tower.getTeamTowers(team)) { - if (cryst.isEntity(event.getEntity())) - crystal = cryst; + if (tower.isEntity(event.getEntity())) + tower = tow; } - if (crystal == null) + if (tower == null) return; event.setCancelled(true); @@ -812,11 +788,17 @@ public class MinecraftLeague extends TeamGame { player = (Player) ((Projectile)event.getDamager()).getShooter(); - if (!crystal.canDamage(player)) + if (!tower.canDamage(player)) return; - if (!crystal.damage(event.getDamage(), player, true)) - player.playSound(crystal.getLocation(), Sound.ORB_PICKUP, 100, 0); + if (!tower.Vulnerable) + { + UtilPlayer.message(player, F.main("Game", "That Tower is protected by the power of another!")); + return; + } + + if (!tower.damage(event.getDamage() / 2, player)) + player.playSound(tower.getLocation(), Sound.ORB_PICKUP, 100, 0); } } } @@ -824,13 +806,19 @@ public class MinecraftLeague extends TeamGame if (event.getDamager() instanceof Player) { player = (Player)event.getDamager(); - if (!crystal.canDamage(player)) + if (!tower.canDamage(player)) return; + if (!tower.Vulnerable) + { + UtilPlayer.message(player, F.main("Game", "That Tower is protected by the power of another!")); + return; + } + if (player.getItemInHand() == null || player.getItemInHand().getType() == Material.AIR) { - if (!crystal.damage(1, player, true)) - player.playSound(crystal.getLocation(), Sound.ZOMBIE_WOODBREAK, 1, 0); + if (!tower.damage(1, player)) + player.playSound(tower.getLocation(), Sound.ZOMBIE_WOODBREAK, 1, 0); return; } @@ -838,8 +826,8 @@ public class MinecraftLeague extends TeamGame int level = player.getItemInHand().getEnchantmentLevel(Enchantment.DAMAGE_ALL); double damage = DamageAmount.getDamageAmount(type).getDamage(level, DamageType.getDamageType(type)); - if (!crystal.damage(damage, player, true)) - player.playSound(crystal.getLocation(), Sound.ZOMBIE_WOODBREAK, 1, 0); + if (!tower.damage(damage, player)) + player.playSound(tower.getLocation(), Sound.ZOMBIE_WOODBREAK, 1, 0); if (DamageAmount.getDamageAmount(type) != DamageAmount.NONE) { @@ -1068,6 +1056,7 @@ public class MinecraftLeague extends TeamGame return; List newDrops = new ArrayList(); + Integer arrows = 0; for (ItemStack item : event.getDrops()) { @@ -1075,11 +1064,26 @@ public class MinecraftLeague extends TeamGame continue; if (_gear.get(event.getEntity()) != null) + { + if (item.getType() == Material.ARROW) + { + arrows += item.getAmount(); + continue; + } if (_gear.get(event.getEntity()).contains(item)) continue; + } newDrops.add(item); } + arrows = arrows / 2; + + while (arrows >= 1) + { + int subtract = Math.min(64, arrows); + newDrops.add(new ItemStack(Material.ARROW, subtract)); + arrows -= subtract; + } event.getDrops().clear(); for (ItemStack item : newDrops) @@ -1104,13 +1108,22 @@ public class MinecraftLeague extends TeamGame } @EventHandler - public void craftMap(PrepareItemCraftEvent event) + public void craftItem(PrepareItemCraftEvent event) { if (!IsLive()) return; if (event.getInventory().getResult().getType() == Material.EMPTY_MAP || event.getInventory().getResult().getType() == Material.MAP) event.getInventory().setResult(new ItemStack(Material.AIR)); + + if (UtilItem.isArmor(event.getInventory().getResult())) + { + event.getInventory().setResult(UtilItem.makeUnbreakable(event.getInventory().getResult())); + } + if (event.getInventory().getResult().getType() == Material.ARROW) + { + event.getInventory().setResult(new ItemStack(Material.ARROW, (event.getInventory().getResult().getAmount() * 2))); + } } @EventHandler @@ -1141,7 +1154,15 @@ public class MinecraftLeague extends TeamGame return; } - Manager.GetCreature().SpawnEntity(event.getLocation(), event.getEntityType()); + EntityType et = event.getEntityType(); + + for (CreatureType pass : _passive) + { + if (pass == event.getCreatureType()) + et = EntityType.CHICKEN; + } + + Manager.GetCreature().SpawnEntity(event.getLocation(), et); if (event.getCreatureType() == CreatureType.SPIDER) { for (int i = 1; i <= 3; i++) @@ -1157,34 +1178,39 @@ public class MinecraftLeague extends TeamGame if (event.GetGame() != this) return; - - for (TeamCrystal c : _crystals.values()) - { - double playercount = GetTeam(ChatColor.RED).GetPlayers(true).size() + GetTeam(ChatColor.AQUA).GetPlayers(true).size(); - c.setMaxHealth(50 * 2 * playercount); - } + + int playercount = GetTeam(ChatColor.RED).GetPlayers(true).size() + GetTeam(ChatColor.AQUA).GetPlayers(true).size(); + _tower.prepareHealth(playercount, 50 * 2); } @EventHandler - public void dropBow(EntityDeathEvent event) + public void dropBowStuff(EntityDeathEvent event) { - if (event.getEntityType() != EntityType.SKELETON) - return; - - boolean addbow = true; - for (ItemStack check : event.getDrops()) + /*if (event.getEntityType() == EntityType.SKELETON) { - if (check.getType() == Material.BOW) - addbow = false; - } - - if (addbow) + boolean addbow = true; + for (ItemStack check : event.getDrops()) + { + if (check.getType() == Material.BOW) + addbow = false; + } + + if (addbow) + { + if (new Random().nextDouble() > .75) + event.getDrops().add(new ItemStack(Material.BOW)); + } + + event.getDrops().add(new ItemStack(Material.ARROW, 15)); + }*/ + if (event.getEntityType() == EntityType.CHICKEN) { - if (new Random().nextDouble() > .75) - event.getDrops().add(new ItemStack(Material.BOW)); + for (ItemStack test : event.getDrops()) + if (test.getType() == Material.FEATHER) + return; + + event.getDrops().add(new ItemStack(Material.FEATHER, UtilMath.random.nextInt(4))); } - - event.getDrops().add(new ItemStack(Material.ARROW, 15)); } @EventHandler @@ -1230,16 +1256,6 @@ public class MinecraftLeague extends TeamGame Player player = (Player)event.getEntity(); List gear = new ArrayList(); - if (!UtilItem.isDiamondProduct(getBestSword(player))) - gear.add(getBestSword(player)); - else - gear.add(new ItemStack(Material.AIR)); - - if (!UtilItem.isDiamondProduct(getBestPick(player))) - gear.add(getBestPick(player)); - else - gear.add(new ItemStack(Material.AIR)); - if (!UtilItem.isDiamondProduct(player.getInventory().getHelmet())) gear.add(player.getInventory().getHelmet()); else @@ -1260,6 +1276,24 @@ public class MinecraftLeague extends TeamGame else gear.add(new ItemStack(Material.AIR)); + if (!UtilItem.isDiamondProduct(getBestSword(player))) + gear.add(getBestSword(player)); + else + gear.add(new ItemStack(Material.AIR)); + + if (!UtilItem.isDiamondProduct(getBestPick(player))) + gear.add(getBestPick(player)); + else + gear.add(new ItemStack(Material.AIR)); + + int arrowsToAdd = UtilInv.getAmount(player, Material.ARROW) / 2; + while (arrowsToAdd >= 1) + { + int subtract = Math.min(64, arrowsToAdd); + gear.add(new ItemStack(Material.ARROW, subtract)); + arrowsToAdd -= subtract; + } + _gear.put(player, gear); } @@ -1347,7 +1381,7 @@ public class MinecraftLeague extends TeamGame return; Player player = Bukkit.getPlayer(event.GetLog().GetPlayer().GetName()); - if (!_crystals.get(GetTeam(player)).Alive) + if (_tower.getAmountAlive(GetTeam(player)) < 1) { SetPlayerState(player, PlayerState.OUT); @@ -1375,8 +1409,8 @@ public class MinecraftLeague extends TeamGame if (OverTime) { - _crystals.get(GetTeam(player)).damage(20, null, false); - if (!_crystals.get(GetTeam(player)).Alive) + _tower.getVulnerable(GetTeam(player)).damage(20, null); + if (_tower.getAmountAlive(GetTeam(player)) < 1) { SetPlayerState(player, PlayerState.OUT); @@ -1420,23 +1454,34 @@ public class MinecraftLeague extends TeamGame if (event.getEntity() instanceof Enderman) event.setCancelled(true); - for (TeamCrystal crystal : _crystals.values()) + for (GameTeam team : GetTeamList()) + for (TeamTowerBase tower : _tower.getTeamTowers(team)) { if (event.getLocation().getWorld().getUID() != WorldData.World.getUID()) continue; - if (event.getLocation().distance(crystal.getLocation()) <= 5) + if (event.getLocation().distance(tower.getLocation()) <= 5) event.setCancelled(true); } } - @EventHandler - public void sigilsIsMean(BlockBreakEvent event) + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void handleBreak(BlockBreakEvent event) { if (!IsLive()) return; if (UtilPlayer.isSpectator(event.getPlayer())) + { event.setCancelled(true); + return; + } + + if (event.getBlock().getType() == Material.GRAVEL) + { + event.setCancelled(true); + event.getBlock().setType(Material.AIR); + event.getBlock().getWorld().dropItemNaturally(event.getBlock().getLocation(), new ItemStack(Material.FLINT)); + } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/DefenderAI.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/DefenderAI.java new file mode 100644 index 000000000..c76b1a489 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/DefenderAI.java @@ -0,0 +1,171 @@ +package nautilus.game.arcade.game.games.minecraftleague.data; + +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; + +import org.bukkit.Location; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.util.Vector; + +public class DefenderAI +{ + private TowerManager _manager; + private TeamTowerBase _tower; + private long _lastAttack; + private long _procTime; + private DefenseAnimation _animation; + + public DefenderAI(TowerManager manager, TeamTowerBase tower) + { + _manager = manager; + _tower = tower; + _lastAttack = System.currentTimeMillis(); + _procTime = -1; + _animation = new DefenseAnimation(); + } + + public void update() + { + if (!_tower.Alive) + return; + + if (_tower instanceof TeamTower) + _animation.activate(); + else + attack(); + + _animation.update(); + } + + private void animate() + { + _animation.activate(); + _animation.deactivate(); //<-- Used for when attack hits + } + + private void attack() + { + if (_procTime != -1) + { + if (System.currentTimeMillis() >= _procTime) + { + _procTime = -1; + attackProc(); + return; + } + } + if (!UtilTime.elapsed(_lastAttack, UtilTime.convert(1, TimeUnit.MINUTES, TimeUnit.MILLISECONDS))) + return; + if (UtilMath.random.nextDouble() < .75) + return; + _procTime = System.currentTimeMillis() + UtilTime.convert(45, TimeUnit.SECONDS, TimeUnit.MILLISECONDS); + animate(); + } + + private void attackProc() + { + for (LivingEntity le : UtilEnt.getInRadius(_tower.getLocation(), 15).keySet()) + { + if (!(le instanceof Player)) + continue; + + Player player = (Player)le; + if (_manager.Host.GetTeam(player).GetColor() == _tower.getTeam().GetColor()) + continue; + if (UtilPlayer.isSpectator(player)) + continue; + + player.getWorld().strikeLightningEffect(player.getLocation()); + player.damage(4 * 2); + } + } + + private class DefenseAnimation + { + private Location _base; + private double _step; + //private final double _baseRadius; + private double _radius; + private long _lastStepIncrease; + private boolean _active; + + public DefenseAnimation() + { + _step = 0; + _lastStepIncrease = System.currentTimeMillis(); + if (_tower instanceof TeamTower) + { + //_baseRadius = -1; + _base = _tower.getLocation().clone().add(0, 10, 0); + } + else + { + //_baseRadius = 11; + _base = _tower.getLocation().clone(); + } + _radius = /*_baseRadius*/2; + } + + public void activate() + { + _active = true; + } + + public void deactivate() + { + _active = false; + } + + public void update() + { + if (!_active) + return; + + if (_tower instanceof TeamTower) + { + drawBeam(); + } + else + { + if (UtilTime.elapsed(_lastStepIncrease, UtilTime.convert(3, TimeUnit.SECONDS, TimeUnit.MILLISECONDS))) + { + _step++; + _lastStepIncrease = System.currentTimeMillis(); + } + drawHelix(); + } + } + + private void drawHelix() + { + for (double y = 0; y <= _step; y += .5) + { + double x = _radius * Math.cos(y); + double z = _radius * Math.sin(y); + Location play = new Location(_base.getWorld(), _base.getX() + x, _base.getY() + y, _base.getZ() + z); + + UtilParticle.PlayParticleToAll(ParticleType.WITCH_MAGIC, play, null, 0, 1, ViewDist.MAX); + } + } + + private void drawBeam() + { + Location target = _manager.getTeamTowers(_tower.getTeam()).getLast().getLocation().clone().add(0, 10, 0); + Location display = _base.clone(); + while (UtilMath.offset(_base, target) > UtilMath.offset(_base, display)) + { + Vector v = UtilAlg.getTrajectory(display, target); + UtilParticle.PlayParticleToAll(ParticleType.FIREWORKS_SPARK, display, null, 0, 1, ViewDist.MAX); + display.add(v); + } + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/OreGenerator.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/OreGenerator.java new file mode 100644 index 000000000..cb785897f --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/OreGenerator.java @@ -0,0 +1,39 @@ +package nautilus.game.arcade.game.games.minecraftleague.data; + +import java.util.List; + +import mineplex.core.common.util.UtilMath; + +import org.bukkit.Location; +import org.bukkit.Material; + +public class OreGenerator +{ + private int _current; + private int _total; + + public void generateOre(Material oreType, List possible, int amount) + { + _current = 0; + _total = amount; + while (_current < _total) + { + iterateOres(oreType, possible); + } + } + + private void iterateOres(Material oreType, List possible) + { + for (Location loc : possible) + { + if (loc.getBlock().getType() == oreType) + continue; + if (UtilMath.random.nextDouble() > .33) + continue; + if (_total <= _current) + return; + loc.getBlock().setType(oreType); + _current++; + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamCrystal.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamCrystal.java index b2438670b..afea34d7e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamCrystal.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamCrystal.java @@ -1,249 +1,14 @@ package nautilus.game.arcade.game.games.minecraftleague.data; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilParticle.ViewDist; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTextBottom; -import mineplex.core.common.util.UtilTextMiddle; -import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilTime.TimeUnit; -import mineplex.core.hologram.Hologram; -import mineplex.core.recharge.Recharge; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; -import org.bukkit.Bukkit; import org.bukkit.Location; -import org.bukkit.Sound; -import org.bukkit.entity.EnderCrystal; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.util.Vector; -public class TeamCrystal +public class TeamCrystal extends TeamTowerBase { - private MinecraftLeague _host; - private Location _spawn; - private GameTeam _team; - private Double _health, _maxHealth; - private EnderCrystal _entity; - private Hologram _name, _healthTag; - public boolean Alive; - - private long _lastAlert = -1; - private long _lastHit = -1; - - public TeamCrystal(MinecraftLeague host, GameTeam team, Location spawn) + public TeamCrystal(MinecraftLeague host, TowerManager manager, GameTeam team, Location spawn) { - _host = host; - _spawn = spawn.clone().add(0.5, 1.2, 0.5); - _team = team; - _maxHealth = 11111D; - _health = 11111D; - _name = new Hologram(_host.getArcadeManager().getHologramManager(), _spawn.clone().add(0, 3, 0), team.GetColor() + team.getDisplayName() + "'s Respawn Crystal"); - _healthTag = new Hologram(_host.getArcadeManager().getHologramManager(), _spawn.clone().add(0, 2, 0), formatHealth(_health)); - - spawn(); + super(host, manager, team, spawn); } - - private void spawn() - { - _name.start(); - _healthTag.start(); - _entity = (EnderCrystal) _host.getArcadeManager().GetCreature().SpawnEntity(_spawn, EntityType.ENDER_CRYSTAL); - _health = _maxHealth; - Alive = true; - } - - private void kill(Player player) - { - String message = ""; - if (player != null) - message = C.cRedB + player.getName() + " has destroyed " + _team.getDisplayName() + "'s " + C.cDPurpleB + "Crystal" + C.cRedB + "!"; - else - message = C.cRedB + _team.getDisplayName() + "'s " + C.cDPurpleB + "Respawn Crystal" + C.cRedB + " has been destroyed!"; - - Bukkit.broadcastMessage(message); - - for (Player inform : _team.GetPlayers(true)) - UtilTextMiddle.display(C.cRedB + "Team Crystal Destroyed", C.cRed + "You will no longer respawn!", inform); - - Alive = false; - _entity.remove(); - _healthTag.stop(); - _name.stop(); - playDeathAnimation(_spawn); - } - - private void playDeathAnimation(Location loc) - { - _spawn.getWorld().playSound(loc, Sound.EXPLODE, 10, 0); - //GFX subject to change - Location loc1 = loc.clone().add(-2, 3, -2); - Location loc2 = loc.clone().add(2, 0, 2); - Location loc3 = loc.clone().add(2, 3, 2); - Location loc4 = loc.clone().add(-2, 0, -2); - Location particle1 = loc2.clone(); - Location particle2 = loc4.clone(); - while (UtilMath.offset(loc1, loc) >= UtilMath.offset(particle1, loc)) - { - Vector v = UtilAlg.getTrajectory(particle1, loc1); - //UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, particle, v, 0, 1, ViewDist.NORMAL, UtilServer.getPlayers()); - UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, particle1, v, 0, 5, ViewDist.MAX, UtilServer.getPlayers()); - particle1.add(v); - } - while (UtilMath.offset(loc3, loc) >= UtilMath.offset(particle2, loc)) - { - Vector v = UtilAlg.getTrajectory(particle2, loc3); - UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, particle2, v, 0, 5, ViewDist.MAX, UtilServer.getPlayers()); - particle2.add(v); - } - } - - private void alert() - { - if (UtilTime.elapsed(_lastAlert, UtilTime.convert(15, TimeUnit.SECONDS, TimeUnit.MILLISECONDS))) - { - _lastHit = System.currentTimeMillis(); - - for (Player player : _team.GetPlayers(true)) - { - player.playSound(player.getLocation(), Sound.NOTE_PLING, 10, 0); - } - } - } - - private void alertTextDisplay() - { - if (UtilTime.elapsed(_lastHit, UtilTime.convert(5, TimeUnit.SECONDS, TimeUnit.MILLISECONDS))) - return; - for (Player player : _team.GetPlayers(true)) - UtilTextBottom.display(C.cRed + "Your Crystal is under attack!", player); - } - - public Entity getEntity() - { - return _entity; - } - - public boolean isEntity(Entity e) - { - return e.getEntityId() == _entity.getEntityId(); - } - - public boolean canDamage(Player player) - { - if (UtilPlayer.isSpectator(player)) - return false; - - if (_host.GetTeam(player) == _team) - return false; - - if (!_host.IsPlaying(player)) - return false; - - if (!Recharge.Instance.usable(player, "Damage Teamcrystal")) - return false; - - return true; - } - - public Double getHealth() - { - if (!Alive) - return 0D; - - return _health; - } - - public String formatHealth(Double healthNumber) - { - String tag = healthNumber.toString(); - - if (healthNumber > (.9 * _maxHealth)) - tag = C.cGreen + tag; - else if (healthNumber < (.45 * _maxHealth)) - tag = C.cRed + tag; - else - tag = C.cYellow + tag; - - return tag; - } - - public boolean damage(double damage, Player player, boolean hit) - { - Double newHealth = Math.max(_health - damage, 0); - - if (newHealth == 0) - { - kill(player); - return true; - } - - if (hit) - alert(); - - _health = newHealth; - if (player != null) - Recharge.Instance.use(player, "Damage Teamcrystal", UtilTime.convert(1, TimeUnit.SECONDS, TimeUnit.MILLISECONDS), false, false); - return false; - } - - public Location getLocation() - { - return _spawn; - } - - public void update() - { - _healthTag.setText(formatHealth(_health)); - - if (Alive) - { - if (_entity.isDead() || !_entity.isValid()) - { - _entity = (EnderCrystal) _host.getArcadeManager().GetCreature().SpawnEntity(_spawn, EntityType.ENDER_CRYSTAL); - } - - if (_health > _maxHealth) - { - _health = _maxHealth; - } - - alertTextDisplay(); - } - } - - public void setMaxHealth(Double health) - { - _maxHealth = Math.abs(health); - } - - public void handleDebug(Player dev, Double damage, boolean kill) - { - if (damage != null) - { - damage(damage, dev, false); - UtilPlayer.message(dev, F.main(_host.GetName(), "The Crystal has been damaged")); - return; - } - - if (kill) - { - kill(dev); - UtilPlayer.message(dev, F.main(_host.GetName(), "The Crystal has been killed")); - } - else - { - spawn(); - UtilPlayer.message(dev, F.main(_host.GetName(), "The Crystal has been spawned")); - } - } -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamTower.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamTower.java new file mode 100644 index 000000000..3fab4b528 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamTower.java @@ -0,0 +1,17 @@ +package nautilus.game.arcade.game.games.minecraftleague.data; + +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; + +import org.bukkit.Location; + +public class TeamTower extends TeamTowerBase +{ + public Integer Number; + + public TeamTower(MinecraftLeague host, TowerManager manager, GameTeam team, Location spawn, Integer number) + { + super(host, manager, team, spawn); + Number = number; + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamTowerBase.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamTowerBase.java new file mode 100644 index 000000000..3ce1548f3 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TeamTowerBase.java @@ -0,0 +1,272 @@ +package nautilus.game.arcade.game.games.minecraftleague.data; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilTime.TimeUnit; +import mineplex.core.hologram.Hologram; +import mineplex.core.recharge.Recharge; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.minecraftleague.DataLoc; +import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.entity.EnderCrystal; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Wither; +import org.bukkit.util.Vector; + +public abstract class TeamTowerBase +{ + private MinecraftLeague _host; + private TowerManager _manager; + private Location _spawn; + private GameTeam _team; + private Double _health, _maxHealth; + private EnderCrystal _entity; + private Hologram _name, _healthTag; + private String _type; + public boolean Alive; + public boolean Vulnerable; + + public TeamTowerBase(MinecraftLeague host, TowerManager manager, GameTeam team, Location spawn) + { + _host = host; + _manager = manager; + _spawn = spawn.clone().add(0.5, 1.2, 0.5); + _team = team; + _maxHealth = 11111D; + _health = 11111D; + _type = "Tower"; + if (this instanceof TeamCrystal) + _type = "Crystal"; + _name = new Hologram(_host.getArcadeManager().getHologramManager(), _spawn.clone().add(0, 3, 0), team.GetColor() + team.getDisplayName() + "'s " + _type); + _healthTag = new Hologram(_host.getArcadeManager().getHologramManager(), _spawn.clone().add(0, 2, 0), formatHealth(_health)); + + spawn(); + } + + private void spawn() + { + _name.start(); + _healthTag.start(); + _entity = (EnderCrystal) _host.getArcadeManager().GetCreature().SpawnEntity(_spawn, EntityType.ENDER_CRYSTAL); + _health = _maxHealth; + Alive = true; + } + + private void kill(Player player) + { + String message = ""; + if (player != null) + message = C.cRedB + player.getName() + " has destroyed " + _team.getDisplayName() + "'s " + C.cDPurpleB + _type + C.cRedB + "!"; + else + message = C.cRedB + _team.getDisplayName() + "'s " + C.cDPurpleB + _type + C.cRedB + " has been destroyed!"; + + Bukkit.broadcastMessage(message); + + if (!_type.equalsIgnoreCase("Tower")) + { + for (Player inform : _team.GetPlayers(true)) + UtilTextMiddle.display(C.cRedB + "Team Crystal Destroyed", C.cRed + "You will no longer respawn!", inform); + } + + Alive = false; + _entity.remove(); + _healthTag.stop(); + _name.stop(); + Bukkit.getScheduler().runTaskLater(_host.Manager.getPlugin(), new Runnable() + { + public void run() + { + playDeathAnimation(_spawn); + } + }, 20 * 5); + detonate(); + _manager.handleTowerDeath(this); + } + + private void playDeathAnimation(Location loc) + { + _spawn.getWorld().playSound(loc, Sound.EXPLODE, 10, 0); + //GFX subject to change + Location loc1 = loc.clone().add(-2, 3, -2); + Location loc2 = loc.clone().add(2, 0, 2); + Location loc3 = loc.clone().add(2, 3, 2); + Location loc4 = loc.clone().add(-2, 0, -2); + Location particle1 = loc2.clone(); + Location particle2 = loc4.clone(); + while (UtilMath.offset(loc1, loc) >= UtilMath.offset(particle1, loc)) + { + Vector v = UtilAlg.getTrajectory(particle1, loc1); + //UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, particle, v, 0, 1, ViewDist.NORMAL, UtilServer.getPlayers()); + UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, particle1, v, 0, 5, ViewDist.MAX, UtilServer.getPlayers()); + particle1.add(v); + } + while (UtilMath.offset(loc3, loc) >= UtilMath.offset(particle2, loc)) + { + Vector v = UtilAlg.getTrajectory(particle2, loc3); + UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, particle2, v, 0, 5, ViewDist.MAX, UtilServer.getPlayers()); + particle2.add(v); + } + } + + private void detonate() + { + UtilParticle.PlayParticleToAll(ParticleType.EXPLODE, _spawn, null, 0, 2, ViewDist.NORMAL); + for (Block b : UtilBlock.getExplosionBlocks(_spawn, 1, false)) + { + b.setType(Material.AIR); + } + for (LivingEntity le : UtilEnt.getInRadius(_spawn, 5).keySet()) + { + if (le instanceof Wither) + le.damage(le.getHealth() / 2); + else + le.damage(6); + } + } + + private Location getBeacon() + { + Location ret = null; + for (Location loc : _host.WorldData.GetDataLocs(DataLoc.BEACON.getKey())) + { + if (ret == null || UtilMath.offset(ret, _spawn) > UtilMath.offset(loc, _spawn)) + ret = loc; + } + + return ret; + } + + public Entity getEntity() + { + return _entity; + } + + public boolean isEntity(Entity e) + { + return e.getEntityId() == _entity.getEntityId(); + } + + public boolean canDamage(Player player) + { + if (UtilPlayer.isSpectator(player)) + return false; + + if (_host.GetTeam(player) == _team) + return false; + + if (!_host.IsPlaying(player)) + return false; + + if (!Recharge.Instance.usable(player, "Damage TeamTower")) + return false; + + return true; + } + + public Double getHealth() + { + if (!Alive) + return 0D; + + return _health; + } + + public String formatHealth(Double healthNumber) + { + String tag = healthNumber.toString(); + + if (healthNumber > (.9 * _maxHealth)) + tag = C.cGreen + tag; + else if (healthNumber < (.45 * _maxHealth)) + tag = C.cRed + tag; + else + tag = C.cYellow + tag; + + return tag; + } + + public boolean damage(double damage, Player player) + { + if (!Vulnerable) + return false; + + Double newHealth = Math.max(_health - damage, 0); + + if (newHealth == 0) + { + kill(player); + return true; + } + + _health = newHealth; + if (player != null) + Recharge.Instance.use(player, "Damage TeamTower", UtilTime.convert(1, TimeUnit.SECONDS, TimeUnit.MILLISECONDS), false, false); + return false; + } + + public Location getLocation() + { + return _spawn; + } + + public GameTeam getTeam() + { + return _team; + } + + public void update() + { + _healthTag.setText(formatHealth(_health)); + + if (Alive) + { + if (_entity.isDead() || !_entity.isValid()) + { + _entity = (EnderCrystal) _host.getArcadeManager().GetCreature().SpawnEntity(_spawn, EntityType.ENDER_CRYSTAL); + } + + if (_health > _maxHealth) + { + _health = _maxHealth; + } + } + } + + public void setMaxHealth(Double health) + { + _maxHealth = Math.abs(health); + } + + public void setVulnerable(boolean vulnerable) + { + if (vulnerable) + { + getBeacon().getBlock().setType(Material.BEACON); + Vulnerable = vulnerable; + } + else + { + getBeacon().getBlock().setType(Material.BEDROCK); + Vulnerable = vulnerable; + } + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TowerManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TowerManager.java new file mode 100644 index 000000000..d4927f767 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/data/TowerManager.java @@ -0,0 +1,181 @@ +package nautilus.game.arcade.game.games.minecraftleague.data; + +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; +import java.util.concurrent.ConcurrentHashMap; + +import mineplex.core.common.util.UtilTextMiddle; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.minecraftleague.DataLoc; +import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; +import nautilus.game.arcade.world.WorldData; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.event.Listener; + +public class TowerManager implements Listener +{ + public MinecraftLeague Host; + private ConcurrentHashMap _towers = new ConcurrentHashMap(); + private ConcurrentHashMap _vulnerableTower = new ConcurrentHashMap(); + private ConcurrentHashMap _def = new ConcurrentHashMap(); + private OreGenerator _ore; + + public TowerManager(MinecraftLeague host) + { + Host = host; + _ore = new OreGenerator(); + } + + private void makeVulnerable(TeamTowerBase base) + { + if (base instanceof TeamTower) + _vulnerableTower.put(base.getTeam(), ((TeamTower)base).Number); + else + _vulnerableTower.put(base.getTeam(), 3); + + base.setVulnerable(true);; + } + + private void oreGen(GameTeam team) + { + if (team.GetColor() == ChatColor.RED) + _ore.generateOre(Material.IRON_ORE, Host.WorldData.GetCustomLocs(DataLoc.RED_ORE.getKey()), 150); + else + _ore.generateOre(Material.IRON_ORE, Host.WorldData.GetCustomLocs(DataLoc.BLUE_ORE.getKey()), 150); + } + + private List getAllTeamTowers(GameTeam team) + { + List ret = new ArrayList(); + + for (TeamTowerBase tower : _towers.keySet()) + { + if (_towers.get(tower).GetColor() == team.GetColor()) + { + ret.add(tower); + } + } + + return ret; + } + + public LinkedList getTeamTowers(GameTeam team) + { + LinkedList ret = new LinkedList(); + TeamTower one = null; + TeamTower two = null; + TeamCrystal three = null; + + for (TeamTowerBase tower : getAllTeamTowers(team)) + { + if (tower instanceof TeamCrystal) + { + three = (TeamCrystal) tower; + continue; + } + if (one == null) + { + one = (TeamTower) tower; + continue; + } + if (one.Number > ((TeamTower)tower).Number) + { + two = one; + one = (TeamTower) tower; + continue; + } + two = (TeamTower) tower; + } + + ret.add(one); + ret.add(two); + ret.add(three); + + return ret; + } + + public Integer getAmountAlive(GameTeam team) + { + int i = 0; + + for (TeamTowerBase tower : getAllTeamTowers(team)) + { + if (tower.Alive) + i++; + } + + return i; + } + + public TeamTowerBase getVulnerable(GameTeam team) + { + return getTeamTowers(team).get(_vulnerableTower.get(team) - 1); + } + + public void parseTowers(WorldData data) + { + GameTeam red = Host.GetTeam(ChatColor.RED); + GameTeam blue = Host.GetTeam(ChatColor.AQUA); + + _towers.put(new TeamTower(Host, this, red, data.GetCustomLocs(DataLoc.RED_TOWER.getKey() + " 1").get(0), 1), red); + _towers.put(new TeamTower(Host, this, red, data.GetCustomLocs(DataLoc.RED_TOWER.getKey() + " 2").get(0), 2), red); + _towers.put(new TeamCrystal(Host, this, red, data.GetCustomLocs(DataLoc.RED_CRYSTAL.getKey()).get(0)), red); + + _towers.put(new TeamTower(Host, this, blue, data.GetCustomLocs(DataLoc.BLUE_TOWER.getKey() + " 1").get(0), 1), blue); + _towers.put(new TeamTower(Host, this, blue, data.GetCustomLocs(DataLoc.BLUE_TOWER.getKey() + " 2").get(0), 2), blue); + _towers.put(new TeamCrystal(Host, this, blue, data.GetCustomLocs(DataLoc.BLUE_CRYSTAL.getKey()).get(0)), blue); + + for (TeamTowerBase tower : _towers.keySet()) + { + _def.put(tower, new DefenderAI(this, tower)); + } + + makeVulnerable(getTeamTowers(red).getFirst()); + makeVulnerable(getTeamTowers(blue).getFirst()); + oreGen(red); + oreGen(blue); + } + + public void prepareHealth(int players, double multiplier) + { + for (TeamTowerBase tower : _towers.keySet()) + { + if (tower instanceof TeamCrystal) + tower.setMaxHealth(players * multiplier); + else + tower.setMaxHealth((double)((int)((2/3)*multiplier)) * players); + } + } + + public void handleTowerDeath(TeamTowerBase towerBase) + { + towerBase.setVulnerable(false); + if (towerBase instanceof TeamCrystal) + { + oreGen(towerBase.getTeam()); + Bukkit.getScheduler().runTaskLater(Host.Manager.getPlugin(), new Runnable() + { + public void run() + { + UtilTextMiddle.display("", towerBase.getTeam().GetColor() + towerBase.getTeam().GetName() + " Team ores have been replenished!"); + } + }, 20 * 5); + return; + } + TeamTower tower = (TeamTower)towerBase; + makeVulnerable(getTeamTowers(tower.getTeam()).get(tower.Number)); + } + + public void update() + { + for (TeamTowerBase tower : _towers.keySet()) + { + tower.update(); + _def.get(tower).update(); + } + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/VariationManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/VariationManager.java index d56239954..2b7a4630b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/VariationManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/VariationManager.java @@ -4,6 +4,7 @@ import java.lang.reflect.InvocationTargetException; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.games.minecraftleague.DataLoc; import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; import org.bukkit.Bukkit; @@ -27,12 +28,12 @@ public class VariationManager implements Listener public void selectVariation() { - VariationType type = VariationType.getFromID(_host.getMapVariantID()); - - if (type.getVariation() == null) + VariationType type = null; + if (_host.getMapVariantIDS().size() != 1) + type = VariationType.STANDARD; + else { - Bukkit.broadcastMessage(type.getDisplayMessage()); - return; + type = VariationType.getFromID(_host.getMapVariantIDS().get(0).replace(DataLoc.VARIANT_BASE.getKey(), "")); } try diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/VariationType.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/VariationType.java index 9a03fb724..de1124d99 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/VariationType.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/VariationType.java @@ -6,17 +6,17 @@ import org.bukkit.ChatColor; public enum VariationType { - STANDARD(1, StandardGameplay.class, "Standard Gameplay", ChatColor.GREEN), - WITHER(2, WitherVariation.class, "Wither Variation", ChatColor.RED), + STANDARD("STANDARD", StandardGameplay.class, "Standard Gameplay", ChatColor.GREEN), + WITHER("WITHER", WitherVariation.class, "Wither Variation", ChatColor.RED), //GUARDIAN(3, GuardianVariation.class, "Guardian Variation", ChatColor.DARK_AQUA) ; - private int _id; + private String _id; private String _name; private ChatColor _color; private Class _variation; - private VariationType(int id, Class variationClass, String displayName, ChatColor displayColor) + private VariationType(String id, Class variationClass, String displayName, ChatColor displayColor) { _id = id; _name = displayName; @@ -34,11 +34,11 @@ public enum VariationType return ChatColor.DARK_AQUA + "Game Type Selected: " + _color + _name; } - public static VariationType getFromID(int id) + public static VariationType getFromID(String id) { for (VariationType type : VariationType.values()) { - if (type._id == id) + if (type._id.equalsIgnoreCase(id)) return type; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java index 7e2f0482c..c9c0eaab3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/WitherVariation.java @@ -16,7 +16,7 @@ import nautilus.game.arcade.events.PlayerGameRespawnEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.minecraftleague.DataLoc; import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; -import nautilus.game.arcade.game.games.minecraftleague.data.TeamCrystal; +import nautilus.game.arcade.game.games.minecraftleague.data.TeamTowerBase; import nautilus.game.arcade.game.games.minecraftleague.variation.GameVariation; import nautilus.game.arcade.game.games.minecraftleague.variation.wither.data.TeamAltar; import nautilus.game.arcade.game.games.minecraftleague.variation.wither.data.WitherMinionManager; @@ -170,7 +170,7 @@ public class WitherVariation extends GameVariation } if (_altars.get(team).ownsWither(event)) { - if (!Host.getCrystal(enemy).Alive) + if (Host.getTowerManager().getAmountAlive(enemy) < 1) { event.setCancelled(true); return; @@ -181,7 +181,7 @@ public class WitherVariation extends GameVariation _wither.setCustomName(team.GetColor() + team.getDisplayName() + "'s Wither"); _wither.setCustomNameVisible(true); UtilTextMiddle.display("", team.GetColor() + team.getDisplayName() + " Team has spawned a Wither Boss!", UtilServer.getPlayers()); - _pathfinder = new WitherPathfinder(this, _wither, getWaypoints(_altars.get(team).getLocation()), team, Host.getCrystal(enemy).getEntity()); + _pathfinder = new WitherPathfinder(this, _wither, getWaypoints(_altars.get(team).getLocation()), team, enemy, Host.getTowerManager()); _skellyMan.onWitherSpawn(); Bukkit.getScheduler().runTaskLater(Manager.getPlugin(), new Runnable() { @@ -229,18 +229,18 @@ public class WitherVariation extends GameVariation { event.setCancelled(true); - TeamCrystal red = Host.getCrystal(Host.GetTeam(ChatColor.RED)); - TeamCrystal blue = Host.getCrystal(Host.GetTeam(ChatColor.AQUA)); + TeamTowerBase red = Host.getActiveTower(Host.GetTeam(ChatColor.RED)); + TeamTowerBase blue = Host.getActiveTower(Host.GetTeam(ChatColor.AQUA)); HashMap inside = UtilBlock.getInRadius(event.getLocation().getBlock(), 4, false); - double dmg = 5 * Host.GetTeam(ChatColor.RED).GetPlayers(true).size(); + double dmg = 5 * (Host.GetTeam(ChatColor.RED).GetPlayers(true).size() + Host.GetTeam(ChatColor.RED).GetPlayers(true).size()); if (inside.containsKey(red.getLocation().getBlock())) { - red.damage(dmg, null, true); + red.damage(dmg, null); } if (inside.containsKey(blue.getLocation().getBlock())) { - blue.damage(dmg, null, true); + blue.damage(dmg, null); } for (Block b : inside.keySet()) { @@ -254,7 +254,7 @@ public class WitherVariation extends GameVariation } for (GameTeam owner : Host.GetTeamList()) { - if (Host.getCrystal(owner).getLocation().distance(b.getLocation()) < 7) + if (Host.getActiveTower(owner).getLocation().distance(b.getLocation()) < 7) { if (b.getType() == Material.BEDROCK) continue; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/TeamAltar.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/TeamAltar.java index 708c336c5..68fe40d4d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/TeamAltar.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/TeamAltar.java @@ -24,36 +24,36 @@ public class TeamAltar private WitherVariation _host; private GameTeam _team; private Location _center; - + private List _protected; - + private Location[] _skullSpots; - + private int _placed; - + public TeamAltar(WitherVariation host, GameTeam team, Location center) { _host = host; _team = team; _center = center; - + spawnSoulsand(); - + _protected = UtilShapes.getSphereBlocks(center, 7, 7, false); } - + public boolean isInsideAltar(Location location) { return _protected.contains(location); } - + public void spawnSoulsand() { _placed = 0; Location s1 = null; Location s2 = null; Location s3 = null; - + for (int i = -1; i <= 1; i++) { _center.getBlock().getRelative(i, 1, 0).setType(Material.SOUL_SAND); @@ -65,10 +65,10 @@ public class TeamAltar s3 = _center.getBlock().getRelative(i, 2, 0).getLocation(); } _center.getBlock().setType(Material.SOUL_SAND); - + _skullSpots = new Location[] {s1, s2, s3}; } - + public boolean canBreak(Player player, Block block, boolean notify) { if (isInsideAltar(block.getLocation())) @@ -91,87 +91,81 @@ public class TeamAltar } return true; } - + public boolean canPlace(Player player, Material blockType, Location location, boolean notify) { - boolean should = false; if (isInsideAltar(location)) { - should = true; if (!_team.HasPlayer(player)) { if (notify) UtilPlayer.message(player, F.main("Game", "This is not your Altar!")); return false; } - + if (_host.WitherSpawned) { if (notify) UtilPlayer.message(player, F.main("Game", "A Wither is already spawned!")); - should = false; return false; } - + if (blockType != Material.SKULL) { if (notify) UtilPlayer.message(player, F.main("Game", "You cannot place that inside an Altar!")); return false; } - + boolean passes = false; for (Location l : _skullSpots) { if (l.equals(location)) passes = true; } - + if (!passes) { if (notify) UtilPlayer.message(player, F.main("Game", "That doesn't go there!")); - should = false; return false; } - + if (_team.GetColor() == ChatColor.RED) { - if (!_host.Host.getCrystal(_host.Host.GetTeam(ChatColor.AQUA)).Alive) + if (_host.Host.getTowerManager().getAmountAlive(_host.Host.GetTeam(ChatColor.AQUA)) < 1) { if (notify) UtilPlayer.message(player, F.main("Game", "You do not need a Wither!")); - should = false; return false; } } - if (_team.GetColor() == ChatColor.RED) + if (_team.GetColor() == ChatColor.AQUA) { - if (!_host.Host.getCrystal(_host.Host.GetTeam(ChatColor.AQUA)).Alive) + if (_host.Host.getTowerManager().getAmountAlive(_host.Host.GetTeam(ChatColor.RED)) < 1) { if (notify) UtilPlayer.message(player, F.main("Game", "You do not need a Wither!")); - should = false; return false; } } - } - - if (_team.HasPlayer(player) && blockType == Material.SKULL && should) - { - if (_placed < 2) + + if (_team.HasPlayer(player) && blockType == Material.SKULL) { - UtilTextMiddle.display("", _team.GetColor() + _team.getDisplayName() + " has placed a Skull on their Altar!"); - for (Player scare : UtilServer.getPlayers()) + if (_placed < 2) { - scare.playSound(scare.getLocation(), Sound.WITHER_SPAWN, 10, 0); + UtilTextMiddle.display("", _team.GetColor() + _team.getDisplayName() + " has placed a Skull on their Altar!"); + for (Player scare : UtilServer.getPlayers()) + { + scare.playSound(scare.getLocation(), Sound.WITHER_SPAWN, 10, 0); + } } + _placed++; } - _placed++; } return true; } - + public boolean ownsWither(EntitySpawnEvent event) { if (event.getEntity() instanceof Wither) @@ -179,10 +173,10 @@ public class TeamAltar Location base = event.getLocation(); return (isInsideAltar(base.getBlock().getLocation())); } - + return false; } - + public Location getLocation() { return _center.clone(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java index e3f2f50df..5916a366a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherMinionManager.java @@ -187,8 +187,8 @@ public class WitherMinionManager implements Listener if (UtilTime.elapsed(_lastDied, UtilTime.convert(45, TimeUnit.SECONDS, TimeUnit.MILLISECONDS))) { - boolean noUse = (!_host.Host.getCrystal(_host.Host.GetTeam(ChatColor.RED)).Alive); - if (_host.Host.getCrystal(_host.Host.GetTeam(ChatColor.AQUA)).Alive) + boolean noUse = _host.Host.getTowerManager().getAmountAlive(_host.Host.GetTeam(ChatColor.RED)) < 1; + if (_host.Host.getTowerManager().getAmountAlive(_host.Host.GetTeam(ChatColor.AQUA)) >= 1) noUse = false; if (!_host.WitherSpawned || noUse) { @@ -200,8 +200,8 @@ public class WitherMinionManager implements Listener if (UtilTime.elapsed(_lastDied, UtilTime.convert(1, TimeUnit.MINUTES, TimeUnit.MILLISECONDS))) { - boolean noUse = (!_host.Host.getCrystal(_host.Host.GetTeam(ChatColor.RED)).Alive); - if (_host.Host.getCrystal(_host.Host.GetTeam(ChatColor.AQUA)).Alive) + boolean noUse = _host.Host.getTowerManager().getAmountAlive(_host.Host.GetTeam(ChatColor.RED)) < 1; + if (_host.Host.getTowerManager().getAmountAlive(_host.Host.GetTeam(ChatColor.AQUA)) >= 1) noUse = false; if (!_host.WitherSpawned || noUse) { @@ -232,8 +232,8 @@ public class WitherMinionManager implements Listener if (event.getType() != UpdateType.FASTEST) return; - boolean noUse = (!_host.Host.getCrystal(_host.Host.GetTeam(ChatColor.RED)).Alive); - if (_host.Host.getCrystal(_host.Host.GetTeam(ChatColor.AQUA)).Alive) + boolean noUse = _host.Host.getTowerManager().getAmountAlive(_host.Host.GetTeam(ChatColor.RED)) < 1; + if (_host.Host.getTowerManager().getAmountAlive(_host.Host.GetTeam(ChatColor.AQUA)) >= 1) noUse = false; if (_entity != null || noUse) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherPathfinder.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherPathfinder.java index 970271347..f5e41c2e0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherPathfinder.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/minecraftleague/variation/wither/data/WitherPathfinder.java @@ -8,10 +8,13 @@ import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilTime.TimeUnit; import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.minecraftleague.DataLoc; +import nautilus.game.arcade.game.games.minecraftleague.data.TeamTower; +import nautilus.game.arcade.game.games.minecraftleague.data.TowerManager; import nautilus.game.arcade.game.games.minecraftleague.variation.wither.WitherVariation; +import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.entity.Arrow; import org.bukkit.entity.Entity; @@ -28,20 +31,23 @@ public class WitherPathfinder private Wither _ent; private LinkedList _waypoints; private GameTeam _team; - private Entity _enemy; + private GameTeam _enemy; + private TowerManager _towerManager; private long _lastAttack; + private long _lastTowerAttack; - private boolean _finishedJourney = false; private boolean _startedJourney = false; - public WitherPathfinder(WitherVariation host, Wither ent, LinkedList waypoints, GameTeam team, Entity enemy) + public WitherPathfinder(WitherVariation host, Wither ent, LinkedList waypoints, GameTeam team, GameTeam enemy, TowerManager towerManager) { _host = host; _ent = ent; _waypoints = waypoints; _team = team; _enemy = enemy; + _towerManager = towerManager; _lastAttack = -1; + _lastTowerAttack = -1; _pathData = new PathfinderData(ent, waypoints.getFirst()); } @@ -99,18 +105,17 @@ public class WitherPathfinder } if (target != null) - shootAt(target.getLocation()); + { + if (UtilTime.elapsed(_lastAttack, 2)) + { + _lastAttack = System.currentTimeMillis(); + shootAt(target.getLocation()); + } + } } private void shootAt(Location loc) { - int sec = 2; - if (_finishedJourney) - sec = 5; - - if (!UtilTime.elapsed(_lastAttack, UtilTime.convert(sec, TimeUnit.SECONDS, TimeUnit.MILLISECONDS))) - return; - Location old = _ent.getLocation(); Location temp = _ent.getLocation(); temp.setPitch(UtilAlg.GetPitch(UtilAlg.getTrajectory(_ent.getEyeLocation(), loc))); @@ -121,7 +126,6 @@ public class WitherPathfinder _ent.removeMetadata("Shooting", _host.Manager.getPlugin()); _ent.teleport(old); //skull.setDirection(UtilAlg.getTrajectory(_ent.getLocation(), loc).normalize()); - _lastAttack = System.currentTimeMillis(); } /** @@ -132,7 +136,8 @@ public class WitherPathfinder if ((_ent == null) || _ent.isDead() || !_ent.isValid()) return true; - if (!_enemy.isValid() || _enemy.isDead() || _enemy == null) + Entity eTower = _towerManager.getVulnerable(_enemy).getEntity(); + if (eTower == null || !eTower.isValid() || eTower.isDead()) { _ent.remove(); return true; @@ -161,15 +166,28 @@ public class WitherPathfinder } } - if (_ent.getLocation().distance(_enemy.getLocation()) <= 10 || _finishedJourney) + if (_ent.getLocation().distance(eTower.getLocation()) <= 10) { - _finishedJourney = true; _ent.setTarget(null); - Location finalize = _waypoints.getLast(); - finalize.setPitch(UtilAlg.GetPitch(UtilAlg.getTrajectory(_ent, _enemy))); - finalize.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(_ent, _enemy))); + String tName = ""; + if (_team.GetColor() == ChatColor.RED) + tName = "RED"; + if (_team.GetColor() == ChatColor.AQUA) + tName = "BLUE"; + Integer cNumber = -1; + if (_towerManager.getVulnerable(_enemy) instanceof TeamTower) + cNumber = ((TeamTower)_towerManager.getVulnerable(_enemy)).Number; + else + cNumber = 3; + Location finalize = _host.Host.WorldData.GetCustomLocs(DataLoc.TOWER_WAYPOINT.getKey().replace("$team$", tName).replace("$number$", cNumber + "")).get(0); + finalize.setPitch(UtilAlg.GetPitch(UtilAlg.getTrajectory(_ent, eTower))); + finalize.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(_ent, eTower))); _ent.teleport(finalize); - shootAt(_enemy.getLocation()); + if (UtilTime.elapsed(_lastTowerAttack, 5)) + { + _lastTowerAttack = System.currentTimeMillis(); + shootAt(eTower.getLocation()); + } return false; }