Reorganise of code

This commit is contained in:
Sam 2017-05-16 18:02:34 +01:00
parent 4148af9214
commit 833ebd310e
24 changed files with 675 additions and 326 deletions

View File

@ -1,18 +1,10 @@
package nautilus.game.arcade.game.games.moba; package nautilus.game.arcade.game.games.moba;
import mineplex.core.common.Rank; import mineplex.core.common.Rank;
import mineplex.core.common.entity.ClientArmorStand;
import mineplex.core.common.util.*; import mineplex.core.common.util.*;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.combat.DeathMessageType; import mineplex.minecraft.game.core.combat.DeathMessageType;
import mineplex.minecraft.game.core.condition.Condition;
import mineplex.minecraft.game.core.condition.Condition.ConditionType;
import mineplex.minecraft.game.core.condition.events.ConditionApplyEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType; import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GamePrepareCountdownCommence;
import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.DebugCommand; import nautilus.game.arcade.game.DebugCommand;
import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GameTeam;
@ -20,22 +12,26 @@ import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.game.games.moba.boss.BossManager; import nautilus.game.arcade.game.games.moba.boss.BossManager;
import nautilus.game.arcade.game.games.moba.boss.wither.WitherBoss; import nautilus.game.arcade.game.games.moba.boss.wither.WitherBoss;
import nautilus.game.arcade.game.games.moba.fountain.MobaFountain; import nautilus.game.arcade.game.games.moba.fountain.MobaFountain;
import nautilus.game.arcade.game.games.moba.general.TeamDamageManager;
import nautilus.game.arcade.game.games.moba.gold.GoldManager; import nautilus.game.arcade.game.games.moba.gold.GoldManager;
import nautilus.game.arcade.game.games.moba.kit.*; import nautilus.game.arcade.game.games.moba.kit.HeroKit;
import nautilus.game.arcade.game.games.moba.kit.KitPlayer;
import nautilus.game.arcade.game.games.moba.kit.anath.HeroAnath; import nautilus.game.arcade.game.games.moba.kit.anath.HeroAnath;
import nautilus.game.arcade.game.games.moba.kit.bob.HeroBob; import nautilus.game.arcade.game.games.moba.kit.bob.HeroBob;
import nautilus.game.arcade.game.games.moba.kit.dana.HeroDana; import nautilus.game.arcade.game.games.moba.kit.dana.HeroDana;
import nautilus.game.arcade.game.games.moba.kit.devon.HeroDevon; import nautilus.game.arcade.game.games.moba.kit.devon.HeroDevon;
import nautilus.game.arcade.game.games.moba.kit.hattori.HeroHattori; import nautilus.game.arcade.game.games.moba.kit.hattori.HeroHattori;
import nautilus.game.arcade.game.games.moba.kit.hp.HPManager;
import nautilus.game.arcade.game.games.moba.minion.MinionManager;
import nautilus.game.arcade.game.games.moba.prepare.PrepareManager;
import nautilus.game.arcade.game.games.moba.prepare.PrepareSelection;
import nautilus.game.arcade.game.games.moba.recall.Recall; import nautilus.game.arcade.game.games.moba.recall.Recall;
import nautilus.game.arcade.game.games.moba.shop.MobaShop; import nautilus.game.arcade.game.games.moba.shop.MobaShop;
import nautilus.game.arcade.game.games.moba.structure.point.CapturePoint; import nautilus.game.arcade.game.games.moba.structure.point.CapturePointManager;
import nautilus.game.arcade.game.games.moba.structure.tower.Tower;
import nautilus.game.arcade.game.games.moba.structure.tower.TowerManager; import nautilus.game.arcade.game.games.moba.structure.tower.TowerManager;
import nautilus.game.arcade.game.modules.CustomScoreboardModule; import nautilus.game.arcade.game.modules.CustomScoreboardModule;
import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.game.modules.compass.CompassModule;
import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.scoreboard.GameScoreboard; import nautilus.game.arcade.scoreboard.GameScoreboard;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
@ -45,11 +41,8 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityRegainHealthEvent;
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.metadata.FixedMetadataValue;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -61,13 +54,9 @@ public class Moba extends TeamGame
"..." "..."
}; };
private static final long PREPARE_TIME = TimeUnit.MINUTES.toMillis(1); private static final long PREPARE_TIME = TimeUnit.MINUTES.toMillis(1);
// Health per 5 seconds.
private static final double HP5 = 0.33;
private final HeroKit[] _kits; private final HeroKit[] _kits;
private final List<CapturePoint> _capturePoints = new ArrayList<>(3);
private final Set<MobaPlayer> _playerData = new HashSet<>(); private final Set<MobaPlayer> _playerData = new HashSet<>();
private final Set<Listener> _listeners = new HashSet<>(); private final Set<Listener> _listeners = new HashSet<>();
@ -76,6 +65,7 @@ public class Moba extends TeamGame
private final GoldManager _goldManager; private final GoldManager _goldManager;
private final BossManager _boss; private final BossManager _boss;
private final TowerManager _tower; private final TowerManager _tower;
private final CapturePointManager _capturePoint;
public Moba(ArcadeManager manager) public Moba(ArcadeManager manager)
{ {
@ -98,30 +88,29 @@ public class Moba extends TeamGame
HungerSet = 20; HungerSet = 20;
DamageFall = false; DamageFall = false;
Listener preGameSelection = new PregameSelection(this); // Instantiate managers
_listeners.add(preGameSelection);
Listener recall = new Recall(this); // Global managers
_listeners.add(recall); _shop = registerManager(new MobaShop(this));
_goldManager = registerManager(new GoldManager(this));
registerManager(new HPManager(this));
registerManager(new TeamDamageManager(this));
registerManager(new MobaFountain(this));
registerManager(new Recall(this));
MobaShop shop = new MobaShop(this); // Pregame managers
_shop = shop; registerManager(new PrepareManager(this));
_listeners.add(shop); registerManager(new PrepareSelection(this));
GoldManager goldManager = new GoldManager(this); // Bosses
_goldManager = goldManager; _boss = registerManager(new BossManager(this));
_listeners.add(goldManager);
MobaFountain fountain = new MobaFountain(this); // Structures
_listeners.add(fountain); _tower = registerManager(new TowerManager(this));
_capturePoint = registerManager(new CapturePointManager(this));
BossManager boss = new BossManager(this); // Minions
_boss = boss; //registerManager(new MinionManager(this));
_listeners.add(boss);
TowerManager tower = new TowerManager(this);
_tower = tower;
_listeners.add(tower);
new CompassModule() new CompassModule()
.setGiveCompass(true) .setGiveCompass(true)
@ -169,20 +158,20 @@ public class Moba extends TeamGame
GameState state = GetState(); GameState state = GetState();
GameTeam perspectiveTeam = GetTeam(perspective); GameTeam perspectiveTeam = GetTeam(perspective);
GameTeam subjectTeam = GetTeam(subject); GameTeam subjectTeam = GetTeam(subject);
MobaPlayer mobaPlayer = getData(subject); MobaPlayer mobaPlayer = getMobaData(subject);
String suffix; String suffix;
if (state == GameState.Prepare && !perspectiveTeam.equals(subjectTeam)) if (state == GameState.Prepare && !perspectiveTeam.equals(subjectTeam))
{ {
suffix = "Unknown"; suffix = "Unknown";
} }
else if (mobaPlayer.Kit == null) else if (mobaPlayer.getKit() == null)
{ {
suffix = "Selecting"; suffix = "Selecting";
} }
else else
{ {
suffix = mobaPlayer.Kit.GetName(); suffix = mobaPlayer.getKit().GetName();
} }
return C.cYellow + " " + suffix + C.Reset; return C.cYellow + " " + suffix + C.Reset;
@ -217,22 +206,22 @@ public class Moba extends TeamGame
}); });
} }
private <T extends Listener> T registerManager(T listener)
{
_listeners.add(listener);
return listener;
}
@Override @Override
public void ParseData() public void ParseData()
{ {
Collection<Location> capturePoints = getLocationStartsWith("POINT").values(); // Register all "Managers"
for (Location location : capturePoints)
{
_capturePoints.add(new CapturePoint(this, location));
}
_listeners.forEach(UtilServer::RegisterEvents); _listeners.forEach(UtilServer::RegisterEvents);
} }
private void writePrepare(Player player, GameScoreboard scoreboard) private void writePrepare(Player player, GameScoreboard scoreboard)
{ {
MobaPlayer mobaPlayer = getData(player); MobaPlayer mobaPlayer = getMobaData(player);
scoreboard.writeNewLine(); scoreboard.writeNewLine();
@ -242,7 +231,7 @@ public class Moba extends TeamGame
scoreboard.writeNewLine(); scoreboard.writeNewLine();
scoreboard.write(C.cYellowB + "Hero"); scoreboard.write(C.cYellowB + "Hero");
scoreboard.write(mobaPlayer.Kit == null ? "Unselected " : mobaPlayer.Kit.GetName() + " (" + mobaPlayer.Role.getName() + ")"); scoreboard.write(mobaPlayer.getKit() == null ? "Unselected " : mobaPlayer.getKit().GetName() + " (" + mobaPlayer.getRole().getName() + ")");
scoreboard.writeNewLine(); scoreboard.writeNewLine();
@ -251,7 +240,7 @@ public class Moba extends TeamGame
for (MobaPlayer otherMobaPlayer : _playerData) for (MobaPlayer otherMobaPlayer : _playerData)
{ {
if (otherMobaPlayer.Kit != null) if (otherMobaPlayer.getKit() != null)
{ {
kits++; kits++;
} }
@ -319,48 +308,6 @@ public class Moba extends TeamGame
} }
} }
@EventHandler
public void live(GameStateChangeEvent event)
{
if (event.GetState() != GameState.Live)
{
return;
}
UtilTextBottom.display(C.cRedB + "!!! Battle !!!", UtilServer.getPlayers());
for (MobaPlayer mobaPlayer : _playerData)
{
Player player = mobaPlayer.Player;
HeroKit kit = mobaPlayer.Kit;
Perk perk = kit.GetPerks()[kit.GetPerks().length - 1];
// Put Ultimates on cooldown
if (perk instanceof HeroSkill)
{
((HeroSkill) perk).useSkill(mobaPlayer.Player);
}
// Teleport players to their respective spawns
GameTeam team = GetTeam(player);
MobaLane lane = mobaPlayer.Role.getLane();
Location toTeleport = WorldData.GetCustomLocs("SPAWN " + team.GetName().toUpperCase() + " " + lane.toString()).get(0);
// Face the location toward the first tower of that lane
Tower tower = _tower.getFirsrtTower(lane);
if (tower != null)
{
toTeleport.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(player.getLocation(), tower.getLocation())));
}
else
{
toTeleport.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(player.getLocation(), GetSpectatorLocation())));
}
player.teleport(toTeleport);
}
}
@Override @Override
public void EndCheck() public void EndCheck()
{ {
@ -428,95 +375,6 @@ public class Moba extends TeamGame
_listeners.clear(); _listeners.clear();
} }
@EventHandler
public void update(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC)
{
return;
}
for (CapturePoint point : _capturePoints)
{
point.update();
}
}
@EventHandler
public void updatePrepare(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC || GetState() != GameState.Prepare)
{
return;
}
if (!UtilTime.elapsed(GetStateTime(), PREPARE_TIME))
{
for (Player player : GetPlayers(true))
{
Kit kit = GetKit(player);
if (!(kit instanceof HeroKit))
{
return;
}
}
}
AnnounceGame();
StartPrepareCountdown();
//Event
GamePrepareCountdownCommence countdownEvent = new GamePrepareCountdownCommence(this);
UtilServer.CallEvent(countdownEvent);
// If players took too long, just give them a random free role and kit.
for (Player player : GetPlayers(true))
{
Kit kit = GetKit(player);
if (kit instanceof HeroKit)
{
continue;
}
HeroKit heroKit = getFirstKit(player);
MobaPlayer mobaPlayer = getData(player);
mobaPlayer.Role = heroKit.getRole();
mobaPlayer.Kit = heroKit;
SetKit(player, heroKit, true);
}
PrepareTime = 0;
Manager.GetChat().Silence(0, false);
}
@EventHandler
public void roleSelect(RoleSelectEvent event)
{
Player player = event.getPlayer();
MobaRole role = event.getRole();
ClientArmorStand stand = event.getStand();
if (stand.hasMetadata("owned"))
{
player.sendMessage(F.main("Game", "Another player has already chosen this role."));
event.setCancelled(true);
return;
}
// Store inside the stand that it is claimed by a player
stand.setMetadata("owned", new FixedMetadataValue(Manager.getPlugin(), true));
// Show that the kit is claimed.
stand.setCustomName(C.cGreenB + role.getName() + C.cGray + " - " + player.getName());
// Store the role of the player
getData(player).Role = role;
}
@Override @Override
public void SetKit(Player player, Kit kit, boolean announce) public void SetKit(Player player, Kit kit, boolean announce)
{ {
@ -524,7 +382,7 @@ public class Moba extends TeamGame
if (kit instanceof HeroKit) if (kit instanceof HeroKit)
{ {
getData(player).Kit = (HeroKit) kit; getMobaData(player).setKit((HeroKit) kit);
} }
} }
@ -534,68 +392,16 @@ public class Moba extends TeamGame
return DeathMessageType.Detailed; return DeathMessageType.Detailed;
} }
@EventHandler
public void preventTeamDamage(CustomDamageEvent event)
{
Player damagee = event.GetDamageePlayer();
Player damager = event.GetDamagerPlayer(true);
if (damagee == null || damager == null)
{
return;
}
GameTeam damageeTeam = GetTeam(damagee);
GameTeam damagerTeam = GetTeam(damager);
if (damageeTeam == null || damagerTeam == null)
{
return;
}
if (damageeTeam.equals(damagerTeam))
{
event.SetCancelled("Team Damage");
}
}
@EventHandler
public void preventTeamFire(ConditionApplyEvent event)
{
Condition condition = event.GetCondition();
if (condition.GetType() != ConditionType.BURNING)
{
return;
}
if (condition.GetEnt() == null || condition.GetSource() == null)
{
return;
}
if (!(condition.GetEnt() instanceof Player && condition.GetSource() instanceof Player))
{
return;
}
if (!GetTeam((Player) condition.GetEnt()).equals(GetTeam((Player) condition.GetSource())))
{
return;
}
event.setCancelled(true);
}
// Clear up memory // Clear up memory
@EventHandler @EventHandler
public void playerQuit(PlayerQuitEvent event) public void playerQuit(PlayerQuitEvent event)
{ {
Player player = event.getPlayer(); Player player = event.getPlayer();
_playerData.removeIf(mobaPlayer -> mobaPlayer.Player.equals(player)); _playerData.removeIf(mobaPlayer -> mobaPlayer.getPlayer().equals(player));
} }
// Clean up arrows
@EventHandler @EventHandler
public void projectileHit(ProjectileHitEvent event) public void projectileHit(ProjectileHitEvent event)
{ {
@ -605,41 +411,6 @@ public class Moba extends TeamGame
} }
} }
/*
HP Regeneration
*/
@EventHandler
public void regeneration(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC_05)
{
return;
}
for (Player player : GetPlayers(true))
{
if (UtilPlayer.isSpectator(player))
{
continue;
}
MobaHPRegenEvent regenEvent = new MobaHPRegenEvent(player, HP5);
UtilServer.CallEvent(regenEvent);
player.setHealth(Math.min(player.getMaxHealth(), player.getHealth() + regenEvent.getHealth()));
}
}
@EventHandler
public void preventHungerRegeneration(EntityRegainHealthEvent event)
{
if (event.getRegainReason() == RegainReason.SATIATED)
{
event.setCancelled(true);
}
}
public Map<String, Location> getLocationStartsWith(String s) public Map<String, Location> getLocationStartsWith(String s)
{ {
Map<String, Location> map = new HashMap<>(); Map<String, Location> map = new HashMap<>();
@ -688,11 +459,16 @@ public class Moba extends TeamGame
return kits; return kits;
} }
public MobaPlayer getData(Player player) public Set<MobaPlayer> getMobaData()
{
return _playerData;
}
public MobaPlayer getMobaData(Player player)
{ {
for (MobaPlayer mobaPlayer : _playerData) for (MobaPlayer mobaPlayer : _playerData)
{ {
if (mobaPlayer.Player.equals(player)) if (mobaPlayer.getPlayer().equals(player))
{ {
return mobaPlayer; return mobaPlayer;
} }
@ -701,19 +477,19 @@ public class Moba extends TeamGame
return null; return null;
} }
private HeroKit getFirstKit(Player player) public HeroKit getFirstKit(Player player)
{ {
MobaPlayer mobaPlayer = getData(player); MobaPlayer mobaPlayer = getMobaData(player);
if (mobaPlayer.Role == null) if (mobaPlayer.getRole() == null)
{ {
MobaRole role = getRandomRole(player); MobaRole role = getRandomRole(player);
return getFirstKit(role); return getFirstKit(role);
} }
else if (mobaPlayer.Kit == null) else if (mobaPlayer.getKit() == null)
{ {
return getFirstKit(mobaPlayer.Role); return getFirstKit(mobaPlayer.getRole());
} }
return null; return null;
@ -738,7 +514,7 @@ public class Moba extends TeamGame
for (MobaPlayer mobaPlayer : getTeamData(GetTeam(player))) for (MobaPlayer mobaPlayer : getTeamData(GetTeam(player)))
{ {
MobaRole role = mobaPlayer.Role; MobaRole role = mobaPlayer.getRole();
if (role != null) if (role != null)
{ {
@ -749,13 +525,13 @@ public class Moba extends TeamGame
return UtilAlg.Random(Arrays.asList(MobaRole.values()), roles); return UtilAlg.Random(Arrays.asList(MobaRole.values()), roles);
} }
public List<MobaPlayer> getTeamData(GameTeam team) private List<MobaPlayer> getTeamData(GameTeam team)
{ {
List<MobaPlayer> players = new ArrayList<>(); List<MobaPlayer> players = new ArrayList<>();
for (MobaPlayer mobaPlayer : _playerData) for (MobaPlayer mobaPlayer : _playerData)
{ {
GameTeam otherTeam = GetTeam(mobaPlayer.Player); GameTeam otherTeam = GetTeam(mobaPlayer.getPlayer());
if (team.equals(otherTeam)) if (team.equals(otherTeam))
{ {
@ -766,11 +542,6 @@ public class Moba extends TeamGame
return players; return players;
} }
public List<CapturePoint> getCapturePoints()
{
return _capturePoints;
}
public MobaShop getShop() public MobaShop getShop()
{ {
return _shop; return _shop;
@ -780,4 +551,14 @@ public class Moba extends TeamGame
{ {
return _goldManager; return _goldManager;
} }
public TowerManager getTowerManager()
{
return _tower;
}
public CapturePointManager getCapturePointManager()
{
return _capturePoint;
}
} }

View File

@ -6,12 +6,48 @@ import org.bukkit.entity.Player;
public class MobaPlayer public class MobaPlayer
{ {
public final Player Player; private final Player _player;
public MobaRole Role; private MobaRole _role;
public HeroKit Kit; private HeroKit _kit;
private int _gold;
public MobaPlayer(Player player) public MobaPlayer(Player player)
{ {
Player = player; _player = player;
}
public Player getPlayer()
{
return _player;
}
public void setRole(MobaRole role)
{
_role = role;
}
public MobaRole getRole()
{
return _role;
}
public void setKit(HeroKit kit)
{
_kit = kit;
}
public HeroKit getKit()
{
return _kit;
}
public void setGold(int gold)
{
_gold = gold;
}
public int getGold()
{
return _gold;
} }
} }

View File

@ -1,25 +1,51 @@
package nautilus.game.arcade.game.games.moba; package nautilus.game.arcade.game.games.moba;
import mineplex.core.common.util.C;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Color; import org.bukkit.Color;
public enum MobaRole public enum MobaRole
{ {
ASSASSIN("Assassin", MobaLane.D, Color.BLUE, ChatColor.AQUA), ASSASSIN("Assassin", new String[]
HUNTER("Hunter", MobaLane.A, Color.LIME, ChatColor.GREEN), {
MAGE("Mage", MobaLane.B, Color.RED, ChatColor.RED),
WARRIOR("Warrior", MobaLane.C, Color.YELLOW, ChatColor.GOLD), "You are playing",
"the " + C.cAqua + "Assassin" + C.cWhite + " role this game",
}, MobaLane.D, Color.BLUE, ChatColor.AQUA),
HUNTER("Hunter", new String[]
{
"You are playing",
"the " + C.cGreen + "Hunter" + C.cWhite + " role this game",
}, MobaLane.A, Color.LIME, ChatColor.GREEN),
MAGE("Mage", new String[]
{
"You are playing",
"the " + C.cRed + "Mage" + C.cWhite + " role this game",
}, MobaLane.B, Color.RED, ChatColor.RED),
WARRIOR("Warrior", new String[]
{
"You are playing",
"the " + C.cGold + "Warrior" + C.cWhite + " role this game",
}, MobaLane.C, Color.YELLOW, ChatColor.GOLD),
; ;
private final String _name; private final String _name;
private final String[] _description;
private final MobaLane _lane; private final MobaLane _lane;
private final Color _color; private final Color _color;
private final ChatColor _chatColor; private final ChatColor _chatColor;
MobaRole(String name, MobaLane lane, Color color, ChatColor chatColor) MobaRole(String name, String[] description, MobaLane lane, Color color, ChatColor chatColor)
{ {
_name = name; _name = name;
_description = description;
_lane = lane; _lane = lane;
_color = color; _color = color;
_chatColor = chatColor; _chatColor = chatColor;
@ -30,6 +56,11 @@ public enum MobaRole
return _name; return _name;
} }
public String[] getDescription()
{
return _description;
}
public MobaLane getLane() public MobaLane getLane()
{ {
return _lane; return _lane;

View File

@ -147,6 +147,8 @@ public class WitherBoss extends MobaBoss
{ {
_entity.setHealth(_entity.getHealth() - SECOND_TOWER_HEALTH_REDUCTION); _entity.setHealth(_entity.getHealth() - SECOND_TOWER_HEALTH_REDUCTION);
} }
updateDisplay();
} }
@EventHandler @EventHandler

View File

@ -36,7 +36,7 @@ public class WitherSkullProjectile implements IThrown
WitherSkull skull = shooter.launchProjectile(WitherSkull.class); WitherSkull skull = shooter.launchProjectile(WitherSkull.class);
skull.setYield(0); skull.setYield(0);
skull.setVelocity(skull.getVelocity().add(UtilAlg.getTrajectory(shooter, target)).normalize().multiply(2)); skull.setVelocity(skull.getVelocity().add(UtilAlg.getTrajectory(shooter, target)));
_manager.GetProjectile().AddThrow(skull, shooter, this, 2000, true, true, true, false, 0.5F); _manager.GetProjectile().AddThrow(skull, shooter, this, 2000, true, true, true, false, 0.5F);
} }

View File

@ -0,0 +1,76 @@
package nautilus.game.arcade.game.games.moba.general;
import mineplex.minecraft.game.core.condition.Condition;
import mineplex.minecraft.game.core.condition.Condition.ConditionType;
import mineplex.minecraft.game.core.condition.events.ConditionApplyEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.games.moba.Moba;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
public class TeamDamageManager implements Listener
{
private final Moba _host;
public TeamDamageManager(Moba host)
{
_host = host;
}
@EventHandler
public void preventTeamDamage(CustomDamageEvent event)
{
Player damagee = event.GetDamageePlayer();
Player damager = event.GetDamagerPlayer(true);
if (damagee == null || damager == null)
{
return;
}
GameTeam damageeTeam = _host.GetTeam(damagee);
GameTeam damagerTeam = _host.GetTeam(damager);
if (damageeTeam == null || damagerTeam == null)
{
return;
}
if (damageeTeam.equals(damagerTeam))
{
event.SetCancelled("Team Damage");
}
}
@EventHandler
public void preventTeamFire(ConditionApplyEvent event)
{
Condition condition = event.GetCondition();
if (condition.GetType() != ConditionType.BURNING)
{
return;
}
if (condition.GetEnt() == null || condition.GetSource() == null)
{
return;
}
if (!(condition.GetEnt() instanceof Player && condition.GetSource() instanceof Player))
{
return;
}
if (!_host.GetTeam((Player) condition.GetEnt()).equals(_host.GetTeam((Player) condition.GetSource())))
{
return;
}
event.setCancelled(true);
}
}

View File

@ -96,7 +96,7 @@ public class GoldManager implements Listener
} }
// Capture points // Capture points
for (CapturePoint point : _host.getCapturePoints()) for (CapturePoint point : _host.getCapturePointManager().getCapturePoints())
{ {
GameTeam owner = point.getOwner(); GameTeam owner = point.getOwner();

View File

@ -62,7 +62,7 @@ public class SkillMeteor extends HeroSkill implements IThrown
FallingBlock block = player.getWorld().spawnFallingBlock(player.getEyeLocation().add(player.getLocation().getDirection()), Material.NETHERRACK, (byte) 0); FallingBlock block = player.getWorld().spawnFallingBlock(player.getEyeLocation().add(player.getLocation().getDirection()), Material.NETHERRACK, (byte) 0);
block.setVelocity(player.getLocation().getDirection()); block.setVelocity(player.getLocation().getDirection());
Manager.GetProjectile().AddThrow(block, player, this, 1000, true, true, true, false, 0.5F); Manager.GetProjectile().AddThrow(block, player, this, 2000, true, true, true, false, 0.5F);
useActiveSkill(player, 7000); useActiveSkill(player, 7000);
} }
@ -138,7 +138,7 @@ public class SkillMeteor extends HeroSkill implements IThrown
@Override @Override
public void Idle(ProjectileUser data) public void Idle(ProjectileUser data)
{ {
Expire(data);
} }
@Override @Override

View File

@ -0,0 +1,57 @@
package nautilus.game.arcade.game.games.moba.kit.hp;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.games.moba.Moba;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityRegainHealthEvent;
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
public class HPManager implements Listener
{
// Health per 5 seconds.
private static final double HP5 = 0.33;
private final Moba _host;
public HPManager(Moba host)
{
_host = host;
}
@EventHandler
public void regeneration(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC_05 || !_host.IsLive())
{
return;
}
for (Player player : _host.GetPlayers(true))
{
if (UtilPlayer.isSpectator(player))
{
continue;
}
MobaHPRegenEvent regenEvent = new MobaHPRegenEvent(player, HP5);
UtilServer.CallEvent(regenEvent);
player.setHealth(Math.min(player.getMaxHealth(), player.getHealth() + regenEvent.getHealth()));
}
}
@EventHandler
public void preventHungerRegeneration(EntityRegainHealthEvent event)
{
if (event.getRegainReason() == RegainReason.SATIATED)
{
event.setCancelled(true);
}
}
}

View File

@ -1,4 +1,4 @@
package nautilus.game.arcade.game.games.moba; package nautilus.game.arcade.game.games.moba.kit.hp;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;

View File

@ -0,0 +1,6 @@
package nautilus.game.arcade.game.games.moba.minion;
public class Minion
{
}

View File

@ -0,0 +1,17 @@
package nautilus.game.arcade.game.games.moba.minion;
import nautilus.game.arcade.game.games.moba.Moba;
import org.bukkit.event.Listener;
public class MinionManager implements Listener
{
private final Moba _host;
public MinionManager(Moba host)
{
_host = host;
}
}

View File

@ -0,0 +1,114 @@
package nautilus.game.arcade.game.games.moba.prepare;
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.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.game.games.moba.Moba;
import nautilus.game.arcade.game.games.moba.MobaPlayer;
import nautilus.game.arcade.game.games.moba.MobaRole;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;
import java.util.concurrent.TimeUnit;
public class PrepareInformation implements Listener
{
private static final long MESSAGE_TIME = TimeUnit.SECONDS.toMillis(5);
private static final int MESSAGE_TIME_TICKS = (int) (MESSAGE_TIME / 50D + 5);
private final Moba _host;
private long _lastMessage;
private int _messageIndex;
public PrepareInformation(Moba host)
{
_host = host;
// How long should the prepare time be.
int longestDescription = 0;
for (MobaRole role : MobaRole.values())
{
int length = role.getDescription().length;
if (length > longestDescription)
{
longestDescription = length;
}
}
// Modify the prepare time
_host.PrepareTime = longestDescription * 1000 + 1000;
UtilServer.RegisterEvents(this);
}
@EventHandler
public void updateMessages(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST || !UtilTime.elapsed(_lastMessage, MESSAGE_TIME))
{
return;
}
Bukkit.broadcastMessage("updateMessages");
for (MobaPlayer mobaPlayer : _host.getMobaData())
{
Bukkit.broadcastMessage(mobaPlayer.getPlayer().getName());
String[] description = mobaPlayer.getRole().getDescription();
// Description is too short
if (description.length > _messageIndex + 2)
{
Bukkit.broadcastMessage("Too short");
continue;
}
UtilTextMiddle.display(description[_messageIndex], description[_messageIndex + 1], 0, MESSAGE_TIME_TICKS, 0, mobaPlayer.getPlayer());
}
_messageIndex++;
_lastMessage = System.currentTimeMillis();
}
@EventHandler
public void playerMove(PlayerMoveEvent event)
{
if (UtilPlayer.isSpectator(event.getPlayer()))
{
return;
}
Location to = event.getTo();
Location from = event.getFrom();
// Player hasn't moved along the X or Z axis
if (to.getX() == from.getX() && to.getZ() == from.getZ())
{
return;
}
event.setCancelled(true);
}
@EventHandler
public void live(GameStateChangeEvent event)
{
if (event.GetState() != GameState.Live)
{
return;
}
UtilServer.Unregister(this);
}
}

View File

@ -0,0 +1,168 @@
package nautilus.game.arcade.game.games.moba.prepare;
import mineplex.core.common.entity.ClientArmorStand;
import mineplex.core.common.util.*;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.events.GamePrepareCountdownCommence;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.games.moba.Moba;
import nautilus.game.arcade.game.games.moba.MobaLane;
import nautilus.game.arcade.game.games.moba.MobaPlayer;
import nautilus.game.arcade.game.games.moba.MobaRole;
import nautilus.game.arcade.game.games.moba.kit.HeroKit;
import nautilus.game.arcade.game.games.moba.kit.HeroSkill;
import nautilus.game.arcade.game.games.moba.kit.RoleSelectEvent;
import nautilus.game.arcade.game.games.moba.structure.tower.Tower;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.Perk;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.metadata.FixedMetadataValue;
import java.util.concurrent.TimeUnit;
public class PrepareManager implements Listener
{
private static final long PREPARE_TIME = TimeUnit.MINUTES.toMillis(1);
private static final String OWNED_METADATA = "owned";
private final Moba _host;
private boolean _informationStage;
public PrepareManager(Moba host)
{
_host = host;
}
@EventHandler(priority = EventPriority.LOW)
public void updatePrepare(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC || _host.GetState() != GameState.Prepare || _informationStage)
{
return;
}
if (!UtilTime.elapsed(_host.GetStateTime(), PREPARE_TIME))
{
for (Player player : _host.GetPlayers(true))
{
Kit kit = _host.GetKit(player);
if (!(kit instanceof HeroKit))
{
return;
}
}
}
_informationStage = true;
_host.AnnounceGame();
_host.StartPrepareCountdown();
//Event
GamePrepareCountdownCommence countdownEvent = new GamePrepareCountdownCommence(_host);
UtilServer.CallEvent(countdownEvent);
// If players took too long, just give them a random free role and kit.
for (Player player : _host.GetPlayers(true))
{
Kit kit = _host.GetKit(player);
if (kit instanceof HeroKit)
{
continue;
}
HeroKit heroKit = _host.getFirstKit(player);
MobaPlayer mobaPlayer = _host.getMobaData(player);
mobaPlayer.setRole(heroKit.getRole());
_host.SetKit(player, heroKit, true);
}
for (MobaPlayer mobaPlayer : _host.getMobaData())
{
// Teleport players to their respective spawns
Player player = mobaPlayer.getPlayer();
GameTeam team = _host.GetTeam(player);
MobaLane lane = mobaPlayer.getRole().getLane();
Location toTeleport = _host.WorldData.GetCustomLocs("SPAWN " + team.GetName().toUpperCase() + " " + lane.toString()).get(0);
// Face the location toward the first tower of that lane
Tower tower = _host.getTowerManager().getFirsrtTower(lane);
if (tower != null)
{
toTeleport.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(player.getLocation(), tower.getLocation())));
}
else
{
toTeleport.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(player.getLocation(), _host.GetSpectatorLocation())));
}
player.teleport(toTeleport);
}
_host.SetStateTime(System.currentTimeMillis());
_host.getArcadeManager().GetChat().Silence(-1, false);
// Start the pregame role information
new PrepareInformation(_host);
}
@EventHandler
public void roleSelect(RoleSelectEvent event)
{
Player player = event.getPlayer();
MobaRole role = event.getRole();
ClientArmorStand stand = event.getStand();
if (stand.hasMetadata(OWNED_METADATA))
{
player.sendMessage(F.main("Game", "Another player has already chosen this role."));
event.setCancelled(true);
return;
}
// Store inside the stand that it is claimed by a player
stand.setMetadata(OWNED_METADATA, new FixedMetadataValue(_host.getArcadeManager().getPlugin(), true));
// Show that the kit is claimed.
stand.setCustomName(C.cGreenB + role.getName() + C.cGray + " - " + player.getName());
// Store the role of the player
_host.getMobaData(player).setRole(role);
}
@EventHandler
public void live(GameStateChangeEvent event)
{
if (event.GetState() != GameState.Live)
{
return;
}
for (MobaPlayer mobaPlayer : _host.getMobaData())
{
HeroKit kit = mobaPlayer.getKit();
Perk perk = kit.GetPerks()[kit.GetPerks().length - 1];
// Put Ultimates on cooldown
if (perk instanceof HeroSkill)
{
((HeroSkill) perk).useSkill(mobaPlayer.getPlayer());
}
}
_host.getArcadeManager().GetChat().Silence(0, true);
}
}

View File

@ -1,4 +1,4 @@
package nautilus.game.arcade.game.games.moba.kit; package nautilus.game.arcade.game.games.moba.prepare;
import mineplex.core.common.entity.ClientArmorStand; import mineplex.core.common.entity.ClientArmorStand;
import mineplex.core.common.util.*; import mineplex.core.common.util.*;
@ -9,16 +9,15 @@ import mineplex.core.packethandler.IPacketHandler;
import mineplex.core.packethandler.PacketHandler.ListenerPriority; import mineplex.core.packethandler.PacketHandler.ListenerPriority;
import mineplex.core.packethandler.PacketInfo; import mineplex.core.packethandler.PacketInfo;
import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.events.PlayerKitApplyEvent;
import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.Moba;
import nautilus.game.arcade.game.games.moba.MobaPlayer; import nautilus.game.arcade.game.games.moba.MobaPlayer;
import nautilus.game.arcade.game.games.moba.MobaRole; import nautilus.game.arcade.game.games.moba.MobaRole;
import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.game.games.moba.kit.HeroKit;
import nautilus.game.arcade.game.games.moba.kit.RoleSelectEvent;
import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity; import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity;
import org.bukkit.*; import org.bukkit.*;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -31,14 +30,14 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
public class PregameSelection implements Listener, IPacketHandler public class PrepareSelection implements Listener, IPacketHandler
{ {
private final Moba _host; private final Moba _host;
private final Map<ClientArmorStand, MobaRole> _roleStands = new HashMap<>(); private final Map<ClientArmorStand, MobaRole> _roleStands = new HashMap<>();
private final Map<ClientArmorStand, HeroKit> _kitStands = new HashMap<>(); private final Map<ClientArmorStand, HeroKit> _kitStands = new HashMap<>();
public PregameSelection(Moba host) public PrepareSelection(Moba host)
{ {
_host = host; _host = host;
@ -111,9 +110,9 @@ public class PregameSelection implements Listener, IPacketHandler
List<Location> spawns = _host.WorldData.GetDataLocs(dataKey); List<Location> spawns = _host.WorldData.GetDataLocs(dataKey);
Location average = UtilAlg.getAverageLocation(team.GetSpawns()); Location average = UtilAlg.getAverageLocation(team.GetSpawns());
MobaPlayer mobaPlayer = _host.getData(player); MobaPlayer mobaPlayer = _host.getMobaData(player);
List<HeroKit> heroKits = _host.getKits(mobaPlayer.Role); List<HeroKit> heroKits = _host.getKits(mobaPlayer.getRole());
ItemStack head = new ItemBuilder(Material.SKULL_ITEM, (byte) 2).build(); ItemStack head = new ItemBuilder(Material.SKULL_ITEM, (byte) 2).build();

View File

@ -4,7 +4,7 @@ import mineplex.minecraft.game.core.condition.Condition.ConditionType;
import mineplex.minecraft.game.core.condition.events.ConditionApplyEvent; import mineplex.minecraft.game.core.condition.events.ConditionApplyEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.events.PlayerGameRespawnEvent; import nautilus.game.arcade.events.PlayerGameRespawnEvent;
import nautilus.game.arcade.game.games.moba.MobaHPRegenEvent; import nautilus.game.arcade.game.games.moba.kit.hp.MobaHPRegenEvent;
import nautilus.game.arcade.game.games.moba.kit.AmmoGiveEvent; import nautilus.game.arcade.game.games.moba.kit.AmmoGiveEvent;
import nautilus.game.arcade.game.games.moba.kit.CooldownCalculateEvent; import nautilus.game.arcade.game.games.moba.kit.CooldownCalculateEvent;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -11,11 +11,11 @@ import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.events.PlayerGameRespawnEvent; import nautilus.game.arcade.events.PlayerGameRespawnEvent;
import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.game.games.moba.Moba; import nautilus.game.arcade.game.games.moba.Moba;
import nautilus.game.arcade.game.games.moba.MobaHPRegenEvent;
import nautilus.game.arcade.game.games.moba.MobaPlayer; import nautilus.game.arcade.game.games.moba.MobaPlayer;
import nautilus.game.arcade.game.games.moba.MobaRole; import nautilus.game.arcade.game.games.moba.MobaRole;
import nautilus.game.arcade.game.games.moba.kit.AmmoGiveEvent; import nautilus.game.arcade.game.games.moba.kit.AmmoGiveEvent;
import nautilus.game.arcade.game.games.moba.kit.CooldownCalculateEvent; import nautilus.game.arcade.game.games.moba.kit.CooldownCalculateEvent;
import nautilus.game.arcade.game.games.moba.kit.hp.MobaHPRegenEvent;
import nautilus.game.arcade.game.games.moba.shop.assassin.MobaAssassinShop; import nautilus.game.arcade.game.games.moba.shop.assassin.MobaAssassinShop;
import nautilus.game.arcade.game.games.moba.shop.hunter.MobaHunterShop; import nautilus.game.arcade.game.games.moba.shop.hunter.MobaHunterShop;
import nautilus.game.arcade.game.games.moba.shop.mage.MobaMageShop; import nautilus.game.arcade.game.games.moba.shop.mage.MobaMageShop;
@ -91,20 +91,20 @@ public class MobaShop implements Listener
public void openShop(MobaPlayer player) public void openShop(MobaPlayer player)
{ {
if (UtilPlayer.isSpectator(player.Player) || _host.GetState() != GameState.Live) if (UtilPlayer.isSpectator(player.getPlayer()) || _host.GetState() != GameState.Live)
{ {
return; return;
} }
MobaShopMenu menu = _roleMenus.get(player.Role); MobaShopMenu menu = _roleMenus.get(player.getRole());
if (menu == null) if (menu == null)
{ {
player.Player.sendMessage(F.main("Game", "There isn't an upgrade shop for that kit yet.")); player.getPlayer().sendMessage(F.main("Game", "There isn't an upgrade shop for that kit yet."));
return; return;
} }
menu.open(player.Player); menu.open(player.getPlayer());
} }
@EventHandler @EventHandler
@ -163,7 +163,7 @@ public class MobaShop implements Listener
{ {
if (clicked.equals(shop)) if (clicked.equals(shop))
{ {
MobaPlayer data = _host.getData(player); MobaPlayer data = _host.getMobaData(player);
if (data == null) if (data == null)
{ {

View File

@ -125,7 +125,7 @@ public class MobaShopCategoryMenu extends Menu<ArcadeManager>
@Override @Override
public void onClick(Player player, ClickType clickType) public void onClick(Player player, ClickType clickType)
{ {
_shop.openShop(_host.getData(player)); _shop.openShop(_host.getMobaData(player));
} }
} }
} }

View File

@ -1,7 +1,7 @@
package nautilus.game.arcade.game.games.moba.shop.effects; package nautilus.game.arcade.game.games.moba.shop.effects;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import nautilus.game.arcade.game.games.moba.MobaHPRegenEvent; import nautilus.game.arcade.game.games.moba.kit.hp.MobaHPRegenEvent;
import nautilus.game.arcade.game.games.moba.shop.MobaItemEffect; import nautilus.game.arcade.game.games.moba.shop.MobaItemEffect;
public class MobaHPRegenEffect extends MobaItemEffect public class MobaHPRegenEffect extends MobaItemEffect

View File

@ -23,7 +23,7 @@ public class MobaHitArrowAmmoEffect extends MobaItemEffect
Player damager = event.GetDamagerPlayer(true); Player damager = event.GetDamagerPlayer(true);
Moba host = (Moba) Managers.get(ArcadeManager.class).GetGame(); Moba host = (Moba) Managers.get(ArcadeManager.class).GetGame();
HeroKit kit = host.getData(damager).Kit; HeroKit kit = host.getMobaData(damager).getKit();
kit.giveAmmo(damager, 1); kit.giveAmmo(damager, 1);
} }

View File

@ -2,9 +2,6 @@ package nautilus.game.arcade.game.games.moba.shop.effects;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import nautilus.game.arcade.events.PlayerGameRespawnEvent;
import nautilus.game.arcade.game.games.moba.MobaHPRegenEvent;
import nautilus.game.arcade.game.games.moba.kit.CooldownCalculateEvent;
import nautilus.game.arcade.game.games.moba.shop.MobaItemEffect; import nautilus.game.arcade.game.games.moba.shop.MobaItemEffect;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -2,8 +2,6 @@ package nautilus.game.arcade.game.games.moba.shop.effects;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import nautilus.game.arcade.events.PlayerGameRespawnEvent; import nautilus.game.arcade.events.PlayerGameRespawnEvent;
import nautilus.game.arcade.game.games.moba.MobaHPRegenEvent;
import nautilus.game.arcade.game.games.moba.kit.CooldownCalculateEvent;
import nautilus.game.arcade.game.games.moba.shop.MobaItemEffect; import nautilus.game.arcade.game.games.moba.shop.MobaItemEffect;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -0,0 +1,64 @@
package nautilus.game.arcade.game.games.moba.structure.point;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.game.games.moba.Moba;
import org.bukkit.Location;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
public class CapturePointManager implements Listener
{
private final Moba _host;
private final List<CapturePoint> _capturePoints;
public CapturePointManager(Moba host)
{
_host = host;
_capturePoints = new ArrayList<>(3);
}
@EventHandler
public void prepare(GameStateChangeEvent event)
{
if (event.GetState() != GameState.Prepare)
{
return;
}
Collection<Location> capturePoints = _host.getLocationStartsWith("POINT").values();
for (Location location : capturePoints)
{
_capturePoints.add(new CapturePoint(_host, location));
}
}
@EventHandler
public void update(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC)
{
return;
}
for (CapturePoint point : _capturePoints)
{
point.update();
}
}
public List<CapturePoint> getCapturePoints()
{
return _capturePoints;
}
}

View File

@ -139,12 +139,16 @@ public class Tower
if (_health <= 0) if (_health <= 0)
{ {
UtilServer.CallEvent(new TowerDestroyEvent(this)); UtilServer.CallEvent(new TowerDestroyEvent(this));
// Boom!
explode();
// Nullify everything and remove all entities
_target = null; _target = null;
setLaserTarget(null); setLaserTarget(null);
_dead = true; _dead = true;
_stand.remove(); _stand.remove();
_crystal.remove(); _crystal.remove();
explode();
} }
else else
{ {
@ -163,7 +167,6 @@ public class Tower
private void explode() private void explode()
{ {
_host.getArcadeManager().GetExplosion().BlockExplosion(UtilBlock.getBlocksInRadius(_location.clone().subtract(0, 3, 0), 3), _location, false);
_location.getWorld().playSound(_location, Sound.EXPLODE, 2, 0.6F); _location.getWorld().playSound(_location, Sound.EXPLODE, 2, 0.6F);
UtilParticle.PlayParticleToAll(ParticleType.HUGE_EXPLOSION, _location, 0, 0, 0, 0.1F, 1, ViewDist.LONG); UtilParticle.PlayParticleToAll(ParticleType.HUGE_EXPLOSION, _location, 0, 0, 0, 0.1F, 1, ViewDist.LONG);
} }