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 6d7862486..37e3e9ba8 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 @@ -49,17 +49,7 @@ import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.managers.GameLobbyManager; import nautilus.game.arcade.scoreboard.GameScoreboard; -import nautilus.game.arcade.stats.AssistsStatTracker; -import nautilus.game.arcade.stats.DamageDealtStatTracker; -import nautilus.game.arcade.stats.DamageTakenStatTracker; -import nautilus.game.arcade.stats.DeathsStatTracker; -import nautilus.game.arcade.stats.GamesPlayedStatTracker; -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.TimeInGameStatTracker; +import nautilus.game.arcade.stats.*; import nautilus.game.arcade.stats.WinStatTracker; import nautilus.game.arcade.world.WorldData; @@ -286,8 +276,7 @@ public abstract class Game implements Listener new DamageTakenStatTracker(this), new TeamDeathsStatTracker(this), new TeamKillsStatTracker(this), - new GamesPlayedStatTracker(this), - new TimeInGameStatTracker(this) + new GamesPlayedStatTracker(this) ); System.out.println("Loading " + GetName() + "..."); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameStatManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameStatManager.java index a57c39651..0b7a0fe12 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameStatManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameStatManager.java @@ -1,5 +1,8 @@ package nautilus.game.arcade.managers; +import java.util.HashMap; +import java.util.UUID; + import mineplex.core.common.util.C; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.events.GameStateChangeEvent; @@ -8,12 +11,17 @@ import nautilus.game.arcade.stats.StatTracker; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerQuitEvent; public class GameStatManager implements Listener { ArcadeManager Manager; + + private final HashMap _joinTimes = new HashMap<>(); public GameStatManager(ArcadeManager manager) { @@ -74,4 +82,23 @@ public class GameStatManager implements Listener } } } + + @EventHandler(priority = EventPriority.MONITOR) + public void playTimeStatJoin(PlayerJoinEvent event) + { + _joinTimes.put(event.getPlayer().getUniqueId(), System.currentTimeMillis()); + } + + @EventHandler + public void playTimeStatQuit(PlayerQuitEvent event) + { + Long joinTime = _joinTimes.remove(event.getPlayer().getUniqueId()); + + if (joinTime != null) + { + int timeInGame = (int) ((System.currentTimeMillis() - joinTime) / 1000); + + Manager.GetStatsManager().incrementStat(event.getPlayer(), "Global.TimeInGame", timeInGame); + } + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/TimeInGameStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/TimeInGameStatTracker.java deleted file mode 100644 index 0b4751c0d..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/TimeInGameStatTracker.java +++ /dev/null @@ -1,39 +0,0 @@ -package nautilus.game.arcade.stats; - -import java.util.HashMap; -import java.util.UUID; - -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerQuitEvent; - -import nautilus.game.arcade.game.Game; - -public class TimeInGameStatTracker extends StatTracker -{ - private final HashMap _joinTimes = new HashMap<>(); - - public TimeInGameStatTracker(Game game) - { - super(game); - } - - @EventHandler(priority = EventPriority.MONITOR) - public void onPlayerJoin(PlayerJoinEvent event) - { - _joinTimes.put(event.getPlayer().getUniqueId(), System.currentTimeMillis()); - } - - @EventHandler - public void onPlayerQuit(PlayerQuitEvent event) - { - Long joinTime = _joinTimes.remove(event.getPlayer().getUniqueId()); - - if (joinTime != null) - { - int timeInGame = (int) ((System.currentTimeMillis() - joinTime) / 1000); - getGame().AddStat(event.getPlayer(), "TimeInGame", timeInGame, false, true); - } - } -}