From f69203884c850488ab535a4cce32860acf98d013 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Tue, 16 May 2017 21:23:46 -0400 Subject: [PATCH] Only allow kills to damage king/crystals if tnt has spawned at least once --- .../games/castleassault/CastleAssault.java | 80 +++++++++++-------- 1 file changed, 46 insertions(+), 34 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java index 38c18a46d..9d651ad84 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java @@ -135,6 +135,8 @@ public class CastleAssault extends TeamGame private boolean _writeScoreboard = true; + private boolean _killsAreObjective = false; + @SuppressWarnings("deprecation") public CastleAssault(ArcadeManager manager) { @@ -636,6 +638,13 @@ public class CastleAssault extends TeamGame } _tntSpawner.update(); + if (!_killsAreObjective) + { + if (_tntSpawner.isSpawned()) + { + _killsAreObjective = true; + } + } } if (InProgress()) { @@ -864,53 +873,56 @@ public class CastleAssault extends TeamGame } AddStat(player, GetKit(player).GetName() + "KitKills", 1, false, false); - _teamKills.merge(GetTeam(player), 1, Integer::sum); - if (GetTeam(player).GetColor() == ChatColor.RED) + if (_killsAreObjective) { - GameTeam enemy = GetTeam(ChatColor.AQUA); - TeamCrystal[] crystals = _crystals.get(enemy).stream().filter(TeamCrystal::isActive).toArray(size -> new TeamCrystal[size]); - if (crystals.length > 0) + _teamKills.merge(GetTeam(player), 1, Integer::sum); + if (GetTeam(player).GetColor() == ChatColor.RED) { - if (_teamKills.getOrDefault(GetTeam(player), 0) % 20 == 0) + GameTeam enemy = GetTeam(ChatColor.AQUA); + TeamCrystal[] crystals = _crystals.get(enemy).stream().filter(TeamCrystal::isActive).toArray(size -> new TeamCrystal[size]); + if (crystals.length > 0) { - crystals[UtilMath.r(crystals.length)].destroy(); - if (crystals.length > 1) + if (_teamKills.getOrDefault(GetTeam(player), 0) % 20 == 0) { - Bukkit.broadcastMessage(F.main("Game", "One of " + F.elem(enemy.GetFormattedName() + "'s Crystals") + " has been destroyed!")); - } - else - { - Bukkit.broadcastMessage(F.main("Game", "All of " + F.elem(enemy.GetFormattedName() + "'s Crystals") + " have been destroyed and " + F.elem(_kings.get(enemy).getName(false)) + " is now vulnerable!")); + crystals[UtilMath.r(crystals.length)].destroy(); + if (crystals.length > 1) + { + Bukkit.broadcastMessage(F.main("Game", "One of " + F.elem(enemy.GetFormattedName() + "'s Crystals") + " has been destroyed!")); + } + else + { + Bukkit.broadcastMessage(F.main("Game", "All of " + F.elem(enemy.GetFormattedName() + "'s Crystals") + " have been destroyed and " + F.elem(_kings.get(enemy).getName(false)) + " is now vulnerable!")); + } } } + else + { + _kings.get(enemy).handleDamage(player.getName(), 10, true); + } } else { - _kings.get(enemy).handleDamage(player.getName(), 10, true); - } - } - else - { - GameTeam enemy = GetTeam(ChatColor.RED); - TeamCrystal[] crystals = _crystals.get(enemy).stream().filter(TeamCrystal::isActive).toArray(size -> new TeamCrystal[size]); - if (crystals.length > 0) - { - if (_teamKills.getOrDefault(GetTeam(player), 0) % 20 == 0) + GameTeam enemy = GetTeam(ChatColor.RED); + TeamCrystal[] crystals = _crystals.get(enemy).stream().filter(TeamCrystal::isActive).toArray(size -> new TeamCrystal[size]); + if (crystals.length > 0) { - crystals[UtilMath.r(crystals.length)].destroy(); - if (crystals.length > 1) + if (_teamKills.getOrDefault(GetTeam(player), 0) % 20 == 0) { - Bukkit.broadcastMessage(F.main("Game", "One of " + F.elem(enemy.GetFormattedName() + "'s Crystals") + " has been destroyed!")); - } - else - { - Bukkit.broadcastMessage(F.main("Game", "All of " + F.elem(enemy.GetFormattedName() + "'s Crystals") + " have been destroyed and " + F.elem(_kings.get(enemy).getName(false)) + " is now vulnerable!")); + crystals[UtilMath.r(crystals.length)].destroy(); + if (crystals.length > 1) + { + Bukkit.broadcastMessage(F.main("Game", "One of " + F.elem(enemy.GetFormattedName() + "'s Crystals") + " has been destroyed!")); + } + else + { + Bukkit.broadcastMessage(F.main("Game", "All of " + F.elem(enemy.GetFormattedName() + "'s Crystals") + " have been destroyed and " + F.elem(_kings.get(enemy).getName(false)) + " is now vulnerable!")); + } } } - } - else - { - _kings.get(enemy).handleDamage(player.getName(), 10, true); + else + { + _kings.get(enemy).handleDamage(player.getName(), 10, true); + } } }