Hub/Stats

This commit is contained in:
Chiss 2013-12-14 16:38:16 +11:00
parent e054b06cc2
commit 9af8676307
2 changed files with 67 additions and 0 deletions

View File

@ -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);
}
} }

View File

@ -47,6 +47,7 @@ import mineplex.core.disguise.disguises.DisguisePlayer;
import mineplex.core.disguise.disguises.DisguiseSlime; import mineplex.core.disguise.disguises.DisguiseSlime;
import mineplex.core.donation.DonationManager; import mineplex.core.donation.DonationManager;
import mineplex.core.portal.Portal; import mineplex.core.portal.Portal;
import mineplex.core.stats.StatsManager;
import mineplex.core.task.TaskManager; import mineplex.core.task.TaskManager;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
@ -69,6 +70,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
private DisguiseManager _disguiseManager; private DisguiseManager _disguiseManager;
private PartyManager _partyManager; private PartyManager _partyManager;
private Portal _portal; private Portal _portal;
private StatsManager _statsManager;
private VisibilityManager _visibilityManager; private VisibilityManager _visibilityManager;
private TutorialManager _tutorialManager; private TutorialManager _tutorialManager;
@ -113,6 +115,8 @@ public class HubManager extends MiniClientPlugin<HubClient>
_partyManager = partyManager; _partyManager = partyManager;
_tutorialManager = new TutorialManager(this, donationManager, taskManager, _textCreator); _tutorialManager = new TutorialManager(this, donationManager, taskManager, _textCreator);
_visibilityManager = new VisibilityManager(this); _visibilityManager = new VisibilityManager(this);
_statsManager = new StatsManager(plugin);
} }
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
@ -266,6 +270,46 @@ public class HubManager extends MiniClientPlugin<HubClient>
*/ */
} }
@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 @EventHandler
public void PlayerQuit(PlayerQuitEvent event) public void PlayerQuit(PlayerQuitEvent event)
{ {
@ -557,6 +601,11 @@ public class HubManager extends MiniClientPlugin<HubClient>
return _tutorialManager; return _tutorialManager;
} }
public StatsManager GetStats()
{
return _statsManager;
}
public VisibilityManager GetVisibility() public VisibilityManager GetVisibility()
{ {
return _visibilityManager; return _visibilityManager;