- Finally finished all of chiss' changes
This commit is contained in:
parent
65be5fcd99
commit
3212b75e4e
@ -1,22 +1,26 @@
|
|||||||
package nautilus.game.arcade.game.games.minecraftleague;
|
package nautilus.game.arcade.game.games.minecraftleague;
|
||||||
|
|
||||||
|
|
||||||
public enum DataLoc
|
public enum DataLoc
|
||||||
{
|
{
|
||||||
//Base
|
//Base
|
||||||
RED_CRYSTAL("RED"),
|
RED_CRYSTAL("RED CRYSTAL"),
|
||||||
BLUE_CRYSTAL("BLUE"),
|
RED_TOWER("RED TOWER"),
|
||||||
VARIANT_ID("ORANGE"),
|
BLUE_CRYSTAL("BLUE CRYSTAL"),
|
||||||
RED_BEACON("PINK"),
|
BLUE_TOWER("BLUE TOWER"),
|
||||||
BLUE_BEACON("CYAN"),
|
VARIANT_BASE("GAMEMODE "),
|
||||||
|
//RED_BEACON("PINK"),
|
||||||
|
/*BLUE_*/BEACON("CYAN"),
|
||||||
SKELETON_SPAWNER("BROWN"),
|
SKELETON_SPAWNER("BROWN"),
|
||||||
MAP_DIAMOND("LIGHT_BLUE"),
|
//MAP_DIAMOND("LIGHT_BLUE"),
|
||||||
MAP_IRON("SILVER"),
|
//MAP_IRON("SILVER"),
|
||||||
|
RED_ORE("15"),
|
||||||
|
BLUE_ORE("14"),
|
||||||
|
|
||||||
//Wither
|
//Wither
|
||||||
WITHER_WAYPOINT("PURPLE"),
|
WITHER_WAYPOINT("PURPLE"),
|
||||||
|
TOWER_WAYPOINT("$team$ TOWER $number$"),
|
||||||
WITHER_SKELETON("BLACK"),
|
WITHER_SKELETON("BLACK"),
|
||||||
BLUE_ALTAR("GREEN"),
|
BLUE_ALTAR("LIME"),
|
||||||
RED_ALTAR("YELLOW")
|
RED_ALTAR("YELLOW")
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@ package nautilus.game.arcade.game.games.minecraftleague;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
import mineplex.core.common.util.C;
|
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.UtilEnt;
|
||||||
import mineplex.core.common.util.UtilInv;
|
import mineplex.core.common.util.UtilInv;
|
||||||
import mineplex.core.common.util.UtilItem;
|
import mineplex.core.common.util.UtilItem;
|
||||||
|
import mineplex.core.common.util.UtilMath;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.common.util.UtilTextMiddle;
|
import mineplex.core.common.util.UtilTextMiddle;
|
||||||
import mineplex.core.common.util.UtilTime;
|
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.OreDeposit;
|
||||||
import nautilus.game.arcade.game.games.minecraftleague.data.PlayerRespawnPoint;
|
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.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.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.data.map.ItemMapManager;
|
||||||
import nautilus.game.arcade.game.games.minecraftleague.kit.KitPlayer;
|
import nautilus.game.arcade.game.games.minecraftleague.kit.KitPlayer;
|
||||||
import nautilus.game.arcade.game.games.minecraftleague.variation.ExtraScoreboardData;
|
import nautilus.game.arcade.game.games.minecraftleague.variation.ExtraScoreboardData;
|
||||||
@ -94,11 +95,10 @@ import com.google.common.base.Objects;
|
|||||||
|
|
||||||
public class MinecraftLeague extends TeamGame
|
public class MinecraftLeague extends TeamGame
|
||||||
{
|
{
|
||||||
private ConcurrentHashMap<GameTeam, TeamCrystal> _crystals = new ConcurrentHashMap<GameTeam, TeamCrystal>();
|
|
||||||
private ConcurrentHashMap<Player, PlayerRespawnPoint> _customRespawns = new ConcurrentHashMap<Player, PlayerRespawnPoint>();
|
private ConcurrentHashMap<Player, PlayerRespawnPoint> _customRespawns = new ConcurrentHashMap<Player, PlayerRespawnPoint>();
|
||||||
//private ConcurrentHashMap<GameTeam, TeamMap> _maps = new ConcurrentHashMap<GameTeam, TeamMap>();
|
//private ConcurrentHashMap<GameTeam, TeamMap> _maps = new ConcurrentHashMap<GameTeam, TeamMap>();
|
||||||
private ConcurrentHashMap<Player, List<ItemStack>> _gear = new ConcurrentHashMap<Player, List<ItemStack>>();
|
private ConcurrentHashMap<Player, List<ItemStack>> _gear = new ConcurrentHashMap<Player, List<ItemStack>>();
|
||||||
private ConcurrentHashMap<GameTeam, TeamBeacon> _beacons = new ConcurrentHashMap<GameTeam, TeamBeacon>();
|
//private ConcurrentHashMap<GameTeam, TeamBeacon> _beacons = new ConcurrentHashMap<GameTeam, TeamBeacon>();
|
||||||
private ConcurrentHashMap<Player, BlockProtection> _blockLock = new ConcurrentHashMap<Player, BlockProtection>();
|
private ConcurrentHashMap<Player, BlockProtection> _blockLock = new ConcurrentHashMap<Player, BlockProtection>();
|
||||||
private ConcurrentHashMap<Player, Long> _spawnAllow = new ConcurrentHashMap<Player, Long>();
|
private ConcurrentHashMap<Player, Long> _spawnAllow = new ConcurrentHashMap<Player, Long>();
|
||||||
private List<Spawner> _spawners = new ArrayList<Spawner>();
|
private List<Spawner> _spawners = new ArrayList<Spawner>();
|
||||||
@ -116,6 +116,9 @@ public class MinecraftLeague extends TeamGame
|
|||||||
|
|
||||||
private VariationManager _vman;
|
private VariationManager _vman;
|
||||||
private FreezeManager _freeze;
|
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)
|
public MinecraftLeague(ArcadeManager manager)
|
||||||
{
|
{
|
||||||
@ -179,6 +182,7 @@ public class MinecraftLeague extends TeamGame
|
|||||||
|
|
||||||
_vman = new VariationManager(this);
|
_vman = new VariationManager(this);
|
||||||
_freeze = new FreezeManager();
|
_freeze = new FreezeManager();
|
||||||
|
_tower = new TowerManager(this);
|
||||||
Bukkit.getPluginManager().registerEvents(_freeze, manager.getPlugin());
|
Bukkit.getPluginManager().registerEvents(_freeze, manager.getPlugin());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -363,14 +367,25 @@ public class MinecraftLeague extends TeamGame
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMapVariantID()
|
public List<String> getMapVariantIDS()
|
||||||
{
|
{
|
||||||
return WorldData.GetDataLocs(DataLoc.VARIANT_ID.getKey()).size();
|
List<String> ids = new ArrayList<String>();
|
||||||
|
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()
|
public FreezeManager getFreezeManager()
|
||||||
@ -385,29 +400,25 @@ public class MinecraftLeague extends TeamGame
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void ParseData()
|
public void ParseData()
|
||||||
{
|
{
|
||||||
Location redLoc = WorldData.GetDataLocs(DataLoc.RED_CRYSTAL.getKey()).get(0);
|
_tower.parseTowers(WorldData);
|
||||||
Location blueLoc = WorldData.GetDataLocs(DataLoc.BLUE_CRYSTAL.getKey()).get(0);
|
|
||||||
|
|
||||||
_crystals.put(GetTeam(ChatColor.RED), new TeamCrystal(this, GetTeam(ChatColor.RED), redLoc));
|
//_beacons.put(GetTeam(ChatColor.RED), new TeamBeacon(GetTeam(ChatColor.RED), WorldData.GetDataLocs(DataLoc.RED_BEACON.getKey()).get(0).getBlock(), redLoc));
|
||||||
_crystals.put(GetTeam(ChatColor.AQUA), new TeamCrystal(this, GetTeam(ChatColor.AQUA), blueLoc));
|
//_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()))
|
for (Location loc : WorldData.GetDataLocs(DataLoc.SKELETON_SPAWNER.getKey()))
|
||||||
{
|
{
|
||||||
_spawners.add(new Spawner(this, loc, EntityType.SKELETON));
|
_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}));
|
Ore.add(new OreDeposit(loc, Material.DIAMOND_ORE, new int[] {0, 255, 255}));
|
||||||
}
|
}
|
||||||
for (Location loc : WorldData.GetDataLocs(DataLoc.MAP_IRON.getKey()))
|
for (Location loc : WorldData.GetDataLocs(DataLoc.MAP_IRON.getKey()))
|
||||||
{
|
{
|
||||||
Ore.add(new OreDeposit(loc, Material.IRON_ORE, new int[] {190, 190, 190}));
|
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);
|
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 red = GetTeam(ChatColor.RED);
|
||||||
GameTeam blue = GetTeam(ChatColor.AQUA);
|
GameTeam blue = GetTeam(ChatColor.AQUA);
|
||||||
TeamCrystal redc = _crystals.get(red);
|
TeamCrystal redc = (TeamCrystal) _tower.getTeamTowers(red).getLast();
|
||||||
TeamCrystal bluec = _crystals.get(blue);
|
TeamCrystal bluec = (TeamCrystal) _tower.getTeamTowers(blue).getLast();
|
||||||
|
|
||||||
_liveTime = Math.max(System.currentTimeMillis() - GetStateTime(), 0);
|
_liveTime = Math.max(System.currentTimeMillis() - GetStateTime(), 0);
|
||||||
|
|
||||||
@ -507,54 +518,16 @@ public class MinecraftLeague extends TeamGame
|
|||||||
player.teleport(GetTeam(player).GetSpawn());
|
player.teleport(GetTeam(player).GetSpawn());
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum EditType
|
public boolean handleCommand(Player caller)
|
||||||
{
|
{
|
||||||
SPAWN, KILL, DAMAGE, STATUS;
|
for (GameTeam team : GetTeamList())
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
if (crystal == null)
|
TeamTowerBase tower = _tower.getVulnerable(team);
|
||||||
return false;
|
UtilPlayer.message(caller, team.GetColor() + team.GetName());
|
||||||
if (crystal.Alive)
|
UtilPlayer.message(caller, C.cGray + "Health: " + tower.getHealth());
|
||||||
return false;
|
UtilPlayer.message(caller, C.cGray + "Alive: " + tower.Alive);
|
||||||
crystal.handleDebug(caller, null, false);
|
|
||||||
}
|
}
|
||||||
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -563,12 +536,7 @@ public class MinecraftLeague extends TeamGame
|
|||||||
if (!_gear.containsKey(player))
|
if (!_gear.containsKey(player))
|
||||||
return;
|
return;
|
||||||
List<ItemStack> items = _gear.get(player);
|
List<ItemStack> items = _gear.get(player);
|
||||||
if (items.get(0) == null)
|
for (int i = 0; i < 4; i++)
|
||||||
UtilInv.insert(player, new ItemStack(Material.AIR));
|
|
||||||
else
|
|
||||||
UtilInv.insert(player, getNewItemStack(items.get(0)));
|
|
||||||
|
|
||||||
for (int i = 1; i < items.size(); i++)
|
|
||||||
{
|
{
|
||||||
ItemStack item;
|
ItemStack item;
|
||||||
if (items.get(i) != null)
|
if (items.get(i) != null)
|
||||||
@ -576,7 +544,7 @@ public class MinecraftLeague extends TeamGame
|
|||||||
else
|
else
|
||||||
item = new ItemStack(Material.AIR);
|
item = new ItemStack(Material.AIR);
|
||||||
|
|
||||||
switch(i)
|
switch(i + 1)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
player.getInventory().setHelmet(getNewItemStack(item));
|
player.getInventory().setHelmet(getNewItemStack(item));
|
||||||
@ -592,6 +560,13 @@ public class MinecraftLeague extends TeamGame
|
|||||||
break;
|
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);
|
_gear.remove(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -703,10 +678,7 @@ public class MinecraftLeague extends TeamGame
|
|||||||
|
|
||||||
if (event.getType() == UpdateType.FASTEST)
|
if (event.getType() == UpdateType.FASTEST)
|
||||||
{
|
{
|
||||||
for (TeamCrystal crystal : _crystals.values())
|
_tower.update();
|
||||||
{
|
|
||||||
crystal.update();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*for (TeamMap map : _maps.values())
|
/*for (TeamMap map : _maps.values())
|
||||||
{
|
{
|
||||||
@ -718,10 +690,10 @@ public class MinecraftLeague extends TeamGame
|
|||||||
spawner.update();
|
spawner.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (TeamBeacon beacon : _beacons.values())
|
/*for (TeamBeacon beacon : _beacons.values())
|
||||||
{
|
{
|
||||||
beacon.update();
|
beacon.update();
|
||||||
}
|
}*/
|
||||||
|
|
||||||
if (!OverTime)
|
if (!OverTime)
|
||||||
{
|
{
|
||||||
@ -759,14 +731,16 @@ public class MinecraftLeague extends TeamGame
|
|||||||
player.setFireTicks(-1);
|
player.setFireTicks(-1);
|
||||||
player.setFoodLevel(20);
|
player.setFoodLevel(20);
|
||||||
}
|
}
|
||||||
if (player.getInventory().getType() == InventoryType.BEACON)
|
if (player.getOpenInventory().getType() == InventoryType.BEACON)
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
|
if (player.getFireTicks() > 20 * 3)
|
||||||
|
player.setFireTicks(20 * 3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void crystalDmg(EntityDamageEvent event)
|
public void towerDmg(EntityDamageEvent event)
|
||||||
{
|
{
|
||||||
if (!InProgress())
|
if (!InProgress())
|
||||||
return;
|
return;
|
||||||
@ -774,15 +748,16 @@ public class MinecraftLeague extends TeamGame
|
|||||||
if (event.getEntity().getType() != EntityType.ENDER_CRYSTAL)
|
if (event.getEntity().getType() != EntityType.ENDER_CRYSTAL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (TeamCrystal cryst : _crystals.values())
|
for (GameTeam team : GetTeamList())
|
||||||
{
|
for (TeamTowerBase tower : _tower.getTeamTowers(team))
|
||||||
if (cryst.isEntity(event.getEntity()))
|
{
|
||||||
event.setCancelled(true);
|
if (tower.isEntity(event.getEntity()))
|
||||||
}
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void crystalDmg(EntityDamageByEntityEvent event)
|
public void towerDmg(EntityDamageByEntityEvent event)
|
||||||
{
|
{
|
||||||
if (!IsLive())
|
if (!IsLive())
|
||||||
return;
|
return;
|
||||||
@ -790,14 +765,15 @@ public class MinecraftLeague extends TeamGame
|
|||||||
if (event.getEntity().getType() != EntityType.ENDER_CRYSTAL)
|
if (event.getEntity().getType() != EntityType.ENDER_CRYSTAL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
TeamCrystal crystal = null;
|
TeamTowerBase tower = null;
|
||||||
for (TeamCrystal cryst : _crystals.values())
|
for (GameTeam team : GetTeamList())
|
||||||
|
for (TeamTowerBase tow : _tower.getTeamTowers(team))
|
||||||
{
|
{
|
||||||
if (cryst.isEntity(event.getEntity()))
|
if (tower.isEntity(event.getEntity()))
|
||||||
crystal = cryst;
|
tower = tow;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (crystal == null)
|
if (tower == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -812,11 +788,17 @@ public class MinecraftLeague extends TeamGame
|
|||||||
{
|
{
|
||||||
player = (Player) ((Projectile)event.getDamager()).getShooter();
|
player = (Player) ((Projectile)event.getDamager()).getShooter();
|
||||||
|
|
||||||
if (!crystal.canDamage(player))
|
if (!tower.canDamage(player))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!crystal.damage(event.getDamage(), player, true))
|
if (!tower.Vulnerable)
|
||||||
player.playSound(crystal.getLocation(), Sound.ORB_PICKUP, 100, 0);
|
{
|
||||||
|
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)
|
if (event.getDamager() instanceof Player)
|
||||||
{
|
{
|
||||||
player = (Player)event.getDamager();
|
player = (Player)event.getDamager();
|
||||||
if (!crystal.canDamage(player))
|
if (!tower.canDamage(player))
|
||||||
return;
|
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 (player.getItemInHand() == null || player.getItemInHand().getType() == Material.AIR)
|
||||||
{
|
{
|
||||||
if (!crystal.damage(1, player, true))
|
if (!tower.damage(1, player))
|
||||||
player.playSound(crystal.getLocation(), Sound.ZOMBIE_WOODBREAK, 1, 0);
|
player.playSound(tower.getLocation(), Sound.ZOMBIE_WOODBREAK, 1, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -838,8 +826,8 @@ public class MinecraftLeague extends TeamGame
|
|||||||
int level = player.getItemInHand().getEnchantmentLevel(Enchantment.DAMAGE_ALL);
|
int level = player.getItemInHand().getEnchantmentLevel(Enchantment.DAMAGE_ALL);
|
||||||
double damage = DamageAmount.getDamageAmount(type).getDamage(level, DamageType.getDamageType(type));
|
double damage = DamageAmount.getDamageAmount(type).getDamage(level, DamageType.getDamageType(type));
|
||||||
|
|
||||||
if (!crystal.damage(damage, player, true))
|
if (!tower.damage(damage, player))
|
||||||
player.playSound(crystal.getLocation(), Sound.ZOMBIE_WOODBREAK, 1, 0);
|
player.playSound(tower.getLocation(), Sound.ZOMBIE_WOODBREAK, 1, 0);
|
||||||
|
|
||||||
if (DamageAmount.getDamageAmount(type) != DamageAmount.NONE)
|
if (DamageAmount.getDamageAmount(type) != DamageAmount.NONE)
|
||||||
{
|
{
|
||||||
@ -1068,6 +1056,7 @@ public class MinecraftLeague extends TeamGame
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
List<ItemStack> newDrops = new ArrayList<ItemStack>();
|
List<ItemStack> newDrops = new ArrayList<ItemStack>();
|
||||||
|
Integer arrows = 0;
|
||||||
|
|
||||||
for (ItemStack item : event.getDrops())
|
for (ItemStack item : event.getDrops())
|
||||||
{
|
{
|
||||||
@ -1075,11 +1064,26 @@ public class MinecraftLeague extends TeamGame
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (_gear.get(event.getEntity()) != null)
|
if (_gear.get(event.getEntity()) != null)
|
||||||
|
{
|
||||||
|
if (item.getType() == Material.ARROW)
|
||||||
|
{
|
||||||
|
arrows += item.getAmount();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (_gear.get(event.getEntity()).contains(item))
|
if (_gear.get(event.getEntity()).contains(item))
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
newDrops.add(item);
|
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();
|
event.getDrops().clear();
|
||||||
for (ItemStack item : newDrops)
|
for (ItemStack item : newDrops)
|
||||||
@ -1104,13 +1108,22 @@ public class MinecraftLeague extends TeamGame
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void craftMap(PrepareItemCraftEvent event)
|
public void craftItem(PrepareItemCraftEvent event)
|
||||||
{
|
{
|
||||||
if (!IsLive())
|
if (!IsLive())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (event.getInventory().getResult().getType() == Material.EMPTY_MAP || event.getInventory().getResult().getType() == Material.MAP)
|
if (event.getInventory().getResult().getType() == Material.EMPTY_MAP || event.getInventory().getResult().getType() == Material.MAP)
|
||||||
event.getInventory().setResult(new ItemStack(Material.AIR));
|
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
|
@EventHandler
|
||||||
@ -1141,7 +1154,15 @@ public class MinecraftLeague extends TeamGame
|
|||||||
return;
|
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)
|
if (event.getCreatureType() == CreatureType.SPIDER)
|
||||||
{
|
{
|
||||||
for (int i = 1; i <= 3; i++)
|
for (int i = 1; i <= 3; i++)
|
||||||
@ -1157,34 +1178,39 @@ public class MinecraftLeague extends TeamGame
|
|||||||
|
|
||||||
if (event.GetGame() != this)
|
if (event.GetGame() != this)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (TeamCrystal c : _crystals.values())
|
int playercount = GetTeam(ChatColor.RED).GetPlayers(true).size() + GetTeam(ChatColor.AQUA).GetPlayers(true).size();
|
||||||
{
|
_tower.prepareHealth(playercount, 50 * 2);
|
||||||
double playercount = GetTeam(ChatColor.RED).GetPlayers(true).size() + GetTeam(ChatColor.AQUA).GetPlayers(true).size();
|
|
||||||
c.setMaxHealth(50 * 2 * playercount);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void dropBow(EntityDeathEvent event)
|
public void dropBowStuff(EntityDeathEvent event)
|
||||||
{
|
{
|
||||||
if (event.getEntityType() != EntityType.SKELETON)
|
/*if (event.getEntityType() == EntityType.SKELETON)
|
||||||
return;
|
|
||||||
|
|
||||||
boolean addbow = true;
|
|
||||||
for (ItemStack check : event.getDrops())
|
|
||||||
{
|
{
|
||||||
if (check.getType() == Material.BOW)
|
boolean addbow = true;
|
||||||
addbow = false;
|
for (ItemStack check : event.getDrops())
|
||||||
}
|
{
|
||||||
|
if (check.getType() == Material.BOW)
|
||||||
if (addbow)
|
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)
|
for (ItemStack test : event.getDrops())
|
||||||
event.getDrops().add(new ItemStack(Material.BOW));
|
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
|
@EventHandler
|
||||||
@ -1230,16 +1256,6 @@ public class MinecraftLeague extends TeamGame
|
|||||||
Player player = (Player)event.getEntity();
|
Player player = (Player)event.getEntity();
|
||||||
List<ItemStack> gear = new ArrayList<ItemStack>();
|
List<ItemStack> gear = new ArrayList<ItemStack>();
|
||||||
|
|
||||||
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()))
|
if (!UtilItem.isDiamondProduct(player.getInventory().getHelmet()))
|
||||||
gear.add(player.getInventory().getHelmet());
|
gear.add(player.getInventory().getHelmet());
|
||||||
else
|
else
|
||||||
@ -1260,6 +1276,24 @@ public class MinecraftLeague extends TeamGame
|
|||||||
else
|
else
|
||||||
gear.add(new ItemStack(Material.AIR));
|
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);
|
_gear.put(player, gear);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1347,7 +1381,7 @@ public class MinecraftLeague extends TeamGame
|
|||||||
return;
|
return;
|
||||||
Player player = Bukkit.getPlayer(event.GetLog().GetPlayer().GetName());
|
Player player = Bukkit.getPlayer(event.GetLog().GetPlayer().GetName());
|
||||||
|
|
||||||
if (!_crystals.get(GetTeam(player)).Alive)
|
if (_tower.getAmountAlive(GetTeam(player)) < 1)
|
||||||
{
|
{
|
||||||
SetPlayerState(player, PlayerState.OUT);
|
SetPlayerState(player, PlayerState.OUT);
|
||||||
|
|
||||||
@ -1375,8 +1409,8 @@ public class MinecraftLeague extends TeamGame
|
|||||||
|
|
||||||
if (OverTime)
|
if (OverTime)
|
||||||
{
|
{
|
||||||
_crystals.get(GetTeam(player)).damage(20, null, false);
|
_tower.getVulnerable(GetTeam(player)).damage(20, null);
|
||||||
if (!_crystals.get(GetTeam(player)).Alive)
|
if (_tower.getAmountAlive(GetTeam(player)) < 1)
|
||||||
{
|
{
|
||||||
SetPlayerState(player, PlayerState.OUT);
|
SetPlayerState(player, PlayerState.OUT);
|
||||||
|
|
||||||
@ -1420,23 +1454,34 @@ public class MinecraftLeague extends TeamGame
|
|||||||
if (event.getEntity() instanceof Enderman)
|
if (event.getEntity() instanceof Enderman)
|
||||||
event.setCancelled(true);
|
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())
|
if (event.getLocation().getWorld().getUID() != WorldData.World.getUID())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (event.getLocation().distance(crystal.getLocation()) <= 5)
|
if (event.getLocation().distance(tower.getLocation()) <= 5)
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void sigilsIsMean(BlockBreakEvent event)
|
public void handleBreak(BlockBreakEvent event)
|
||||||
{
|
{
|
||||||
if (!IsLive())
|
if (!IsLive())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (UtilPlayer.isSpectator(event.getPlayer()))
|
if (UtilPlayer.isSpectator(event.getPlayer()))
|
||||||
|
{
|
||||||
event.setCancelled(true);
|
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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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<Location> possible, int amount)
|
||||||
|
{
|
||||||
|
_current = 0;
|
||||||
|
_total = amount;
|
||||||
|
while (_current < _total)
|
||||||
|
{
|
||||||
|
iterateOres(oreType, possible);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void iterateOres(Material oreType, List<Location> 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++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,249 +1,14 @@
|
|||||||
package nautilus.game.arcade.game.games.minecraftleague.data;
|
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.GameTeam;
|
||||||
import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague;
|
import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Location;
|
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;
|
public TeamCrystal(MinecraftLeague host, TowerManager manager, GameTeam team, Location spawn)
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
_host = host;
|
super(host, manager, team, spawn);
|
||||||
_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();
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
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"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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<TeamTowerBase, GameTeam> _towers = new ConcurrentHashMap<TeamTowerBase, GameTeam>();
|
||||||
|
private ConcurrentHashMap<GameTeam, Integer> _vulnerableTower = new ConcurrentHashMap<GameTeam, Integer>();
|
||||||
|
private ConcurrentHashMap<TeamTowerBase, DefenderAI> _def = new ConcurrentHashMap<TeamTowerBase, DefenderAI>();
|
||||||
|
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<TeamTowerBase> getAllTeamTowers(GameTeam team)
|
||||||
|
{
|
||||||
|
List<TeamTowerBase> ret = new ArrayList<TeamTowerBase>();
|
||||||
|
|
||||||
|
for (TeamTowerBase tower : _towers.keySet())
|
||||||
|
{
|
||||||
|
if (_towers.get(tower).GetColor() == team.GetColor())
|
||||||
|
{
|
||||||
|
ret.add(tower);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LinkedList<TeamTowerBase> getTeamTowers(GameTeam team)
|
||||||
|
{
|
||||||
|
LinkedList<TeamTowerBase> ret = new LinkedList<TeamTowerBase>();
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -4,6 +4,7 @@ import java.lang.reflect.InvocationTargetException;
|
|||||||
|
|
||||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||||
import nautilus.game.arcade.game.Game.GameState;
|
import nautilus.game.arcade.game.Game.GameState;
|
||||||
|
import nautilus.game.arcade.game.games.minecraftleague.DataLoc;
|
||||||
import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague;
|
import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -27,12 +28,12 @@ public class VariationManager implements Listener
|
|||||||
|
|
||||||
public void selectVariation()
|
public void selectVariation()
|
||||||
{
|
{
|
||||||
VariationType type = VariationType.getFromID(_host.getMapVariantID());
|
VariationType type = null;
|
||||||
|
if (_host.getMapVariantIDS().size() != 1)
|
||||||
if (type.getVariation() == null)
|
type = VariationType.STANDARD;
|
||||||
|
else
|
||||||
{
|
{
|
||||||
Bukkit.broadcastMessage(type.getDisplayMessage());
|
type = VariationType.getFromID(_host.getMapVariantIDS().get(0).replace(DataLoc.VARIANT_BASE.getKey(), ""));
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -6,17 +6,17 @@ import org.bukkit.ChatColor;
|
|||||||
|
|
||||||
public enum VariationType
|
public enum VariationType
|
||||||
{
|
{
|
||||||
STANDARD(1, StandardGameplay.class, "Standard Gameplay", ChatColor.GREEN),
|
STANDARD("STANDARD", StandardGameplay.class, "Standard Gameplay", ChatColor.GREEN),
|
||||||
WITHER(2, WitherVariation.class, "Wither Variation", ChatColor.RED),
|
WITHER("WITHER", WitherVariation.class, "Wither Variation", ChatColor.RED),
|
||||||
//GUARDIAN(3, GuardianVariation.class, "Guardian Variation", ChatColor.DARK_AQUA)
|
//GUARDIAN(3, GuardianVariation.class, "Guardian Variation", ChatColor.DARK_AQUA)
|
||||||
;
|
;
|
||||||
|
|
||||||
private int _id;
|
private String _id;
|
||||||
private String _name;
|
private String _name;
|
||||||
private ChatColor _color;
|
private ChatColor _color;
|
||||||
private Class<? extends GameVariation> _variation;
|
private Class<? extends GameVariation> _variation;
|
||||||
|
|
||||||
private VariationType(int id, Class<? extends GameVariation> variationClass, String displayName, ChatColor displayColor)
|
private VariationType(String id, Class<? extends GameVariation> variationClass, String displayName, ChatColor displayColor)
|
||||||
{
|
{
|
||||||
_id = id;
|
_id = id;
|
||||||
_name = displayName;
|
_name = displayName;
|
||||||
@ -34,11 +34,11 @@ public enum VariationType
|
|||||||
return ChatColor.DARK_AQUA + "Game Type Selected: " + _color + _name;
|
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())
|
for (VariationType type : VariationType.values())
|
||||||
{
|
{
|
||||||
if (type._id == id)
|
if (type._id.equalsIgnoreCase(id))
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ import nautilus.game.arcade.events.PlayerGameRespawnEvent;
|
|||||||
import nautilus.game.arcade.game.GameTeam;
|
import nautilus.game.arcade.game.GameTeam;
|
||||||
import nautilus.game.arcade.game.games.minecraftleague.DataLoc;
|
import nautilus.game.arcade.game.games.minecraftleague.DataLoc;
|
||||||
import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague;
|
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.GameVariation;
|
||||||
import nautilus.game.arcade.game.games.minecraftleague.variation.wither.data.TeamAltar;
|
import nautilus.game.arcade.game.games.minecraftleague.variation.wither.data.TeamAltar;
|
||||||
import nautilus.game.arcade.game.games.minecraftleague.variation.wither.data.WitherMinionManager;
|
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 (_altars.get(team).ownsWither(event))
|
||||||
{
|
{
|
||||||
if (!Host.getCrystal(enemy).Alive)
|
if (Host.getTowerManager().getAmountAlive(enemy) < 1)
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
@ -181,7 +181,7 @@ public class WitherVariation extends GameVariation
|
|||||||
_wither.setCustomName(team.GetColor() + team.getDisplayName() + "'s Wither");
|
_wither.setCustomName(team.GetColor() + team.getDisplayName() + "'s Wither");
|
||||||
_wither.setCustomNameVisible(true);
|
_wither.setCustomNameVisible(true);
|
||||||
UtilTextMiddle.display("", team.GetColor() + team.getDisplayName() + " Team has spawned a Wither Boss!", UtilServer.getPlayers());
|
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();
|
_skellyMan.onWitherSpawn();
|
||||||
Bukkit.getScheduler().runTaskLater(Manager.getPlugin(), new Runnable()
|
Bukkit.getScheduler().runTaskLater(Manager.getPlugin(), new Runnable()
|
||||||
{
|
{
|
||||||
@ -229,18 +229,18 @@ public class WitherVariation extends GameVariation
|
|||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
|
||||||
TeamCrystal red = Host.getCrystal(Host.GetTeam(ChatColor.RED));
|
TeamTowerBase red = Host.getActiveTower(Host.GetTeam(ChatColor.RED));
|
||||||
TeamCrystal blue = Host.getCrystal(Host.GetTeam(ChatColor.AQUA));
|
TeamTowerBase blue = Host.getActiveTower(Host.GetTeam(ChatColor.AQUA));
|
||||||
HashMap<Block, Double> inside = UtilBlock.getInRadius(event.getLocation().getBlock(), 4, false);
|
HashMap<Block, Double> 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()))
|
if (inside.containsKey(red.getLocation().getBlock()))
|
||||||
{
|
{
|
||||||
red.damage(dmg, null, true);
|
red.damage(dmg, null);
|
||||||
}
|
}
|
||||||
if (inside.containsKey(blue.getLocation().getBlock()))
|
if (inside.containsKey(blue.getLocation().getBlock()))
|
||||||
{
|
{
|
||||||
blue.damage(dmg, null, true);
|
blue.damage(dmg, null);
|
||||||
}
|
}
|
||||||
for (Block b : inside.keySet())
|
for (Block b : inside.keySet())
|
||||||
{
|
{
|
||||||
@ -254,7 +254,7 @@ public class WitherVariation extends GameVariation
|
|||||||
}
|
}
|
||||||
for (GameTeam owner : Host.GetTeamList())
|
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)
|
if (b.getType() == Material.BEDROCK)
|
||||||
continue;
|
continue;
|
||||||
|
@ -24,36 +24,36 @@ public class TeamAltar
|
|||||||
private WitherVariation _host;
|
private WitherVariation _host;
|
||||||
private GameTeam _team;
|
private GameTeam _team;
|
||||||
private Location _center;
|
private Location _center;
|
||||||
|
|
||||||
private List<Location> _protected;
|
private List<Location> _protected;
|
||||||
|
|
||||||
private Location[] _skullSpots;
|
private Location[] _skullSpots;
|
||||||
|
|
||||||
private int _placed;
|
private int _placed;
|
||||||
|
|
||||||
public TeamAltar(WitherVariation host, GameTeam team, Location center)
|
public TeamAltar(WitherVariation host, GameTeam team, Location center)
|
||||||
{
|
{
|
||||||
_host = host;
|
_host = host;
|
||||||
_team = team;
|
_team = team;
|
||||||
_center = center;
|
_center = center;
|
||||||
|
|
||||||
spawnSoulsand();
|
spawnSoulsand();
|
||||||
|
|
||||||
_protected = UtilShapes.getSphereBlocks(center, 7, 7, false);
|
_protected = UtilShapes.getSphereBlocks(center, 7, 7, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInsideAltar(Location location)
|
public boolean isInsideAltar(Location location)
|
||||||
{
|
{
|
||||||
return _protected.contains(location);
|
return _protected.contains(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void spawnSoulsand()
|
public void spawnSoulsand()
|
||||||
{
|
{
|
||||||
_placed = 0;
|
_placed = 0;
|
||||||
Location s1 = null;
|
Location s1 = null;
|
||||||
Location s2 = null;
|
Location s2 = null;
|
||||||
Location s3 = null;
|
Location s3 = null;
|
||||||
|
|
||||||
for (int i = -1; i <= 1; i++)
|
for (int i = -1; i <= 1; i++)
|
||||||
{
|
{
|
||||||
_center.getBlock().getRelative(i, 1, 0).setType(Material.SOUL_SAND);
|
_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();
|
s3 = _center.getBlock().getRelative(i, 2, 0).getLocation();
|
||||||
}
|
}
|
||||||
_center.getBlock().setType(Material.SOUL_SAND);
|
_center.getBlock().setType(Material.SOUL_SAND);
|
||||||
|
|
||||||
_skullSpots = new Location[] {s1, s2, s3};
|
_skullSpots = new Location[] {s1, s2, s3};
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canBreak(Player player, Block block, boolean notify)
|
public boolean canBreak(Player player, Block block, boolean notify)
|
||||||
{
|
{
|
||||||
if (isInsideAltar(block.getLocation()))
|
if (isInsideAltar(block.getLocation()))
|
||||||
@ -91,87 +91,81 @@ public class TeamAltar
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canPlace(Player player, Material blockType, Location location, boolean notify)
|
public boolean canPlace(Player player, Material blockType, Location location, boolean notify)
|
||||||
{
|
{
|
||||||
boolean should = false;
|
|
||||||
if (isInsideAltar(location))
|
if (isInsideAltar(location))
|
||||||
{
|
{
|
||||||
should = true;
|
|
||||||
if (!_team.HasPlayer(player))
|
if (!_team.HasPlayer(player))
|
||||||
{
|
{
|
||||||
if (notify)
|
if (notify)
|
||||||
UtilPlayer.message(player, F.main("Game", "This is not your Altar!"));
|
UtilPlayer.message(player, F.main("Game", "This is not your Altar!"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_host.WitherSpawned)
|
if (_host.WitherSpawned)
|
||||||
{
|
{
|
||||||
if (notify)
|
if (notify)
|
||||||
UtilPlayer.message(player, F.main("Game", "A Wither is already spawned!"));
|
UtilPlayer.message(player, F.main("Game", "A Wither is already spawned!"));
|
||||||
should = false;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (blockType != Material.SKULL)
|
if (blockType != Material.SKULL)
|
||||||
{
|
{
|
||||||
if (notify)
|
if (notify)
|
||||||
UtilPlayer.message(player, F.main("Game", "You cannot place that inside an Altar!"));
|
UtilPlayer.message(player, F.main("Game", "You cannot place that inside an Altar!"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean passes = false;
|
boolean passes = false;
|
||||||
for (Location l : _skullSpots)
|
for (Location l : _skullSpots)
|
||||||
{
|
{
|
||||||
if (l.equals(location))
|
if (l.equals(location))
|
||||||
passes = true;
|
passes = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!passes)
|
if (!passes)
|
||||||
{
|
{
|
||||||
if (notify)
|
if (notify)
|
||||||
UtilPlayer.message(player, F.main("Game", "That doesn't go there!"));
|
UtilPlayer.message(player, F.main("Game", "That doesn't go there!"));
|
||||||
should = false;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_team.GetColor() == ChatColor.RED)
|
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)
|
if (notify)
|
||||||
UtilPlayer.message(player, F.main("Game", "You do not need a Wither!"));
|
UtilPlayer.message(player, F.main("Game", "You do not need a Wither!"));
|
||||||
should = false;
|
|
||||||
return 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)
|
if (notify)
|
||||||
UtilPlayer.message(player, F.main("Game", "You do not need a Wither!"));
|
UtilPlayer.message(player, F.main("Game", "You do not need a Wither!"));
|
||||||
should = false;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
if (_team.HasPlayer(player) && blockType == Material.SKULL)
|
||||||
if (_team.HasPlayer(player) && blockType == Material.SKULL && should)
|
|
||||||
{
|
|
||||||
if (_placed < 2)
|
|
||||||
{
|
{
|
||||||
UtilTextMiddle.display("", _team.GetColor() + _team.getDisplayName() + " has placed a Skull on their Altar!");
|
if (_placed < 2)
|
||||||
for (Player scare : UtilServer.getPlayers())
|
|
||||||
{
|
{
|
||||||
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean ownsWither(EntitySpawnEvent event)
|
public boolean ownsWither(EntitySpawnEvent event)
|
||||||
{
|
{
|
||||||
if (event.getEntity() instanceof Wither)
|
if (event.getEntity() instanceof Wither)
|
||||||
@ -179,10 +173,10 @@ public class TeamAltar
|
|||||||
Location base = event.getLocation();
|
Location base = event.getLocation();
|
||||||
return (isInsideAltar(base.getBlock().getLocation()));
|
return (isInsideAltar(base.getBlock().getLocation()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Location getLocation()
|
public Location getLocation()
|
||||||
{
|
{
|
||||||
return _center.clone();
|
return _center.clone();
|
||||||
|
@ -187,8 +187,8 @@ public class WitherMinionManager implements Listener
|
|||||||
|
|
||||||
if (UtilTime.elapsed(_lastDied, UtilTime.convert(45, TimeUnit.SECONDS, TimeUnit.MILLISECONDS)))
|
if (UtilTime.elapsed(_lastDied, UtilTime.convert(45, TimeUnit.SECONDS, TimeUnit.MILLISECONDS)))
|
||||||
{
|
{
|
||||||
boolean noUse = (!_host.Host.getCrystal(_host.Host.GetTeam(ChatColor.RED)).Alive);
|
boolean noUse = _host.Host.getTowerManager().getAmountAlive(_host.Host.GetTeam(ChatColor.RED)) < 1;
|
||||||
if (_host.Host.getCrystal(_host.Host.GetTeam(ChatColor.AQUA)).Alive)
|
if (_host.Host.getTowerManager().getAmountAlive(_host.Host.GetTeam(ChatColor.AQUA)) >= 1)
|
||||||
noUse = false;
|
noUse = false;
|
||||||
if (!_host.WitherSpawned || noUse)
|
if (!_host.WitherSpawned || noUse)
|
||||||
{
|
{
|
||||||
@ -200,8 +200,8 @@ public class WitherMinionManager implements Listener
|
|||||||
|
|
||||||
if (UtilTime.elapsed(_lastDied, UtilTime.convert(1, TimeUnit.MINUTES, TimeUnit.MILLISECONDS)))
|
if (UtilTime.elapsed(_lastDied, UtilTime.convert(1, TimeUnit.MINUTES, TimeUnit.MILLISECONDS)))
|
||||||
{
|
{
|
||||||
boolean noUse = (!_host.Host.getCrystal(_host.Host.GetTeam(ChatColor.RED)).Alive);
|
boolean noUse = _host.Host.getTowerManager().getAmountAlive(_host.Host.GetTeam(ChatColor.RED)) < 1;
|
||||||
if (_host.Host.getCrystal(_host.Host.GetTeam(ChatColor.AQUA)).Alive)
|
if (_host.Host.getTowerManager().getAmountAlive(_host.Host.GetTeam(ChatColor.AQUA)) >= 1)
|
||||||
noUse = false;
|
noUse = false;
|
||||||
if (!_host.WitherSpawned || noUse)
|
if (!_host.WitherSpawned || noUse)
|
||||||
{
|
{
|
||||||
@ -232,8 +232,8 @@ public class WitherMinionManager implements Listener
|
|||||||
if (event.getType() != UpdateType.FASTEST)
|
if (event.getType() != UpdateType.FASTEST)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
boolean noUse = (!_host.Host.getCrystal(_host.Host.GetTeam(ChatColor.RED)).Alive);
|
boolean noUse = _host.Host.getTowerManager().getAmountAlive(_host.Host.GetTeam(ChatColor.RED)) < 1;
|
||||||
if (_host.Host.getCrystal(_host.Host.GetTeam(ChatColor.AQUA)).Alive)
|
if (_host.Host.getTowerManager().getAmountAlive(_host.Host.GetTeam(ChatColor.AQUA)) >= 1)
|
||||||
noUse = false;
|
noUse = false;
|
||||||
|
|
||||||
if (_entity != null || noUse)
|
if (_entity != null || noUse)
|
||||||
|
@ -8,10 +8,13 @@ import mineplex.core.common.util.UtilEnt;
|
|||||||
import mineplex.core.common.util.UtilMath;
|
import mineplex.core.common.util.UtilMath;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.common.util.UtilTime;
|
import mineplex.core.common.util.UtilTime;
|
||||||
import mineplex.core.common.util.UtilTime.TimeUnit;
|
|
||||||
import nautilus.game.arcade.game.GameTeam;
|
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 nautilus.game.arcade.game.games.minecraftleague.variation.wither.WitherVariation;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Arrow;
|
import org.bukkit.entity.Arrow;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
@ -28,20 +31,23 @@ public class WitherPathfinder
|
|||||||
private Wither _ent;
|
private Wither _ent;
|
||||||
private LinkedList<Location> _waypoints;
|
private LinkedList<Location> _waypoints;
|
||||||
private GameTeam _team;
|
private GameTeam _team;
|
||||||
private Entity _enemy;
|
private GameTeam _enemy;
|
||||||
|
private TowerManager _towerManager;
|
||||||
private long _lastAttack;
|
private long _lastAttack;
|
||||||
|
private long _lastTowerAttack;
|
||||||
|
|
||||||
private boolean _finishedJourney = false;
|
|
||||||
private boolean _startedJourney = false;
|
private boolean _startedJourney = false;
|
||||||
|
|
||||||
public WitherPathfinder(WitherVariation host, Wither ent, LinkedList<Location> waypoints, GameTeam team, Entity enemy)
|
public WitherPathfinder(WitherVariation host, Wither ent, LinkedList<Location> waypoints, GameTeam team, GameTeam enemy, TowerManager towerManager)
|
||||||
{
|
{
|
||||||
_host = host;
|
_host = host;
|
||||||
_ent = ent;
|
_ent = ent;
|
||||||
_waypoints = waypoints;
|
_waypoints = waypoints;
|
||||||
_team = team;
|
_team = team;
|
||||||
_enemy = enemy;
|
_enemy = enemy;
|
||||||
|
_towerManager = towerManager;
|
||||||
_lastAttack = -1;
|
_lastAttack = -1;
|
||||||
|
_lastTowerAttack = -1;
|
||||||
_pathData = new PathfinderData(ent, waypoints.getFirst());
|
_pathData = new PathfinderData(ent, waypoints.getFirst());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,18 +105,17 @@ public class WitherPathfinder
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (target != null)
|
if (target != null)
|
||||||
shootAt(target.getLocation());
|
{
|
||||||
|
if (UtilTime.elapsed(_lastAttack, 2))
|
||||||
|
{
|
||||||
|
_lastAttack = System.currentTimeMillis();
|
||||||
|
shootAt(target.getLocation());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void shootAt(Location loc)
|
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 old = _ent.getLocation();
|
||||||
Location temp = _ent.getLocation();
|
Location temp = _ent.getLocation();
|
||||||
temp.setPitch(UtilAlg.GetPitch(UtilAlg.getTrajectory(_ent.getEyeLocation(), loc)));
|
temp.setPitch(UtilAlg.GetPitch(UtilAlg.getTrajectory(_ent.getEyeLocation(), loc)));
|
||||||
@ -121,7 +126,6 @@ public class WitherPathfinder
|
|||||||
_ent.removeMetadata("Shooting", _host.Manager.getPlugin());
|
_ent.removeMetadata("Shooting", _host.Manager.getPlugin());
|
||||||
_ent.teleport(old);
|
_ent.teleport(old);
|
||||||
//skull.setDirection(UtilAlg.getTrajectory(_ent.getLocation(), loc).normalize());
|
//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())
|
if ((_ent == null) || _ent.isDead() || !_ent.isValid())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (!_enemy.isValid() || _enemy.isDead() || _enemy == null)
|
Entity eTower = _towerManager.getVulnerable(_enemy).getEntity();
|
||||||
|
if (eTower == null || !eTower.isValid() || eTower.isDead())
|
||||||
{
|
{
|
||||||
_ent.remove();
|
_ent.remove();
|
||||||
return true;
|
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);
|
_ent.setTarget(null);
|
||||||
Location finalize = _waypoints.getLast();
|
String tName = "";
|
||||||
finalize.setPitch(UtilAlg.GetPitch(UtilAlg.getTrajectory(_ent, _enemy)));
|
if (_team.GetColor() == ChatColor.RED)
|
||||||
finalize.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(_ent, _enemy)));
|
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);
|
_ent.teleport(finalize);
|
||||||
shootAt(_enemy.getLocation());
|
if (UtilTime.elapsed(_lastTowerAttack, 5))
|
||||||
|
{
|
||||||
|
_lastTowerAttack = System.currentTimeMillis();
|
||||||
|
shootAt(eTower.getLocation());
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user