From 4ce537a3a7647560816b5781aca72aa773112a9c Mon Sep 17 00:00:00 2001 From: CoderTim Date: Mon, 25 Aug 2014 16:27:02 -0400 Subject: [PATCH 1/3] Fixed some NPEs and achievement bugs --- .../game/arcade/stats/AssistsStatTracker.java | 26 +++++++++++++------ .../arcade/stats/BackstabKillStatTracker.java | 6 +++++ .../arcade/stats/BadHiderStatTracker.java | 6 +++++ .../stats/BehindEnemyLinesStatTracker.java | 4 +++ .../arcade/stats/BlockShreadStatTracker.java | 3 +++ .../arcade/stats/BloodThirstyStatTracker.java | 3 +++ .../stats/BridgesSniperStatTracker.java | 4 +++ .../arcade/stats/CannibalStatTracker.java | 3 +++ .../arcade/stats/ChooChooStatTracker.java | 3 +++ .../arcade/stats/ComeAtMeBroStatTracker.java | 3 +++ .../arcade/stats/DamageDealtStatTracker.java | 5 +++- .../arcade/stats/DamageTakenStatTracker.java | 5 +++- .../arcade/stats/DeathBomberStatTracker.java | 3 +++ .../game/arcade/stats/DeathsStatTracker.java | 19 +++++++++----- .../stats/ElectrocutionStatTracker.java | 3 +++ .../arcade/stats/FastKillsStatTracker.java | 3 +++ .../stats/FirstSupplyDropOpenStatTracker.java | 3 +++ .../stats/FoodForTheMassesStatTracker.java | 3 +++ .../arcade/stats/FreeKitWinStatTracker.java | 7 +++-- .../arcade/stats/HunterKillerStatTracker.java | 3 +++ .../stats/HunterOfTheYearStatTracker.java | 3 +++ .../game/arcade/stats/KeenEyeStatTracker.java | 3 +++ .../stats/KillAllOpposingStatTracker.java | 3 +++ .../game/arcade/stats/KillsStatTracker.java | 19 +++++++++----- .../KillsWithinTimeLimitStatTracker.java | 3 +++ .../arcade/stats/KingDamageStatTracker.java | 3 +++ .../arcade/stats/KingSlayerStatTracker.java | 3 +++ .../arcade/stats/LastStandStatTracker.java | 4 +++ .../game/arcade/stats/LoseStatTracker.java | 16 +++++++----- .../game/arcade/stats/MedicStatTracker.java | 3 +++ .../game/arcade/stats/MeowStatTracker.java | 3 +++ .../arcade/stats/MrSquiggleStatTracker.java | 4 +++ .../arcade/stats/OneVThreeStatTracker.java | 3 +++ .../arcade/stats/ParalympicsStatTracker.java | 3 +++ .../arcade/stats/PureLuckStatTracker.java | 4 +++ .../stats/RecoveryMasterStatTracker.java | 6 +++++ .../arcade/stats/SeismicSlamStatTracker.java | 3 +++ .../arcade/stats/SharpShooterStatTracker.java | 8 +++++- .../arcade/stats/SheepDropStatTracker.java | 3 +++ .../arcade/stats/SheepThiefStatTracker.java | 3 +++ .../SimultaneousSkeletonStatTracker.java | 3 +++ .../arcade/stats/SlimySheepStatTracker.java | 3 +++ .../arcade/stats/SparklezStatTracker.java | 3 +++ .../stats/SpleefBlockDestroyStatTracker.java | 5 +++- .../arcade/stats/TheComebackStatTracker.java | 12 ++++----- .../stats/TheLongestShotStatTracker.java | 3 +++ .../arcade/stats/TntMinerStatTracker.java | 3 +++ .../game/arcade/stats/WinStatTracker.java | 16 +++++++----- .../stats/WinWithoutDyingStatTracker.java | 4 +++ .../WinWithoutWearingArmorStatTracker.java | 5 +++- 50 files changed, 227 insertions(+), 45 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/AssistsStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/AssistsStatTracker.java index b34ac722b..7d31e65d8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/AssistsStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/AssistsStatTracker.java @@ -1,11 +1,13 @@ package nautilus.game.arcade.stats; -import mineplex.core.common.util.*; -import mineplex.minecraft.game.core.combat.*; -import mineplex.minecraft.game.core.combat.event.*; -import nautilus.game.arcade.game.*; -import org.bukkit.entity.*; -import org.bukkit.event.*; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; + +import mineplex.core.common.util.UtilPlayer; +import mineplex.minecraft.game.core.combat.CombatComponent; +import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; +import nautilus.game.arcade.game.Game; public class AssistsStatTracker extends StatTracker { @@ -17,6 +19,9 @@ public class AssistsStatTracker extends StatTracker @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onCombatDeath(CombatDeathEvent event) { + if (getGame().GetState() != Game.GameState.Live) + return; + for (CombatComponent log : event.GetLog().GetAttackers()) { if (event.GetLog().GetKiller() != null && log.equals(event.GetLog().GetKiller())) @@ -24,8 +29,13 @@ public class AssistsStatTracker extends StatTracker Player player = UtilPlayer.searchExact(log.GetName()); - getGame().AddStat(player, "Assists", 1, false, false); - getGame().AddStat(player, getGame().GetKit(player).GetName() + " Assists", 1, false, false); + if (player != null) + { + getGame().AddStat(player, "Assists", 1, false, false); + + if (getGame().GetKit(player) != null) + getGame().AddStat(player, getGame().GetKit(player).GetName() + " Assists", 1, false, false); + } } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/BackstabKillStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/BackstabKillStatTracker.java index f9724ec07..a51d15bbb 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/BackstabKillStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/BackstabKillStatTracker.java @@ -27,6 +27,9 @@ public class BackstabKillStatTracker extends StatTracker @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onCombatDeath(CombatDeathEvent event) { + if (getGame().GetState() != Game.GameState.Live) + return; + if (event.GetLog().GetKiller() == null) return; @@ -59,6 +62,9 @@ public class BackstabKillStatTracker extends StatTracker @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onCustomDamage(CustomDamageEvent event) { + if (getGame().GetState() != Game.GameState.Live) + return; + if (event.GetDamageePlayer() != null && event.GetDamagerPlayer(true) != null) { Set hasDamaged = _hasDamaged.get(event.GetDamagerPlayer(true).getUniqueId()); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/BadHiderStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/BadHiderStatTracker.java index ee7592238..604138f5f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/BadHiderStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/BadHiderStatTracker.java @@ -26,6 +26,9 @@ public class BadHiderStatTracker extends StatTracker @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onChangeForm(HideSeek.ChangeFormEvent event) { + if (getGame().GetState() != Game.GameState.Live) + return; + if (event.getForm() instanceof CreatureForm) _disqualified.add(event.getPlayer().getUniqueId()); } @@ -33,6 +36,9 @@ public class BadHiderStatTracker extends StatTracker @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onPlayerDeath(PlayerDeathEvent event) { + if (getGame().GetState() != Game.GameState.Live) + return; + _disqualified.add(event.getEntity().getUniqueId()); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/BehindEnemyLinesStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/BehindEnemyLinesStatTracker.java index d8c638892..082318e54 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/BehindEnemyLinesStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/BehindEnemyLinesStatTracker.java @@ -5,6 +5,7 @@ import org.bukkit.event.EventHandler; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.games.turfforts.TurfForts; public class BehindEnemyLinesStatTracker extends StatTracker @@ -17,6 +18,9 @@ public class BehindEnemyLinesStatTracker extends StatTracker @EventHandler public void onUpdate(UpdateEvent event) { + if (getGame().GetState() != Game.GameState.Live) + return; + if (event.getType() == UpdateType.SEC) { for (Player player : getGame().GetPlayers(true)) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/BlockShreadStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/BlockShreadStatTracker.java index c39965a2c..cb32d23a7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/BlockShreadStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/BlockShreadStatTracker.java @@ -18,6 +18,9 @@ public class BlockShreadStatTracker extends StatTracker @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onShredBlock(TurfForts.ShredBlockEvent event) { + if (getGame().GetState() != Game.GameState.Live) + return; + if (event.getArrow().getShooter() instanceof Player) { Player shooter = (Player) event.getArrow().getShooter(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/BloodThirstyStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/BloodThirstyStatTracker.java index ff4a7c653..07653ecee 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/BloodThirstyStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/BloodThirstyStatTracker.java @@ -26,6 +26,9 @@ public class BloodThirstyStatTracker extends StatTracker @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onCombatDeath(CombatDeathEvent event) { + if (getGame().GetState() != Game.GameState.Live) + return; + if (event.GetLog().GetKiller() == null) return; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/BridgesSniperStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/BridgesSniperStatTracker.java index 2f55e7006..25e7554f3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/BridgesSniperStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/BridgesSniperStatTracker.java @@ -2,6 +2,7 @@ package nautilus.game.arcade.stats; import mineplex.core.common.util.*; import mineplex.minecraft.game.core.combat.event.*; +import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.games.bridge.*; import org.bukkit.entity.*; import org.bukkit.event.*; @@ -17,6 +18,9 @@ public class BridgesSniperStatTracker extends StatTracker @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onCombatDeath(CombatDeathEvent event) { + if (getGame().GetState() != Game.GameState.Live) + return; + if (getGame().isBridgesDown()) return; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/CannibalStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/CannibalStatTracker.java index 9ef4558f5..3f876333f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/CannibalStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/CannibalStatTracker.java @@ -22,6 +22,9 @@ public class CannibalStatTracker extends StatTracker @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onTailCollision(Snake.TailCollisionEvent event) { + if (getGame().GetState() != Game.GameState.Live) + return; + Integer killCount = _kills.get(event.getKiller().getUniqueId()); killCount = (killCount == null ? 0 : killCount) + 1; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/ChooChooStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/ChooChooStatTracker.java index 205cf6b94..bb5afee0f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/ChooChooStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/ChooChooStatTracker.java @@ -16,6 +16,9 @@ public class ChooChooStatTracker extends StatTracker @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onTailGrow(Snake.TailGrowEvent event) { + if (getGame().GetState() != Game.GameState.Live) + return; + if (event.getLength() >= 60) getGame().AddStat(event.getPlayer(), "ChooChoo", 1, true, false); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/ComeAtMeBroStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/ComeAtMeBroStatTracker.java index e79da1797..9de8b7825 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/ComeAtMeBroStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/ComeAtMeBroStatTracker.java @@ -25,6 +25,9 @@ public class ComeAtMeBroStatTracker extends StatTracker @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onCombatDeath(CombatDeathEvent event) { + if (getGame().GetState() != Game.GameState.Live) + return; + if (event.GetLog().GetKiller() == null) return; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/DamageDealtStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/DamageDealtStatTracker.java index 9f1b03693..2f57e0262 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/DamageDealtStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/DamageDealtStatTracker.java @@ -15,13 +15,16 @@ public class DamageDealtStatTracker extends StatTracker @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onCustomDamage(CustomDamageEvent event) { + if (getGame().GetState() != Game.GameState.Live) + return; + Player damager = event.GetDamagerPlayer(false); if (damager == null) return; getGame().AddStat(damager, "Damage Dealt", (int) Math.round(event.GetDamage()), false, false); - if (getGame() != null && getGame().GetKit(damager) != null) + if (getGame().GetKit(damager) != null) getGame().AddStat(damager, getGame().GetKit(damager).GetName() + " Damage Dealt", (int) Math.round(event.GetDamage()), false, false); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/DamageTakenStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/DamageTakenStatTracker.java index 581f60b42..af817603c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/DamageTakenStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/DamageTakenStatTracker.java @@ -15,13 +15,16 @@ public class DamageTakenStatTracker extends StatTracker @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onCustomDamage(CustomDamageEvent event) { + if (getGame().GetState() != Game.GameState.Live) + return; + Player damagee = event.GetDamageePlayer(); if (damagee == null) return; getGame().AddStat(damagee, "Damage Taken", (int) Math.round(event.GetDamage()), false, false); - if (getGame() != null && getGame().GetKit(damagee) != null) + if (getGame().GetKit(damagee) != null) getGame().AddStat(damagee, getGame().GetKit(damagee).GetName() + " Damage Taken", (int) Math.round(event.GetDamage()), false, false); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/DeathBomberStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/DeathBomberStatTracker.java index ca0d906be..979d9b001 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/DeathBomberStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/DeathBomberStatTracker.java @@ -25,6 +25,9 @@ public class DeathBomberStatTracker extends StatTracker @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onCombatDeath(CombatDeathEvent event) { + if (getGame().GetState() != Game.GameState.Live) + return; + if (event.GetLog().GetKiller() == null) return; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/DeathsStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/DeathsStatTracker.java index 2945db7ac..feca5aad4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/DeathsStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/DeathsStatTracker.java @@ -1,10 +1,12 @@ package nautilus.game.arcade.stats; -import mineplex.core.common.util.*; -import mineplex.minecraft.game.core.combat.event.*; -import nautilus.game.arcade.game.*; -import org.bukkit.entity.*; -import org.bukkit.event.*; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; + +import mineplex.core.common.util.UtilPlayer; +import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; +import nautilus.game.arcade.game.Game; public class DeathsStatTracker extends StatTracker { @@ -16,6 +18,9 @@ public class DeathsStatTracker extends StatTracker @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onCombatDeath(CombatDeathEvent event) { + if (getGame().GetState() != Game.GameState.Live) + return; + if (event.GetLog().GetPlayer() == null) return; @@ -27,6 +32,8 @@ public class DeathsStatTracker extends StatTracker return; getGame().AddStat(player, "Deaths", 1, false, false); - getGame().AddStat(player, getGame().GetKit(player).GetName() + " Deaths", 1, false, false); + + if (getGame().GetKit(player) != null) + getGame().AddStat(player, getGame().GetKit(player).GetName() + " Deaths", 1, false, false); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/ElectrocutionStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/ElectrocutionStatTracker.java index dc270239e..34d31dd60 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/ElectrocutionStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/ElectrocutionStatTracker.java @@ -14,6 +14,9 @@ public class ElectrocutionStatTracker extends StatTracker @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onLightningOrb(LightningOrb.LightningOrbEvent event) { + if (getGame().GetState() != Game.GameState.Live) + return; + if (event.getStruck().size() >= 4) getGame().AddStat(event.getPlayer(), "MassElectrocution", 1, true, false); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/FastKillsStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/FastKillsStatTracker.java index 124cad183..d53dfc1be 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/FastKillsStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/FastKillsStatTracker.java @@ -33,6 +33,9 @@ public class FastKillsStatTracker extends StatTracker @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onCombatDeath(CombatDeathEvent event) { + if (getGame().GetState() != Game.GameState.Live) + return; + if (event.GetLog().GetKiller() == null) return; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/FirstSupplyDropOpenStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/FirstSupplyDropOpenStatTracker.java index 845be8cd7..bca446fe3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/FirstSupplyDropOpenStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/FirstSupplyDropOpenStatTracker.java @@ -16,6 +16,9 @@ public class FirstSupplyDropOpenStatTracker extends StatTracker @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onSupplyChestOpen(SupplyChestOpenEvent event) { + if (getGame().GetState() != Game.GameState.Live) + return; + if (first) { getGame().AddStat(event.getPlayer(), "SupplyDropsOpened", 1, false, false); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/FoodForTheMassesStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/FoodForTheMassesStatTracker.java index 187ebba28..d03b9bb0e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/FoodForTheMassesStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/FoodForTheMassesStatTracker.java @@ -18,6 +18,9 @@ public class FoodForTheMassesStatTracker extends StatTracker @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onCombatDeathEvent(CombatDeathEvent event) { + if (getGame().GetState() != Game.GameState.Live) + return; + if (event.GetLog().GetKiller() == null) return; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/FreeKitWinStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/FreeKitWinStatTracker.java index a2b5d123b..8ddffeff4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/FreeKitWinStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/FreeKitWinStatTracker.java @@ -28,8 +28,11 @@ public class FreeKitWinStatTracker extends StatTracker { for (Player winner : winners) { - if (getGame().GetKit(winner).GetAvailability() == KitAvailability.Free) - getGame().AddStat(winner, "FreeKitsForever", 1, false, false); + if (getGame().GetKit(winner) != null) + { + if (getGame().GetKit(winner).GetAvailability() == KitAvailability.Free) + getGame().AddStat(winner, "FreeKitsForever", 1, false, false); + } } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/HunterKillerStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/HunterKillerStatTracker.java index 0396deac1..b08368261 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/HunterKillerStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/HunterKillerStatTracker.java @@ -25,6 +25,9 @@ public class HunterKillerStatTracker extends StatTracker @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onCombatDeath(CombatDeathEvent event) { + if (getGame().GetState() != Game.GameState.Live) + return; + if (event.GetLog().GetKiller() == null) return; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/HunterOfTheYearStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/HunterOfTheYearStatTracker.java index 1ae602247..849d44fe5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/HunterOfTheYearStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/HunterOfTheYearStatTracker.java @@ -26,6 +26,9 @@ public class HunterOfTheYearStatTracker extends StatTracker @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onCombatDeath(CombatDeathEvent event) { + if (getGame().GetState() != Game.GameState.Live) + return; + if (event.GetLog().GetKiller() == null) return; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KeenEyeStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KeenEyeStatTracker.java index 3a74bfe22..35c5aa81f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KeenEyeStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KeenEyeStatTracker.java @@ -25,6 +25,9 @@ public class KeenEyeStatTracker extends StatTracker @EventHandler public void onDrawRoundEnd(DrawRoundEndEvent event) { + if (getGame().GetState() != Game.GameState.Live) + return; + for (Iterator it = _guessAll.iterator(); it.hasNext(); ) { Player player = it.next(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KillAllOpposingStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KillAllOpposingStatTracker.java index 0f1631f63..3502c9cf4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KillAllOpposingStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KillAllOpposingStatTracker.java @@ -21,6 +21,9 @@ public class KillAllOpposingStatTracker extends StatTracker @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onCombatDeath(CombatDeathEvent event) { + if (getGame().GetState() != Game.GameState.Live) + return; + if (event.GetLog().GetKiller() == null) return; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KillsStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KillsStatTracker.java index 5a93f342d..571208772 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KillsStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KillsStatTracker.java @@ -1,10 +1,12 @@ package nautilus.game.arcade.stats; -import mineplex.core.common.util.*; -import mineplex.minecraft.game.core.combat.event.*; -import nautilus.game.arcade.game.*; -import org.bukkit.entity.*; -import org.bukkit.event.*; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; + +import mineplex.core.common.util.UtilPlayer; +import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; +import nautilus.game.arcade.game.Game; public class KillsStatTracker extends StatTracker { @@ -16,6 +18,9 @@ public class KillsStatTracker extends StatTracker @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onCombatDeath(CombatDeathEvent event) { + if (getGame().GetState() != Game.GameState.Live) + return; + if (event.GetLog().GetKiller() == null) return; @@ -27,6 +32,8 @@ public class KillsStatTracker extends StatTracker return; getGame().AddStat(player, "Kills", 1, false, false); - getGame().AddStat(player, getGame().GetKit(player).GetName() + " Kills", 1, false, false); + + if (getGame().GetKit(player) != null) + getGame().AddStat(player, getGame().GetKit(player).GetName() + " Kills", 1, false, false); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KillsWithinTimeLimitStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KillsWithinTimeLimitStatTracker.java index cf2e2a5a1..d7fd56200 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KillsWithinTimeLimitStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KillsWithinTimeLimitStatTracker.java @@ -38,6 +38,9 @@ public class KillsWithinTimeLimitStatTracker extends StatTracker @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onCombatDeath(CombatDeathEvent event) { + if (getGame().GetState() != Game.GameState.Live) + return; + if (event.GetLog().GetKiller() == null) return; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KingDamageStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KingDamageStatTracker.java index 771aeb486..d86cb3601 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KingDamageStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KingDamageStatTracker.java @@ -25,6 +25,9 @@ public class KingDamageStatTracker extends StatTracker @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onKingDamage(CastleSiege.KingDamageEvent event) { + if (getGame().GetState() != Game.GameState.Live) + return; + _totalKingDamage += event.getDamage(); Double damage = _kingDamage.get(event.getPlayer().getUniqueId()); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KingSlayerStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KingSlayerStatTracker.java index 3df4d1d1b..6fb872f5e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KingSlayerStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KingSlayerStatTracker.java @@ -15,6 +15,9 @@ public class KingSlayerStatTracker extends StatTracker @EventHandler public void onKingSlaughtered(CastleSiege.KingSlaughterEvent event) { + if (getGame().GetState() != Game.GameState.Live) + return; + getGame().AddStat(event.getPlayer(), "KingSlayer", 1, true, false); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/LastStandStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/LastStandStatTracker.java index 4890e17d9..32d0dc649 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/LastStandStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/LastStandStatTracker.java @@ -10,6 +10,7 @@ import org.bukkit.event.EventPriority; import mineplex.core.common.util.UtilPlayer; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; +import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.TeamGame; import nautilus.game.arcade.game.games.castlesiege.kits.KitUndead; @@ -25,6 +26,9 @@ public class LastStandStatTracker extends StatTracker @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onCombatDeath(CombatDeathEvent event) { + if (getGame().GetState() != Game.GameState.Live) + return; + if (event.GetLog().GetKiller() == null) return; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/LoseStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/LoseStatTracker.java index b375fe8f2..56712cfa2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/LoseStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/LoseStatTracker.java @@ -1,11 +1,13 @@ package nautilus.game.arcade.stats; -import nautilus.game.arcade.events.*; -import nautilus.game.arcade.game.*; -import org.bukkit.entity.*; -import org.bukkit.event.*; +import java.util.List; -import java.util.*; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; + +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game; public class LoseStatTracker extends StatTracker { @@ -26,7 +28,9 @@ public class LoseStatTracker extends StatTracker for (Player loser : losers) { getGame().AddStat(loser, "Losses", 1, false, false); - getGame().AddStat(loser, getGame().GetKit(loser).GetName() + " Losses", 1, false, false); + + if (getGame().GetKit(loser) != null) + getGame().AddStat(loser, getGame().GetKit(loser).GetName() + " Losses", 1, false, false); } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/MedicStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/MedicStatTracker.java index 5e79433f7..5ef6ae0ba 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/MedicStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/MedicStatTracker.java @@ -16,6 +16,9 @@ public class MedicStatTracker extends StatTracker @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onCombatDeath(Paintball.ReviveEvent event) { + if (getGame().GetState() != Game.GameState.Live) + return; + getGame().AddStat(event.getPlayer(), "Medic", 1, false, false); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/MeowStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/MeowStatTracker.java index 770e56a7a..8fda7be6c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/MeowStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/MeowStatTracker.java @@ -22,6 +22,9 @@ public class MeowStatTracker extends StatTracker @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onMeow(HideSeek.MeowEvent event) { + if (getGame().GetState() != Game.GameState.Live) + return; + Integer meows = _meowCount.get(event.getPlayer().getUniqueId()); meows = (meows == null ? 0 : meows) + 1; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/MrSquiggleStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/MrSquiggleStatTracker.java index 7b5fd9f96..093ccb950 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/MrSquiggleStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/MrSquiggleStatTracker.java @@ -10,6 +10,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; +import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.games.draw.Draw; import nautilus.game.arcade.game.games.draw.DrawGuessCorrectlyEvent; @@ -25,6 +26,9 @@ public class MrSquiggleStatTracker extends StatTracker @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onDrawGuessCorrectly(DrawGuessCorrectlyEvent event) { + if (getGame().GetState() != Game.GameState.Live) + return; + if (event.getRank() != 1) return; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/OneVThreeStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/OneVThreeStatTracker.java index 0954a26fb..5ead47332 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/OneVThreeStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/OneVThreeStatTracker.java @@ -26,6 +26,9 @@ public class OneVThreeStatTracker extends StatTracker @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onCombatDeath(CombatDeathEvent event) { + if (getGame().GetState() != Game.GameState.Live) + return; + if (event.GetLog().GetKiller() == null) return; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/ParalympicsStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/ParalympicsStatTracker.java index 23e1dc036..9dcabf8e9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/ParalympicsStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/ParalympicsStatTracker.java @@ -25,6 +25,9 @@ public class ParalympicsStatTracker extends StatTracker @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onePerkLeap(PerkLeapEvent event) { + if (getGame().GetState() != Game.GameState.Live) + return; + _hasLeaped.add(event.GetPlayer().getUniqueId()); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/PureLuckStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/PureLuckStatTracker.java index e503be713..7e271a2fb 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/PureLuckStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/PureLuckStatTracker.java @@ -3,6 +3,7 @@ package nautilus.game.arcade.stats; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; +import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.games.draw.Draw; import nautilus.game.arcade.game.games.draw.DrawGuessCorrectlyEvent; @@ -16,6 +17,9 @@ public class PureLuckStatTracker extends StatTracker @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onDrawGuessCorrectly(DrawGuessCorrectlyEvent event) { + if (getGame().GetState() != Game.GameState.Live) + return; + if (System.currentTimeMillis() - event.getDrawRound().Time < 5000) getGame().AddStat(event.getPlayer(), "PureLuck", 1, true, false); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/RecoveryMasterStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/RecoveryMasterStatTracker.java index 64bfb199c..9e26f4652 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/RecoveryMasterStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/RecoveryMasterStatTracker.java @@ -25,6 +25,9 @@ public class RecoveryMasterStatTracker extends StatTracker @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onCombatDeath(CombatDeathEvent event) { + if (getGame().GetState() != Game.GameState.Live) + return; + if (event.GetLog().GetPlayer() == null) return; @@ -41,6 +44,9 @@ public class RecoveryMasterStatTracker extends StatTracker @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onCustomDamage(CustomDamageEvent event) { + if (getGame().GetState() != Game.GameState.Live) + return; + Player damagee = event.GetDamageePlayer(); if (damagee == null) return; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/SeismicSlamStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/SeismicSlamStatTracker.java index 4d2383bf3..da9289188 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/SeismicSlamStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/SeismicSlamStatTracker.java @@ -14,6 +14,9 @@ public class SeismicSlamStatTracker extends StatTracker @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onLongshotHit(SeismicSlam.SeismicSlamEvent event) { + if (getGame().GetState() != Game.GameState.Live) + return; + if (event.getTargets().size() >= 5) getGame().AddStat(event.getPlayer(), "Earthquake", 1, true, false); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/SharpShooterStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/SharpShooterStatTracker.java index 90242df63..65385f0ea 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/SharpShooterStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/SharpShooterStatTracker.java @@ -27,7 +27,10 @@ public class SharpShooterStatTracker extends StatTracker @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onProjectileLaunch(ProjectileLaunchEvent event) { - if (event.getEntity().getShooter() instanceof Player) + if (getGame().GetState() != Game.GameState.Live) + return; + + if (event.getEntity().getShooter() instanceof Player && event.getEntity() instanceof Arrow) { Player player = (Player) event.getEntity(); @@ -40,6 +43,9 @@ public class SharpShooterStatTracker extends StatTracker @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onArrowHit(CustomDamageEvent event) { + if (getGame().GetState() != Game.GameState.Live) + return; + if (event.GetProjectile() instanceof Arrow && event.GetDamageePlayer() != null) { if (event.GetProjectile().getShooter() instanceof Player && event.GetProjectile().getShooter() != event.GetDamageePlayer()) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/SheepDropStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/SheepDropStatTracker.java index c311f2046..1c01836d7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/SheepDropStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/SheepDropStatTracker.java @@ -16,6 +16,9 @@ public class SheepDropStatTracker extends StatTracker @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onSheepStolen(SheepGame.DropEnemySheepEvent event) { + if (getGame().GetState() != Game.GameState.Live) + return; + getGame().AddStat(event.getPlayer(), "AnimalRescue", 1, false, false); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/SheepThiefStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/SheepThiefStatTracker.java index ddb005c74..9a9e8987a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/SheepThiefStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/SheepThiefStatTracker.java @@ -16,6 +16,9 @@ public class SheepThiefStatTracker extends StatTracker @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onSheepStolen(SheepGame.SheepStolenEvent event) { + if (getGame().GetState() != Game.GameState.Live) + return; + getGame().AddStat(event.getPlayer(), "Thief", 1, false, false); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/SimultaneousSkeletonStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/SimultaneousSkeletonStatTracker.java index 449edb04e..bbe42cf25 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/SimultaneousSkeletonStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/SimultaneousSkeletonStatTracker.java @@ -21,6 +21,9 @@ public class SimultaneousSkeletonStatTracker extends StatTracker @EventHandler public void onMinionSpawn(PerkSkeletons.MinionSpawnEvent event) { + if (getGame().GetState() != Game.GameState.Live) + return; + List skeletons = event.getPerkSkeletons().getSkeletons(event.getPlayer()); if (skeletons != null) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/SlimySheepStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/SlimySheepStatTracker.java index 10951171c..780944229 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/SlimySheepStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/SlimySheepStatTracker.java @@ -22,6 +22,9 @@ public class SlimySheepStatTracker extends StatTracker @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onTailCollision(Snake.SlimeUpgradeEvent event) { + if (getGame().GetState() != Game.GameState.Live) + return; + Integer count = _count.get(event.getPlayer().getUniqueId()); count = (count == null ? 0 : count) + 1; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/SparklezStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/SparklezStatTracker.java index 20b683273..e755b66b8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/SparklezStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/SparklezStatTracker.java @@ -16,6 +16,9 @@ public class SparklezStatTracker extends StatTracker @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onThrowSparkler(PerkSparkler.ThrowSparklerEvent event) { + if (getGame().GetState() != Game.GameState.Live) + return; + getGame().AddStat(event.getPlayer(), "Sparklez", 1, false, false); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/SpleefBlockDestroyStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/SpleefBlockDestroyStatTracker.java index e48e51d59..22685062e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/SpleefBlockDestroyStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/SpleefBlockDestroyStatTracker.java @@ -14,8 +14,11 @@ public class SpleefBlockDestroyStatTracker extends StatTracker } @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) - public void onThrowSparkler(SpleefDestroyBlockEvent event) + public void onSpleefDestroyBlock(SpleefDestroyBlockEvent event) { + if (getGame().GetState() != Game.GameState.Live) + return; + getGame().AddStat(event.getPlayer(), "SpleefBlocks", 1, false, false); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/TheComebackStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/TheComebackStatTracker.java index a13256ba3..877baeb43 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/TheComebackStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/TheComebackStatTracker.java @@ -26,15 +26,15 @@ public class TheComebackStatTracker extends StatTracker @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onUpdate(UpdateEvent event) { + if (getGame().GetState() != Game.GameState.Live) + return; + if (event.getType() == UpdateType.TICK) { - if (getGame().GetState() == Game.GameState.Live) + for (GameTeam team : getGame().GetTeamList()) { - for (GameTeam team : getGame().GetTeamList()) - { - if (getGame().getLines(team) <= 5) - _hasWentFiveOrBelow.add(team); - } + if (getGame().getLines(team) <= 5) + _hasWentFiveOrBelow.add(team); } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/TheLongestShotStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/TheLongestShotStatTracker.java index 39507e4c1..d834877aa 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/TheLongestShotStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/TheLongestShotStatTracker.java @@ -20,6 +20,9 @@ public class TheLongestShotStatTracker extends StatTracker @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onCombatDeath(CombatDeathEvent event) { + if (getGame().GetState() != Game.GameState.Live) + return; + if (event.GetLog().GetKiller() == null) return; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/TntMinerStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/TntMinerStatTracker.java index 85a9b78d7..04cfd622b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/TntMinerStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/TntMinerStatTracker.java @@ -14,6 +14,9 @@ public class TntMinerStatTracker extends StatTracker @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onEntityExplode(PerkBomber.BomberExplodeDiamondBlock event) { + if (getGame().GetState() != Game.GameState.Live) + return; + getGame().AddStat(event.getPlayer(), "FortuneBomber", 1, false, false); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/WinStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/WinStatTracker.java index c0a57e301..801c860cf 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/WinStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/WinStatTracker.java @@ -1,11 +1,13 @@ package nautilus.game.arcade.stats; -import nautilus.game.arcade.events.*; -import nautilus.game.arcade.game.*; -import org.bukkit.entity.*; -import org.bukkit.event.*; +import java.util.List; -import java.util.*; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; + +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game; public class WinStatTracker extends StatTracker { @@ -26,7 +28,9 @@ public class WinStatTracker extends StatTracker for (Player winner : winners) { getGame().AddStat(winner, "Wins", 1, false, false); - getGame().AddStat(winner, getGame().GetKit(winner).GetName() + " Wins", 1, false, false); + + if (getGame().GetKit(winner) != null) + getGame().AddStat(winner, getGame().GetKit(winner).GetName() + " Wins", 1, false, false); } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/WinWithoutDyingStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/WinWithoutDyingStatTracker.java index a42523fbe..150716c6f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/WinWithoutDyingStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/WinWithoutDyingStatTracker.java @@ -22,12 +22,16 @@ public class WinWithoutDyingStatTracker extends StatTracker public WinWithoutDyingStatTracker(Game game, String stat) { super(game); + _stat = stat; } @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onCombatDeath(CombatDeathEvent event) { + if (getGame().GetState() != Game.GameState.Live) + return; + if (event.GetLog().GetPlayer() == null) return; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/WinWithoutWearingArmorStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/WinWithoutWearingArmorStatTracker.java index cda58b23e..9f3c29e27 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/WinWithoutWearingArmorStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/WinWithoutWearingArmorStatTracker.java @@ -23,7 +23,10 @@ public class WinWithoutWearingArmorStatTracker extends StatTracker @EventHandler public void onUpdate(UpdateEvent event) { - if (event.getType() == UpdateType.FAST && getGame().GetState() == Game.GameState.Live) + if (getGame().GetState() != Game.GameState.Live) + return; + + if (event.getType() == UpdateType.FAST) { for (Player player : getGame().GetPlayers(true)) { From 9acc7d8496967013521a851cd52072dcefdc462c Mon Sep 17 00:00:00 2001 From: CoderTim Date: Mon, 25 Aug 2014 17:43:49 -0400 Subject: [PATCH 2/3] Added team kill and death achievement trackers --- .../nautilus/game/arcade/game/TeamGame.java | 8 ++++ .../stats/TeamGameDeathsStatTracker.java | 41 +++++++++++++++++++ .../stats/TeamGameKillsStatTracker.java | 41 +++++++++++++++++++ 3 files changed, 90 insertions(+) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/TeamGameDeathsStatTracker.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/TeamGameKillsStatTracker.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/TeamGame.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/TeamGame.java index da7b7fa6d..94739b377 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/TeamGame.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/TeamGame.java @@ -8,6 +8,9 @@ import nautilus.game.arcade.*; import nautilus.game.arcade.events.*; import nautilus.game.arcade.game.GameTeam.*; import nautilus.game.arcade.kit.*; +import nautilus.game.arcade.stats.TeamGameDeathsStatTracker; +import nautilus.game.arcade.stats.TeamGameKillsStatTracker; + import org.bukkit.entity.*; import org.bukkit.event.*; import org.bukkit.event.player.*; @@ -27,6 +30,11 @@ public abstract class TeamGame extends Game public TeamGame(ArcadeManager manager, GameType gameType, Kit[] kits, String[] gameDesc) { super(manager, gameType, kits, gameDesc); + + registerStatTrackers( + new TeamGameDeathsStatTracker(this), + new TeamGameKillsStatTracker(this) + ); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/TeamGameDeathsStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/TeamGameDeathsStatTracker.java new file mode 100644 index 000000000..634853ca7 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/TeamGameDeathsStatTracker.java @@ -0,0 +1,41 @@ +package nautilus.game.arcade.stats; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; + +import mineplex.core.common.util.UtilPlayer; +import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.TeamGame; + +public class TeamGameDeathsStatTracker extends StatTracker +{ + public TeamGameDeathsStatTracker(TeamGame game) + { + super(game); + } + + @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) + public void onCombatDeath(CombatDeathEvent event) + { + if (getGame().GetState() != Game.GameState.Live) + return; + + if (event.GetLog().GetPlayer() == null) + return; + + if (!event.GetLog().GetPlayer().IsPlayer()) + return; + + Player player = UtilPlayer.searchExact(event.GetLog().GetPlayer().GetName()); + if (player == null) + return; + + GameTeam team = getGame().GetTeam(player); + + if (team != null && team.GetName() != null) + getGame().AddStat(player, team.GetName() + " Deaths", 1, false, false); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/TeamGameKillsStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/TeamGameKillsStatTracker.java new file mode 100644 index 000000000..00dee397f --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/TeamGameKillsStatTracker.java @@ -0,0 +1,41 @@ +package nautilus.game.arcade.stats; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; + +import mineplex.core.common.util.UtilPlayer; +import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.TeamGame; + +public class TeamGameKillsStatTracker extends StatTracker +{ + public TeamGameKillsStatTracker(TeamGame game) + { + super(game); + } + + @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) + public void onCombatDeath(CombatDeathEvent event) + { + if (getGame().GetState() != Game.GameState.Live) + return; + + if (event.GetLog().GetKiller() == null) + return; + + if (!event.GetLog().GetKiller().IsPlayer()) + return; + + Player player = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName()); + if (player == null) + return; + + GameTeam team = getGame().GetTeam(player); + + if (team != null && team.GetName() != null) + getGame().AddStat(player, team.GetName() + " Kills", 1, false, false); + } +} From 933d32d8f804a01b9c82c6f9869435097358338d Mon Sep 17 00:00:00 2001 From: CoderTim Date: Mon, 25 Aug 2014 18:06:50 -0400 Subject: [PATCH 3/3] Fixed team death/kills stats --- .../src/nautilus/game/arcade/game/Game.java | 6 +++++- .../src/nautilus/game/arcade/game/TeamGame.java | 9 ++------- ...DeathsStatTracker.java => TeamDeathsStatTracker.java} | 8 +++++--- ...meKillsStatTracker.java => TeamKillsStatTracker.java} | 8 +++++--- 4 files changed, 17 insertions(+), 14 deletions(-) rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/{TeamGameDeathsStatTracker.java => TeamDeathsStatTracker.java} (85%) rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/{TeamGameKillsStatTracker.java => TeamKillsStatTracker.java} (85%) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java index 92257bfee..d77a2b868 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java @@ -25,6 +25,8 @@ import nautilus.game.arcade.stats.DeathsStatTracker; import nautilus.game.arcade.stats.KillsStatTracker; import nautilus.game.arcade.stats.LoseStatTracker; import nautilus.game.arcade.stats.StatTracker; +import nautilus.game.arcade.stats.TeamDeathsStatTracker; +import nautilus.game.arcade.stats.TeamKillsStatTracker; import nautilus.game.arcade.stats.WinStatTracker; import nautilus.game.arcade.world.WorldData; @@ -250,7 +252,9 @@ public abstract class Game implements Listener new WinStatTracker(this), new LoseStatTracker(this), new DamageDealtStatTracker(this), - new DamageTakenStatTracker(this) + new DamageTakenStatTracker(this), + new TeamDeathsStatTracker(this), + new TeamKillsStatTracker(this) ); System.out.println("Loading " + GetName() + "..."); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/TeamGame.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/TeamGame.java index 94739b377..111f450b4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/TeamGame.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/TeamGame.java @@ -8,8 +8,8 @@ import nautilus.game.arcade.*; import nautilus.game.arcade.events.*; import nautilus.game.arcade.game.GameTeam.*; import nautilus.game.arcade.kit.*; -import nautilus.game.arcade.stats.TeamGameDeathsStatTracker; -import nautilus.game.arcade.stats.TeamGameKillsStatTracker; +import nautilus.game.arcade.stats.TeamDeathsStatTracker; +import nautilus.game.arcade.stats.TeamKillsStatTracker; import org.bukkit.entity.*; import org.bukkit.event.*; @@ -30,11 +30,6 @@ public abstract class TeamGame extends Game public TeamGame(ArcadeManager manager, GameType gameType, Kit[] kits, String[] gameDesc) { super(manager, gameType, kits, gameDesc); - - registerStatTrackers( - new TeamGameDeathsStatTracker(this), - new TeamGameKillsStatTracker(this) - ); } @EventHandler diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/TeamGameDeathsStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/TeamDeathsStatTracker.java similarity index 85% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/TeamGameDeathsStatTracker.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/TeamDeathsStatTracker.java index 634853ca7..2d787c8f5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/TeamGameDeathsStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/TeamDeathsStatTracker.java @@ -8,11 +8,10 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.GameTeam; -import nautilus.game.arcade.game.TeamGame; -public class TeamGameDeathsStatTracker extends StatTracker +public class TeamDeathsStatTracker extends StatTracker { - public TeamGameDeathsStatTracker(TeamGame game) + public TeamDeathsStatTracker(Game game) { super(game); } @@ -23,6 +22,9 @@ public class TeamGameDeathsStatTracker extends StatTracker if (getGame().GetState() != Game.GameState.Live) return; + if (getGame().GetTeamList().size() < 2) + return; + if (event.GetLog().GetPlayer() == null) return; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/TeamGameKillsStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/TeamKillsStatTracker.java similarity index 85% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/TeamGameKillsStatTracker.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/TeamKillsStatTracker.java index 00dee397f..f723246f6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/TeamGameKillsStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/TeamKillsStatTracker.java @@ -8,11 +8,10 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.GameTeam; -import nautilus.game.arcade.game.TeamGame; -public class TeamGameKillsStatTracker extends StatTracker +public class TeamKillsStatTracker extends StatTracker { - public TeamGameKillsStatTracker(TeamGame game) + public TeamKillsStatTracker(Game game) { super(game); } @@ -23,6 +22,9 @@ public class TeamGameKillsStatTracker extends StatTracker if (getGame().GetState() != Game.GameState.Live) return; + if (getGame().GetTeamList().size() < 2) + return; + if (event.GetLog().GetKiller() == null) return;