From 9af8676307b56be87d9b99ce9610a390c4d26449 Mon Sep 17 00:00:00 2001 From: Chiss Date: Sat, 14 Dec 2013 16:38:16 +1100 Subject: [PATCH] Hub/Stats --- .../src/mineplex/core/stats/StatsManager.java | 18 +++++++ .../src/mineplex/hub/HubManager.java | 49 +++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java index c73864b95..8ebd90c88 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java @@ -269,4 +269,22 @@ public class StatsManager extends MiniPlugin } } } + + public int getStat(Player player, String table, String stat) + { + return getStat(player.getName(), table, stat); + } + + public int getStat(String player, String table, String stat) + { + if (!_playerStatList.containsKey(table)) + return 0; + + if (!_playerStatList.get(table).containsKey(player)) + return 0; + + PlayerStats stats = _playerStatList.get(table).get(player); + + return stats.getStat(stat); + } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index 7ce6291ed..98401f90e 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -47,6 +47,7 @@ import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.disguise.disguises.DisguiseSlime; import mineplex.core.donation.DonationManager; import mineplex.core.portal.Portal; +import mineplex.core.stats.StatsManager; import mineplex.core.task.TaskManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -69,6 +70,7 @@ public class HubManager extends MiniClientPlugin private DisguiseManager _disguiseManager; private PartyManager _partyManager; private Portal _portal; + private StatsManager _statsManager; private VisibilityManager _visibilityManager; private TutorialManager _tutorialManager; @@ -113,6 +115,8 @@ public class HubManager extends MiniClientPlugin _partyManager = partyManager; _tutorialManager = new TutorialManager(this, donationManager, taskManager, _textCreator); _visibilityManager = new VisibilityManager(this); + + _statsManager = new StatsManager(plugin); } @EventHandler(priority = EventPriority.HIGHEST) @@ -265,6 +269,46 @@ public class HubManager extends MiniClientPlugin } */ } + + @EventHandler(priority = EventPriority.HIGHEST) + public void TournamentWins(PlayerJoinEvent event) + { + for (Player player : Bukkit.getOnlinePlayers()) + { + Scoreboard board = player.getScoreboard(); + if (board == null) + continue; + + Objective obj = board.getObjective(DisplaySlot.BELOW_NAME); + if (obj == null) + { + obj = board.registerNewObjective("Tournament Kills", "dummy"); + obj.setDisplaySlot(DisplaySlot.BELOW_NAME); + } + + obj.getScore(event.getPlayer()).setScore(GetStats().GetStat(event.getPlayer(), "Pvp", "Kills")); + } + + if (event.getPlayer().getScoreboard() != null) + { + Scoreboard board = event.getPlayer().getScoreboard(); + + Objective obj = board.getObjective(DisplaySlot.BELOW_NAME); + if (obj == null) + { + obj = board.registerNewObjective("Tournament Kills", "dummy"); + obj.setDisplaySlot(DisplaySlot.BELOW_NAME); + } + + for (Player player : Bukkit.getOnlinePlayers()) + { + if (player.equals(event.getPlayer())) + continue; + + obj.getScore(player).setScore(player.getName().length()); + } + } + } @EventHandler public void PlayerQuit(PlayerQuitEvent event) @@ -556,6 +600,11 @@ public class HubManager extends MiniClientPlugin { return _tutorialManager; } + + public StatsManager GetStats() + { + return _statsManager; + } public VisibilityManager GetVisibility() {